Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: foreach loops

by mrbbking (Hermit)
on Dec 16, 2001 at 01:08 UTC ( #132258=note: print w/replies, xml ) Need Help??

in reply to foreach loops

In the last example, where foreach uses the default $_, you could go one step further and allow print to do the same.
If you're willing to forego the commas, that is:
foreach(@numbers){ print; }

Replies are listed 'Best First'.
Re (tilly) 2: foreach loops
by tilly (Archbishop) on Dec 16, 2001 at 05:00 UTC
    You can keep the commas and forgo the loop if you want...
    local $, = ","; print @numbers;
Re: Re: foreach loops
by blakem (Monsignor) on Dec 16, 2001 at 01:17 UTC
    Or keep the comma with:
    foreach(@numbers) { local $\ = ','; print; }


      Really i am enjoying doing perl ,as perlmonks are with me. Thanks! for this work.

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2022-05-26 10:20 GMT
Find Nodes?
    Voting Booth?
    Do you prefer to work remotely?

    Results (93 votes). Check out past polls.