the => operator

F

fatwallet961

in the following code

what's => means?
is it an operator in perl?
any document on this opeartor?

my $xml = get (ItemPriceSearch_url());
my $xp = XML::XPath->new(xml => $xml);

thanks
 
P

perlguru

Yes; it is a operator, used to specify Key-Value pair of a hash.

As my friend said, you can even use comma replacing '=>'

Hence the line
my $xp = XML::XPath->new(xml => $xml);
can be changed to
my $xp = XML::XPath->new(xml , $xml);
 
A

anno4000

[please don't top-post]
Yes; it is a operator, used to specify Key-Value pair of a hash.

Not exclusively. You can use it anywhere you can use a comma, though
some modifications may be necessary.
As my friend said, you can even use comma replacing '=>'

That isn't quite right. Some modifications may be necessary for that
replacement too.
Hence the line
my $xp = XML::XPath->new(xml => $xml);
can be changed to
my $xp = XML::XPath->new(xml , $xml);

No, it can't. You didn't test that, did you? It is using the
auto-quote property of "=>", so the apparent bareword xml is actually
quoted. Plain comma doesn't do that, so the line must now be

my $xp = XML::XPath->new('xml' , $xml);

[tofu snipped]

Anno
 
W

Wayne M. Poe

Abigail said:
(e-mail address removed) ([email protected]) wrote on MMMMDCCCLXXXV
September MCMXCIII in
<URL:-- in the following code

And is normally used with hashes (an associative array, like std::map in
the C++ STL, or Object in JavaScript & VBScript.)
-- is it an operator in perl?

Yes.

-- any document on this opeartor?

$ perldoc perlop
Of course. In the same document that documents all the other
operators: perlop.



Abigail

Abigail, why in the name of Larry Wall are you using a sig delimiter for
a quote-char ? You do realize you breaking any processor that does
things like color coding quote levels and re-wrapping as necessary. I
know this isn't the first time someone has asked you to fix your
quoting, even if it's not always a problem, but being as random as it
is, you're just run the risk of breaking things for other people.

Could you please explain why you cannot just use one quoting style
instead of changing it every time you post, like everyone seems to be
able to do? Seriously, there is a good reason why the majority use
standard quoting.
 
W

Wayne M. Poe

Michele said:
-- any document on this opeartor?
^
^

[snip]

Abigail, why in the name of Larry Wall are you using a sig
delimiter for a quote-char ? You do realize you breaking any
processor that does

AFAIK the sig delimiter is "-- \n", so he's *not* using it as a quote
char.

In some places thats exactly what was there (any plank lien that was
quoted ends up being "-- \n"), and that makes it break any processor
that color codes quoting levels as well sigs based on that key you
noted.
 
W

Wayne Poe

Abigail said:
Wayne M. Poe ([email protected]) wrote on MMMMDCCCLXXXVI
September MCMXCIII in <URL:`` Michele Dondi wrote:
`` > On Tue, 16 Jan 2007 09:13:44 -0800, "Wayne M. Poe"
`` >
`` > > > -- any document on this opeartor?
`` > ^
`` > ^
`` >
`` > [snip]
`` > > > Abigail
`` > > > --
`` > > > #!/opt/perl/bin/perl -w
`` > >
`` > > Abigail, why in the name of Larry Wall are you using a sig
`` > > delimiter for a quote-char ? You do realize you breaking any
`` > > processor that does
`` >
`` > AFAIK the sig delimiter is "-- \n", so he's *not* using it as a
quote `` > char.
``
`` In some places thats exactly what was there (any plank lien that
was `` quoted ends up being "-- \n")

No.

Actually at the begining there is one occurance:

------------------------------------------------
(e-mail address removed) ([email protected]) wrote on MMMMDCCCLXXXV
September MCMXCIII in
<URL:-- in the following code
--
-- what's => means?
------------------------------------------------

Second to last line. From that line on, my reader shows the content as a
comment. No big deal, just wanted to point out that your unusual quoting
sometime creates problems. "> " has been the defacto quote char for as
long as I can remember, so what's wrong with it?
 
W

Wayne M. Poe

Abigail said:
Wayne Poe ([email protected]) wrote on MMMMDCCCLXXXVIII September
MCMXCIII in <URL:== Abigail wrote:
== > Wayne M. Poe ([email protected]) wrote on MMMMDCCCLXXXVI
== > September MCMXCIII in
<URL:== > `` In some
places thats exactly what was there (any plank lien that == > was ``
quoted ends up being "-- \n") == >
== > No.
==
== Actually at the begining there is one occurance:
==
== ------------------------------------------------
== (e-mail address removed) ([email protected]) wrote on
MMMMDCCCLXXXV == September MCMXCIII in
== <URL:== -- in the following code
== --
== -- what's => means?
== ------------------------------------------------

Second to last line.


No. Go to the original message and count carefully again. All you need
to do is count to 2.

------------------------------------------------------
1 (e-mail address removed) ([email protected]) wrote on MMMMDCCCLXXXV
2 September MCMXCIII in
<URL:3 --,,in the following code
4 --,,
5 --,,what's => means?
6
7 It's a comma which quotes a bareword on its left hand side.
------------------------------------------------------

Line 4 was the one I was talking about. Ok, you actually have two spaces
at the end rather than one (prior to the newline), so it's not the same,
I'll give you that

However, it appears to be close enough to interfere with some quote/sig
formatters. I've seen this break 2 that I have tested. One being
Quote-Fix for OE on win32, a news reader on my linux test box (whose
name escapes right now, but does nice color formatting of quote levels
sort of like OE-QF.) The both color from like 4, on, as if that was the
beginning of your sig.

This is in addition to the fact most quote processors like those I
listed don't recognize most of the quote characters you use. I also
remember problems on the old version of Google Groups when reading your
posts.

Please just answer the question (which you always seem to avoid), why
can't you just use standard, or at least more normal quoting, if for
nothing else than for the sake of sanity? I believe this is a perfectly
valid question.
 

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

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,662
Latest member
sxarexu

Latest Threads

Top