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

Re^2: Array searching, grep, first

by jimbus (Friar)
on Sep 01, 2005 at 18:13 UTC ( #488445=note: print w/replies, xml ) Need Help??

in reply to Re: Array searching, grep, first
in thread Array searching, grep, first

There are usually 90-120 lines in the CSV per day, so I'm not sure it matters.

Can I get a little explaination on whats going on with grep { $csvlist[$_] =~ /$x/} 0..$#csvlist; it looks like it would be useful.


Never moon a werewolf!

Replies are listed 'Best First'.
Re^3: Array searching, grep, first
by friedo (Prior) on Sep 01, 2005 at 18:29 UTC
    What's going on here is that the list that is being greped consists of the numbers 0..$#csvlist. (Or zero through the highest index in the array.) The conditional inside the grep block looks at the array item indexed at each number and returns that number if the condition is true.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://488445]
[choroba]: To avoid accidental overwriting of the variable in if ($x = 3)
[karlgoethebier]: Corion: Auch in hessisch? Mer wasses net.
[Corion]: Hmm - I'm not sure, I haven't read the mundart/slang translations ;)
[Eily]: $F[1] =~ s/^0//r could be written as (0+$F[1]). It's less explicit though
[Discipulus]: ah! seems wise choroba, you play safe
[shmem]: Eily: also -+-$F[1]
[shmem]: hmm... there should be a glyph for "bembel" in unicode "miscellaneous symbols"
[karlgoethebier]: shmem: ++1000. Also for Schöppsche
[Eily]: shmem Indeed :)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (12)
As of 2017-05-24 08:44 GMT
Find Nodes?
    Voting Booth?