[26781] in Perl-Users-Digest
Perl-Users Digest, Issue: 8847 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 10 14:05:29 2006
Date: Tue, 10 Jan 2006 11:05:07 -0800 (PST)
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, 10 Jan 2006 Volume: 10 Number: 8847
Today's topics:
"Use of implicit split to @_ is deprecated" <mrbig@spam.invalid>
Re: "Use of implicit split to @_ is deprecated" <glex_no-spam@qwest-spam-no.invalid>
Re: "Use of implicit split to @_ is deprecated" <mrbig@spam.invalid>
Re: "Use of implicit split to @_ is deprecated" <penryu@saiyix.ath.cx>
Re: GD - way to preserve PNG transparency? <kisrael@sunfire13.eecs.tufts.edu>
merciless garbage collector <nobody@this.home.com>
Re: merciless garbage collector <jurgenex@hotmail.com>
Re: merciless garbage collector <tassilo.von.parseval@rwth-aachen.de>
Re: merciless garbage collector <nobody@this.home.com>
paste buffer in X11 <jwolff@freebee.essentkabel.com>
Re: Uploading 2 files with 1 CGI buffer <wh2leung@student.cs.uwaterloo.ca>
Re: Uploading 2 files with 1 CGI buffer <wh2leung@student.cs.uwaterloo.ca>
using perl mechanize <nospam@home.com>
Re: using perl mechanize <no@email.com>
Re: using perl mechanize <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Jan 2006 17:02:34 +0000 (UTC)
From: Budd Good <mrbig@spam.invalid>
Subject: "Use of implicit split to @_ is deprecated"
Message-Id: <dq0pba$sn0$1@reader2.panix.com>
Greetings,
I have the following line in my script:
} elsif (scalar(split (/\s+/, $list)) > 1) {
I want the expression to evaluate to true whenever $list contains more
than one whitespace-delimited item, and this works as I'd expect.
However when I have warnings turned on (-w), the compiler whines:
"Use of implicit split to @_ is deprecated at ./vcmapping.pl line 15."
I still can't see anything wrong with it and I've changed the input and
still get the expected result, so I'm wondering if someone can explain
what the compiler is on about.
Thanks,
B
------------------------------
Date: Tue, 10 Jan 2006 11:27:04 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: "Use of implicit split to @_ is deprecated"
Message-Id: <I7Swf.16$2Z3.67@news.uswest.net>
Budd Good wrote:
> Greetings,
>
> I have the following line in my script:
>
> } elsif (scalar(split (/\s+/, $list)) > 1) {
>
> I want the expression to evaluate to true whenever $list contains more
> than one whitespace-delimited item, and this works as I'd expect.
> However when I have warnings turned on (-w), the compiler whines:
>
> "Use of implicit split to @_ is deprecated at ./vcmapping.pl line 15."
>
> I still can't see anything wrong with it and I've changed the input and
> still get the expected result, so I'm wondering if someone can explain
> what the compiler is on about.
The documentation explains it pretty well.
perldoc perldiag
"Use of implicit split to @_ is deprecated
(D deprecated) It makes a lot of work for the compiler when you clobber
a subroutine's argument list, so it's better if you assign the results
of a split() explicitly to an array (or list)."
------------------------------
Date: Tue, 10 Jan 2006 17:58:17 +0000 (UTC)
From: Budd Good <mrbig@spam.invalid>
Subject: Re: "Use of implicit split to @_ is deprecated"
Message-Id: <dq0sjp$ngs$1@reader2.panix.com>
J. Gleixner <glex_no-spam@qwest-spam-no.invalid> wrote:
> Budd Good wrote:
> > Greetings,
> >
> > I have the following line in my script:
> >
> > } elsif (scalar(split (/\s+/, $list)) > 1) {
> >
> > I want the expression to evaluate to true whenever $list contains more
> > than one whitespace-delimited item, and this works as I'd expect.
> > However when I have warnings turned on (-w), the compiler whines:
> >
> > "Use of implicit split to @_ is deprecated at ./vcmapping.pl line 15."
> >
> > I still can't see anything wrong with it and I've changed the input and
> > still get the expected result, so I'm wondering if someone can explain
> > what the compiler is on about.
> The documentation explains it pretty well.
I disagree - that's cryptic at best. The response from the gentleman who
actually made an attempt to answer my question in the context in which I
posed it was far more helpful.
> perldoc perldiag
> "Use of implicit split to @_ is deprecated
> (D deprecated) It makes a lot of work for the compiler when you clobber
> a subroutine's argument list, so it's better if you assign the results
> of a split() explicitly to an array (or list)."
B
------------------------------
Date: Tue, 10 Jan 2006 18:43:10 GMT
From: Tim Hammerquist <penryu@saiyix.ath.cx>
Subject: Re: "Use of implicit split to @_ is deprecated"
Message-Id: <slrnds801u.24og.penryu@haruko.saiyix>
Budd Good <mrbig@spam.invalid> wrote:
> J. Gleixner <glex_no-spam@qwest-spam-no.invalid> wrote:
> > Budd Good wrote:
> > > Greetings,
Hullo.
> > > I have the following line in my script:
> > >
> > > } elsif (scalar(split (/\s+/, $list)) > 1) {
[ snip ]
> > > "Use of implicit split to @_ is deprecated at
> > > ./vcmapping.pl line 15."
[ snip ]
>
> > The documentation explains it pretty well.
>
> I disagree - that's cryptic at best. The response from the
> gentleman who actually made an attempt to answer my question
> in the context in which I posed it was far more helpful.
You may have gotten into a good many persons' killfiles right
there. You just about got into mine. There's an old saying
about "beggars"...
I think the perlfunc entry for split() says it slightly clearer,
FWIW. See below.
> > perldoc perldiag
>
> > "Use of implicit split to @_ is deprecated
> > (D deprecated) It makes a lot of work for the compiler when
> > you clobber a subroutine's argument list, so it's better if
> > you assign the results of a split() explicitly to an array
> > (or list)."
This is also mentioned as the second paragraph in `perldoc -f
split`:
In scalar context, returns the number of fields found and
splits into the @_ array. Use of split in scalar context is
deprecated, however, because it clobbers your subroutine
argu- ments.
For what it's worth, after more than 7 years working with Perl,
I was still unaware of this behavior, having stopped reading
that paragraph at "In scalar context" simply because I never use
it in scalar context. That's hardly an excuse for me, though.
HTH,
Tim Hammerquist
------------------------------
Date: Tue, 10 Jan 2006 15:27:09 GMT
From: Kirk Is <kisrael@sunfire13.eecs.tufts.edu>
Subject: Re: GD - way to preserve PNG transparency?
Message-Id: <hnQwf.1449$No6.34386@news.tufts.edu>
Bill Ricker N1VUX <wdr@theworld.com> wrote:
> Kirk Is [who gets a couresy BCC:] wrote:
> > So I'm trying to load a PNG with transprency...
> %<snip
> > but it always prints -1
> Interesting. I haven't tried that, but I ought to play with transparency.
> What verion of Perl GD:: modules are you using?
2.30 I believe...that's the one that comes up with
ppm install http://theoryx5.uwinnipeg.ca/ppms/GD.ppd
which ActiveState recommends...
> What version of the underlying GD libraries are you using?
> (bgd.dll or libgd.so&.lib or whatever; libpng.lib also)
I'm not sure where to look for that...
> Where does the PNG with transparency come from? Which kinds of pallete and
> transparency does it have? There are a large number of possibilities. If you
> repeat the problem with one of the published test images, that might help.
> (see below)
http://kisrael.com/journal.aux/plumber.png
> That could be a problem, haven't tried that. Having the same RGB in the
> palette of the input image twice could indeed be an error. Where did the
> image come from?
I generated that from the "Marios. 64." thing that was floating around, in
Gimp, by loading a .PSD, making only the one layer visible, then
saving/exporting. There are 64-odd images, so I probably shoulda just set
the background to something ugly and unused and then let GD recreate the
transparency, I wouldn't mind saving myself the work of doing it again
though.
--
QUOTEBLOG: http://kisrael.com SKEPTIC MORTALITY: http://kisrael.com/mortal
"There are two adults and one child. Majority rules.
Live like an animal or die." --James Israel
------------------------------
Date: Tue, 10 Jan 2006 17:13:35 +0100
From: Krystian <nobody@this.home.com>
Subject: merciless garbage collector
Message-Id: <0mm7s1h4pa96pca92jnmkeoj165lagnhr8@4ax.com>
Hi there,
perl normally cleans unused references, example:
my $object = SomeObject::->new;
$object = {};
now instance of SomeObject can be cleared out by perl - sure thing.
but perl also clears references which are used as keys in hashes -
it's very strange and unnatural for me. i've spent near an hour to
discover what is going on in my program. example:
my $phtab = {};
for(my $i=0; $i<50; $i++) {
my $obj = SomeObject::->new;
print "obj = $obj\n";
$phtab->{$obj} = 'aaa';
}
some of print commands will now display the same. when we change:
$phtab->{$obj} = 'aaa';
to
$phtab->{$obj} = $obj;
addresses will be different what indicates that perl doesn't free
references which are used as values of hash entries.
isn't it strange for you? what is the idea behind this behaviour?
best regards
krychu
------------------------------
Date: Tue, 10 Jan 2006 16:31:18 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: merciless garbage collector
Message-Id: <qjRwf.4163$Tn6.3010@trnddc04>
Krystian wrote:
> Hi there,
> perl normally cleans unused references, example:
>
> my $object = SomeObject::->new;
> $object = {};
>
> now instance of SomeObject can be cleared out by perl - sure thing.
> but perl also clears references which are used as keys in hashes -
> it's very strange and unnatural for me.
AFAIR you cannot use references as hash keys.
If you try then perl will actually use the textual representation of the
reference instead. And this textual representation cannot be converted back
into a valid reference.
jue
------------------------------
Date: Tue, 10 Jan 2006 17:34:42 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: merciless garbage collector
Message-Id: <42i614F1iqofmU1@news.dfncis.de>
Also sprach Krystian:
> perl normally cleans unused references, example:
>
> my $object = SomeObject::->new;
> $object = {};
>
> now instance of SomeObject can be cleared out by perl - sure thing.
> but perl also clears references which are used as keys in hashes -
> it's very strange and unnatural for me. i've spent near an hour to
> discover what is going on in my program. example:
>
> my $phtab = {};
>
> for(my $i=0; $i<50; $i++) {
> my $obj = SomeObject::->new;
> print "obj = $obj\n";
> $phtab->{$obj} = 'aaa';
> }
>
> some of print commands will now display the same. when we change:
>
> $phtab->{$obj} = 'aaa';
> to
> $phtab->{$obj} = $obj;
>
> addresses will be different what indicates that perl doesn't free
> references which are used as values of hash entries.
>
> isn't it strange for you? what is the idea behind this behaviour?
The difference is that perl stores the actual object in a hash-value
slot thereby incrementing its reference-count. If on the other hand you
try to use an object as hash-key, not the object itself will be stored
but rather its stringified address.
Always keep in mind that hash-keys are strings, nothing more.
Tassilo
--
use bigint;
$n=71423350343770280161397026330337371139054411854220053437565440;
$m=-8,;;$_=$n&(0xff)<<$m,,$_>>=$m,,print+chr,,while(($m+=8)<=200);
------------------------------
Date: Tue, 10 Jan 2006 17:49:17 +0100
From: Krystian <nobody@this.home.com>
Subject: Re: merciless garbage collector
Message-Id: <1bp7s1d2elkk1vb665a4pgvo3soana3okj@4ax.com>
Hi,
thank you all.
cheers,
k
------------------------------
Date: Tue, 10 Jan 2006 17:07:23 +0100
From: Jeroen Wolff <jwolff@freebee.essentkabel.com>
Subject: paste buffer in X11
Message-Id: <slrnds7mf5.1dgb.jwolff@freebee.essentkabel.com>
Hi, i would like to make way to stuff some text in the X11 paste buffer, so
that in another xterm i can past the text (middle mouse button)
Is there a way in perl?
Thanks!
Jeroen
------------------------------
Date: Tue, 10 Jan 2006 09:39:55 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: Re: Uploading 2 files with 1 CGI buffer
Message-Id: <Pine.GSO.4.64.0601100928560.27078@cpu02.student.cs.uwaterloo.ca>
On Mon, 9 Jan 2006, xhoster@gmail.com wrote:
> William <wh2leung@student.cs.uwaterloo.ca> wrote:
>> Code in question:
> ...
>>
>> Question: my above code only uploads 1 file. How do I upload 2 files
>> simulataenously with the same CGI buffer?
>
> I would use the module CGI.pm to do it. If I couldn't use CGI.pm for some
> bizarre reason, then I would look at the source code for CGI.pm, mostly in
> the subroutine "read_multipart", and use that as a starting point.
I looked at perldoc -m CGI and found the method read_multipart. I have to
concede that I have difficulty understanding the ~150 lines of code as I
plowed through them.
I would appreciate an example of reading multiple files using
read_multipart, which I could not found on google.
The following sample script can be used as a basis for the example:
#!/usr/bin/perl -w
use strict;
my $tempfile = "temp.txt";
my $savedfilename = "trs_vol.txt";
# The following reads in the CGI buffer, and writes it to a temporary file
# which will used later.
read ( STDIN, my $buffer, $ENV{'CONTENT_LENGTH'} );
open ( TEMP_FD,">$tempfile" );
print TEMP_FD $buffer;
close ( TEMP_FD );
open ( TEMPFILE_FD, $tempfile );
# Gotta pull the MIME/multipart separator line out
$_ = <TEMPFILE_FD>; (
my $vernum) = /(\d+)/;
$_ = <TEMPFILE_FD>;
my $filetemp = $1 if (/filename=\"(.*)\"/);
#create the output file in the upload directory
open ( OUTFILE_FD, ">$savedfilename");
close ( TEMPFILE_FD );
close ( OUTFILE_FD );
------------------------------
Date: Tue, 10 Jan 2006 09:47:42 -0500
From: William <wh2leung@student.cs.uwaterloo.ca>
Subject: Re: Uploading 2 files with 1 CGI buffer
Message-Id: <Pine.GSO.4.64.0601100944410.27078@cpu02.student.cs.uwaterloo.ca>
On Mon, 9 Jan 2006, Gunnar Hjalmarsson wrote:
> xhoster@gmail.com wrote:
>> William <wh2leung@student.cs.uwaterloo.ca> wrote:
>>> How do I upload 2 files simulataenously with the same CGI buffer?
>>
>> I would use the module CGI.pm to do it.
>
> And I would use CGI::UploadEasy (which, in turn, makes use of CGI.pm).
I tried "use CGI::UploadEasy" as follows:
use CGI::UploadEasy;
but I got the following error message:
perl -c test2.pl
Can't locate CGI/UploadEasy.pm in @INC (@INC contains:
/usr/perl5/5.00503/sun4-solaris /usr/perl5/5.00503
/usr/perl5/site_perl/5.005/sun4-solaris /usr/perl5/site_perl/5.005 .) at
test2.pl line 4.
BEGIN failed--compilation aborted at test2.pl line 4.
> > #!/usr/bin/perl
-T
> use strict;
> use warnings;
> use CGI::UploadEasy;
> use Data::Dumper;
>
> my $uploaddir = '/path/to/upload/directory';
> my $ue = CGI::UploadEasy->new(-uploaddir => $uploaddir);
>
> # At this point all the files are saved in $uploaddir.
> # For a raw printout of related info, you can do:
>
> my $info = $ue->fileinfo;
> my $cgi = $ue->cgiobject;
> print $cgi->header('text/plain');
> print Dumper $info;
> __END__
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>
------------------------------
Date: Tue, 10 Jan 2006 17:12:52 GMT
From: "Nospam" <nospam@home.com>
Subject: using perl mechanize
Message-Id: <oWRwf.51435$Dg6.27542@newsfe3-gui.ntli.net>
Given html such as this, what would I need to place in the fields for
mechanize to recognise the forms :
<head>
<link rel="stylesheet" href="/css/main.css" type="text/css">
<link rel="stylesheet" href="/css/guestbook.css" type="text/css">
</head>
<body>
<h2>{ <span style="color: #CC9900">Post a message</span> }</h2>
<div class="smallheader" style="text-align: center;">{ <a
href="guestbook.php?action=view">My Guestbook</a> }</div>
<form method="POST" action="guestbook.php">
<div align="center">
<center>
<table id="AutoNumber1" style="BORDER-COLLAPSE: collapse"
cellSpacing="0" cellPadding="4" width="410" border="1">
<tr>
<td width="100" class="GBV_name_title">Name:</td>
<td width="310" class="GBV_name_data"><input type="text" name="name"
size="40"></td>
</tr>
<tr>
<td width="100" class="GBV_name_title">Email:</td>
<td width="310" class="GBV_name_data"><input type="text" name="email"
size="40"></td>
</tr>
<tr>
<td width="100" class="GBV_name_title">Homepage:</td>
<td width="310" class="GBV_name_data"><input type="hidden" value="7"
name="comments_news_id">
<input type="text" name="homepage" size="40"></td>
</tr>
<tr>
<td width="100" class="GBV_name_title">Homepage Url:</td>
<td width="310" class="GBV_name_data"><input type="text"
name="homepage_url" size="40"></td>
</tr>
<tr>
<td width="100" class="GBV_name_title">How you Found Us:</td>
<td width="310" class="GBV_name_data"><select size="1"
name="how_you_foundus"><option>Search
Engine</option><option>Other</option></select></td>
</tr>
<tr>
<td width="100" class="GBV_name_title">Title</td>
<td width="310" class="GBV_name_data"><input type="text" name="title"
size="40"></td>
</tr>
<tr>
<td width="100" class="GBV_name_title">Comments</td>
<td width="310" class="GBV_name_data"><textarea rows="8"
name="comments" cols="32"></textarea></td>
</tr>
</table>
</center>
</div>
<p align="center"><input type="submit" value="Submit"
name="dopostcomments"><input type="reset" value="Reset" name="B2"><br>
</p>
</form><div class="smallheader" style="text-align: center;">{ <a
href="guestbook.php?action=view">Read Jenn's Guestbook</a> }</div>
$mech->form(1);
if $mech->field('Name','guesthere52');
if $mech->field('Title','interesting');
if $mech->field('Email','gue@dd.com');
if $mech->field('message','Testing');
doesn't seem to work, I get an error msg of no such field called form(1),
any suggestions will be greatly appreciated.
------------------------------
Date: Tue, 10 Jan 2006 17:22:57 +0000
From: Brian Wakem <no@email.com>
Subject: Re: using perl mechanize
Message-Id: <42i8rhF1j326vU1@individual.net>
Nospam wrote:
> Given html such as this, what would I need to place in the fields for
> mechanize to recognise the forms :
>
> <head>
> <link rel="stylesheet" href="/css/main.css" type="text/css">
> <link rel="stylesheet" href="/css/guestbook.css" type="text/css">
> </head>
> <body>
> <h2>{ <span style="color: #CC9900">Post a message</span> }</h2>
> <div class="smallheader" style="text-align: center;">{ <a
> href="guestbook.php?action=view">My Guestbook</a> }</div>
> <form method="POST" action="guestbook.php">
> <div align="center">
> <center>
> <table id="AutoNumber1" style="BORDER-COLLAPSE: collapse"
> cellSpacing="0" cellPadding="4" width="410" border="1">
> <tr>
> <td width="100" class="GBV_name_title">Name:</td>
> <td width="310" class="GBV_name_data"><input type="text" name="name"
> size="40"></td>
> </tr>
> <tr>
> <td width="100" class="GBV_name_title">Email:</td>
> <td width="310" class="GBV_name_data"><input type="text"
> name="email"
> size="40"></td>
> </tr>
> <tr>
> <td width="100" class="GBV_name_title">Homepage:</td>
> <td width="310" class="GBV_name_data"><input type="hidden" value="7"
> name="comments_news_id">
> <input type="text" name="homepage" size="40"></td>
> </tr>
> <tr>
> <td width="100" class="GBV_name_title">Homepage Url:</td>
> <td width="310" class="GBV_name_data"><input type="text"
> name="homepage_url" size="40"></td>
> </tr>
> <tr>
> <td width="100" class="GBV_name_title">How you Found Us:</td>
> <td width="310" class="GBV_name_data"><select size="1"
> name="how_you_foundus"><option>Search
> Engine</option><option>Other</option></select></td>
> </tr>
> <tr>
> <td width="100" class="GBV_name_title">Title</td>
> <td width="310" class="GBV_name_data"><input type="text"
> name="title"
> size="40"></td>
> </tr>
> <tr>
> <td width="100" class="GBV_name_title">Comments</td>
> <td width="310" class="GBV_name_data"><textarea rows="8"
> name="comments" cols="32"></textarea></td>
> </tr>
> </table>
> </center>
> </div>
> <p align="center"><input type="submit" value="Submit"
> name="dopostcomments"><input type="reset" value="Reset" name="B2"><br>
> </p>
> </form><div class="smallheader" style="text-align: center;">{ <a
> href="guestbook.php?action=view">Read Jenn's Guestbook</a> }</div>
>
> $mech->form(1);
> if $mech->field('Name','guesthere52');
> if $mech->field('Title','interesting');
> if $mech->field('Email','gue@dd.com');
> if $mech->field('message','Testing');
>
> doesn't seem to work, I get an error msg of no such field called form(1),
> any suggestions will be greatly appreciated.
None of those field names exist in the HTML. Why on Earth would you expect
it to work?
I see name, email, comments_news_id, homepage_url, how_you_foundus, title
and comments.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: Tue, 10 Jan 2006 11:34:19 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: using perl mechanize
Message-Id: <weSwf.11$Vi7.569@news.uswest.net>
Nospam wrote:
> Given html such as this, what would I need to place in the fields for
> mechanize to recognise the forms :
[...]
> $mech->form(1);
> if $mech->field('Name','guesthere52');
> if $mech->field('Title','interesting');
> if $mech->field('Email','gue@dd.com');
> if $mech->field('message','Testing');
>
> doesn't seem to work, I get an error msg of no such field called form(1),
> any suggestions will be greatly appreciated.
Of course it doesn't work, it's not real code. Show us your real code.
Something we can run to try to help you. How do you construct $mech?
How do 'get' the URL? etc. Also, what's with the various if statements,
that doesn't make any sense.
Typically, you should set all of the form's fields, in your agent. So
every attribute that has name="some value", the "some_value" should be set.
------------------------------
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 V10 Issue 8847
***************************************