Re: urgent:reading 2 files into 2 different $ variables

geot wrote:
i have html file containing 2 parts

1 . javascript code
2 html table.

now i am asked to search all html files in the foldr to see whether
this 2 parts are found in the html files found in the folder if they
are found the replace it with null string.

i splited the first html file in to 2 one containing jscript.txt file
which contains the javascript and other file is table.txt which
contains the table. i read both files into 2 scalar variables. so i
have $jscript which contain jscript.txt and $table which contains

now i opened a third file (html ) into a scalar and tried to match
whether that file contains
$jscript & $table.

Um, I assume you are counting on the Javascript and HTML table entries remaining bit-for-bit the same in all your files, right? The problem with this approach is that the Javascript and HTML table strings almost certainly contain regular expression meta-characters. Those characters need to be quoted so they don't have their meta-meanings, but are considered as ordinary characters to be matched. This can be done with the \Q and \E (note case) regular expression atoms, as in:

#code to run if $javascript is present

Note that the g and i modifiers you show are probably not needed if the text is verbatim and not repeated, which seems likely.

Alternatively you can use the quotemeta() function to add appropriate quoting to your character strings. See:

perldoc -f quotemeta

Also, your post contains a red flag for responders -- the statement "it's not working". This is next to meaningless, and we can't read your mind. Please give copy/pasted error messages the are generated, and state precisely what it is that your program is not doing that you think it should do, or what it is doing that you think it should not do. Also state why you think it should behave differently than it is.

For best results, include a short but complete Perl program that anyone can copy/paste/run that demonstrates the problem you are having.

sub file_open {

my $name =shift;
local(undef $/);
my $content = <FILE>;
return $content;

my $match_content = &file_open($match_file);
$match_content =~s/\b$jscript\b//gi;
$match_content =~s/$table//gi;

but its not working .
Bob Walton