Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Elegant way to split into sequences of identical chars? (for)

by tphyahoo (Vicar)
on Nov 30, 2005 at 16:01 UTC ( #512974=note: print w/replies, xml ) Need Help??


in reply to Re^3: Elegant way to split into sequences of identical chars? (for)
in thread Elegant way to split into sequences of identical chars?

Thanks, but what is that exactly? Google and supersearch weren't much help.
  • Comment on Re^4: Elegant way to split into sequences of identical chars? (for)

Replies are listed 'Best First'.
Re^5: Elegant way to split into sequences of identical chars? (for)
by tye (Sage) on Nov 30, 2005 at 16:47 UTC

    for can be used to loop over a list of items (in which case it makes more sense to use foreach except that Perl programmers are usually too interested in being terse). It can be used to construct a C-style loop, for(init;whileTrue;gotoNext). It can also be used to create a temporary alias to some scalar that you want to do more than one operation on.

    for( $thingy{foo()}{bar()} ) { s/^\s+//; s/\s+(#.*)?$//; tr/A-Z/a-z/; }

    vs.

    $thingy{foo()}{bar()} =~ s/^\s+//; $thingy{foo()}{bar()} =~ s/\s+(#.*)?$//; $thingy{foo()}{bar()} =~ tr/A-Z/a-z/;

    - tye        

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2019-05-22 12:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you enjoy 3D movies?



    Results (140 votes). Check out past polls.

    Notices?
    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!