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

Relevant Pages

  • Re: Forms in table cells modify cell height - grrr
    ... By HTML versions from HTML 4.0 onwards, the meaning of a form element is undefined unless it has an action attribute with a http URL. ... a page might be generated by JavaScript code but the user might then disable scripting. ... To take a less far-fetched example, an author might just goof things up and e.g. omit the JavaScript code that prevents normal form submission.) ... Posting a URL is still the best approach in HTML problems. ...
  • Re: HTML entities not rendered when appended to SELECT
    ... Web Interface Tricks wrote: ... It uses javascript to move the names from one list to another. ... All is OK except for some names which contain special characters ... The original HTML is built server- ...
  • Security holes in Hotmail, Yahoo, and other webmails
    ... Most webmails services and applications have huge security holes on the ... execution of malicious javascript and HTML code ... some parts of the user's mailbox, without use of javascript. ... Cross-site scripting vulnerabilities on the domain was reported ...
  • Re: HTML4.01 STRICT and hyperlinks with target
    ... new window *in HTML* instead of in JavaScript. ... have a link open a new window in HTML instead of in JavaScript. ... I know this is not a great reason, but I think it is reason ...
  • [Full-disclosure] [RT-SA-2009-001] IceWarp WebMail Server: Cross Site Scripting in E
    ... RedTeam Pentesting discovered that the IceWarp ... WebMail Server is prone to Cross Site Scripting attacks in its email view. ... To prevent the execution of JavaScript and VBScript code in HTML emails ... and to remove unwanted HTML tags, the IceWarp WebMail Server filters HTML ...