Consider this code:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
#!/usr/local/bin/perl -w
$num = 234;
$line1 = "$num some text here";
$line2 = "$num "; ## note the space after.
@array = ("$line1","$line2");
for (@array){
$trimmed_line = (split(/^$num /,$_))[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
at ./sptest line 13.
$trimmed_line = <>
But if you use the commented line instead of the split line:
./sptest
$trimmed_line = <some text here>
$trimmed_line = <>
Either way, $line2 = ''; but the split way throws the error message.
Why is that?
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]