Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^2: Assignments for Subroutines

by nemesdani (Friar)
on Sep 27, 2012 at 10:29 UTC ( #995965=note: print w/ replies, xml ) Need Help??


in reply to Re: Assignments for Subroutines
in thread Assignments for Subroutines

$,=", "; #change list delimiter for fancy printing print @evens; print "\n"; #newline $,=""; #change list delimiter back before it is a problem
That could be written as
{ local $,=", "; print @evens; print "\n"; #newline }
No need to change it back, less possibility of an error. My 2 cents.


I'm too lazy to be proud of being impatient.


Comment on Re^2: Assignments for Subroutines
Select or Download Code
Re^3: Assignments for Subroutines
by protist (Monk) on Sep 27, 2012 at 10:55 UTC
    That is better. You have my +1
Re^3: Assignments for Subroutines
by tobyink (Abbot) on Sep 27, 2012 at 16:17 UTC

    Indeed. Especially because this...

    $,=""; #change list delimiter back before it is a problem

    ... changes the list delimited "back" to the empty string, when we never checked that it started off as the empty string to begin with!

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2014-09-22 20:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (201 votes), past polls