Unknown Warning

Ryan, Martin Martin.Ryan at sensis.com.au
Mon Oct 21 00:30:39 CDT 2002


Hi Scott,

At a guess off the top of my head - is one being evaluated in a list context
and the other in a scalar context giving the different results?

Martin

> -----Original Message-----
> From: Scott Penrose [mailto:scottp at dd.com.au]
> Sent: Monday, 21 October 2002 14:57
> To: melbourne-pm at pm.org
> Cc: benno at myinternet.com.au
> Subject: Unknown Warning
> 
> 
> 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