in reply to Re: reading an input file
in thread reading an input file
my ($section, $code, %passwds); while (<>) { chomp; undef $section, next unless /\S/; # next line is equivalent to duff's; just showing a # different WTDI next if ($section) = /^\[(.*?)\]$/; if ($section eq 'CODE') { warn "overriding previous CODE" if defined $code; $code = $_; # CODE section automatically ends after one line undef $section; } elsif ($section eq 'PASS') { if ((my ($name, $pass) = split) != 2) { warn "bad input $_ ignored"; next; } $passwds{$name} = $pass; } else { warn "unexpected input $_; possibly invalid section $section"; } }
|
|---|