Hello monks , I am new to perl and this site :
my question is , I have the following file which I am reading :
[PASSWORDS]
GUY ddd
GIRL dfd33
BOY df341
I am reading it as follow
my @listOfPass;
open(INPUT , "<$input_file" ) or die "couldn't open";
my ($section,%passwds);
while(<CONFILE>)
{ chomp;
if (/^\[(.*?)\]$/) { $section = $1; next; }
if ($section eq 'PASSWORDS') {
my ($mkt,$pass) = split;
$passwds{$mkt} = $pass;
$passwds{$pass} = $mkt;
@listOfPass = "$pass"; # <------ not working :((
}#end while loop
close (INPUT);
What I am trying tod do is after getting the passwords , store it into the array that is declared outside the open statment, when I try to store it into the array , it says it is not declare and when I declare it inside , it can't see it outside that loop. I just want to have all the passwords stored in a global array in the order it was read from the config file so I can pass that array to a different subs inside my program.
I hope I am clear ,,, thanks
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.