in reply to Re: Loop stops at first iteration
in thread Loop stops at first iteration
I understand that every loop grabs one element in the @folder array and executes the subroutine. Each iteration is unique and it doesn't have to remember the previous executions. my ($cue) = <$fqname/*.cue>; gets a different cue file on every iteration. Now if it has to do with the context of glob and I push @cues , ($cue) i will have an array of cue files in @cues. So how i will be helped by this approach?foreach my $folder (@folders) { # for instance folder1 next if ($folder eq "."); next if ($folder eq ".."); my $fqname = catdir( $output, $folder ); #$fqname is /mnt/music/output/folder1 if ( -d $fqname ) { #passed the test if (glob("$fqname/*.cue")) { # yes there is /mnt/music/found/output/folder1/a.cue print "$fqname: cue found\n"; #prints: /mnt/music/found/output/folder1/: cue found my ($cue) = <$fqname/*.cue>; # my ($cue) grabs /mnt/music/output/folder1/a.cue } elsif(!glob(("fqname/*.cue"))) { print "$fqname: no cue found\n"; next; } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Loop stops at first iteration
by ikegami (Patriarch) on Dec 29, 2007 at 04:39 UTC |