On Fri, Jul 9, 2010 at 06:16, marcos rebelo <ole...@gmail.com> wrote: > I'm getting crazy with this one > > the fact of or not the prototype in the xpto function, I get this > warning: 'Use of implicit split to @_ is deprecated at script.pl line > 5.' > > use strict; > use warnings; > > sub xpto($) {}; > xpto( split(/\n/, "fv\nfg" ) ); > > > How do I go around this without creating more lines of code? > > > Note: I didn't do the prototype subroutine
snip xpto has a prototype of $, this means it will place its argument in scalar context. So, you code is equivalent to my $temp = split(/\n/, "fv\nfg" ); xpto $temp; Splitting into scalar context is a fairly obscure trick to get the number of fields in a string. Is this what you desired? If you wanted to get the first field, you should use list indexing to get the first return. If you wanted the last field, just use an index of -1. If you want to avoid the warning, split into an array first. #!/usr/bin/perl use strict; use warnings; sub xpto($) { print shift, "\n"; } { my @temp = split /\n/, "first\nsecond\nthird"; xpto @temp; } xpto( (split /\n/, "first\nsecond\nthird")[0] ); xpto( (split /\n/, "first\nsecond\nthird")[-1] ); -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/