Unknown Warning
Scott Penrose
scottp at dd.com.au
Sun Oct 20 23:56:30 CDT 2002
Hey Dudes,
Try the following bit of code...
#!/usr/bin/perl -w
use strict;
my $fred = 'a b c d';
for (my $i = scalar(split(/ /, $fred)); $i > 0; $i--) {
print $i . "\n";
}
You get the following warning
"Use of implicit split to @_ is deprecated at ... line 6."
Now I don't understand.
The following code
#!/usr/bin/perl -w
use strict;
my $fred = 'a b c d';
foreach my $x (split(/ /, $fred)) {
print $x . "\n";
}
Produces no warnings.
Calling a method like split, should just return a list. That list can
be used inside methods.
So I though maybe it is coz we are calling a sub (eg: scalar)
#!/usr/bin/perl -w
use strict;
my $fred = 'a b c d';
x(split(/ /, $fred));
exit 0;
sub x {
my @list = @_;
print join("\n", @list) . "\n";
}
Nope, this code has no errors either.
Is it
a) A bug (5.6 and 5.8 do the same thing)
b) Something special about 'scalar'
Scott
--
Scott Penrose
VP in charge of Pancakes
http://linux.dd.com.au/
scottp at dd.com.au
Dismaimer: If you receive this email in error - please eat it
immediately to prevent it from falling into the wrong hands.
More information about the Melbourne-pm
mailing list