Hi all,
I am 100% new to Perl but do have some PHP knowledge. I'm trying to create a quick script that will take the @url vars and save it to a .txt file. The problem that I'm having is that it's saving the url again everytime it runs through the loop which is super annoying. So when the loop runs, it'll look like this.
url1.com
url1.com url2.com
url1.com url2.com url3.com
What I would like it to look like is just a plain and simple..
url1.com
url2.com
url3.com
Here is my code. If anyone can help, I would appreciate it SO SO much!
PHP Code:#!/usr/bin/perl
use strict;
use warnings;
my $file = "data.rdf.u8";
my @urls;
open(my $fh, "<", $file) or die "Unable to open $file\n";
while (my $line = <$fh>) {
if ($line =~ m/<(?:ExternalPage about|link r:resource)="([^\"]+)"\/?>/) {
push @urls, $1;
}
open (FH, ">>my_urls.txt") or die "$!";
print FH "@urls ";
close(FH);
}
close $fh;


Reply With Quote
Bookmarks