On 11/17/03 2:52 AM, "xweb" <[EMAIL PROTECTED]> wrote:
> Thanks all but...
> I don't explain well the problem!
> So, i'm processing a very big text file ( from A DB ) in this format
> number|field 1|field2| field 3| etc. Every line is a record.Every line
> contains many url.
> I'm interested about specific url and i don't consider the others.
>
> while ( $line =~ s/href=\"([^"]+)\"//) {
> $url = $1; ###ALL URL#####
> if ($url =~ m/\/[^,]+,([^,]+),([^,]+),[^,]+\.html?$/) {
> ($var1,$var2)=($1,$2); ###INTERESTING URL AND VALUES####
> }
> }
> In this way i obtain two values that interested me! It's works!
> Now i must substitute these url <a href="$url">the_link </a> with
> <idlink=$var2>the_link</idlink> and then i write to a new file with this
> substitution on all the field of file!
> Can you help me?
>
The only thing you haven't captured is `the_link`.
open (FH, "> path/to/new/file") || die "$!\n"; # open new file to write to
while ( $line =~ /<a href=\"([^"]+)\".*?>(.*?)<\/a>/) {
$url = $1; ###ALL URL#####
$the_link = $2;
if ($url =~ m/\/[^,]+,([^,]+),([^,]+),[^,]+\.html?$/) {
($var1,$var2)=($1,$2); ###INTERESTING URL AND VALUES####
print FH "<idlink=$var2>$the_link</idlink>"; # print to new file
}
}
close(FH)