Advertisement

07.06.2008 at 07:39PM PDT, ID: 23542345
[x]
Attachment Details

Why this does not delete the lines in my file?

Asked by ikon32 in Perl Programming Language

Tags: perl

I have a text file with links like:
<br><li><a href="http://www.domain.com">text</a>
<br><li><a href="http://www.domain1.com">text</a>
...
<br><li><a href="http://www.domain1000.com/page.asp">text</a>
------------------------------------------------------------------------------------
and I use this to delete lines from it but it does not delete the line or lines from the file.

open(FILES, "$link_file") || die "Can't open FILE: $link_file\n";
@files =<FILES>;
close(FILES);

$x=0;
$set=0;
$num=1;

foreach $line (@files) {
$x++;
if($line =~ /$FORM{'url'}/i) {

@tic[$num] = " Deleted: On Line $x" . $line ."<br>" . "-" x 75 ."<br>";
$set++;
$num++;
@files=grep !/$line/, @files;
        }
}
$z=0;
open(XFILES, ">$link_file") || die "Can't open FILE: $link_file\n";
flock (XFILES, 2);

for $line (@files)        {
print XFILES $line;
$z++;
}
flock (XFILES, 8);
close(XFILES);Start Free Trial
 
Loading Advertisement...
 
[+][-]07.06.2008 at 07:50PM PDT, ID: 21942528

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 07:53PM PDT, ID: 21942535

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 07:56PM PDT, ID: 21942545

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.06.2008 at 08:01PM PDT, ID: 21942557

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Perl Programming Language
Tags: perl
Sign Up Now!
Solution Provided By: ozo
Participating Experts: 1
Solution Grade: A
 
 
[+][-]07.06.2008 at 08:10PM PDT, ID: 21942575

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628