Am Dienstag, 10. Mai 2005 11.23 schrieb Kpramod:
> Hi John,
> Try to use 'chop' to get null value
> Thanks and Regards
> Pramod
Hi Pramad,
sorry, I don't understand what you mean. Do you refer to the line
my @new=grep {$_ and !/^\s+$/ and !/^\0+$/} @array1;
(I see that the test for \0 is ugly, but I found nothing else - and I can't
see a usage for chop here)
greetings
joe
> John Doe wrote:
> >Am Dienstag, 10. Mai 2005 11.01 schrieb Tielman Koekemoer (TNE):
> >>Hi all,
> >>
> >>I have tried various regular expressions to remove null or empty
> >>values on array @array1 and create a new array @OPD01 with the values.
> >>This, however, does not work as I still get a number of empty values
> >>in the @OPD01 array after this processing. As you'll see I tried
> >>various things - check for null(\0), empty lines, lines that do not
> >>contain words etc.
> >>
> >>$counter2 = 0;
> >
> >What's that for? (never used)
> >
> >> foreach $line ( @array1 )
> >> {
> >> $line =~ s/^\s+//;
> >> $line =~ s/\s+$//;
> >> next if $line =~ /!\w/;
> >> next if $line =~ /^\s+$/;
> >> next if $line =~ /'\0'/;
> >> next if $line =~ /^$/;
> >>
> >> $OPD01[$counter]=$line;
> >> $counter++;
> >
> >Use push() to avoid holding the current array index.
> >
> >> }
> >>
> >>Any info would be appreciated.
> >
> >my @array1=(' ', 'a', '', 'b', "\0", 'c', undef, 'd', ' ', 'e');
> >my @new=grep {$_ and !/^\s+$/ and !/^\0+$/} @array1;
> >print join "\n", @new;
> >
> ># prints:
> >a
> >b
> >c
> >d
> >e
> >
> >>TIA
> >>
> >>Tielman
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>