By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,374 Members | 2,014 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,374 IT Pros & Developers. It's quick & easy.

String manipulation in perl

P: 123
Hi all,
I got one value after all computation which is something like
" 3643294 /usr/local/bin/xyz"

The last xyz is the user input and hence changable.
I wanted store just 3643294 in one variable and remove all starting with /usr........
How can I do so??
Dec 11 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 2.5K+
P: 4,059
There are a number of ways to go about this. Next time post the code you have tried to resolve your question, even if it didn't work. Here is one way:

Expand|Select|Wrap|Line Numbers
  1. $var = "3643294 /usr/local/bin/xyz";
  2. $var =~ tr/0-9//cd;
  3. print $var;
assumes there are never digits in the /usr/blah/blah part
Dec 11 '08 #2

P: 123
Thanks ,
The problem is resolved.
Dec 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.