Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Variable matching on a regex

by almut (Canon)
on Jun 17, 2010 at 14:47 UTC ( [id://845217]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    $data =~ /^(?:(\d+)\s*(?{ push @results, $^N }))+$/;
    
  2. or download this
    my @results;
    while (<DATA>) {
    ...
    1 2 3 4 5
    2 3 4 5 6
    3 4 5 6 7
    
  3. or download this
    line 1: 1-2-3-4-5
    line 2: 2-3-4-5-6
    line 3: 3-4-5-6-7
    
  4. or download this
    while (<DATA>) {
        my @results;
        /^(?:(\d+)\s*(?{ push @results, $^N }))+$/;
        print "line $.: ", join('-', @results), "\n";
    }
    
  5. or download this
    line 1: 1-2-3-4-5
    line 2: 
    line 3:
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-03-19 07:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found