[29598] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 842 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 11 21:09:39 2007

Date: Tue, 11 Sep 2007 18:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 11 Sep 2007     Volume: 11 Number: 842

Today's topics:
    Re: (?{ code }) block works fine in child rule but not  <nospam-abuse@ilyaz.org>
        adsense-abuse@google.com (was: Go Here to win a free gu <jeffm_@email.com>
        Can't use an undefined value as an ARRAY reference at s <webmaster@valleywebnet.com>
    Re: Can't use an undefined value as an ARRAY reference  <mritty@gmail.com>
    Re: Can't use an undefined value as an ARRAY reference  <glex_no-spam@qwest-spam-no.invalid>
    Re: Can't use an undefined value as an ARRAY reference  <dummy@example.com>
    Re: Do my variables scoped to a subroutine get reconstr <clint.olsen@gmail.com>
    Re: Go Here to win a free guitar <zwsdotcom@gmail.com>
    Re: Go Here to win a free guitar <joel-garry@home.com>
    Re: Go Here to win a free guitar <kst-u@mib.org>
    Re: Go Here to win a free guitar <kst-u@mib.org>
    Re: Go Here to win a free guitar <zwsdotcom@gmail.com>
    Re: How can I get a colored subject in my Perl created  <mark.clementsREMOVETHIS@wanadoo.fr>
        How to draw a tree/graph of a web site? (David Combs)
    Re: Sharing object between threads - howto? <mjp-perl@pilcrow.madison.wi.us>
    Re: We urgently require SAP consultant with 5 year of S <dha@panix.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 11 Sep 2007 20:11:57 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: (?{ code }) block works fine in child rule but not in parent
Message-Id: <fc6sqd$13i2$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to

<xhoster@gmail.com>], who wrote in article <20070911125925.933$Iq@newsreader.com>:
> Was there ever a time when qr// was the only way to have different parts
> of the pattern have different "global" options, or was qr// introduced
> after (?-xism:...) was introduced?

If you want to know the history: the original form of qr// was called

 study m//;

;-) (I was too lazy to add a new syntax to the lexer).  In
this form, it existed for quite some time (several months?); almost
immediately, the understanding emerged that the effects (but not
speed) were similar to "a new quoting operator".  (I do not know how
soon the interpolation of the result into strings appeared; the main
initial purpose was a speedup due to compile-once use-often.)

After it was redone as qr// (not by me), it may have existed (for
several days?) without support of (?-xism:).  Again, the understanding
appeared that its use without (?-xism:) is too confusing; so this
feature was implemented.

Hope this helps,
Ilya


------------------------------

Date: Tue, 11 Sep 2007 13:03:02 -0700
From:  JeffM <jeffm_@email.com>
Subject: adsense-abuse@google.com (was: Go Here to win a free guitar)
Message-Id: <1189540982.545550.155410@i13g2000prf.googlegroups.com>

nutsbreaker1@ gmail.com wrote:
>[SPAM]blogspot[SPAM]

FreeRTOS.org wrote:
:Please everybody that reads this
:report the poster to gmail for spam[...]
:and to google adsense for promoting via spam (against rules).
:The poster is a persistant nusance
:and should have both email and adverts accounts suspended.

Ah.  Another weapon against the unjust.
mailto:adsense-abuse@google.com
mailto:gmail-abuse@google.com
 ...and, though it's mostly a waste of time (Parasites!)
mailto:groups-abuse@google.com

Here is his posting history:
http://groups.google.com/groups/search?q=freeguitars+blogspot&scoring=d&filter=0&num=100
(Can't easily weed out the replies.)

I was going to suggest a report to his ISP,
but they are obvious parasites:
http://www.dnsstuff.com/tools/whois.ch?ip=201.14.237.68&email=on



------------------------------

Date: Tue, 11 Sep 2007 11:15:16 -0700
From:  JimJx <webmaster@valleywebnet.com>
Subject: Can't use an undefined value as an ARRAY reference at search.cgi line 139.
Message-Id: <1189534516.536872.320630@y42g2000hsy.googlegroups.com>

Hi all,

I have what seems to me to be a strange problem....

I have the script below:

<code>
if ($type eq 'alpha') {
$query = sprintf (
                "SELECT name, address, city, phone
                FROM valley
				        where name like '$search%'
                ORDER BY name LIMIT %d,%d",
                $start - 1,         # number of records to skip
                $per_page + 1);     # number of records to select
        } elsif  ($type eq '') {
$query = sprintf (
                "SELECT name, address, city, phone
                FROM valley
				        where keywords like '%$search%'
                ORDER BY name LIMIT %d,%d",
                $start - 1,         # number of records to skip
                $per_page + 1);     # number of records to select
}
my $tbl_ref = $dbh->selectall_arrayref ($query);

$dbh->disconnect ( );

# Display results as HTML table

for (my $i = 0; $i < $per_page && $i < @{$tbl_ref}-1; $i+=2)  {
    # get data values in row $i
    my @cells = @{$tbl_ref->[$i]};  # get data values in row $i
    my @cells2 = @{$tbl_ref->[$i+1]};  # get data values in row $i+1
    # map values to HTML-encoded values, or to &nbsp; if null/empty
    @cells = map {
                defined ($_) && $_ ne "" ? escapeHTML ($_) : "&nbsp;"
                } @cells;
    @cells2 = map {
                defined ($_) && $_ ne "" ? escapeHTML ($_) : "&nbsp;"
                } @cells2;
    # add cells to table
    my @cells = "<b>$cells[0]</b><br>$cells[1]<br>$cells[2]<br>
$cells[3]<br>";
    my @cells2 = "<b>$cells2[0]</b><br>$cells2[1]<br>$cells2[2]<br>
$cells2[3]<br>";
    push (@rows, Tr (td (\@cells),(td (\@cells2))));
}
</code>

It works great.  However if I change it to:
<code>
if ($search = '#') {
                $query = sprintf (
                "SELECT name, address, city, phone
                FROM valley where REGEXP '^[0-9]'
                ORDER BY name LIMIT %d,%d",
                $start - 1,
                $per_page + 1);
       } elsif ($type eq 'alpha') {
$query = sprintf (
                "SELECT name, address, city, phone
                FROM valley
		where name like '$search%'
                ORDER BY name LIMIT %d,%d",
                $start - 1,         # number of records to skip
                $per_page + 1);     # number of records to select
        } elsif  ($type eq '') {
$query = sprintf (
                "SELECT name, address, city, phone
                FROM valley
		where keywords like '%$search%'
                ORDER BY name LIMIT %d,%d",
                $start - 1,         # number of records to skip
                $per_page + 1);     # number of records to select
}
my $tbl_ref = $dbh->selectall_arrayref ($query);

$dbh->disconnect ( );

# Line 139 is the FOR below......

for (my $i = 0; $i < $per_page && $i < @{$tbl_ref}-1; $i+=2)  {
    # get data values in row $i
    my @cells = @{$tbl_ref->[$i]};  # get data values in row $i
    my @cells2 = @{$tbl_ref->[$i+1]};  # get data values in row $i+1
    # map values to HTML-encoded values, or to &nbsp; if null/empty
    @cells = map {
                defined ($_) && $_ ne "" ? escapeHTML ($_) : "&nbsp;"
                } @cells;
    @cells2 = map {
                defined ($_) && $_ ne "" ? escapeHTML ($_) : "&nbsp;"
                } @cells2;
    # add cells to table
    my @cells = "<b>$cells[0]</b><br>$cells[1]<br>$cells[2]<br>
$cells[3]<br>";
    my @cells2 = "<b>$cells2[0]</b><br>$cells2[1]<br>$cells2[2]<br>
$cells2[3]<br>";
    push (@rows, Tr (td (\@cells),(td (\@cells2))));
}
</code>
I get the error 'Can't use an undefined value as an ARRAY reference at
search.cgi line 139.'

My questions, why would adding that code at the beginning cause that
error and how can I fix it?

Any ideas/suggestions greatly appreciated.
Jim



------------------------------

Date: Tue, 11 Sep 2007 12:09:48 -0700
From:  Paul Lalli <mritty@gmail.com>
Subject: Re: Can't use an undefined value as an ARRAY reference at search.cgi line 139.
Message-Id: <1189537788.446175.282040@t8g2000prg.googlegroups.com>

On Sep 11, 2:15 pm, JimJx <webmas...@valleywebnet.com> wrote:

> It works great.  However if I change it to:
> <code>
> if ($search = '#') {

You realize of course that this line *assigns* $search to be equal to
'#', and then returns true, meaning that this if statement (and none
of the else clauses) will ALWAYS be executed, right?

You meant to have an 'eq' here, just like all the other if conditions
had, not an '='.

> my $tbl_ref = $dbh->selectall_arrayref ($query);
>
> $dbh->disconnect ( );
>
> # Line 139 is the FOR below......
>
> for (my $i = 0; $i < $per_page && $i < @{$tbl_ref}-1; $i+=2)  {

> I get the error 'Can't use an undefined value as an ARRAY
> reference at search.cgi line 139.'

You are not checking your DBI calls for errors.  You are assuming they
all work fine.  Perl doesn't tell you there's a problem unless you ask
it to.  I recommend turning on RaiseError in your connect statement

my $dbh = DBI->connect($dsn, $user, $pass, { RaiseError => 1} );

Or you can turn it on after the fact:
$dbh->{RaiseError} = 1;

Or you can manually check the results of every single database call:
my $tbl_ref = $dbh->selectall_arrayref($query);
die $dbh->errstr if $dbh->err();


Paul Lalli



------------------------------

Date: Tue, 11 Sep 2007 14:05:45 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Can't use an undefined value as an ARRAY reference at search.cgi line 139.
Message-Id: <46e6e709$0$507$815e3792@news.qwest.net>

JimJx wrote:
> Hi all,
> 
> I have what seems to me to be a strange problem....
> 
> I have the script below:

Which isn't terribly helpful, because you don't say what $type,
$start, etc. is so we have no idea what SQL is being tried.
[...]
> My questions, why would adding that code at the beginning cause that
> error and how can I fix it?
> 
> Any ideas/suggestions greatly appreciated.

Look at your SQL and the results.

use Data::Dumper;

#... your code
print "SQL=$query\n";
my $tbl_ref = $dbh->selectall_arrayref ($query);
print 'Results:', Dumper( $tbl_ref );

Something isn't what you think it is.


------------------------------

Date: Tue, 11 Sep 2007 21:37:33 GMT
From: "John W. Krahn" <dummy@example.com>
Subject: Re: Can't use an undefined value as an ARRAY reference at search.cgi line 139.
Message-Id: <xUDFi.33966$Pd4.17180@edtnps82>

JimJx wrote:
> 
> I have what seems to me to be a strange problem....
> 
> I have the script below:
> 
> <code>
> if ($type eq 'alpha') {
> $query = sprintf (
>                 "SELECT name, address, city, phone
>                 FROM valley
> 				        where name like '$search%'
>                 ORDER BY name LIMIT %d,%d",
>                 $start - 1,         # number of records to skip
>                 $per_page + 1);     # number of records to select
>         } elsif  ($type eq '') {
> $query = sprintf (
>                 "SELECT name, address, city, phone
>                 FROM valley
> 				        where keywords like '%$search%'
>                 ORDER BY name LIMIT %d,%d",
>                 $start - 1,         # number of records to skip
>                 $per_page + 1);     # number of records to select
> }
> my $tbl_ref = $dbh->selectall_arrayref ($query);
> 
> [ SNIP ]
> 
> </code>
> 
> It works great.

Are you sure that that "works great"?

You have variable interpolation inside sprintf() format strings and you are 
using '%' without properly escaping it.  You probably want this instead:

if ( $type eq 'alpha' ) {
     $query = sprintf
                 "SELECT name, address, city, phone
                 FROM valley
				        where name like '%s%%'
                 ORDER BY name LIMIT %d,%d",
                 $search,
                 $start - 1,         # number of records to skip
                 $per_page + 1;     # number of records to select
         } elsif ( $type eq '' ) {
    $query = sprintf
                 "SELECT name, address, city, phone
                 FROM valley
				        where keywords like '%%%s%%'
                 ORDER BY name LIMIT %d,%d",
                 $search,
                 $start - 1,         # number of records to skip
                 $per_page + 1;     # number of records to select
}
my $tbl_ref = $dbh->selectall_arrayref( $query );



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


------------------------------

Date: Tue, 11 Sep 2007 13:14:08 -0500
From: Clint Olsen <clint.olsen@gmail.com>
Subject: Re: Do my variables scoped to a subroutine get reconstructed every time?
Message-Id: <slrnfedmng.5mi.clint.olsen@belle.0lsen.net>

In the spirit of this post, I was curious as to whether the my variables
that are the result of a qr/// are reconstructed every time a subroutine is
executed.  The reason is that some of my code blocks in the qr/// I want to
affect lexically scoped variables in the sub.

use strict;
use warnings;

my $simple_identifier  = qr/([a-zA-Z_][a-zA-Z0-9_\$]*)/;
my $escaped_identifier = qr/\\(\S+)(?=\s)(?{ $x += 2 })/;
my $identifier         = qr/$simple_identifier|$escaped_identifier/;

#
# scan
#
# Given a string, apply the pattern and return a token ID and lvalue data.
#
sub scan {
    my ($data,$y,$x) = @_;

    if ($$data =~ s/
        $identifier
                   //x) {
        $x += len $^N;
    }
}

print "Hello\n";

This code won't compile because $escaped_identifier references $x.  I have
these outside the scan scope for fear that calling scan millions of times
could cause performance issues.  If it turns out that the interpreter can
determine these are 'constant' expressions and calculates them only once,
then great.  I'll put it back inside the subroutine.

Thanks,

-Clint


------------------------------

Date: Tue, 11 Sep 2007 13:15:45 -0700
From:  larwe <zwsdotcom@gmail.com>
Subject: Re: Go Here to win a free guitar
Message-Id: <1189541745.067723.207960@x40g2000prg.googlegroups.com>

On Sep 11, 9:12 am, "FreeRTOS.org" <noem...@address.com> wrote:
> Please everybody that reads this report the poster to gmail for spam and,
> and to google adsense for promoting via spam (against rules).  The poster is
> a persistant nusance and should have both email and adverts accounts
> suspended.

If Google Groups had a filter, I would automatically block any post
that references a blogspot URL. They are all spam. Every last one.
Without exception.



------------------------------

Date: Tue, 11 Sep 2007 14:22:34 -0700
From:  joel garry <joel-garry@home.com>
Subject: Re: Go Here to win a free guitar
Message-Id: <1189545754.851182.182380@z24g2000prh.googlegroups.com>

On Sep 11, 1:15 pm, larwe <zwsdot...@gmail.com> wrote:
> On Sep 11, 9:12 am, "FreeRTOS.org" <noem...@address.com> wrote:
>
> > Please everybody that reads this report the poster to gmail for spam and,
> > and to google adsense for promoting via spam (against rules).  The poster is
> > a persistant nusance and should have both email and adverts accounts
> > suspended.
>
> If Google Groups had a filter, I would automatically block any post
> that references a blogspot URL. They are all spam. Every last one.
> Without exception.

Hey, I've referenced Tom Kyte's as well as others (like Noon's, Robert
Freeman's).  There are so exceptions!

jg
--
@home.com is bogus.
http://heartbeat.skype.com/



------------------------------

Date: Tue, 11 Sep 2007 16:10:31 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Go Here to win a free guitar
Message-Id: <lnveag4x3s.fsf@nuthaus.mib.org>

"FreeRTOS.org" <noemail@address.com> writes:
> Please everybody that reads this report the poster to gmail for spam and, 
> and to google adsense for promoting via spam (against rules).  The poster is 
> a persistant nusance and should have both email and adverts accounts 
> suspended. 

Please post followups to spam.  If you must do so, please drop
comp.lang.c from the newsgroups list.  I can assure you that everyone
here recognized the parent article as spam.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


------------------------------

Date: Tue, 11 Sep 2007 16:46:37 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Go Here to win a free guitar
Message-Id: <lnk5qw4vfm.fsf@nuthaus.mib.org>

Keith Thompson <kst-u@mib.org> writes:
[...]
> Please post followups to spam.
[...]

Argh!  Of course I meant please *don't* post followups to spam.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


------------------------------

Date: Tue, 11 Sep 2007 17:28:31 -0700
From:  larwe <zwsdotcom@gmail.com>
Subject: Re: Go Here to win a free guitar
Message-Id: <1189556911.566718.297290@r29g2000hsg.googlegroups.com>

On Sep 11, 5:22 pm, joel garry <joel-ga...@home.com> wrote:

> > that references a blogspot URL. They are all spam. Every last one.
> > Without exception.
>
> Freeman's).  There are so exceptions!

This is like saying that there are honest online businesses and/or
customers in Nigeria. While it might be possible to find one, it's a
statistically insignificant number.



------------------------------

Date: Tue, 11 Sep 2007 20:12:53 +0200
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: How can I get a colored subject in my Perl created e-mails.
Message-Id: <46e6daa5$0$5087$ba4acef3@news.orange.fr>

ab wrote:
> My script is sending e-mails to certain parties. It runs fine. Now I
> want to have the recipients of my Perl created e-mail to see a colored
> (say: red) subject. How can I direct my mail header to do this or
> should I use a trick? All our customers use Outlook.
> 
> I'm using this format to crfeate the e-mail:
> 
> 		from => 'me@domain.com',
> 		to => 'you@yourdomain.com',
> 		subject => "this is the subject",
> 		encoding => "7bit",
> 		multipart => 'related
> 
> All help is appreciated.
> 
You may (I'm guessing here) want to try setting a header that is 
understood by Outlook to indicate priority, maybe X-Priority or 
X-MSMail-Priority. You don't say which module you're using to send mail 
so I can't help you with exactly how you'd accomplish that.

Mark


------------------------------

Date: 11 Sep 2007 14:59:21 -0400
From: dkcombs@panix.com (David Combs)
Subject: How to draw a tree/graph of a web site?
Message-Id: <fc6oi9$jsq$1@panix3.panix.com>

(I just posted this to comp.unix.solaris -- but
since there might well be some perl trickery
for doing this, I'm posting it here too.)

Some websites, designed perhaps as pure trees, I find
difficult to use -- especially when the interesting pages
might be several levels down in the tree, with no hint
above that such pages even exist.

(Assuming that the a href names of the pages
do give a hint of their contents), 

, it might be a big help to be able to see a drawn
tree or (directed?) graph of the whole site.

Any comments on this idea, or hints on how to do it?

Thanks!

David Combs




------------------------------

Date: Tue, 11 Sep 2007 19:00:19 GMT
From: Mike Pomraning <mjp-perl@pilcrow.madison.wi.us>
Subject: Re: Sharing object between threads - howto?
Message-Id: <7BBFi.38503$G23.36315@newsreading01.news.tds.net>

Lejf Diecks wrote:

> is it possible to share an object between the main program and a thread?

Yes, easily.  Thread::Queue, for example, does this:

   sub new {
     my $class = shift;
     my @q : shared = @_;
     return bless \@q, $class;
   }

> I tried "threads::shared" from CPAN, but it does'nt work for me.

Your examples didn't show any sharing, either with the :shared attribute
or threads::shared::share().

> The perldoc for "threads::shared" points out:
>
> "BUGS: bless is not supported on shared references. In the current 
> version, bless will only bless the thread local reference and the 
> blessing will not propagate to the other threads. This is expected to be 
> implemented in a future version of Perl."

This disclaimer is unfortunately phrased and easy to misread/mislead.

Briefly, perl thread creation clones (copies) all variables for the new 
thread.  Subsequent clones of blessed objects are themselves blessed 
(barring something like CLONE_SKIP).  Subsequent clones of shared 
objects are magically tied together so that they refer to the same 
underlying variable and can be safely manipulated (lock()d, 
cond_signal()d, etc.).

Subsequent clones of blessed, shared objects are both blessed and 
magically tied together.  However, blessing a shared object does not 
update _already existing_ clones tied to that shared object, as it very 
plausibly should.  That is the bug.

Note that this bug is never an issue if you bless/share while only only 
one thread is aware of the object, for example in your class' constructor.

Regards,
Mike


------------------------------

Date: Tue, 11 Sep 2007 21:54:08 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: We urgently require SAP consultant with 5 year of SAP experience
Message-Id: <slrnfee3k0.pn.dha@panix2.panix.com>

On 2007-09-08, HR Head <msmanu78@yahoo.com> wrote:
> Hi,
>
> We urgently require SAP consultant 

You have posted a job posting or a resume in a technical group.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

http://jobs.perl.org may be of more use to you

Yours for a better usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
America leads the world in shocks.
	- Gil Scott-Heron


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 842
**************************************


home help back first fref pref prev next nref lref last post