[25437] in Perl-Users-Digest
Perl-Users Digest, Issue: 7682 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 22 06:05:29 2005
Date: Sat, 22 Jan 2005 03:05:10 -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 Sat, 22 Jan 2005 Volume: 10 Number: 7682
Today's topics:
Re: [VERY OT] Seeya all! <dha@panix.com>
Re: [VERY OT] Seeya all! <matthew.garrish@sympatico.ca>
Check it out! <residulizer@imasales.com>
Re: File::Find gives me current dir (.)? <jkeen_via_google@yahoo.com>
Re: File::Find gives me current dir (.)? <tadmc@augustmail.com>
gensym vs. other way <alex_the_hart@yahoo.com>
Re: gensym vs. other way <nobull@mail.com>
Re: gensym vs. other way <alex_the_hart@yahoo.com>
Re: how to write a tutorial <jeffrey@cunningham.net>
IO::Select extension xhoster@gmail.com
Re: IO::Select extension <nobull@mail.com>
Re: net::SFTP to capture 'get' reference? <nodj.athensspam@surfeu.fi.useless>
newbie perl questions chrispatton@gmail.com
Re: newbie perl questions <alex_the_hart@yahoo.com>
Re: newbie perl questions <nobull@mail.com>
Re: Perl on Windows <jurgenex@hotmail.com>
Re: Perl script issues - Need help <tadmc@augustmail.com>
Re: Radix Sort in CPAN <tadmc@augustmail.com>
Re: The world's shortest 'Hello World!' program: a prop <dha@panix.com>
Re: Win32::api doesn't work? <dontmewithme@got.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 22 Jan 2005 00:10:07 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: [VERY OT] Seeya all!
Message-Id: <slrncv36ev.dl0.dha@panix2.panix.com>
On 2005-01-21, Brian McCauley <nobull@mail.com> wrote:
>
>
> A. Sinan Unur wrote:
>> Michele Dondi <bik.mido@tiscalinet.it> wrote:
>>
>>>I can't go on like this any more: I must take this f**ked up degree!
>>>So what? Well, I realize that if I'm _really_ serious about this then
>>>I must abandon a whole series of distractions,
>>
>>
>> Good luck. Hope to see you back soon.
>
> I echo those senitments exactly.
And again from here.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I believe myself to be the daughter of a one-eyed space robot named
Malcolm. -Fallon Young, http://www.bobbins.org/d/20000915.html
------------------------------
Date: Fri, 21 Jan 2005 22:56:24 -0500
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: [VERY OT] Seeya all!
Message-Id: <F9kId.62738$W33.1914038@news20.bellglobal.com>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:5920v0hg7oeocelneqvj514h20partgbck@4ax.com...
>
> I can't go on like this any more: I must take this f**ked up degree!
> So what? Well, I realize that if I'm _really_ serious about this then
> I must abandon a whole series of distractions, and I'd include taking
> part to discussions here in the (black-)list.
>
I think you just scored a perfect 10 on the melodrama scale...
Matt
------------------------------
Date: Fri, 21 Jan 2005 21:18:11
From: "Charles Peterson" <residulizer@imasales.com>
Subject: Check it out!
Message-Id: <qdWdnbIwyuVlWGzcRVn-pg@comcast.com>
One of the webs newest and hottest opportunities. Besides making a residual income, you can meet people through chat and forums, advertize your business, and participate in exciting contests. Go to www.residulizer.com and find out what everyone is talking about!
---
MAF Anti-Spam ID: 20050121132653G4k9TuI4
------------------------------
Date: Sat, 22 Jan 2005 00:06:45 GMT
From: Jim Keenan <jkeen_via_google@yahoo.com>
Subject: Re: File::Find gives me current dir (.)?
Message-Id: <pOgId.11246$1l2.5532@trndny05>
ben.rogers@gmail.com wrote:
> I wrote a subroutine that finds all of the files of a certain type.
>
> ################################# FIND FILES
> # Print instructions for finding files to the script created by
> createScriptFile.
> # Get the input directory ($inputdir) and recursion setting ($recursion
> = 1 or 0).
> # Get the file types (@file_types) and make a string used by grep or
> File::Find.
> sub fileFinder {
> my $file_match_string = join ("|", @file_types);
> if ($recursive =~ 1) {
Wrong Perl syntax. =~ is the binding operator used in testing strings
with regular expressions. You probably want:
if ($recursive == 1) { ...
See: perldoc perlop
But since you're only permitting $recursive to be either '1' or '0', you
can more simply say:
if ($recursive) { ...
> chdir "$inputdir";
> find (\\&wanted, "$inputdir");
> sub wanted(){
> if (\$File::Find::name =~ /($file_match_string)\$/i && -f){
> print STDOUT "FOUND: \$File::Find::name\\n";
> push \@files, \$File::Find::name;
Wrong, wrong! What your code says is "Push a reference to a scalar onto
a reference to an array" ... which doesn't work.
You probably want:
push @files, $File::Find::name;
Read the docs:
perldoc -f push
But the fact that you're putting your call to File::Find inside another
subroutine suggests to me that you don't really understand how to use
it. (Granted, its syntax is not the easiest to grok at first.) But
once you've corrected the mistakes above, try rewriting your program
without sub FileFinder and without any of the code below this point.
> }
> }
> print STDOUT "Finished finding files.";
> } else { # Just GREP and don't use recursion.
> print "my \@files = '';\n";
> print "opendir(DIR, \"$inputdir\");\n";
> print "\@files = grep /$file_match_string/,";
> print "readdir(DIR);\nclosedir(DIR);\n";
> }
> }
>
Jim Keenan
------------------------------
Date: Fri, 21 Jan 2005 19:31:06 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: File::Find gives me current dir (.)?
Message-Id: <slrncv3b6q.269.tadmc@magna.augustmail.com>
ben.rogers@gmail.com <ben.rogers@gmail.com> wrote:
[ something horrid has happened to the formatting of your code...]
> if ($recursive =~ 1) {
if ($recursive =~ /1/) { # contains a "1" character
or
if ($recursive eq '1') { # equals the "1" chararacter
or
if ($recursive == 1 ) { # equals the number 1
depending on whichever it is that you were really trying to get there.
> chdir "$inputdir";
You should not use useless quotes.
You should check the return value to see if you actually
got what you asked for:
chdir $inputdir or die "could not cd to '$inputdir' $!";
> find (\\&wanted, "$inputdir");
^
^ why the extra backslash?
> sub wanted(){
^^
^^ why the prototype?
> if (\$File::Find::name =~ /($file_match_string)\$/i && -f){
^ ^
^ ^
^ why the extra backslashes?
> print STDOUT "FOUND: \$File::Find::name\\n";
^
^ why the extra backslash?
> push \@files, \$File::Find::name;
^ ^
^ ^
^ why the extra backslashes?
> print "my \@files = '';\n";
> print "opendir(DIR, \"$inputdir\");\n";
> print "\@files = grep /$file_match_string/,";
> print "readdir(DIR);\nclosedir(DIR);\n";
Why are you print()ing code?
Is this a program-writing program that you are working on?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 2005 21:55:20 -0800
From: "Alex Hart" <alex_the_hart@yahoo.com>
Subject: gensym vs. other way
Message-Id: <1106373320.404302.325440@c13g2000cwb.googlegroups.com>
I thought that these are equivalent:
use Symbol;
my $fh = gensym;
and
local *FH;
my $fh = \*FH;
But the following code doesn't treat them the same.
#!/usr/bin/perl -w
use Symbol;
use strict;
my $file = Test_close->new("test");
package Test_close;
{
my $testdiename;
sub new {
my ($class, $name) = @_;
print ("Test_close on $name\n");
$testdiename=$name;
local *TMP;
my $tmp = \*TMP; # THIS LINE AND THE NEXT ARE THE TEST
# my $tmp = Symbol::gensym();
bless $tmp, $class;
}
sub DESTROY {
print "\n\n$testdiename died\n\n";
}
}
__END__
When I run this using gensym, it does what I expect, but when I create
the anonymous glob myself, the DESTROY function is not called.
Can someone explain what's the difference and why the object is not
destroyed.
Thanks.
- Alex Hart
------------------------------
Date: Sat, 22 Jan 2005 08:53:08 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: gensym vs. other way
Message-Id: <cst3vp$1v8$1@sun3.bham.ac.uk>
Alex Hart wrote:
> I thought that these are equivalent:
>
> use Symbol;
> my $fh = gensym;
>
> and
>
> local *FH;
> my $fh = \*FH;
Well, fairly close.
GLOBs and local() are scary things.
GLOBs are little structures that contain a SCALAR ref, and ARRAY ref, a
HASH ref, a CODE ref, an IO ref and so on.
What local does is change GLOB it does does _not_ create a new GLOB
structure and change the symbol table to point to that one.
open(FH,'>','/dev/null') or die $!;
print \*FH,*FH{IO},"\n"; # GLOB(0x18243e8)IO::Handle=IO(0x1824418)
local *FH;
print \*FH,*FH{IO},"\n"; # GLOB(0x18243e8)
So you are not actually creating an anonymous GLOB. If you bless *FH
then the destructor is not called because *FH itself is not destryed
when you hit the end of the local scope.
Now, Perl's scalar variables are able to hold GLOB stuctures so you can say
my $fh = do { local *FH };
This temporarily clears all the entries in the GLOB *FH and then places
a duplicate of that GLOB structure in $fh.
Note that here the scalar variable $fh _becomes_ and anonymous GLOB. It
is IMNSHO better to avoid fiddling with these naked anonymous GLOBs.
I prefer to work with GLOBrefs which feel much cleaner.
my $fh = do { my $glob = local *FH; \$glob };
This is more or less what Symbol::gensym does.
If you bless $fh now you are blessing the duplicate GLOB object, the one
that will be garbage collected when the reference to it in $fh goes away.
Anyhow all this is largely moot in current Perl as it's much simpler to
use autovivification to get anonymous GLOB refs.
------------------------------
Date: 22 Jan 2005 01:47:00 -0800
From: "Alex Hart" <alex_the_hart@yahoo.com>
Subject: Re: gensym vs. other way
Message-Id: <1106387220.304268.246850@z14g2000cwz.googlegroups.com>
Very helpful. Thanks a lot.
------------------------------
Date: Fri, 21 Jan 2005 18:30:22 -0800
From: Jeffrey Cunningham <jeffrey@cunningham.net>
Subject: Re: how to write a tutorial
Message-Id: <pan.2005.01.22.02.30.21.274638@cunningham.net>
On Fri, 21 Jan 2005 03:08:50 -0800, Xah Lee wrote:
> i've started to read python tutorial recently.
> http://python.org/doc/2.3.4/tut/tut.html
>
(snip rest of misleading filler)
>
> http://xahlee.org/PageTwo_dir/more.html
The first line is solipsistic (..like..'so what?'). But I think its all
misleading. The real purpose of his cross-post is to get people to visit
his website, ooh-and-ahh at his unique and daring Bush-bashing at the top,
and finally admire (along with Xah himself) the pictures he takes of
himself.
Vanity, vanity, all is vanity...
The only remaining question is 'why does he restrict his cross-posting to
this particular collection of groups?' I don't have an answer to that one.
[incidentally, I'm still cracking up over k.t. and the soldier...]
--Jeff
------------------------------
Date: 22 Jan 2005 00:51:12 GMT
From: xhoster@gmail.com
Subject: IO::Select extension
Message-Id: <20050121195112.584$HW@newsreader.com>
IO::Select does a nice job of hiding the ugliness of 'select'. But
it warns that it shouldn't be mixed with buffered I/O, which still leaves
me to deal with all the messy sysread and syswrite stuff. I've been
thinking lately of making a module that would either subclass or contain
IO::Select objects and give them the veneer of being buffered IO rather
than unbuffered IO. Have I overlooked something already in CPAN that does
this? Am I insane for thinking this is desirable and/or possible?
Thanks,
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Sat, 22 Jan 2005 09:03:50 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: IO::Select extension
Message-Id: <cst4js$281$1@sun3.bham.ac.uk>
xhoster@gmail.com wrote:
> IO::Select does a nice job of hiding the ugliness of 'select'. But
> it warns that it shouldn't be mixed with buffered I/O, which still leaves
> me to deal with all the messy sysread and syswrite stuff. I've been
> thinking lately of making a module that would either subclass or contain
> IO::Select objects and give them the veneer of being buffered IO rather
> than unbuffered IO. Have I overlooked something already in CPAN that does
> this? Am I insane for thinking this is desirable and/or possible?
I have often thought about this but have never done anything about it.
There is a problem. If you want to avoid the need to play with sysread
then you need to find a way to allow read() or readline() not to block
when there is insufficient data avialable to satisfy them.
To do this all the handles returned by IO::Select would have to be
wrapped in a special class that simulates read()/readline() using
sysread() and return undef with $!=EAGAIN when there's insufficient data.
Then you have to find a way to avoid a busy loop when there is data in
the buffer but not enough to satisfy the read() or readline(). One way
to do this would be to make an unsatisfied read()/readline() set a flag
to say that even though there is data in the buffer that the special
buffered IO::Select must not report that the handle is readable.
On the write side you need and extra layer of buffering to set a
threshold and tell the buffered IO::Select only to return a handle as
writable if there is at least that much space in the buffer.
As you can see I've given this a little thought.
------------------------------
Date: Sat, 22 Jan 2005 12:53:39 +0200
From: "Jussi Mononen" <nodj.athensspam@surfeu.fi.useless>
Subject: Re: net::SFTP to capture 'get' reference?
Message-Id: <cstb89$6ik$1@nyytiset.pp.htv.fi>
> I'm running perl 5.8.0 on a redhat WS3 machine.
> when I run the script, it prints the error message
> to the STDOUT:
> Couldn't stat remote file: No such file or directory at
> /usr/lib/perl5/site_perl/5.8.0/Net/SFTP.pm line 130.
>
> I want this in $x so I can call fx2txt funcion within
> SFTP::Util pm.
If the status method
(http://search.cpan.org/~dbrobins/Net-SFTP-0.09/lib/Net/SFTP.pm#$sftp->status)
does not help you, you could try to use a localised signal handler for
warnings to capture them into a variable since some SFTP functions warn()
you when they fail.
eg.
{
my $warnings;
local $SIG{__WARN__} = sub { chomp; $warnings .= $_; };
if( ! $sftp-get($from, $to, \&callback) {
print "Unable to get $from : $warnings\n";
}
}
/jUSSi
------------------------------
Date: 21 Jan 2005 22:31:45 -0800
From: chrispatton@gmail.com
Subject: newbie perl questions
Message-Id: <1106375505.017246.161130@z14g2000cwz.googlegroups.com>
Hello, everyone.
Is there a way to use the Perl interpereter interactivwely? As in, I
type a command
and the interpereter gives me the same responce it would give me in a
regular running program.
Is anyone familiar with the Python statement "exec"? Is there and
equivelant to this in Perl? I tried this statement in Perl, and the OS
executed the string passed to it. (awsome!)
Thanks!
------------------------------
Date: 21 Jan 2005 22:37:17 -0800
From: "Alex Hart" <alex_the_hart@yahoo.com>
Subject: Re: newbie perl questions
Message-Id: <1106375837.793931.163360@c13g2000cwb.googlegroups.com>
perl -e 'print "hello world"
------------------------------
Date: Sat, 22 Jan 2005 08:16:01 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: newbie perl questions
Message-Id: <cst1q6$10q$1@sun3.bham.ac.uk>
chrispatton@gmail.com wrote:
> Subject: newbie perl questions
Please put the subjuect of your post in the Subject of your post. Your
post is not about newbie perl questions, the subject of your post is:
> Is there a way to use the Perl interpereter interactivwely?
This is, of course, FAQ: "How can I use Perl interactively?"
Note: the answer given in the latest version of the FAQ is much more
complete than in older versions so I suggest reading the FAQ on a
website such as CPAN rather than your local copy.
> Is anyone familiar with the Python statement "exec"?
No I'm not but at a guess you are looking for another function starting
with the same letter.
A full list of Perl builtin functions can be found in the perlfunc
manual. If you are learning Perl it's really worth speding 5-10
minuites skimming this document.
------------------------------
Date: Sat, 22 Jan 2005 03:53:30 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl on Windows
Message-Id: <_6kId.13541$Os6.5676@trnddc08>
Adam Smith wrote:
> Could anyone advise on HOW TO set up
No idea how you would set up a script.
> and run Perl scripts on windows,
Just install a Perl interpreter. The most common an convenient version is
probably ActivePerl from ActiveState
(http://activestate.com/Products/ActivePerl/)
> and is it possible to run them as "standalones" without a server /
> browser
Aehmmm, "standalone" _is_ the normal way to run a Perl program.
jue
------------------------------
Date: Fri, 21 Jan 2005 17:16:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl script issues - Need help
Message-Id: <slrncv33at.1nd.tadmc@magna.augustmail.com>
George Monappallil <georgemj@sympatico.ca> wrote:
> Great tips.
Here is another one:
check the Perl FAQ *before* posting to the Perl newsgroup.
> Would you know how I can have this script monitor a
> log file continiously..like a daemon.
perldoc -q daemon
How do I fork a daemon process?
[ snip upside-down quoted text, please don't do that ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 21 Jan 2005 17:09:54 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Radix Sort in CPAN
Message-Id: <slrncv32u2.1nd.tadmc@magna.augustmail.com>
Edward Wijaya <ewijaya@singnet.com.sg.removethis> wrote:
> Hope it works ;-)
That is not an encouraging sign, I'll pass on using
any of your modules.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 22 Jan 2005 00:09:08 +0000 (UTC)
From: "David H. Adler" <dha@panix.com>
Subject: Re: The world's shortest 'Hello World!' program: a proposal
Message-Id: <slrncv36d4.dl0.dha@panix2.panix.com>
On 2005-01-21, Rocco Caputo <troc@pobox.com> wrote:
> On 18 Jan 2005 10:22:22 -0800, Larry wrote:
>>
>> My proposal for Perl6 is to make Perl execute a sequence of code which
>> is 0 bytes in length with the action of printing to STDOUT:
>>
>> Hello World
>
> You can get the solution down to 1 byte by writing a HQ9+ compiler for
> Parrot. Please see http://www.cliff.biffle.org/esoterica/hq9plus.html
> for the language specification.
Although it's not a compiler, there does exist an interpreter for HQ9+
in parrot.
http://www.thetasigma.com/parrot/
It seems to have developed a subtle bug or two with recent releases of
parrot, but for the purposes of this thread, it should work fine.
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Your pluck is admirable. However, arguing for a 'pure computer
science' approach in the perl5-porters mailing list is somewhat like
inquiring about mileage in a Maserati dealership. People are given to
drop their champagne glasses and stare. - Felix Gallo, p5p
------------------------------
Date: Sat, 22 Jan 2005 09:00:33 GMT
From: Larry <dontmewithme@got.it>
Subject: Re: Win32::api doesn't work?
Message-Id: <dontmewithme-72D8AA.10001522012005@twister1.tin.it>
I GIVE up!
http://www.theartofweb.netfirms.com/cgi-bin/bbsmart/bbsmart.cgi?DO=showto
pic&FORUM_ID=3&TOPIC_ID=45
------------------------------
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 7682
***************************************