Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: accessing a part of a string

by phenom (Chaplain)
on May 18, 2012 at 11:11 UTC ( #971277=note: print w/ replies, xml ) Need Help??


in reply to accessing a part of a string

You want everything but a part of the string? You could play with this and alter it as needed:

my $string = 'some/very/varied_length/string'; my $subs = substr( $string, 0, length($string) - 6 ); say $subs;
Don't forget to add the OFFSET portion of substr.


Comment on Re: accessing a part of a string
Download Code
Replies are listed 'Best First'.
Re^2: accessing a part of a string
by Eliya (Vicar) on May 18, 2012 at 11:30 UTC
    substr( $string, 0, length($string) - 6 );

    can also be written as

    substr( $string, 0, -6 );

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (18)
As of 2015-07-30 20:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls