Barry Millman <> wrote:
> The format for the HYPERLINK that I am
> searching for in the document is:
>
> HYPERLINK "mydoc.doc"
> PROBLEM: The program works on the Windows 2000 machine, but does not
> find the files on the Win Xp machine.
I don't think I can help with that part, but the code is too hokey
to just let it pass...
> ----------- start actual code segment --------------------
> while (/HYPERLINK(\s+.{1,80}?\.doc)/gim) # the "g" causes multiple
> matches
The //m does not do anything, so why is it there?
It changes the meaning of ^ and $, but you don't use those
anchors in your pattern, so you don't need //m.
.{1,80}?
is the same as
.{0,80}
Do you really want to match ' .doc' ?
We can't help you analyse why the match is failing because we
need two things to do that: the pattern and the string that
the pattern is to be matched against.
We have only one of those two things...
>
> {
> $fndxx = $1;
>
> $fndxx =~ s/\"//; # remove leading quote
> $fndxx =~ s/\s+//; # remove leading spaces
Why capture them only to strip them out of the captured string?
Why not just leave them out of the capture in the first place?
while (/HYPERLINK\s+"(.{1,78}\.doc")/gi)
or, probably better:
while (/HYPERLINK\s+"([^"]{1,78}\.doc")/gi)
> $dir="C:\\IGINproducts\\UserDocuments\\";
>
Use single quotes unless you want to make use of one of the two
extra things that double quotes give you (interpolation
and backslash escapes).
Use forward slashes instead of silly slashes unless the path
is going to be fed to the "command interpreter".
$dir='C:/IGINproducts/UserDocuments/';
> print(OUTFILE $fndxx,",",$date_string,", in: ",basename($file),
> "\n") ;
Gak!
Use double quoted strings to concatenate your output string:
print(OUTFILE "$fndxx,$date_string, in: ", basename($file), "\n") ;
> If I try this with a test program (the string to test is in the program
> itself ) it works fine on the XP machine.
If you had shown us your complete test program, then we could
have helped you debug it.
But you didn't, so we can't. (hint)
> I would really appreciate any comments or suggestions about what I am
> doing wrong.
Not posting a short and complete program that we can run that
illustrates your problem.
Have you seen the Posting Guidelines that are posted here frequently?
--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas