Re: looping issue
- From: Jürgen Exner <jurgenex@xxxxxxxxxxx>
- Date: Mon, 30 Jun 2008 11:38:39 GMT
dakin999 <akhilshri@xxxxxxxxx> wrote:
foreach my $row (@$array_ref) {[...]
open (FILE, "<file_name") || die "Could not open the file: $!";
while (<FILE>) {
chomp;
(my $nusr_id) = split(); #read into a variable
--
--
--
}
}
This code reads and loops through all of <FILE> for each element of
@$array_ref.
The problem is in the looping of input <FILE> that I need to read for
each $row. Basically there can be more than 1 $row values and I need
to pick a new line from <FILE> for each $row entry.
Are you saying that is not what you want but instead you want to loop
through @$array_ref and <FILE> in sync, i.e. for each element of
@$array_ref read exactly one line of <FILE>?
If so, then just do it:
open (FILE, "<file_name") || die "Could not open the file: $!";
foreach my $row (@$array_ref) {
[...]
$_ = <FILE>;
chomp;
(my $nusr_id) = split(); #read into a variable
--
--
--
}
jue
.
- References:
- looping issue
- From: dakin999
- looping issue
- Prev by Date: Re: editing smb.conf (INI files)
- Next by Date: Re: looping issue
- Previous by thread: Re: looping issue
- Next by thread: Re: looping issue
- Index(es):
Relevant Pages
|