Tolgar
asked on
How to extract a value from a string seperated by dot character in Perl?
Hi,
I have a variable somewhere in my code.
The string looks like this:
From this string I want to extract the followings:
The grammar rule is:
The beginning of the string is always same:
and the number that I want is always after the last dot character till the end
In general according to the rule I can write:
I want to extract X values from this string
How can I do it in Perl?
Thanks,
I have a variable somewhere in my code.
The string looks like this:
/mycmp/kmg/vel/kat/Atk/cache/0915/0914222222.submit.tolgar.111111
From this string I want to extract the followings:
Atk
111111
The grammar rule is:
The beginning of the string is always same:
/mycmp/kmg/vel/kat/
and the number that I want is always after the last dot character till the end
In general according to the rule I can write:
/mycmp/kmg/vel/kat/X/cache/ANYTHING.X
I want to extract X values from this string
How can I do it in Perl?
Thanks,
ASKER
is it possible to separate them into two lines to make it more readable?
Thanks,
Thanks,
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
";
my ($val1, $val2) = $str =~ m{/kat/(\w+).*\.(\w+)};
$val1 and $val2 is what you need.