----- Original Message -----
From: "$Bill Luebkert" <[EMAIL PROTECTED]>
To: "Malcolm Debono" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Thursday, February 13, 2003 1:31 AM
Subject: Re: help reading file url & loop



Malcolm Debono wrote:

Hello,
Can someone please help.

I am trying to get my script to read url's from a file and loop through.

I

can run the script from a form reading the
my $url = param('url');  (but it will take to long). The code below will
loop but it doesn't seem to get the url and read the title. I am not

very

experienced so please explain as simple as possible.

[snip]


Malcolm Debono wrote:
> Thank you Bill.
>
> Can I ask (trying to understand, reading the docs and lama book).
> My understanding is that Keys is the $url and the Value is the title which
> in my presumption is stored in $links
> of $links{$url} = $1;
> I don't understand the $1. Confused here?? how are the keys and values
> passed to the %links, are both keys & values stored in $1.
>
> If so then is it then possible for other criteria such as
> $links{$url} = '';
> if ($content =~ /<whatever[^>]*>\s*(.*)\s*<\/whatever>/i) {
> $links{$url} = $2;
>
> Any help is appreciated.
>
> Malcolm

Malcolm --

The $1, $2, ...$9 are the capture buffers represented by the parens in the regex, so, if you were capturing some other element in a later parenthetical expression, *it* would be $2, and so on.

So, your example will give you empty values.

Try "perldoc perlre" on your machine?

"
The bracketing construct "( ... )" creates capture buffers. To refer to
the digit'th buffer use \<digit> within the match. Outside the match use
"$" instead of "\". (The \<digit> notation works in certain
circumstances outside the match. See the warning below about \1 vs $1
for details.) Referring back to another part of the match is called a
*backreference*.

There is no limit to the number of captured substrings that you may use.
However Perl also uses \10, \11, etc. as aliases for \010, \011, etc.
(Recall that 0 means octal, so \011 is the character at number 9 in your
coded character set; which would be the 10th character, a horizontal tab
under ASCII.) Perl resolves this ambiguity by interpreting \10 as a
backreference only if at least 10 left parentheses have opened before
it. Likewise \11 is a backreference only if at least 11 left parentheses
have opened before it. And so on. \1 through \9 are always interpreted
as backreferences.

Examples:

s/^([^ ]*) *([^ ]*)/$2 $1/; # swap first two words

if (/(.)\1/) { # find first doubled char
print "'$1' is the first doubled character\n";
}

if (/Time: (..):(..):(..)/) { # parse out values
$hours = $1;
$minutes = $2;
$seconds = $3;
"

-- Mike Higgins


^ ^
<-|->
(.)__ the world is a big box of paints.
__ __ and others, the canvas we're dealt.
| | - XTC
_/ \_

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to