##
open( $l, ";
close( $l );
foreach my $line ( @lines ) {
# Skipping if the line is empty or a comment
next if ( $line =~ /^\s*$/ );
next if ( $line =~ /^\s*#/ );
my ($firstname, $lastname, $age) = split( /\s+/, $line );
# then do whatever you have to
}
## ##
# lastname firstname age gender phone
mcgee bobby 27 M 555-555-5555
kincaid marl 67 M 555-666-6666
hofhazards duke 22 M 555-696-6969
####
open( $l, ";
close( $l );
my @keys = split( /\s+/, $lines[0] );
shift( @keys ); # to remove the # as the first field
foreach my $line ( @lines ) {
# Skipping if the line is empty or a comment
next if ( $line =~ /^\s*$/ );
next if ( $line =~ /^\s*#/ );
my %hash;
@hash{ @keys } = split( /\s+/, $line );
# then do whatever you have to
}