Perl Error Use Of Implicit Split To Is Deprecated
compile. I've managed to clean up all but two lines of code, which are being used in a peculiar way. The code is as follows:$var_cellsplit=split( //. $var_cellname ); $var_cdrcellsplit=split( //. $var_cdrcellname ); [download] Now what he's trying to do is to get the length of $var_cellname and $var_cdrcellname by splitting into elements and counting the elements. It works, but it returns the error shown above. Is there a way to make this cleaner? I'm assuming he went this way for a reason instead of using length(). Thanks, Alatar *EDIT* Roy and Dave, thanks for the explanation. The . was simply a typo as I'm accessing the web from a different PC than where I have the Code. I'm pretty sure now that he was doing this because he wasn't aware of the length() function. Comment on Use of implicit split to @_ is deprecatedDownload Code Replies are listed 'Best First'. Re: Use of implicit split to @_ is deprecated by davido (Archbishop) on Jun 04, 2004 at 15:32UTC The reason for this warning is that split is creating a list in @_, and then you're evaluating that @_ array in scalar context. This has the effect of counting @_'s elements, but has the side effect of wiping out whatever happened to be in @_ beforehand. Because this is a common cause of grief for people who didn't realize they're clobbering a subroutine's parameter list, a warning is issued to alert the programmer that (s)he may be creating a hidden bug. Moreover, the entire notion of splitting into @_, because of its inherent risks, has been deprecated (discouraged... dis-recommended). The obvious solution is to not use some contrived solution like this when Perl has a perfectly good length function. What we don't know from the code snippet you provided is if the original code actually relies on @_ containing the results of the split. You've got one other serious problem, and that's the use of a dot (concatenation operator) where you probably intended to use a comma (list operator). Because your code has a dot where a comma belongs, Perl silently translates what you've got there into the following (use "perl -MO=Deparse scriptname.pl" if you don't believe me): $var_cellsplit = split( ( // . $var_cellname ), $_, 0 ); [download] Why this isn't a syntax error is a little perplexing, but the result is that your "split" regexp looks p
PerlNews Q&A Tutorials Poetry RecentThreads NewestNodes Donate What'sNew on Oct 22, 2009 at 13:39UTC ( #802744=perlquestion: print w/replies, xml ) Need Help?? kp2a has asked for the wisdom of the Perl Monks concerning the following question: problem solved - needed an extra pair of eyes to see simply mistake - thanks! #! /usr/bin/perl -w use strict; my $debug; my $test = $ARGV[0]; print "<$test>\n"; if($test) { my $die = 1; my @a; if($test =~ s!/!\t!) { split @a = http://www.perlmonks.org/bare/?node_id=360929 split m/\t/,$test; print "($a[0],$a[1])\n"; $die = 0 if isip($a[0]) && ($a[1] <= 32 and $a[1] > 16); } die "updatenodes.pl networkIP/numberofbits\n" if $die; $debug = 2; } else { $debug = 15; } [download] results in $ ./updatenodes.pl 10.100.20.52/24 Use of implicit split to @_ is deprecated at ./updatenodes.pl line 19. <10.100.20.52/24> Use http://www.perlmonks.org/?node_id=802744 of uninitialized value in split at ./updatenodes.pl line 19. (10.100.20.52,24) [download] unexpected split to @_ and unexpected uninitialized warnings - script produces correct results - I am splitting to a list (array) - earlier I had my ($ip,$mask) as my list with same results - the Friendly Manual says "In scalar context, returns the number of fields found and splits into the @_ array." - my use is in list context NOT scalar - how to get rid of unexpected warnings? print statements were added to debug Comment on Unexpected "Use of implicit split to @_ is deprecated"Select or Download Code Replies are listed 'Best First'. Re: Unexpected "Use of implicit split to @_ is deprecated" by BrowserUk (Pope) on Oct 22, 2009 at 13:46UTC What do you think this line does? split @a = split m/\t/,$test; [download] Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon e
Search Username Password Remember Me? Register Lost Password? facebook google twitter rss Free Web Developer Tools Advanced Search Forum Programming Languages Perl Programming Use of implicit split to @_ is deprecated Thread: Use of implicit split to http://forums.devshed.com/perl-programming-6/implicit-split-_-deprecated-148054.html @_ is deprecated Share This Thread Tweet This + 1 this Post To http://www.thecodingforums.com/threads/implicit-split-to-_-is-deprecated-but-but.896454/ Linkedin Subscribe to this Thread Subscribe to This Thread May 14th, 2004,06:23 PM #1 No Profile Picture easy_coder View Profile View Forum Posts Contributing User Devshed Newbie (0 - 499 posts) Join Date Oct 2003 Posts 421 Rep Power 14 Use of implicit split to @_ is deprecated Why do I get these perl error error? Thanks Use of implicit split to @_ is deprecated "my" variable @keywords masks earlier declaration in same scope at s my @keywords = (); my @keywords = ("marketing", "coordinator", "technical"); foreach my $words (@keywords) { my $s = split($words, $text); # split text using keyword. Faq Reply With Quote May 14th, 2004,07:19 PM #2 keath View Profile View Forum Posts Visit Homepage !~ /m$/ Devshed Specialist (4000 - 4499 perl error use posts) Join Date May 2004 Location Reno, NV Posts 4,273 Rep Power 1812 You don't need the two 'my @keyword' declarations. The second is better where you both declare and initialize the array. I'm not sure what exactly you want to happen in the second section. You have text somewhere that we can't see that is to be split using the keywords? One thing to keep in mind is that when you split you will get multiple outputs, not a single scalar value. So you can't capture the return in a single $s variable. You could capture the output in an array, but without seeing an example of the text you are trying to split I'm not sure it will work like you want. Faq Reply With Quote May 14th, 2004,07:47 PM #3 No Profile Picture justice41 View Profile View Forum Posts Devshed Newbie (0 - 499 posts) Join Date Apr 2002 Location The Emerald City Posts 289 Rep Power 15 Check out the perldoc for split. In scalar context, returns the number of fields found and splits into the @_ array. Use of split in scalar context is deprecated, however, because it
@_ is deprecated at /Users/wgroleau/bin/INDENTREC.cgi line 95." Huh ? sub RecType { my $Key = shift; my $GedRec = split (/\n/, $Params{$Key}, 1); # line 95 I am trying to split off the first line of the multi-line record from the hash, into GedRec. I don't see how it is going into @_ -- Wes Groleau Even if you do learn to speak correct English, whom are you going to speak it to? -- Clarence Darrow Wes Groleau, Feb 6, 2006 #1 Advertisements Joachim Pense Guest Am Mon, 06 Feb 2006 04:14:59 GMT schrieb Wes Groleau: > "Use of implicit split to @_ is deprecated at > /Users/wgroleau/bin/INDENTREC.cgi line 95." > > Huh ? > > sub RecType > { > my $Key = shift; > my $GedRec = split (/\n/, $Params{$Key}, 1); # line 95 > > I am trying to split off the first line of the multi-line > record from the hash, into GedRec. I don't see how it is > going into @_ The result of a split is an array, not a scalar. You call split in a scalar context (as $GedRec is a scalar), so what happens is that the result of the split will be put into @_ implicitly, and $GedRec will receive the element count of @_. Joachim Joachim Pense, Feb 6, 2006 #2 Advertisements MSG Guest Re: implicit split to @_ is deprecated ? but, but, Wes Groleau wrote: > "Use of implicit split to @_ is deprecated at > /Users/wgroleau/bin/INDENTREC.cgi line 95." > > Huh ? > > sub RecType > { > my $Key = shift; > my $GedRec = split (/\n/, $Params{$Key}, 1); # line 95 > > I am trying to split off the first line of the multi-line > record from the hash, into GedRec. I don't see how it is > going into @_ > > -- > Wes Groleau > > Even if you do learn to speak correct English, > whom are you going to speak it to? > -- Clarence Darrow my ($GedRec) = split (/\n/, $Params{$Key}, 1); -----^-------------^----------------------------------------------- split returns a list. MSG, Feb 6, 2006 #3 John W. Krahn Guest Wes Groleau wrote: > "Use of implicit split to @_ is deprecated at > /Users/wgroleau/bin/INDENTREC.cgi line 95." > > Huh ? > > sub RecType > { > my $Key = shift; > my $GedRec = split (/\n/, $Params{$Key}, 1); # line 95 > > I am trying to split off the first line of the multi-lin