Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

Re: split question (boo)

by boo_radley (Parson)
on Sep 08, 2001 at 03:04 UTC ( #111070=note: print w/replies, xml ) Need Help??

in reply to split question

split may not be so hot for this, especially behind an =~ operator... .
I'd suggest using a regex for this, something similar to :
my $inLine= "RPC, rpc #001b, (1987)"; $inLine=~/\((\d+)\)/; print $1

or, if you really wanna use split,

my $inLine= "RPC, rpc #001b, (1987)"; ($itm, $date)= split /[()]/, $inLine; print $date;

but I'd shy away from that, personally.

Replies are listed 'Best First'.
Re: Re: split question (boo)
by chiller (Scribe) on Sep 08, 2001 at 03:44 UTC
    Or if he really wants the "remainder":
    my $inLine= "RPC, rpc #001b, (1987)"; $inLine =~ /([^(]+)\((\d+)\)/; my ($remainder, $date) = ($1, $2);
    .. assuming $inline is the only line of data...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://111070]
[dazz]: Hi I have grabbed an image from an IP camera with Image::Grab. I then want to pass that image object to a subroutine where I do a read-only test on the image with Image:Magick.
[dazz]: How do I pass an image object to a subroutine and then apply a Image::Magick a read-only method to the image object???

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (9)
As of 2017-03-27 07:35 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (317 votes). Check out past polls.