Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

ucfirst strangeness

by dominix (Deacon)
on Nov 01, 2004 at 09:52 UTC ( [id://404250]=perlquestion: print w/replies, xml ) Need Help??

dominix has asked for the wisdom of the Perl Monks concerning the following question:

making some test using one-liner, I've hit this :
perl -le "print join ' ', map{ucfirst} split / /, 'toto fait du velo' +" Toto Fait Du Velo ... sound like what I expected ... perl -MO=Deparse -le "print join ' ', map{ucfirst} split / /, 'toto fa +it du velo' " BEGIN { $/ = "\n"; $\ = "\n"; } print join(' ', map({ucfirst $_;} split(/ /, 'toto fait du velo', 0))) +; -e syntax OK perl -le "print join(' ', map({ucfirst $_;} split(/ /, 'toto fait du v +elo', 0)));" Toto Fait Du Velo Toto Fait Du Velo Toto Fait Du Velo Toto Fait Du Velo 1 1 1 1
if I replay it I've got plainty more lines
it look like {ucfirst} and {ucfirst $_} are not considered the same.
...
can someone explain me what I'm missing ?
--
dominix

Replies are listed 'Best First'.
Re: ucfirst strangeness
by PodMaster (Abbot) on Nov 01, 2004 at 10:04 UTC
    You're not the first and you won't be the last to be bit by shell interpolation. Try
    perl -le "print join(' ', map({ucfirst \$_;} split(/ /, 'toto fait du +velo', 0)));"
    instead.

    MJD says "you can't just make shit up and expect the computer to know what you mean, retardo!"
    I run a Win32 PPM repository for perl 5.6.x and 5.8.x -- I take requests (README).
    ** The third rule of perl club is a statement of fact: pod is sexy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://404250]
Approved by ysth
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-19 07:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found