in reply to remove specific data from a line

I think you want:
$line =~ s/^myword \S+//; # strip myword, a space, and any stretch of +non-spaces
Update: After seeing your clarification, I see that you could have spaces in the comma-separated list. So you'd want:
$line =~ s/^ #strip, from the beginning of the string, myword\s+ #myword, followed by whitespace \S+ #followed by non-whitespace (?:,\s*\S+)* #followed by any number of comma, optional w +hitespace, non-whitespace //x; # update: two slashes are needed here

Caution: Contents may have been coded under pressure.

Replies are listed 'Best First'.
Re^2: remove specific data from a line
by Anonymous Monk on Feb 03, 2006 at 09:54 UTC
    This one nearly work but not handle this line
    abcefgh qwerty, asdfg yuio jklh
    It print out
    asdfg yuio jklh
    I had to add extra slash to your code like this
    $line =~ s/^abc\w+\s+\S+(?:,\s*\S+)*//x;
    otherwise got errors. I hope this was what you mean. I try to change your code to handle last line which don't leave just  yuio jklh.
    How do I fix this ?
    Thank you for answer so far , it show me how much flexible Perl is
      I forgot to substitute the first word back in.
      $line =~ s/^(abc)\w+\s+\S+(?:,\s*\S+)*/$1/x;
      should give you what you want. You were right about the missing slash.

      Caution: Contents may have been coded under pressure.