Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: Array issue

by monktim (Friar)
on Jan 28, 2004 at 20:32 UTC ( [id://324776] : note . print w/replies, xml ) Need Help??

in reply to Array issue

use strict; use warnings; my @listOfPass; my ($section,%passwds); while(<DATA>) { chomp; if (/^\[(.*?)\]$/) { $section = $1; next; } elsif ($section eq 'PASSWORDS') { my ($mkt,$pass) = split; push @listOfPass, $pass; } }#end while loop print join(',', @listOfPass); __DATA__ [PASSWORDS] GUY ddd GIRL dfd33 BOY df341
UPDATE I just reread the OP. The passwords need to be in the order that they were received. I modified this code to use the push function like Ovid suggested. I got too trigger happy with my caffeine induced post :)