[16897] in Perl-Users-Digest
Perl-Users Digest, Issue: 4309 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 13 09:05:32 2000
Date: Wed, 13 Sep 2000 06:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <968850312-v9-i4309@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 13 Sep 2000 Volume: 9 Number: 4309
Today's topics:
Re: - Free ebooks and resources - <je@bton.ac.uk>
Another novice question - host equivalent? <bd83h@bedford.waii.com>
Re: Another novice question - host equivalent? <jeffp@crusoe.net>
calendar (Eric Mosley)
Re: calendar <tward10@jaguar.com>
Re: Change Windows Desktop BG <jluongonospam@draper.com>
Re: Change Windows Desktop BG <jluongonospam@draper.com>
convert date -> unixtime gumbygumbygumby@my-deja.com
Re: Count of items is EXCEPTION not RULE (was Re: Littl <iltzu@sci.invalid>
Re: cross-platform archive mgt <elephant@squirrelgroup.com>
Re: cross-platform archive mgt <davids@wwwwdesertigloo.com>
Re: DBI/MySQL Question for the WISE (Anthony Peacock)
Re: DBI/MySQL Question for the WISE <anders@wall.alweb.dk>
Re: E-Commerce scripts <jevon@islandtelecom.com>
Re: email form script <lincolnmarr@nospam.europem01.nt.com>
File upload trough proxy <sven@rheingau.netsurf.de>
Re: Finding maximum length (Logan Shaw)
Re: Finding maximum length <ug@suse.de>
Re: Finding maximum length <jeffp@crusoe.net>
Re: Help with perl/cgi (using book: perl,cgi, and javas (Tim Hammerquist)
Re: Incremental HTML output as script is running <bilgates@hem1.passagen.se>
Is there a more elegant way? (Sean McAfee)
Re: Is there a more elegant way? <bcaligari@my-deja.com>
LWP::UserAgent->as_string() known Method ? <lu@bbi.ch>
Re: LWP::UserAgent->as_string() known Method ? (Garry T. Williams)
Re: LWP::UserAgent->as_string() known Method ? <sven@rheingau.netsurf.de>
module/script to parse c++ headers? barneydalton@my-deja.com
Re: Prune doesn't work in find brianr@liffe.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 13 Sep 2000 12:02:32 +0100
From: John English <je@bton.ac.uk>
Subject: Re: - Free ebooks and resources -
Message-Id: <39BF5EC8.8AC7555C@bton.ac.uk>
COM Service (webmaster@swap-resources.com) wrote:
> I would like to know where I can find free ebooks and good resources
about
> Java, Perl, Unix, ASP and Visual Basic.
Try http://burks.bton.ac.uk/burks/language/.
-----------------------------------------------------------------
John English | mailto:je@brighton.ac.uk
Senior Lecturer | http://www.it.bton.ac.uk/staff/je
Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS **
University of Brighton | -- see http://burks.bton.ac.uk
-----------------------------------------------------------------
------------------------------
Date: Wed, 13 Sep 2000 12:22:01 +0100
From: Steve Drewell <bd83h@bedford.waii.com>
Subject: Another novice question - host equivalent?
Message-Id: <1000913121027.58376E-100000@bisv3.bedford.waii.com>
Within a perl script, how do I do the equivalent of:
variable=`host 111.222.333.444` ?
(ie. find the hostname of a machine given it's IP address)
Is there a way of doing it without using "system"?
Cheers,
Steve
Western Geophysical, Bedford, UK
Tel: +44 (0) 1234 224404
Fax: +44 (0) 1234 224517
------------------------------
Date: Wed, 13 Sep 2000 08:30:35 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Another novice question - host equivalent?
Message-Id: <Pine.GSO.4.21.0009130829030.23599-100000@crusoe.crusoe.net>
[posted & mailed]
On Sep 13, Steve Drewell said:
>variable=`host 111.222.333.444` ?
>Is there a way of doing it without using "system"?
use Socket;
$addr = gethostbyaddr(inet_aton($IP), AF_INET);
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Wed, 13 Sep 2000 09:38:57 GMT
From: ericm@iol.ie (Eric Mosley)
Subject: calendar
Message-Id: <RWHv5.2351$44.7592@news.iol.ie>
Hi,
Does anybody know of some good web based calendar applications that run
through perl and apache on Linux?
Only looking for something basic, user specific, add an appointment,
delete an appointment. Probably with a mySQL database...
There must be loads?
Thanks
Eric
------------------------------
Date: Wed, 13 Sep 2000 11:46:16 +0100
From: "Trevor Ward" <tward10@jaguar.com>
Subject: Re: calendar
Message-Id: <8pnlto$4ul3@eccws12.dearborn.ford.com>
I have written a time management system using DBM files so will run anywhere
can let you have some of the code if you like.
Eric Mosley <ericm@iol.ie> wrote in message
news:RWHv5.2351$44.7592@news.iol.ie...
> Hi,
>
> Does anybody know of some good web based calendar applications that run
> through perl and apache on Linux?
>
> Only looking for something basic, user specific, add an appointment,
> delete an appointment. Probably with a mySQL database...
>
> There must be loads?
>
> Thanks
>
> Eric
------------------------------
Date: Wed, 13 Sep 2000 08:45:31 -0400
From: "James M. Luongo" <jluongonospam@draper.com>
Subject: Re: Change Windows Desktop BG
Message-Id: <39BF76EB.4B60AAFB@draper.com>
> you are clearly unaware of the 'perldoc' utility .. type the following
> at the command prompt
Not anymore
>
> perldoc perldoc
>
> and start reading about it .. or on a Win32 machine that has
> ActiveState's Perl port installed on it (the standard Win32 port) go to
> the Programs section of your State menu .. there's an entry for
> ActivePerl with documentation in it
thankyou very much
------------------------------
Date: Wed, 13 Sep 2000 08:55:27 -0400
From: "James M. Luongo" <jluongonospam@draper.com>
Subject: Re: Change Windows Desktop BG
Message-Id: <39BF793F.E3795504@draper.com>
> At the command prompt, type:
>
> perldoc Win32::TieRegistry
> perldoc Win32API::Registry
>
I typed those on my UNIX box at work. Even copied and pasted.
I get
No documentation found for "Win32::TieRegistry".
then I tried perldoc Win32 and no documentation was found
I think its that the version of Perl I have is 5.005 built for Solaris.
Why would it contain Win32 stuff?
I'll just have to check the ActiveState documentation when I get home.
Thanks though
------------------------------
Date: Wed, 13 Sep 2000 10:48:42 GMT
From: gumbygumbygumby@my-deja.com
Subject: convert date -> unixtime
Message-Id: <8pnm27$67r$1@nnrp1.deja.com>
Hi, how do i do this conversion, is there some function i can use or do
i have to code it myself?
cheers,
/Carl
***********************************************************************
* * My webpage about the author Tom Holt: *
* /_\ http://hem.passagen.se/gumby/holt/ *
* { ~._.~ } Bookreviews can be found at: http://go.to/10 *
* ( Y ) other things like SF/Fantasy-articles & biographies *
* ( )~*~( ) and heaps of musiclinks can be found at *
* (__)-(__) http://hem.passagen.se/gumby/ *
***********************************************************************
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 13 Sep 2000 11:25:41 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <968844027.14399@itz.pp.sci.fi>
In article <brian-ya02408000R1209001643400001@news.panix.com>, brian d foy wrote:
>In article <968784201.19632@itz.pp.sci.fi>, Ilmari Karonen <usenet11212@itz.pp.sci.fi> posted:
>
>> something that can give it a scalar. The language has been designed
>> so that this is always possible; every builtin has a scalar value.
>
>even sort()? ;)
I was sure someone would mention this. Note the conspicuous absence
of the word "meaningful" in the last sentence you quoted. Undef is a
perfectly fine scalar value as far as perl is concerned.
--
Ilmari Karonen - http://www.sci.fi/~iltzu/
Please ignore Godzilla | "By promoting postconditions to
and its pseudonyms - | preconditions, algorithms become
do not feed the troll. | remarkably simple." -- Abigail
------------------------------
Date: Wed, 13 Sep 2000 18:18:21 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: cross-platform archive mgt
Message-Id: <MPG.1429c734ffa70f569897a9@localhost>
Logan Shaw <logan@cs.utexas.edu> wrote ..
>In article <MPG.14299c837d0d85a39897a2@localhost>,
>jason <elephant@squirrelgroup.com> wrote:
>>David P. Schwartz <davids@YYYYdesertigloo.com> wrote ..
>>>Are there any Perl language plugins or libraries for handling Zip archives?
>>
>>that's it .. it's time to coin a new acronym for a self-answering-
>>question - SAQ
>
>O.K., I don't get the self-answering question thing.
>
>Just because a question contains all or most of the words necessary to
>answer it doesn't make the question stupid or the answer obvious.
>
>For instance, which of the following questions are self-answering?
>
> a. What is the name of Peter Case's first album?
> b. What is the name of Bruce Cockburn's first album?
> c. What is the name of T-Bone Burnett's first album?
>
>Well, it turn out that "a" and "b" are, but "c" isn't. All three
>artists have released eponymous albums, but T-Bone's eponymous one was
>not his first. (It was his 3rd, 4th, 5th, or 6th, depending on whether
>you count EPs and/or albums released under the name J. Henry Burnett.)
>
>Anyway, my point is that the fact that the question contains the answer
>doesn't necessarily mean the question is answered.
no .. but when that answer is plugged in to one of the documentation
tools that come with Perl and it reveals the answer - then there's
little excuse for asking the SAQ in a newsgroup
if similar tools were available for those albums then I'd consult them
first before running to alt.music.jason.has.never.heard.of and asking ..
I mean if you ask a question like "how do I delete a hash element" ..
don't you think you might try a little hunt through perlfunc first ?
as far as I'm concerned .. asking a SAQ here is the most obvious case of
"roll over and have someone scratch your tummy for you" because it is
perfectly clear that - despite being _so_ close to having the answer ..
they just didn't have the inclination to open the documentation or
search CPAN
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Wed, 13 Sep 2000 02:44:10 -0700
From: "David P. Schwartz" <davids@wwwwdesertigloo.com>
Subject: Re: cross-platform archive mgt
Message-Id: <39BF4C6A.2761F67B@wwwwdesertigloo.com>
jason wrote:
> <snip>
> >Anyway, my point is that the fact that the question contains the answer
> >doesn't necessarily mean the question is answered.
>
> no .. but when that answer is plugged in to one of the documentation
> tools that come with Perl and it reveals the answer - then there's
> little excuse for asking the SAQ in a newsgroup
>
> if similar tools were available for those albums then I'd consult them
> first before running to alt.music.jason.has.never.heard.of and asking ..
> I mean if you ask a question like "how do I delete a hash element" ..
> don't you think you might try a little hunt through perlfunc first ?
>
> as far as I'm concerned .. asking a SAQ here is the most obvious case of
> "roll over and have someone scratch your tummy for you" because it is
> perfectly clear that - despite being _so_ close to having the answer ..
> they just didn't have the inclination to open the documentation or
> search CPAN
>
> --
> jason -- elephant@squirrelgroup.com --
While I generally share your annoyance at "dumb questions", I'm afraid you're
making some assumptions here that aren't valid. First off, I went to five of the
"top" search engines, like Yahoo and Lycos. Typing only "zip" or "archive" yields
WAY over 100k hits. I never managed to formulate a query that yielded fewer than
8k hits. It didn't occur to me to go to CPAN -- duh. I had Perl installed on my
machine a while back, but it had some system problems and I had to wipe my disk
and start from scratch, so it's been gone for a while. I'm not a big Perl
programmer; I'm looking for this because I need a script that can use it and I
want to contract out some work and have been told by about half-dozen other folks
I've talked to that there are no libs around for handling zip archives in Perl.
These guys ARE regular Perl programmers, and I figured they'd done the kind of
search you're suggesting. So AFAIK, I wasn't even in the ballpark when I posted
my question here. The REASON I posted it is because there ARE folks like you who
DO know the answers to this kind of apparent trivia.
Anyway, thanks for being of service, in spite of how trivial it seemed to you.
-David
------------------------------
Date: 13 Sep 2000 10:16:23 GMT
From: a.peacock@chime.ucl.ac.uk (Anthony Peacock)
Subject: Re: DBI/MySQL Question for the WISE
Message-Id: <8pnk5n$keq$2@uns-a.ucl.ac.uk>
In article <8plnlc$t98$1@nnrp1.deja.com>, desertedge@my-deja.com says...
>
>As I add a record to the MySQL database, I have an auto-incremented
>number assigned to the first field within the table. When the record
>is created (with the code below), I would like to then instantly
>retrieve the new auto-incremented number. I've thrown FETCH commands
>in, but it doesn't seem to work. Is there a way to do this easily,
>without generating a new query????
>
>MY EXAMPLE CODE:
> use DBI ;
> $query = "INSERT INTO appls (NETappID,
> clienID,
> CEappID_
> VALUES ('blahblah','etc', 'etc')";
>
> $sth = $dbh->prepare ( $query ) or
> &dieerror ("Error Code<p>$DBI::errstr");
> $sth->execute or
> &dieerror ("Error Code2<p>$DBI::errstr");
>
my $last_id1 = $sth->{mysql_insertid}; # For mysql modules >=
v1.21_xx
my $last_id2 = $sth->{insertid}; # For mysql modules >=
v1.20_xx
> ######HERE IS WHERE I WOULD LIKE TO FETCH THE ID OF THE RECORD ##
> $sth->finish;
> $dbh->disconnect;
Or you could just perform the standard mySQL query for getting the last
insert id:
$sth->do("SELECT LAST_INSERT_ID()");
This does not create any race conditions because mySQL handles
incrementing the insert id on a per connection basis, so as long as you
don't close the connection you will always get the last inserted id that
_you_ created.
PS This information was checked by refereing to the O'Reilly
"Programming DBI" book by Alligator Descartes and Tim Bunce.
------------------------------
Date: Wed, 13 Sep 2000 11:10:59 GMT
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: DBI/MySQL Question for the WISE
Message-Id: <7hJv5.1160$Tn3.19910@news010.worldonline.dk>
Garry T. Williams wrote:
> On Tue, 12 Sep 2000, Anders Lund wrote:
> > Garry T. Williams wrote:
> > > On Tue, 12 Sep 2000, Anders Lund wrote:
> > > > desertedge@my-deja.com wrote:
> > > > > ######HERE IS WHERE I WOULD LIKE TO FETCH THE ID OF THE
> > > > > ######RECORD
> > > > > ########
> > > >
> > > > $sql = $dbh->prepare("select auto_col from table_name sort by
> > > > auto_col desc limit 1");
> ...
> > > So how is it that you *know* that the highest number in this table is
> > > the
> > > row just inserted by *you*? Is it possible that another insert by
> > > another client is now the row you are retrieving?
> > >
> > > I think the original poster wants an "atomic" operation that both
> > > instantiates a new row with an automatically incremented column *and*
> > > returns the value of that column.
> ...
> > Thanks Gary, you are absolutely right!!
> >
> > Mysql has means for letting you know if the query was accepted, and DBI
> > I think knows that and returns an error if no rows was affected.
> >
> > But the table should be locked while this operation runs, can be done
> > with an SQL statement.
>
> No. At least it cannot be done with:
>
> $ mysql -V
> mysql Ver 9.38 Distrib 3.22.32, for sun-solaris2.7 (sparc)
>
> because there is no transaction support in this version. I believe that
> there is a new release that *will* support transactions, but I have no
> experience with it. You should consult the MySql documentation. You
> might even find a supported interface to get back the value of the
> auto-increment column that is inserted.
>
> But, of course, this isn't a Perl issue any longer.
>
> -Garry Williams
>
No transactions, but read what the MySql docs has to say about that.
And you can lock tables/rows using SQL
-anders
--
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]
------------------------------
Date: Wed, 13 Sep 2000 12:48:07 GMT
From: "Jevon MacDonald" <jevon@islandtelecom.com>
Subject: Re: E-Commerce scripts
Message-Id: <bIKv5.8$JP6.7771@sapphire.mtt.net>
> PS. Flat file access is preferable over database access.
No it's not.
:)
-Jevon
------------------------------
Date: Wed, 13 Sep 2000 09:05:30 +0200
From: "Lincoln Marr" <lincolnmarr@nospam.europem01.nt.com>
Subject: Re: email form script
Message-Id: <8pn8vk$2ao$1@qnsgh006.europe.nortel.com>
> I have a need for a cgi/perl script that will take a forms data, then
> generate an email.
Check out matts script archive (you can use a search engine can't you?),
it's got a script called formmail which will do what you want....
stylistically speaking it's not too good as it's written for Perl 4, but it
still works and is simple to set up.
--Lincoln
------------------------------
Date: Wed, 13 Sep 2000 09:24:48 GMT
From: Sven Rudolph <sven@rheingau.netsurf.de>
Subject: File upload trough proxy
Message-Id: <8pnh4h$166$1@nnrp1.deja.com>
Hello
I'm trying to write a perlscript, that does a file-upload through a
proxy which requests username and password.
I'm pretty new to perl-programming, so I can't find out what I'm doing
wrong.
Here is what I have written so far:
use HTTP::Request;
use LWP::UserAgent;
$browser = new LWP::UserAgent;
$browser->proxy(['http'] => 'http://proxy:8080');
my $req = new HTTP::Request
'POST','http://targetserver/getpicture.php3';
$req->content_type('image/jpeg');
$req->content('userfile = picture.jpg');
$req->proxy_authorization_basic("username","passwd");
$ergebnis = $browser->request($req)->as_string;
print $ergebnis;
Well, the proxy-password part works. I tested it with a GET-request.
What doesn't work, is the file-upload.
Binarys are normaly transmitted inside the header (?), so I assume I hav
to use HTTP::Headers to set content-type and content. Is that right?
The last thing I thought about, was to base64-encode the picture and to
decode it on the Server, but I think there has to be a more elegant way.
Can anybody help me?
Thanks in advance
Sven Rudolph
--
--
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 13 Sep 2000 02:05:30 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Finding maximum length
Message-Id: <8pn8vq$490$1@provolone.cs.utexas.edu>
In article <5TEv5.3168$O5.63702@news.itd.umich.edu>,
Sean McAfee <mcafee@waits.facilities.med.umich.edu> wrote:
>In article <8pmkss$1it$1@nnrp1.deja.com>, <greg_sands@my-deja.com> wrote:
>>I'm trying to find the maximum length of the elements of an array.
>
>Here's an idiom I like:
>
>sub maximum (&@) {
> my $sub = shift;
> my ($max, $value);
> foreach (@_) {
> $value = $sub->();
Don't you want to give some sort of argument to &$sub, i.e. shouldn't
you do something like
$value = $sub->($_);
instead? Or does that actually work and it's just really obfuscated?
> !defined $max || $max < $value and $max = $value;
Wouldn't it be simpler to just do this?
$max = $value if $max < $value;
When $max is undef, it should evaluate as less than $value.
Or is this considered bad style? If so, that would be nice to know
since I've been known to use it.
Anyway, I have to admit that this is an elegant way to do it, even if
it's not terse.
- Logan
------------------------------
Date: Wed, 13 Sep 2000 10:20:13 +0200
From: Uwe Gansert <ug@suse.de>
Subject: Re: Finding maximum length
Message-Id: <8pndbt$qjl$1@Fourier.suse.de>
Yanick Champoux wrote:
> : I'm trying to find the maximum length of the elements of an array. Both
> while++$l,grep/.{$l}./,@a;
> print $l;
cute.
It's as short as slow. But it looks really cool. :-)
cu , Uwe Gansert
------------------------------
Date: Wed, 13 Sep 2000 07:26:48 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Finding maximum length
Message-Id: <Pine.GSO.4.21.0009130725330.23599-100000@crusoe.crusoe.net>
On Sep 13, jason said:
>Jeff Pinyan <jeffp@crusoe.net> wrote ..
>>>> $len < $_ and ($len = $_) for @array;
>> s'$_'length'g;
>
>now you're left with $len containing the longest length .. not the
>element *with* the longest length
The one I had in my brain worked. Pshaw. The correct algorithm was the
one the OP presented.
And I was silly.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Wed, 13 Sep 2000 07:11:45 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Help with perl/cgi (using book: perl,cgi, and javascript complete)
Message-Id: <slrn8ruatc.49q.tim@degree.ath.cx>
On Wed, 13 Sep 2000 03:19:54 -0400, peter <peterp100@hotmail.com> wrote:
> I get "not found"
> when I try to use the "geturl.pl" cgi program working.
Seems self-evident. It's not in any search path Perl uses.
> The program also had the perl "require" command, requiring a file
> called html.pl, what's funny is that there is no mention of what this
> file does or where it is, and guess what, it's not on my system.
And the book doesn't explain it? Maybe in an earlier chapter?
> What's also funny is the directory pub/scripts/perl-cgi/[html.pl] is
> not there.
Sounds like a server config issue and/or book-to-programmer translation
issue. Either way, the problem doesn't have that perl ring to it.
> I love all these books on perl and linux, they really make sense...
Is that sarcasm I detect? =)
> Can you point me to any book that is well written and worth the paper
> it is written on, I'm really tired of getting ripped off everytime I
> buy a computer book.
The only thing I used to learn CGI programming was `perldoc CGI` and an
Apache manual published by Wrox titled "Professional Apache."
--
-Tim Hammerquist <timmy@cpan.org>
Intellectual brilliance is no guarantee against being dead wrong.
-- David Fasold
------------------------------
Date: Wed, 13 Sep 2000 11:48:46 +0200
From: "vinste" <bilgates@hem1.passagen.se>
Subject: Re: Incremental HTML output as script is running
Message-Id: <39bf4d3e@news1e1.seinf.abb.se>
Hmm, couldnt $|=1; solve the problem ?
/ Jakob
"Andy Flisher" <news@flish.co.uk> wrote in message
news:MPG.1428aa68db60029a98968b@alt-news.gradwell.net...
> On perusing <8pm1iu$a2n$1@nnrp1.deja.com>, michaeld@brown-cole.com was
> heard to mumble...
>
> > I'll email the scripts to you for your perusal.
>
> Thanks, would be appreciated.
>
> Suspect I'm gonna have to rethink the costings for this job though, way
> too much time going in for what I (obviously incorrectly) thought would
> be a simple practice.
>
> Really must start planning these things out in my head before jumping in
> ;-(
> --
> Andy Flisher
>
> 'All postings are a reflection of my state of mind,
> and not necessarily of any worthwhile opinion'
>
> news@flish.co.uk http://www.flish.co.uk
------------------------------
Date: Wed, 13 Sep 2000 06:53:07 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Is there a more elegant way?
Message-Id: <nvFv5.3170$O5.63671@news.itd.umich.edu>
I wrote a function that essentially looks like this:
sub myfunc {
my ($arg1, $arg2) = @_;
local $_ = get_data($arg1, $arg2); # This function may return
# a very large scalar.
otherfunc(); # This function modifies $_.
return $_;
}
I'll generally know before calling myfunc whether the scalar that will be
returned will be very large or not. I want to reduce unnecessary copying of
large blocks of memory, so I decided I wanted to optionally be able to pass
an extra argument to myfunc--call it $target--which could be aliased to $_,
so the "$_ = get_data()" statement assigns directly to $target. In this
case nothing would be returned from the function.
I produced a solution, but I'm wondering if it could be made to look more
elegant. Can someone suggest a better way?
sub myfunc {
my ($arg1, $arg2) = @_;
my ($usetarget, $target) = (@_ >= 3, \$_[2]);
local *_;
*_ = $target if $usetarget;
$_ = get_data($arg1, $arg2);
otherfunc();
return if $usetarget;
return $_;
}
--
Sean McAfee mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!
------------------------------
Date: Wed, 13 Sep 2000 08:31:30 GMT
From: Brendon Caligari <bcaligari@my-deja.com>
Subject: Re: Is there a more elegant way?
Message-Id: <8pne12$tr0$1@nnrp1.deja.com>
In article <SdFv5.3169$O5.63644@news.itd.umich.edu>,
mcafee@waits.facilities.med.umich.edu (Sean McAfee) wrote:
> I wrote a function that essentially looks like this:
[snip snip]
> I'll generally know before calling myfunc whether the scalar that
will be
> returned will be very large or not. I want to reduce unnecessary
copying of
> large blocks of memory, so I decided I wanted to optionally be able
to pass
unless you want to preserve the contents of the scalar being passed as
parameter, you could try passing a reference to it.
#!/usr/bin/perl -w
use strict;
my $scalar = 'foo bar';
print("$scalar\n");
screwup(\$scalar);
print("$scalar\n");
exit(0);
sub screwup {
my $scalarRef = shift();
$$scalarRef =~ s/foo/cocktail/;
return 1;
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 09:39:06 +0200
From: Yves Lustenberger <lu@bbi.ch>
Subject: LWP::UserAgent->as_string() known Method ?
Message-Id: <39BF2F1A.394FEBEF@bbi.ch>
I've tried the following Examplescript:
use LWP::UserAgent;
$ua = new LWP::UserAgent;
my $req = new HTTP::Request
'POST','http://www.perl.com/cgi-bin/BugGlimpse';
$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');
my $res = $ua->request($req);
print $res->as_string;
It generates me the following error:
Can't locate object method "as_string" via package "LWP::UserAgent"
The UserAgent Object does really not have the Method as_string();
What does this Method in the example Script ?
What can i do instead ?
Thank you for your help.
Yves
--
Yves Lustenberger Phone: +41 41 348 01 48
BBI Informationstechnologie AG Fax: +41 41 348 01 49
Kuonimatt E-Mail: mailto:lu@bbi.ch
Industriestrasse 13 WWW: http://www.bbi.ch
CH-6010 Kriens
Download PGP Public-Keys: http://www.bbi.ch/pgp/
------------------------------
Date: Wed, 13 Sep 2000 08:27:56 GMT
From: garry@ifr.zvolve.net (Garry T. Williams)
Subject: Re: LWP::UserAgent->as_string() known Method ?
Message-Id: <gUGv5.2$fa2.1081@eagle.america.net>
On Wed, 13 Sep 2000 09:39:06 +0200, Yves Lustenberger <lu@bbi.ch> wrote:
>I've tried the following Examplescript:
>
> use LWP::UserAgent;
> $ua = new LWP::UserAgent;
>
> my $req = new HTTP::Request
>'POST','http://www.perl.com/cgi-bin/BugGlimpse';
> $req->content_type('application/x-www-form-urlencoded');
> $req->content('match=www&errors=0');
>
> my $res = $ua->request($req);
> print $res->as_string;
>
>It generates me the following error:
>Can't locate object method "as_string" via package "LWP::UserAgent"
That's funny. I don't see the problem:
$ cat x
use LWP::UserAgent;
$ua = new LWP::UserAgent;
my $req = new HTTP::Request
'POST','http://www.perl.com/cgi-bin/BugGlimpse';
$req->content_type('application/x-www-form-urlencoded');
$req->content('match=www&errors=0');
my $res = $ua->request($req);
print $res->as_string;
$ perl x
HTTP/1.1 404 Not Found
Connection: close
Date: Wed, 13 Sep 2000 08:10:37 GMT
Server: Apache/1.3.12 (Unix) PHP/4.0RC1
Content-Type: text/html
Client-Date: Wed, 13 Sep 2000 08:10:34 GMT
Client-Peer: 208.201.239.56:80
Title: Sorry, that page is unavailable
<html>
...
------------------------------
Date: Wed, 13 Sep 2000 08:40:13 GMT
From: Sven Rudolph <sven@rheingau.netsurf.de>
Subject: Re: LWP::UserAgent->as_string() known Method ?
Message-Id: <8pneha$uf2$1@nnrp1.deja.com>
Hello Yves
> my $res = $ua->request($req);
> print $res->as_string;
Try it this way
$res = $ua->request($req)->as_string;
print $res;
I hope it helps
Sven Rudolph
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 13 Sep 2000 08:56:15 GMT
From: barneydalton@my-deja.com
Subject: module/script to parse c++ headers?
Message-Id: <8pnff8$vcg$1@nnrp1.deja.com>
I recently downloaded
matwrap (http://lnc.usc.edu/~holt/matwrap/matwrap.html) which is a perl
script that parses C++ headers to produce a matlab wrapper file. This
can then be turned into a mex DLL and called directly from matlab. It
works well, but doesn't support all C++ constructs, such as enums, and
templates.
The parser is hand coded, and I am thinking of trying to update it (for
enums at least). But a preferable solution would to be able to plug into
a c++ header parser that already supports these things.
Note it only needs to parse headers, and return some form of
type/class/function map. No parsing of implementation code is required.
I don't know a huge amount parsers, so any general pointers would also
be useful
thanks
barney
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 13 Sep 2000 13:25:10 +0100
From: brianr@liffe.com
Subject: Re: Prune doesn't work in find
Message-Id: <vtvgw0iimx.fsf@liffe.com>
mnelsen@nc.rr.com (Mike Nelsen) writes:
> On 12 Sep 2000 13:36:21 +0100, brianr@liffe.com wrote:
> >sub wanted {
> > print "$File::Find::name\n";
> > $File::Find::prune=1 if -d && $opt_nosub;
> >}
> >
> >Should work
> Unfortunately, it doesn't. The -d doesn't really make any difference.
Ooops that should have been:
sub wanted {
print "$File::Find::name\n";
$File::Find::prune=1 if -d && $_ ne '.' && $opt_nosub;
}
Sorry, I should have tested the code I posted rather than expect it to
work just because it came from a working script.
--
Brian Raven
Perl itself is usually pretty good about telling you what you shouldn't
do. :-)
-- Larry Wall in <11091@jpl-devvax.JPL.NASA.GOV>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4309
**************************************