Here's an (untested) implementation of what I think you want:
my ($section, $code, %passwds); while (<>) { chomp; if (/^\[(.*?)\]$/) { $section = $1; next; } if ($section eq 'CODE') { $code = $_; } elsif ($section eq 'PASS') { my ($name,$pass) = split; $passwds{$name} = $pass; } }
This actually makes a hash to map the names to passwords rather than creating a bunch of scalars. There's other ways you could do it too.
In reply to Re: reading an input file
by duff
in thread reading an input file
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |