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

Re: how to get numbers only from n numbers or more digit numbers?

by zork42 (Monk)
on Jun 13, 2013 at 07:09 UTC ( #1038694=note: print w/replies, xml ) Need Help??


in reply to how to get numbers only from n numbers or more digit numbers?

Are you saying you want your output to look like this?
chapter 01 02 03 04
Also, it might help if you add a few more example elements to @f on line 1.

Replies are listed 'Best First'.
Re^2: how to get numbers only from n numbers or more digit numbers?
by virudinesh (Acolyte) on Jun 13, 2013 at 07:26 UTC
    chapter 01 no need only 02,03,04

      split by ",", shift the resulting array, here you are.

      my @results = split /,/,$_; shift @results; print "@results\n";

      use warnings; use strict; my $f='chapter 01,02,03,04'; if(my @m=$f=~/,([0-9]{2})/g){ print "@m\n"; #prints 02 03 04 }
      Note: I would rather use a scalar variable, instead of an array variable with only one element like you had.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me
        if your using use @m array.. if possible to store in any variable.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1038694]
help
Chatterbox?
[LanX]: choroba yes that's why a have no cars left
[Eily]: maybe you could crash the python compiler instead
[LanX]: Larry the greatest
[LanX]: hmm this joke may be too old for millennials
[LanX]: s/joke/reference/

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (15)
As of 2017-03-23 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should Pluto Get Its Planethood Back?



    Results (292 votes). Check out past polls.