Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: The most annoying common way to get a string literal in Perl is...

by saskaqueer (Friar)
on Jun 16, 2004 at 23:44 UTC ( #367473=note: print w/ replies, xml ) Need Help??


in reply to The most annoying common way to get a string literal in Perl is...

I'm surprised that bareword came up as most unpopular. I know for a fact that there are a million and two Perl programmers that use unquoted strings when it comes to hashes and lists. This makes me wonder if perhaps using => as a comma operator and unquoted hash keys are not generally considered barewords. Example follows of course.

#!perl -w use strict; my %en2fr = ( one => 'un', two => 'deux', three => 'trois' ); # yes I realize there are better ways to grab the # hash values, this is for demonstration only :) print join( ', ', $en2fr{one}, $en2fr{two}, $en2fr{three} ), $/;


Comment on Re: The most annoying common way to get a string literal in Perl is...
Select or Download Code
Re^2: The most annoying common way to get a string literal in Perl is...
by mojotoad (Monsignor) on Jun 17, 2004 at 07:37 UTC
    I thought of this as well, before I voted for bareword. And I thought some more. And I arrived at the conclusion that bare words that are not ambiguous in their context are not bare at all -- in fact, they bear it quite well.

    There you have it. The Emperor has Clothes.

    Cheers!
    Matt

    Don't make me groan and bare it.

Re^2: The most annoying common way to get a string literal in Perl is...
by Skeeve (Vicar) on Jul 12, 2004 at 21:33 UTC
    I voted for bareword too. But I don't consider one => 'un' as being bareword as => explicitly (AFAIK) defines the word to it's left as being quoted.

    OTOH I render $en2fr{one} as being use of a bareword which I absolutely dislike. Consider this example and tell me without testing it's output:
    $umask= umask; $hash{$umask}='umask value'; $hash{'umask'}='umask text'; print $hash{umask};
    • Is the output 'umask text'?
      How can you make sure it will be 'umask value'?
    • Or is the output 'umask value'?
      How can you make sure it will be 'umask text'?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://367473]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (9)
As of 2014-09-01 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (299 votes), past polls