amarbvn has asked for the wisdom of the Perl Monks concerning the following question:

I am having a string like this:

$abc= ' NAME=ABCDEF 128 @# CLASS= @# EIGHT 8.58 SCHOOL=GRAMMAR HIGH L-1 '

I am accepting a variable ($input_var) from the user. Based on the variable the user provides I want to delete that line.

Ex: If the input variable provided is NAME, I want to delete: NAME=ABCDEF 128 @#

Ex: If the input variable provided is CLASS, I want to delete: CLASS= @# EIGHT 8.58

I want to write some thing like
$abc =~ s/$input_var(Has to fill some thing here)//;

Early help is highly appreciable.
Thanks in Advance.

Replies are listed 'Best First'.
Re: Required help on substitution using a string in perl
by moritz (Cardinal) on Aug 12, 2011 at 13:28 UTC
Re: Required help on substitution using a string in perl
by jethro (Monsignor) on Aug 12, 2011 at 13:24 UTC

    It seems your variable $abc is a multiline string, i.e. there are \n inside. So probably you can just delete anything starting with your search string to the next \n. Surely your teacher showed you how to specify "anything"