On Mon May 14 06:19:31 2012, mst@shadowcat.co.uk wrote:
> > So when there are commas separating elements in the list, single
> quotes
> > are required?
>
> The key thing to remember is that => is a comma that autoquotes its
> left
> hand side if its left hand side is a valid bareword.
>
> So given a valid bareword to the left of an =>, it does not need
> quoting.
> Perl already does so.
>
> Whether a comma is used further on to separate later elements doesn't
> affect
> this - could you point out which specific part of the documentation
> leaves
> this unclear to you and suggest a rewording?
>
> > my ($dat, $tim) = @{$p}{dat=>tim};
>
> Here, since the dat is to the left of the => and is a valid bareword,
> it's
> autoquoted; if you wanted the output of the dat() function then yes,
> you
> could use & but I'd rather write it
>
> my ($dat, $time) = @{$p}{dat()=>'tim'};
>
> (bear in mind that strict will simply refuse to accept the unquoted
> tim
> before you get as far as worrying about possible clashes with future
> reserved names).
>
> > funny how I was always taught that => and , are synonymous... Seems
> > that's changed.
>
> I'm not sure what you mean; as I mention above, => is a comma that, if
> its
> left hand side is a valid bareword, implicitly quotes it.
>
> It's worth remembering though that while -foo is not a valid bareword,
> unary
> minus when applied to a string prepends a - to it - hence
>
> -'foo'
>
> returns
>
> "-foo"
>
> although the single quotes are optional since the parsing for unary
> minus
> will implicitly quote a *following* bareword in the same way that =>
> implicitly quotes a *preceding* one.
It doesnât autoquote it, but simply exempts it from strictures. -time
is the current time negated, not "-time".
--
Father Chrysostomos
---
via perlbug: queue: perl5 status: rejected
https://rt.perl.org:443/rt3/Ticket/Display.html?id=112914
Thread Previous
|
Thread Next