On Friday 16 November 2007 09:44, lerameur wrote:
> hello,
Hello,
> I have a small function using lenght, I am getting the
> following error:
> Use of uninitialized value in length at ./count2.pl line 95, <
> $wordlisting1> line 1.
>
> while (my $line = <$wordlisting1> ) {
> if ($line =~ m/backlog/ ) {
> my @items = (split(/,/,$line))[0..88];
perldoc -f split
split Splits a string into a list of strings and returns
that list. By default, empty leading fields are
preserved, and empty trailing ones are deleted.
Even if you have 89 fields the empty trailing ones are deleted and the
list slice fills those empty fields with the undef value.
So you probably want to do this instead:
my @items = split /,/, $line, -1;
Or maybe even:
my @items = split /,/, $line, 89;
> if (length($items[86]) == 0){
> $counter++;
> }
> }
> }
John
--
use Perl;
program
fulfillment
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/