Harry Putnam wrote:
> 
> Consider this code:
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> #!/usr/local/bin/perl -w
> $num = 234;
> $line1 = "$num some text here";
> $line2 = "$num ";  ## note the space after.
> 
> @array = ("$line1","$line2");

You don't need quotes there, the scalars are already strings.

my @array = ( $line1, $line2 );


> for (@array){
>     $trimmed_line = (split(/^$num /,$_))[1];

For "$num " you are assigning the second element of a list that only has
one element.  You need to tell split to return a two element list or the
second element will be undef and not ''.

      $trimmed_line = (split /^$num /, $_, 2)[1];


>    # ($trimmed_line = $_) =~ s/^$num //;
> 
>   print "\$trimmed_line = <$trimmed_line>\n";
> }
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Returns:
>  ./sptest
>  $trimmed_line = <some text here>
>   Use of uninitialized value in concatenation (.) or string

When you try to use the value undef in a print statement you will get
this warning.


>   at ./sptest line 13.
>  $trimmed_line = <>


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to