#!/usr/local/bin/perl5 -w
# a solution to 2.3

#    This one illustrates some fancy ways of doing things:
#    The result of the split is used as a list to loop over.
#    A global match (i.e., with /.../g ) is used to return a list.

while(<>)
{
    foreach $field ( ($id,$name,$email,$major,$level) = split ":" )
    {
        $field =~ /\S/ or $field = '(no information)';
    }
    ($id1,$id2,$id3) = ($id =~ /\d\d\d/g);        #  or /\d{3}/g
    print "Name:  $name\n";
    print "ID:    $id1-$id2-$id3\n";
    print "email: $email\n";
    print "major: $major\n";
    print "level: $level\n";
    print "\n";
}

#    Note: "or" is used instead of "||", since "||" binds too tightly
#      to the preceding match and confuses Perl; with "||" we'd need
#      to use extra parens:  ($field =~ /\S/) || ...
