On Sat, Apr 22, 2000 at 12:59:19AM +0000, D ONeill wrote:
> You need to post the entire block of source before that can be answered.
> Normally, if you're going to use the assingment variables, you do it right
> after the match statement. By not assigning the variables right away, you
> risk not having what you expect in the assingment variables.
Yes, I know that, and I referred to it in my original post. What I posted
shows the problem, and my code is not relevant. However, I threw
together a small program which you can cut and paste to show the problem:
#!/usr/bin/perl
#
use DBI;
use strict "vars";
my ($Filename, $title, $dbh);
$dbh = DBI->connect("DBI:mysql:Photocall", "web", "web");
$Filename = "1 Anything at all /WHATEVER";
$Filename =~ m-(\d+ +)(.*)(/WHATEVER)-;
print "backreference 2 is $2\n"; # remove this line to see problem
$title = $dbh->quote($2);
print "Title is $title\n";
# replace with code from block below
$dbh->disconnect;
exit(0);
Of course you'll need to substitute your own values for database, username &
password and to run the above you'll need to be running MySQL and have all
the relevant modules. I don't know if also occurs with any DBI modules
other than DBI:mysql.
When scribbling the above, I noticed a further oddity. I tried to write a
program which showed the problem occurring and then not occurring - the
problem stops occuring once $2 is used before $dbh->quote, even if there are
subsequent matches. If you insert this code where marked above
$Filename = "1 A new thing /WHICHEVER";
$Filename =~ m-(\d+ +)(.*)(/WHICHEVER)-;
$title = $dbh->quote($2);
print "Title is $title\n";
the problem occurs in both places unless the print statement (or a statement
with $2 as an rvalue) is executed, but only one reference to $2 is needed.
Chew on that for the weekend . . . . .
Regards,
Niall O Broin
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!