Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Extract info from a list

by Zaxo (Archbishop)
on Jul 16, 2003 at 01:36 UTC ( [id://274657]=note: print w/replies, xml ) Need Help??


in reply to Extract info from a list

An easy way is to split on '/' which ordinarily needs to be escaped. The resulting array has nothing in the first two slots,

my %count; $count{(split /\//)[2]}++ while <DATA>; printf "%s = %d\n", $_, $count{$_} for keys %count; __DATA__ //word.one.team/other.stuff/Info.info //this.sentence/other.inforation/moreInfo //first.part.here/set.list //this.sentence/data/processing

Update: ++tos for the correction. Repaired.

After Compline,
Zaxo

Replies are listed 'Best First'.
Re: Re: Extract info from a list
by tos (Deacon) on Jul 16, 2003 at 09:24 UTC
    a little typo in your fine solution

    $_ and $count{$_} have to be swapped

    printf "%s = %d\n", $_, $count{$_} for keys %count;
    greetings, tos

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-19 00:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found