> while (<SOURCE>){
> if (m/\/nic\/login/){
this just says yes or no, you have a match or you don't.
m// (and friends like s///) can do more than that for you.
for one thing, they can grab a particular piece of what
they match.
> substr ($_,28,4);
what substr normally does -- get or change a piece of
a string -- overlaps what m// and friends can do. if you
are already using m// or friend it's often simpler to use
that to do what substr can do.
in the above case, substr isn't doing anything at all!
you don't set that part of the string to anything, nor do
you set any variable to contain the bit that's grabbed.
you're simply saying, grab a copy of that part of the
string, then throw it in to the great big bit void in the
sky. you could do:
$foo = substr($_, 28, 4);
but, as noted above, it's easier to extend your use of m//.
btw, why did you say 4, not 5? 'Login' has 5 characters
last time I looked!
back to m//. Try this:
($mybit) = m#/nic/login/">([^<]*?)<#;
I used # as the m delimiters so you don't have
to escape the / characters.
the (...) is the bit that grabs something.
the [^<] bit means match anything but a < character.
the * bit means match any number of non <'s.
the ? bit means match as few as still makes the
match true (if possible). (otherwise the grabbed bit
would be the rest of the line up to just before the last <
encountered.