Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: extract the value before a particualr string

by space_monk (Chaplain)
on Sep 05, 2013 at 10:12 UTC ( #1052536=note: print w/replies, xml ) Need Help??


in reply to extract the value before a particualr string

If you don't like split, try regexes instead. Something like ...
if (/(\d+)\/total$/) { print "$1\n"; }
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

Replies are listed 'Best First'.
Re^2: extract the value before a particualr string
by nanban (Initiate) on Sep 05, 2013 at 10:23 UTC
    Thanks for the reply... Can we implement it using split? i am pretty new to perl...
Re^2: extract the value before a particualr string
by nanban (Initiate) on Sep 05, 2013 at 10:29 UTC
    will it be possible to use split???
      nanban,
      will it be possible to use split???

      The first argument to split is a regular expression so it is really the difference between using capturing parens in a regular expression or using a regular expression to break the string into pieces but they are both regular expression solutions.

      Cheers - L~R

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1052536]
help
Chatterbox?
[choroba]: talking about golfing, I did Pascal's triangle in 51 characters ;-)
[choroba]: and 99 bottles of beer in 217

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2017-10-22 20:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (275 votes). Check out past polls.

    Notices?