implicit split to @_ is deprecated ? but, but,

W

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 @_

--
Wes Groleau

Even if you do learn to speak correct English,
whom are you going to speak it to?
-- Clarence Darrow
 
J

Joachim Pense

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
 
M

MSG

Wes said:
"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.
 
J

John W. Krahn

Wes said:
"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 @_

When split() is used in void or scalar context the results are stored in the
@_ array. To do what you want you have to either put the scalar in a list:

my ( $GedRec ) = split /\n/, $Params{ $Key }; # line 95

Or use a list slice on split():

my $GedRec = ( split /\n/, $Params{ $Key } )[ 0 ]; # line 95


Also, using 1 as the third argument does not do what you appear to think it does:

$ perl -le' @x = split /X/, "oneXtwoXthreeXfourX"; print for @x '
one
two
three
four
$ perl -le' @x = split /X/, "oneXtwoXthreeXfourX", 1; print for @x '
oneXtwoXthreeXfourX

So your original statement is the same as writing:

my $GedRec = $Params{$Key};




John
 
K

Keith Keller

The result of a split is an array, not a scalar.

This has already been posted correctly elsewhere, but I thought it
worthwhile to followup to be explicit: the result of a split is not an
array, but a list. You can of course store the result in an array, but
you don't have to; the other solutions have it being stored in a list of
scalars, for example.

Yes, that's pedantic, but the list/array distinction is confusing
enough to beginners. :)

--keith
 
P

Paul Lalli

Wes said:
"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 @_

Other posters have given you the answer, but I'm forced to wonder if
you even *tried* to figure it out on your own first. Please make sure
you check the built-in perl documentation for the functions your using,
especially if the warning message is nice enough to tell you exactly
what function is not working correctly:

perldoc -f 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
clobbers your subroutine arguments.

Paul Lalli
 
W

Wes Groleau

Paul said:
Other posters have given you the answer, but I'm forced to wonder if
you even *tried* to figure it out on your own first. Please make sure
you check the built-in perl documentation for the functions your using,
especially if the warning message is nice enough to tell you exactly
what function is not working correctly:

For what it's worth, never in my decades of Usenet use can I remember
asking a question without doing some research. With perl, usually
I spend 5-10 minutes with perltoc or perlfaq or ... trying to figure out
which of the 131 perl man pages (157 K lines) to look in, 5-10 minutes
figuring out it ain't in that one, .... how many reps of that depends
on how tired I am. About half (?) the time, I find the right one and
don't need to troll Usenet for RTFMs.
perldoc -f 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
clobbers your subroutine arguments.

You don't have to believe me, but the biggest problem was that in spite
of having been doing off and on perl for ten years, I actually did not
realize the implications of trying to treat "one item" as if it were "a
list containing one item" as being the same. In other words, _others_
foolishly gave me the answer, while you nobly upheld the finest
traditions of Usenet by bestowing upon me well-deserved and elegantly
worded contempt for my lack of skill at navigating the stacks of the
awesome Perl Public Library.

OTOH, I realize not everyone agrees with those traditions.
For example, Larry Wall: "There ain't nothin' in this world
that's worth being a snot over."

--
Wes Groleau

Those who make peaceful revolution impossible
will make violent revolution inevitable.
-- John F. Kennedy
 
W

Wes Groleau

Keith said:
worthwhile to followup to be explicit: the result of a split is not an
array, but a list. You can of course store the result in an array, but
you don't have to; the other solutions have it being stored in a list of
scalars, for example.

Yes, that's pedantic, but the list/array distinction is confusing
enough to beginners. :)

Well, as I have hinted elsewhere, in this case the distinction that was
hidden by my OldTimer's disease was that a scalar is not the same thing
as a list containing one scalar.

Many thanks to Joachim, MSG, and John for giving my spinning wheels
a little helpful shove.

I still don't understand the third parameter. I thought I had read
that it meant split off that many and ignore the rest.
 
W

Wes Groleau

Wes said:
Many thanks to Joachim, MSG, and John for giving my spinning wheels
a little helpful shove.

Wouldn't you know, now that I know how to make it work,
I've discovered I don't need that sub after all. :)

--
Wes Groleau

I've noticed lately that the paranoid fear of computers becoming
intelligent and taking over the world has almost entirely disappeared
from the common culture. Near as I can tell, this coincides with
the release of MS-DOS.
-- Larry DeLuca
 
P

Paul Lalli

Wes said:
For what it's worth, never in my decades of Usenet use can I remember
asking a question without doing some research.

Good! Unfortunately, that puts you in the vast minority.
With perl, usually
I spend 5-10 minutes with perltoc or perlfaq or ... trying to figure out
which of the 131 perl man pages (157 K lines) to look in, 5-10 minutes
figuring out it ain't in that one,

I can understand that frustration. But in this case, it seemed obvious
that if you are having a problem with split(), then you should look at
the docs for split().
You don't have to believe me, but the biggest problem was that in spite
of having been doing off and on perl for ten years, I actually did not
realize the implications of trying to treat "one item" as if it were "a
list containing one item" as being the same.

I believe you just fine. That's not a completely foolish error to
make. My problem was that you gave no indication you had attempted to
solve the problem for yourself. If you had simply said "I read
`perldoc -f split`, but I still don't understand this warning. . . "
I'd have had no problem, and probably wouldn't have posted at all.
In other words, _others_ foolishly gave me the answer,

As I noted in the very first line of my post.
while you nobly upheld the finest
traditions of Usenet by bestowing upon me well-deserved and elegantly
worded contempt for my lack of skill at navigating the stacks of the
awesome Perl Public Library.

No no. I bestowed upon you contempt for seemingly not attempting to
help yourself before asking thousands of other people to help you.
Read the Posting Guidelines for this group. They will inform you that
your best bet to receive help is to explicitly state what you have
tried to solve your problem on your own. By not stating any such
thing, you implied that you had made no effort.

Indeed, if you had said that you read the docs, but still didn't
understand the warning, then we could have deduced that you did not
understand that assigning to a scalar was forcing split() to be called
in a scalar context, and could have helped you better.

(FWIW, this exact issue happened to me about a year ago in this group -
I was seeing odd behavior with the .. operator, and read the docs, but
my post did not indicate that. I was justly chided for not reading the
documentation, when in fact the issue was me not realizing my code was
using .. in a scalar context:
http://groups.google.com/group/comp...ul+author:Lalli&rnum=1&hl=en#66a7666442c770f2
)
OTOH, I realize not everyone agrees with those traditions.
For example, Larry Wall: "There ain't nothin' in this world
that's worth being a snot over."

I am truly sorry if you considered my post to be snotty. That was not
the intent. The intent was both to inform you of where you could have
found the answer on your own, and to help anyone lurking learn where
they could have found the answer had they had a similar problem.

Regards,
Paul Lalli
 
T

Tad McClellan

Wes Groleau said:
For what it's worth, never in my decades of Usenet use can I remember
asking a question without doing some research.


I can remember you doing it less than a month ago:

Subject: Where do you report perl bugs?
Message-Id: (e-mail address removed)

You don't have to believe me, but the biggest problem was that in spite
of having been doing off and on perl for ten years, I actually did not
realize the implications of trying to treat "one item" as if it were "a
list containing one item" as being the same.


perldoc perldata

See the "Context" section.

In other words, _others_
foolishly gave me the answer,


Exactly so.

while you nobly upheld the finest
traditions of Usenet by bestowing upon me well-deserved and elegantly
worded contempt for my lack of skill at navigating the stacks of the
awesome Perl Public Library.


Typing

perldoc -q bug
and
perldoc -f split

does not require navigating stacks of awesome documentation.

Your credibility suffers, in my observations of your posting history.
 
W

Wes Groleau

Paul said:
solve the problem for yourself. If you had simply said "I read
`perldoc -f split`, but I still don't understand this warning. . . "

:) I couldn't have done that because two days ago I had never
heard of "perldoc -f"

This is odd, but I have read three or more perl books cover to
cover, and I don't remember ANY of them paying any attention
to man pages or other electronic documentation.

"perldoc -f" I suspect I won't forget that one. :)

--
Wes Groleau
"Ideas are more powerful than guns,
We would not let our enemies have guns;
why should we let them have ideas?"
-- Jozef Stalin
 
W

Wes Groleau

Tad said:
I can remember you doing it less than a month ago:

Subject: Where do you report perl bugs?
Message-Id: (e-mail address removed)

Apparently your memory is no better than mine.
I abandoned gbronline a heck of a lot longer
than a month ago. Long enough that I can't be certain
I did any research on that question. I do know that it
wouldn't be like me to not try to figure it out on my own.

But of course, you will believe whatever you want to
believe about me. Enjoy.

--
Wes Groleau
"Ideas are more powerful than guns,
We would not let our enemies have guns;
why should we let them have ideas?"
-- Jozef Stalin
 
A

A. Sinan Unur

This is badly quoted out of context. Paul did not say "solve the problem
yourself". Instead, he said:

<blockquote author="Paul Lalli">
My problem was that you gave no indication you had attempted to
solve the problem for yourself.
:) I couldn't have done that because two days ago I had never
heard of "perldoc -f"

That statement also means that you have not read the posting guidelines
before posting here:

http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html#must

Since you chose not to satisfy the most basic requirement for receiving
help here, Paul's warning was entirely appropriate.
"perldoc -f" I suspect I won't forget that one. :)

That's good because it is becoming less and less likely that you'd be
able to get help any other way.

So long.

Sinan
 
W

Wes Groleau

Wes said:
OTOH, I realize not everyone agrees with those traditions.
For example, Larry Wall: "There ain't nothin' in this world
that's worth being a snot over."

Amusing that I had to BE a snot to introduce a quote
about being a snot.

Sorry.
 
T

Tad McClellan

Wes Groleau said:
Apparently your memory is no better than mine.


Apparently we have entered the Twilight Zone then, as that
message ID appears on both my news server and on google groups.

I abandoned gbronline a heck of a lot longer
than a month ago.


So that wasn't you using your name in that thread?
 
T

Tad McClellan

Tad McClellan said:
I can remember you doing it less than a month ago:

Subject: Where do you report perl bugs?
Message-Id: (e-mail address removed)


Doh!

That was January 200_5_, not 2006.

I guess my $current_year++ takes a few months to finish executing. :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top