Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

(jcwren) RE: regexp's

by jcwren (Prior)
on Oct 03, 2000 at 06:24 UTC ( [id://35040]=note: print w/replies, xml ) Need Help??

in reply to regexp's

Or, in a few less lines...
#!/usr/local/bin/perl -w use strict; { my %hash = (); while (<DATA>) { my @items = split; $hash {pop @items} = shift @items; } print "key=$_, val=$hash{$_}\n" foreach sort keys (%hash); } __DATA__ 1 time 02:11:05 djw 5 time 04:20:03 bert 2 time 00:01:39 chris

[jcw@linux fs]$ perl key=bert, val=5 key=chris, val=2 key=djw, val=1 [jcw@linux fs]$


e-mail jcwren

Replies are listed 'Best First'.
RE: (jcwren) RE: regexp's
by extremely (Priest) on Oct 04, 2000 at 02:17 UTC

    A benchmark vs. Ovid's regex. =) Tho you all knew split beats regex, here is the numbers.

    Benchmark: timing 50000 iterations of Ovid, jcwren...
          Ovid:  4 wallclock secs ( 3.32 usr +  0.00 sys =  3.32 CPU) @ 15060.24/s (
        jcwren:  2 wallclock secs ( 2.63 usr +  0.00 sys =  2.63 CPU) @ 19011.41/s (
              Rate   Ovid jcwren
    Ovid   15060/s     --   -21%
    jcwren 19011/s    26%     --

    $you = new YOU;
    honk() if $you->love(perl)

RE: (jcwren) RE: regexp's
by princepawn (Parson) on Oct 03, 2000 at 18:03 UTC


    that is elegant. Too bad I can only ++ you one time on that one. This is one the most elegant things I have EVER seen, save for something merlyn did in Effective Perl programming:
    ($_ & ~$_) eq 0
    to determine if a scalar is a number (i may be slightly off on the actual expression)

Log In?

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-15 16:25 GMT
Find Nodes?
    Voting Booth?

    No recent polls found