Beefy Boxes and Bandwidth Generously Provided by pair Networks BBQ
P is for Practical
 
PerlMonks  

Re: Make Love, not war...

by thunders (Priest)
on Sep 24, 2001 at 15:53 UTC ( [id://114350]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Make Love, not war...

just a quick tip,
after you set up your array, the important part of your foreach loop could be rewritten like so:

for(@h1){$_=chr;print}

get to know the $_ special variable. it'll save you tons of typing and redundant statements. also, the for and foreach loops are interchangable. Any place you can use one you can use the other. example:
foreach ($i=0;$i < 10;$i++){do something}
for is three characters foreach is seven, guess which one most Perl programmers use :)
hint: think lazy

Replies are listed 'Best First'.
Re: Re: Make Love, not war...
by Sifmole (Chaplain) on Sep 24, 2001 at 16:51 UTC
    Perhaps the choice of using the code the programmer did is based on the aesthetic layout?

    While you are at it? Why bother reassigning the result of chr to $_? Just drop that line alltogether to get  for(@h1){ print chr; } and of course if your decision is to be based on the number of characters you can go to print chr for(@h1); but getting the smallest WTDI is golf and not obfuscation.

      I'd personally use:
      print map chr, @h1;
      But to each their own. I was just offering some advice.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://114350]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.