Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: RegEx & Approach Question

by snoopy (Deacon)
on Oct 10, 2007 at 23:31 UTC ( #644112=note: print w/ replies, xml ) Need Help??

in reply to RegEx & Approach Question

String::Scanf's format_to_re method might be useful for parsing these patterns. It lets you setup regular expressions in an sprintf like format.

#!/usr/bin/perl use warnings; use strict; use String::Scanf qw(); sub scanf { my $pat = String::Scanf::format_to_re(shift); my $input = shift; return $input =~ /^${pat}$/; } my $format = "Input queue: %d/%d/%d/%d (size/max/drops/flushes); Total + output drops: %d"; my $input = "Input queue: 0/75/0/39 (size/max/drops/flushes); Total ou +tput drops: 19845805"; if (my ($size,$max,$drops,$flush,$total) = scanf($format, $input)) { warn "Gotcha: size=$size, max=$max,drops=$drops,flush=$flush,total=$ +total"; }

Comment on Re: RegEx & Approach Question
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (13)
As of 2015-01-27 14:51 GMT
Find Nodes?
    Voting Booth?

    My top resolution in 2015 is:

    Results (200 votes), past polls