Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re^2: Little annoying mistakes ... of others

by Porculus (Hermit)
on Dec 07, 2008 at 14:25 UTC ( #728713=note: print w/ replies, xml ) Need Help??


in reply to Re: Little annoying mistakes ... of others
in thread Little annoying mistakes ... of others

Can be written chomp(my $line = <STDIN>); ;D

But that doesn't generalise for all rvalue uses. For example, I frequently want to write something like

frobnicate(chomp) while <$file>;     # doesn't work

and am of course instead forced to write the loop out longhand, since

chomp, frobnicate($_) while <$file>; # yuck

is starting to get hard to read.

Personally I consider this a failure in Perl's Huffman coding. I can't think of a single case where I've cared in the slightest how many characters chomp removed, but I do want to be able to chomp something and then immediately pass the chomped value to some other routine.


Comment on Re^2: Little annoying mistakes ... of others
Select or Download Code
Re^3: Little annoying mistakes ... of others
by ikegami (Pope) on Dec 08, 2008 at 00:10 UTC
    I think the point is efficiency (avoid copying the argument) rather than counting characters.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://728713]
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-17 22:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (100 votes), past polls