Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: extract the value before a particualr string

by space_monk (Chaplain)
on Sep 05, 2013 at 10:12 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1052536]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2024-03-28 09:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found