tadman has asked for the wisdom of the Perl Monks concerning the following question:
Use of implicit split to @_ is deprecated at Foo.pm line XIV.Here's a bit of code that causes that particular problem:
my $foo = split (/,/, $bar);It would seem that since the split() call is being assigned to something that the default behaviour would not kick in, yet this is clearly not the case.
my $foo = ($bar =~ /,/) + 1;Yet this is only an approximation, considering it erroneously returns 1 when $bar is empty. So, more formally:
my $foo = defined($bar) && length($bar) && (($bar =~ /,/) + 1);Yet, this does seem to be going to quite the trouble just to get a simple answer.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Idiomatic Split to Scalar Conversion
by jmcnamara (Monsignor) on Apr 29, 2002 at 22:47 UTC | |
by sfink (Deacon) on Apr 30, 2002 at 00:11 UTC | |
by particle (Vicar) on Apr 30, 2002 at 04:29 UTC | |
|
Re: Idiomatic Split to Scalar Conversion
by japhy (Canon) on Apr 29, 2002 at 22:46 UTC | |
|
Re: Idiomatic Split to Scalar Conversion
by stephen (Priest) on Apr 29, 2002 at 22:59 UTC | |
|
Re: Idiomatic Split to Scalar Conversion
by samtregar (Abbot) on Apr 29, 2002 at 22:50 UTC | |
|
Re: Idiomatic Split to Scalar Conversion
by particle (Vicar) on Apr 29, 2002 at 22:43 UTC | |
by tadman (Prior) on Apr 29, 2002 at 22:49 UTC |