Ask a Question related to Perl / CGI, Design and Development.
-
Purl Gurl #1
Re: "Simple" regex advice (possibly '/' causing an issue?)
Ian.H wrote:
(snipped)
> my $scan_results = `$scan_command $scan_path`;> $scan_results =~ s#.*Switches: -ARCHIVE -PACKED
> -COLLECT\n\n(.*)\n\nResults of virus scanning:.*#$1#s;> if (m#^$scan_path(.*?)->(.*)\s+Infection:\s+(.*)$#) {
> ($user,$attachment, $infection) = ($1, $2, $3);> Use of uninitialized value in pattern match (m//) at ./mail_scan.pl line 13
You are trying to use Perl's $_ but it does not exist, for your context.
if (m#^$scan_path ....
if ($scan_results =~ m#^$scan_path ....
It is a good practice to always use explicit variable names
even when $_ is used invisibly. You have fallen into this
pitfall of thinking $_ is there, is defined. It is not.
Use explicit variable names always and you won't encounter
this problem of "shortcut pitfalls."
Purl Gurl
Purl Gurl Guest
-
FileReference upload -> "script is causing Flash to runslowly"?
Hi all, We have recently released an 100% Flash online portal (http://www.muveemix.com) but we have hit a problem with the upload system (via... -
System.Data.SqlClient "Timeout expired" causing ASP.net web application to automatically restart.
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET... -
"replace pages" / "rotate pages" orientation issue
in Adobe acrobat you can open a PDF file and "replace pages" (some or all) with pages from another PDF file. it used to be that when I did this,... -
Advice and WTB: Focal Photo Guides ("All About ....." series)
I am looking for seven booklets in the Focal Press Photo Guides series "All About ....." (from the 1950s, the ones I need are all among the last 15... -
"regex literal in condition"
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all, I'm getting an erorr that I don't understand. # My code while gets. break if... -
Purl Gurl #2
Re: "Simple" regex advice (possibly '/' causing an issue?)
Purl Gurl wrote:
(snipped)> Ian.H wrote:
> > Use of uninitialized value in pattern match (m//) at ./mail_scan.pl line 13> You are trying to use Perl's $_ but it does not exist, for your context.> if (m#^$scan_path ....> if ($scan_results =~ m#^$scan_path ....> It is a good practice to always use explicit variable names
> even when $_ is used invisibly. You have fallen into this
> pitfall of thinking $_ is there, is defined. It is not.
Below is an example of what you are experiencing.
Should you try to print regex numerical variables
immediately after line 8 matching, warnings will
generate three "uninitialized value" messages.
Other subsequent code which relies on your malformed
match operator, will also generate the same message,
leading you to believe an error exists elsewhere.
Use explicit variable names to avoid this pitfall.
Purl Gurl
--
#!perl -w
our ($variable, $user, $attachment, $infection);
$variable = "Test One Here";
## LINE 8 NEXT:
if (m#^(T\w+) (\w*) (\w*)#)
{ ($user,$attachment, $infection) = ($1, $2, $3); }
if ($variable =~ m#^(T\w+) (\w*) (\w*)#)
{ ($user,$attachment, $infection) = ($1, $2, $3); }
print "Match Out: $1 $2 $3";
PRINTED RESULTS:
________________
Use of uninitialized value in pattern match (m//) at test.pl line 8.
Match Out: Test One Here
Purl Gurl Guest
-
Brian McCauley #3
Re: "Simple" regex advice (possibly '/' causing an issue?)
"Ian.H [dS]" <ian@WINDOZEdigiserv.net> writes:
Due to the propagation delays of Usenet, the timezone differences in> Evening all =)
an international forum and the fact that most people only read
newsgroups a couple of times a day it is totally unsafe to assume that
it is evening to all. :-)
[ snip 11 lines of code that doesn't do anything that would set $_ ]> #!/usr/bin/perl
> if (m#^$scan_path(.*?)->(.*)\s+Infection:\s+(.*)$#) {Well, you've done nothing to set $_ (so it'll be undef) then you do a> Use of uninitialized value in pattern match (m//) at ./mail_scan.pl line
> 13
m// with no =~ (so it'll act on $_, which, as I said, is undef).
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
Brian McCauley Guest



Reply With Quote

