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

Re: Re(ALL): Putting it together

by fruiture (Curate)
on Aug 30, 2002 at 21:18 UTC ( [id://194257]=note: print w/replies, xml ) Need Help??


in reply to Re(ALL): Putting it together
in thread H of A optimization

I'd rather say:

my (%edgeHash,@alreadySeen); while(<STDIN>){ # simpler regexp if(/(\d+)\D+(\d+)/){ # don't use '$a' and '$b'! # and don't quote "$vars" # in fact you can keep $1 and $2 push @{$edgeHash{$1}}, $2 unless $alreadySeen[int($2)]++; } }
--
http://fruiture.de

Replies are listed 'Best First'.
Re(3): Putting it together
by Arien (Pilgrim) on Aug 30, 2002 at 21:30 UTC

    Well, in that case...

    my (%edge, @seen); while (<STDIN>) { $seen[$2]++ or push @{$edge{$1}}, $2 if /(\d+)\D+(\d+)/; # push @{$edge{$1}}, $2 if /(\d+)\D+(\d+)/ and not $seen[$2]++; }

    — Arien

    Edit: added the commented alternative.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-24 23:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found