in reply to Re^2: perl system command
in thread perl system command

in order to get what I want

It isn't overly clear what you want. If you have a string with words separated by underscores and just want to return the last such word then you could do this:

my $row = 'We_need_feed'; my ($last) = $row =~ /[^_]*$/g; print $last;

or you could split and then pop but maybe extracting the last isn't what you want at all.

Replies are listed 'Best First'.
Re^4: perl system command
by cbtshare (Monk) on Nov 10, 2016 at 16:27 UTC
    thank you , I learned from your example. I wanted to extract just the word "feed", I was using my $result=$row=~/feed*/m but $result would just contain 0 or 1 which I read is expected, but your way gets the phrase.Thank you , but what does /^_*$/ do? You are saying you are searching for underscore at the front, followed by anything at the end? and what does the brackets [] do? Thank you

      The square brackets indicate a character class and the caret inside negates what follows such that [^_] means any character other than an underscore. The dollar anchors it to the end. All this is in perlre and related pages which are well worth a read.