String manipulation in perl

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ajd335
    New Member
    • Apr 2008
    • 123

    String manipulation in perl

    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??
    Thanks,
  • KevinADC
    Recognized Expert Specialist
    • Jan 2007
    • 4092

    #2
    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:

    Code:
    $var = "3643294 /usr/local/bin/xyz";
    $var =~ tr/0-9//cd;
    print $var;
    assumes there are never digits in the /usr/blah/blah part

    Comment

    • ajd335
      New Member
      • Apr 2008
      • 123

      #3
      Thanks ,
      The problem is resolved.

      Comment

      Working...