Perl: extracting substrings from scalar variable.?

  • Thread starter Thread starter schmals
  • Start date Start date
S

schmals

Guest
So, I'm pretty new to the perl language and still trying to hammer out some details. If I have a scalar variable and wish to take a substring of that variable, how do I do that. For example:

$var = "15 PLUS 10";
(how to i extract the string "PLUS" from $var??)

I know there is a substr() function, but that doesn't help me here because it's parameters take in a starting index and a length. In my case the 'P' character will not always be in the same index of the $var string. Any and all suggestions would be greatly appreciated.
 
Back
Top