in reply to Re: Is there a better way to check if an array is empty?
in thread Is there a better way to check if an array is empty?
I should have been more specific.Basically I want to push $newfile to another array @newfiles only if the array is empty and the instructions after the push instruction should not be executed.The following works for me but I want to know if there is a better way
if{ my $newfile="$file\n"; @array = grep(/\Q$newfile\E/,keys %hash); if (!@array) { push @newfiles,$newfile; #last; } next unless (@array); ..................... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is there a better way to check if an array is empty?
by JavaFan (Canon) on Dec 21, 2010 at 19:27 UTC | |
by iphone (Beadle) on Dec 21, 2010 at 19:33 UTC | |
by GrandFather (Saint) on Dec 21, 2010 at 20:24 UTC | |
by JavaFan (Canon) on Dec 21, 2010 at 20:35 UTC | |
|
Re^3: Is there a better way to check if an array is empty?
by Marshall (Canon) on Dec 23, 2010 at 09:11 UTC |