http://www.perlmonks.org?node_id=1023263


in reply to Parsing a line of text

in pseudocode

# we read the /etc/shadow to a filehandle open (my $filehandle, '<', '/etc/shadow') or die $!; while (<$filehandle>){ # we read line by line now chomp; # and split the line by fields my ($name, $passwd, $field3, $field4,... ETC until $field8) = split /: +/ $_; if ($passwd = '*'){do something...} elsif ($passwd = '!'){do other...} } # we close the while loop close $filehandle;

Updated: you don't need to double the !! probably

Updated again: missed a semicolon after die