[23248] in Perl-Users-Digest
Perl-Users Digest, Issue: 5469 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Sep 9 11:06:14 2003
Date: Tue, 9 Sep 2003 08:05:10 -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, 9 Sep 2003 Volume: 10 Number: 5469
Today's topics:
Re: "Surrogate infinity" in Perl? (Anno Siegel)
Re: Active Perl, Windows scheduler, regular task... <bart.lateur@pandora.be>
Re: Can Perl do this? <bart.lateur@pandora.be>
Creating a DSN-less connection to a MySQL database <al@bat400.com>
dynamic access to multidimensional array (Stefan Schnitter)
Re: dynamic access to multidimensional array (Anno Siegel)
Re: dynamic access to multidimensional array <nobull@mail.com>
Re: Flocking Advise news@roaima.freeserve.co.uk
Re: How do I count keys in a BerkeleyDB *quickly* (usin (Lack Mr G M)
Re: How To activate command line history in debugger? <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
Re: illegal seek news@roaima.freeserve.co.uk
Re: illegal seek <flavell@mail.cern.ch>
Re: Image::Magick perl: constitute.c:2015: ReadImage: A (Rob Bell)
Re: Image::Magick perl: constitute.c:2015: ReadImage: A <darshans@aztec.soft.net>
Re: mod_perl memory leak? <tenchi-dono@jurai.network>
Re: pass cmd line file glob to grep for readdir (qanda)
Re: pass cmd line file glob to grep for readdir (Sam Holden)
Re: pass cmd line file glob to grep for readdir (Tad McClellan)
Re: pass cmd line file glob to grep for readdir (Tad McClellan)
Re: pass cmd line file glob to grep for readdir (Tad McClellan)
Re: Perl Arguements (Paul)
Perl vs TCL (Selwyn Leeke)
Re: Problem with simple contact script. <flavell@mail.cern.ch>
Re: Problem with simple contact script. <wsegrave@mindspring.com>
Re: qr// question (Anno Siegel)
Re: qr// question <nobull@mail.com>
Re: qr// question (Anno Siegel)
Re: qr// question <pinyaj@rpi.edu>
Re: Quotes and circular references (JR)
Re: Threads troubles <spaceman-a299c-20030925@ausgehaucht.sensenmann.at>
Very special: How to get data from rtic (rmds) using TI (Ulf Rimkus)
Re: yEnc decoding (Tad McClellan)
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 9 Sep 2003 12:18:09 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: "Surrogate infinity" in Perl?
Message-Id: <bjkge1$5l5$3@mamenchi.zrz.TU-Berlin.DE>
J Krugman <jill_krugman@yahoo.com> wrote in comp.lang.perl.misc:
> In <3F5CC784.D3675FF5@acm.org> "John W. Krahn" <krahnj@acm.org> writes:
>
> >use POSIX;
>
> >my $min_val = INT_MAX;
>
> That's the ticket. Thanks!
...or not. INT_MAX is the maximum value a native integer can assume.
Perl numbers (even integers) can be larger than that, because Perl
switches to float point representation when needed.
In fact, initializing a minimum to "some huge value" is only a cop-out.
The right method is to initialize it to one of the values the minimum
is to be taken of.
Anno
------------------------------
Date: Tue, 09 Sep 2003 12:18:21 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Active Perl, Windows scheduler, regular task...
Message-Id: <m4arlvcongv54tiglp1fo5okr2t99sosal@4ax.com>
Chas Friedman wrote:
> Is there some documentation for "wperl" somewhere? I can't seem to find
>anything about it, and always wondered just what it did...
No, but I can show you how it's created...
Take a look at the Makefile for ActivePerl:
<http://public.activestate.com/gsar/APC/perl-current/win32/Makefile>
Search for "wperl", and you'll see these lines:
copy $(PERLEXE) $(WPERLEXE)
$(MINIPERL) -I..\lib bin\exetype.pl $(WPERLEXE) WINDOWS
So "wperl.exe" is a slightly modified "perl.exe". It has been modified
with the script exetype.pl. If you can't find that, search for
"exetype.bat". "perldoc exetype" will show you the docs... Or you can
see them here:
<http://aspn.activestate.com/ASPN/docs/ActivePerl-5.6/bin/exetype.html>
You can examine the source of the script. What it does is search for a
special short integer (2 bytes -- actually 1 would have been enough) and
modify it. So the difference between "perl.exe" and "wperl.exe" is this
one byte.
So what does it do then? When perl starts up, this byte tells Windows
what kind of executable it is. A CONSOLE type program will create a
console window, also known as a "DOS window", when it starts. A WINDOWS
type program will not. You can always still create one later, if you
want it, using some API calls...
<http://msdn.microsoft.com/library/en-us/dllproc/base/creation_of_a_console.asp>
--
Bart.
------------------------------
Date: Tue, 09 Sep 2003 12:24:31 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Can Perl do this?
Message-Id: <mbhrlv80rm1ci7mpg8mno95n037advra8e@4ax.com>
CountryLover wrote:
>First off, I know next to nothing about Perl, other than a few scripts that I
>have used (written by others).
>
>A project that I am working on requires the following steps:
>
>1. Parse a directory containing text files, potentially thousands
>2. Open each text file and read in the first 25 lines or so
>3. Write these lines to a temporary file
>4. Delete each original file & replace with the temp file, using same filename
>5. Parse the truncated files and find a specific keyword
>6. Create directories based on the value of the keywords found
>7. Move the truncated files to their respective directories.
>8. Optionally, create a log file of all operations
>
>Is this something that Perl could be persuaded to do?
Yes.
In fact, given such a task, Perl would be my first choice. (Perl's not
the only language I use...)
BTW instead of copying the first N lines of a file and then overwriting
the original file with the truncated one, you can just as well use the
truncate() keyword... you may have to use seek() for this to take
effect.
Or you can use the -i command line switch, and stop after reading and
printing 25 lines.
To move a file, use the File::Copy module.
--
Bart.
------------------------------
Date: Tue, 9 Sep 2003 13:37:09 +0100
From: "Al Reynolds" <al@bat400.com>
Subject: Creating a DSN-less connection to a MySQL database
Message-Id: <bjkhno$enl02$1@athena.ex.ac.uk>
Hello,
I hope someone will be able to help me with this.
I am trying to set up a connection to my MySQL
database using perl. I already have the database
set up and have used it with PHP without any problems.
When I try and execute the following code, I get an error:
(obviously I have substituted the names/passwords)
#!/usr/bin/perl
use DBI;
my $dbh =
DBI->connect('DBI:mysql:databasename:localhost','username','password');
$dbh->disconnect or warn "Disconnection error: $DBI::errstr\n";
exit;
I contacted the service provider and they replied:
"Using this code, are you trying to create a dsn-less
(adodb) connection, as opposed to dsn (odbc), because
only the former is supported on our hosting packages?"
I think I understand from what I have read so far that I
am currently trying to create a dsn connection, but I might
well be completely wrong about that! Does what the ISP
said make sense?
Can I use DBI to create a dsn-less (ADODB) connection,
or do I need to use something completely different?
IN ASP, I would need to use CreateObject('ADODB.Connection')
Is there something similar I can use in Perl?
The perl version is 5.00503
DB_File, CGI, DBI and DBD-Mysql modules are installed.
Server software is:
Apache/1.3.20 Sun Cobalt (Unix) Chili!Soft-ASP/3.6.2
mod_ssl/2.8.4 OpenSSL/0.9.6b PHP/4.1.2
mod_auth_pam_external/0.1 FrontPage/4.0.4.3 mod_perl/1.25
Thanks in advance,
Al Reynolds
------------------------------
Date: 9 Sep 2003 04:48:45 -0700
From: kompakt17@gmx.net (Stefan Schnitter)
Subject: dynamic access to multidimensional array
Message-Id: <459b684a.0309090348.75aba023@posting.google.com>
Hi,
Is it somehow possible to index an array by another array?
Example:
@AoA = (
[ "fred", "barney" ],
[ "george", "jane", "elroy" ],
[ "homer", "marge", "bart" ],
);
and I have another array
@ind = ( 0, 1 );
How can I use @ind to index @AoA to get $AoA[0][1] ?
(and I *dont* want to write $AoA[$ind[0]][$ind[1]], since this might be dynamic:
@ind might have length 1,2,3,...)
Any ideas?
TIA,
Stefan
------------------------------
Date: 9 Sep 2003 12:34:59 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dynamic access to multidimensional array
Message-Id: <bjkhdj$7n7$1@mamenchi.zrz.TU-Berlin.DE>
Stefan Schnitter <kompakt17@gmx.net> wrote in comp.lang.perl.misc:
> Hi,
>
> Is it somehow possible to index an array by another array?
> Example:
>
> @AoA = (
> [ "fred", "barney" ],
> [ "george", "jane", "elroy" ],
> [ "homer", "marge", "bart" ],
> );
>
> and I have another array
>
> @ind = ( 0, 1 );
>
> How can I use @ind to index @AoA to get $AoA[0][1] ?
> (and I *dont* want to write $AoA[$ind[0]][$ind[1]], since this might be dynamic:
> @ind might have length 1,2,3,...)
You'll need a recursive access routine for that. Here is one way to
write it:
sub nested_access {
my $array = shift;
my ( $i, @rest) = @_;
@rest ? nested_access( $array->[ $i], @rest) : $array->[ $i];
}
Called as
my $x = nested_access( \ @AoA, 0, 1);
it will set $x to "barney".
Anno
------------------------------
Date: 09 Sep 2003 12:58:10 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: dynamic access to multidimensional array
Message-Id: <u9ad9eywat.fsf@wcl-l.bham.ac.uk>
kompakt17@gmx.net (Stefan Schnitter) writes:
> Is it somehow possible to index an array by another array?
> Example:
>
> @AoA = (
> [ "fred", "barney" ],
> [ "george", "jane", "elroy" ],
> [ "homer", "marge", "bart" ],
> );
>
> and I have another array
>
> @ind = ( 0, 1 );
>
> How can I use @ind to index @AoA to get $AoA[0][1] ?
#!/usr/bin/perl
use strict;
use warnings;
sub index_AoA : lvalue {
my $v = \shift;
$v = \$$v->[$_] for @{shift()};
$$v;
}
my @AoA = (
[ "fred", "barney" ],
[ "george", "jane", "elroy" ],
[ "homer", "marge", "bart" ],
);
my @ind = ( 0, 1 );
print index_AoA(\@AoA,\@ind),"\n";
index_AoA(\@AoA,[1,1]) = 'june';
print $AoA[1][1],"\n";
__END__
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Tue, 9 Sep 2003 12:14:03 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: Flocking Advise
Message-Id: <r8p031-ids.ln1@moldev.cmagroup.co.uk>
David Efflandt <efflandt@xnet.com> wrote:
> My approach is to open it read/write ( +< ), flock it, seek the beginning
> (just in case something else opened it before flock), modify and save
> data, and then close it.
There's a very similar issue going on in a parallel thread at the moment.
What I really don't see is why there's a requirement to seek back to the
beginning of a file after it's been flocked. If you've not read anything
then the file pointer's at the start of the file anyway. (flock applies a
file lock rather than a partial region lock.) I appreciate you need a seek
when swapping between reading and writing, but that's not the issue here.
Can anyone give a concrete explanation as to why the seek is required
immediately after the flock?
Cheers,
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Tue, 09 Sep 2003 10:03:36 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: How do I count keys in a BerkeleyDB *quickly* (using DB_File)?
Message-Id: <bjkjl2$l84$1@news.Stanford.EDU>
In article <76c7896d.0309051913.6bf1afb7@posting.google.com>, damonhastings@yahoo.com (Damon Hastings) writes:
|>
|> I have a berkeley db which I'm accessing via the DB_File interface (a
|> btree). I would like a quick way to count how many keys are in the
|> file. If I just use "scalar keys %hash", then it takes forever! (The
|> file has millions of keys.) Can anyone help me?
my $n = 0;
while (my ($dnc1, dnc2) = each %DB_hash) {$n++};
might be quicker - but you'll have to test it...
--
--------- Gordon Lack --------------- gml4410@ggr.co.uk ------------
This message *may* reflect my personal opinion. It is *not* intended
to reflect those of my employer, or anyone else.
------------------------------
Date: Tue, 09 Sep 2003 13:49:05 +0200
From: Kurt Kronschnabl <kurt.kronschnabl-nospam@ica-intercom-akademie.de>
Subject: Re: How To activate command line history in debugger?
Message-Id: <bjkfn4$g1d$03$1@news.t-online.com>
Daniel Pfeiffer schrieb:
> Versuch's stattdessen mit Emacs M-x shell (M- heißt normalerweise Alt-Taste). Das gibt Dir eine Art Terminal in einem Emacs Puffer. Wenn Du auf der letzten Zeile nach dem Prompt Return, M-p oder M-n benutzt ist das, das was Du brauchst. Du hast aber auch die ganze Interaktion im Puffer, und kannst von dort Befehle nochmal abschicken oder das ganze sogar editieren :-)
Sounds good, but please give me a hint how to activate this? Do I need
to create a .perldb file?
Regards, Kurt
------------------------------
Date: Tue, 9 Sep 2003 12:06:21 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: illegal seek
Message-Id: <dqo031-ids.ln1@moldev.cmagroup.co.uk>
Alan J. Flavell <flavell@mail.cern.ch> wrote:
>> Get shared locks for reading and exclusive locks for writing.
> Indeed. However, AIUI anyone who's reading a file in order to
> subsequently update it will need an exclusive lock from the start.
Yes - but in this case you'd open the file for updating (with "<+ $file"),
so it's effectively an exclusive write lock that you'd need here anyway.
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Tue, 9 Sep 2003 15:09:42 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: illegal seek
Message-Id: <Pine.LNX.4.53.0309091457360.5973@lxplus015.cern.ch>
On Tue, Sep 9, news@roaima.freeserve.co.uk inscribed on the eternal scroll:
> Alan J. Flavell <flavell@mail.cern.ch> wrote:
> >> Get shared locks for reading and exclusive locks for writing.
>
> > Indeed. However, AIUI anyone who's reading a file in order to
> > subsequently update it will need an exclusive lock from the start.
>
> Yes - but in this case you'd open the file for updating (with "<+ $file"),
> so it's effectively an exclusive write lock that you'd need here anyway.
Yes, I agree: but I've heard people saying that it would take them a
long time to read their file, but adding a new record at the end would
be fast, so can't they take a shared lock to read the file, and then
somehow upgrade it to an exclusive lock to add the new record?
Sounds a plausible idea, but I don't think it can be done in those
terms.
cheers
------------------------------
Date: 9 Sep 2003 03:39:33 -0700
From: robbelljr@aol.com (Rob Bell)
Subject: Re: Image::Magick perl: constitute.c:2015: ReadImage: Assertion `image_info->signature == 0xabacadab' failed
Message-Id: <b3c4dce1.0309090239.47737e75@posting.google.com>
Vlad Tepes <minceme@start.no> wrote in message news:<bji17b$8fj$1@troll.powertech.no>...
> Rob Bell <robbelljr@aol.com> wrote:
>
> > perl: constitute.c:2015: ReadImage: Assertion `image_info->signature
> > == 0xabacadab' failed
> >
> > If anyone here has encountered the error above when using the
> > Image::Magick module please share how you adapted your scripts to
> > avoid or work around it.
>
> You need to provide more information:
>
> What platform are you on?
> Which version of Image::Magick?
> How can I reproduce the error?
>
> Regards,
I'll rephrase my question at the risk of being off-topic for this
newsgroup as I am speculating that the error is resulting from a
mis-setup of the underlying ImageMagick program on the server but am
not in a position to request it be re-setup without evidence to
demonstrate the cause of the error. The error is occuring on read of
an image file. It's a Linux box. My new questions are: Can anyone
here give an indication what type of problem would lead to this type
of error:
perl: constitute.c:2015: ReadImage: Assertion `image_info->signature
== 0xabacadab' failed
Does this seem to be an exception thrown by Perl, by the operating
system, or by ImageMagick. Naturally, if you have experience with
this particular error I'd appreciate information on how it was
corrected. You may feel free to direct me to a more appropriate
newsgroup.
Thanks,
Rob
------------------------------
Date: Tue, 09 Sep 2003 19:28:30 +0530
From: Darshan Shaligram <darshans@aztec.soft.net>
Subject: Re: Image::Magick perl: constitute.c:2015: ReadImage: Assertion `image_info->signature == 0xabacadab' failed
Message-Id: <n0de2hdl.fsf@evylle.aztec.soft.net>
robbelljr@aol.com (Rob Bell) writes:
[ImageMagick]
> The error is occuring on read of an image file. It's a Linux box. My
> new questions are: Can anyone here give an indication what type of
> problem would lead to this type of error:
> perl: constitute.c:2015: ReadImage: Assertion `image_info->signature
> == 0xabacadab' failed
> Does this seem to be an exception thrown by Perl, by the operating
> system, or by ImageMagick.
Looks like ImageMagick doesn't like your image file. What kind of image
is it? Can you open that image file using, say, the GIMP? Can you open
*other* image files using ImageMagick?
Your image file is probably corrupted.
> You may feel free to direct me to a more appropriate newsgroup.
The ImageMagick mailing lists are probably a better place to ask, since
your problem seems to be unrelated to Perl.
--
Darshan Shaligram darshans@aztec.soft.net
------------------------------
Date: 9 Sep 2003 05:42:54 -0700
From: tenchi-dono <tenchi-dono@jurai.network>
Subject: Re: mod_perl memory leak?
Message-Id: <bjkhse025te@drn.newsguy.com>
In article <3EE62CB3.935AD041@news.com>, swen says...
>win2k
>mod_perl 1.27_01_dev
>apache 1.3.27
>I have a trivial cgi script (print "content-type: text/html\n\n"; print
>'hello';) served by the machine described above under Apache::PerlRun.
>The script runs fine, but each time I make a request to the script the
>memory usage for the apache process increases by a few kB or so. If I
>repeatedly make requests to this script apache's memory usage increases
>indefinitely.
Hi
I have the same problem with this config (NT4 SP6, Apache 1.3.27/28, mod_perl
1.28):
ScriptAlias /perl/ "E:/Apache/cgi-bin/"
<Location /perl>
SetHandler perl-script
PerlHandler Apache::Registry
#PerlSetupEnv Off
Options ExecCGI
</Location>
I found out that if you set "PerlSetupEnv Off" then the leaking stops!!!
But you also lose the Apache ENV vars :(
--- quote from mod_perl documentation ---
The last thing Apache::Registry does, is emulation of mod_cgi's environment
variables, like $ENV{SERVER_NAME}, $ENV{REMOTE_USER} and so on. PerlSetupEnv Off
disables this feature which saves some memory and CPU cycles.
-----------------------------------------
I think mod_perl generates the ENV hash every time and doesn't free up the
memory afterwards...
cu
------------------------------
Date: 9 Sep 2003 05:53:29 -0700
From: fumail@freeuk.com (qanda)
Subject: Re: pass cmd line file glob to grep for readdir
Message-Id: <62b4710f.0309090453.1f3afac0@posting.google.com>
> Why not use perl's glob function (perldoc -f glob)?
Because it won't work, as perldoc says, it returns the filename
expansions from the shell, the underlying problem is because the shell
has a limit in the number of characters allowed in one line (it may be
big, maybe 1MB) but with thousands of files, each with 30 or 40
character filenames that soon runs out. I don't want the user to try
using find and/or xargs, I just want to call myscript file*.ext or
quoted as in myscript "file*.ext" if need be.
Thanks.
------------------------------
Date: 9 Sep 2003 13:24:56 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: pass cmd line file glob to grep for readdir
Message-Id: <slrnblrl57.hvr.sholden@flexal.cs.usyd.edu.au>
On 9 Sep 2003 05:53:29 -0700, qanda <fumail@freeuk.com> wrote:
>> Why not use perl's glob function (perldoc -f glob)?
>
> Because it won't work, as perldoc says, it returns the filename
> expansions from the shell, the underlying problem is because the shell
> has a limit in the number of characters allowed in one line (it may be
> big, maybe 1MB) but with thousands of files, each with 30 or 40
> character filenames that soon runs out. I don't want the user to try
> using find and/or xargs, I just want to call myscript file*.ext or
> quoted as in myscript "file*.ext" if need be.
Maybe you should use a perl from this century, since the text:
Beginning with v5.6.0, this operator is implemented using the
standard "File::Glob" extension. See File::Glob for details.
in the documentation seems to disagree with your claim.
It might also be worthwhile finding a non-broken shell.
; cd /dev
; echo * * * * * * * * * * * * * * * * * * * * * * * \
* * * * * * * * * * * * * * * * * * * * * * * \
* * * * * * * * * * * * * * * * * * * * * * * \
* * * * * * * * * * * * * * * * * * * * * * * \
| wc
1 128984 783012
; perl -le 'print join " ", <* * * * * * * * * * * * * * * * * * * * * * *'\
' * * * * * * * * * * * * * * * * * * * * * * *'\
' * * * * * * * * * * * * * * * * * * * * * * *'\
' * * * * * * * * * * * * * * * * * * * * * * *>' | wc
0 128984 783012
; /bin/echo * * * * * * * * * * * * * * * * * * * * * * * \
* * * * * * * * * * * * * * * * * * * * * * * \
* * * * * * * * * * * * * * * * * * * * * * * \
* * * * * * * * * * * * * * * * * * * * * * * \
| wc
bash: /bin/echo: Argument list too long
The limit is with the operating system, not the shell, so why should perl's
glob have any more difficulty than the shell's?
Have you actually tried it out? My 10 second test above seems to disagree
with your "it won't work" statement.
--
Sam Holden
------------------------------
Date: Tue, 9 Sep 2003 08:20:24 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pass cmd line file glob to grep for readdir
Message-Id: <slrnblrkso.l3p.tadmc@magna.augustmail.com>
Sam Holden <sholden@flexal.cs.usyd.edu.au> wrote:
> On 8 Sep 2003 22:57:15 -0700, qanda <fumail@freeuk.com> wrote:
>>
>> My question is how can I take a file glob on the command line and
>> transform it into an expression for grep. I suppose this also implies
>> we must prevent the shell from expanding by quoting the expression
>> such as myscript *file*.ext"
>
> Why not use perl's glob function (perldoc -f glob)?
This is a good idea if you have a perl version >= 5.6.0.
(otherwise the glob will fail because of the shell's limitations)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 9 Sep 2003 08:21:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pass cmd line file glob to grep for readdir
Message-Id: <slrnblrku7.l3p.tadmc@magna.augustmail.com>
Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
> fumail@freeuk.com (qanda) wrote in news:62b4710f.0309082157.4c16ee32
> @posting.google.com:
>
>> Hi all
>>
>> I want to process lots of files (too many for the shell to expand on
>
> Have you considered using the xargs shell command?
This is a good idea if you have perl version < 5.6.0.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 9 Sep 2003 09:06:35 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: pass cmd line file glob to grep for readdir
Message-Id: <slrnblrnjb.l6d.tadmc@magna.augustmail.com>
qanda <fumail@freeuk.com> wrote:
>> Why not use perl's glob function (perldoc -f glob)?
>
> Because it won't work, as perldoc says, it returns the filename
> expansions from the shell,
Only with old perls.
What perl version do you have?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 9 Sep 2003 06:21:08 -0700
From: pecymanski@yahoo.com (Paul)
Subject: Re: Perl Arguements
Message-Id: <f65ace75.0309090521.73452064@posting.google.com>
Tina Mueller <usenet@expires12.2003.tinita.de> wrote in message news:<bjis87$ivcqu$1@ID-24002.news.uni-berlin.de>...
> Paul wrote:
> > I am having difficulty in getting the Perl Interpretor to recognize
> > arguements submitted with a perl script. For example,I have a simple
> > perl script like this called temp.pl
>
> > print "ARGV0 : $ARGV[0]\n";
> > print "ARGV1 : $ARGV[1]\n";
> > print "ARGV2 : $ARGV[2]\n";
>
> > If I run the script as 'temp.pl A B C',I get the following output:
> > ARGV0 :
> > ARGV1 :
> > ARGV2 :
>
> which operating sytem, which perl version?
>
> > If I run the script as 'perl temp.pl A B C', the arguements are then
> > recognized and I get the following output:
> > ARGV0 : A
> > ARGV1 : B
> > ARGV2 : C
>
> > I do not understand why the difference, the perl scripts is running in
> > both cases, but in the first case no arguements seem to be recognized.
>
> i don't understand the difference, either. for me it works, if
> i call the script with ./temp.pl (if the rights are set correctly):
>
> $ cat temp.pl
> #!/usr/bin/perl -w
> use strict;
> print "ARGV0 : $ARGV[0]\n";
> print "ARGV1 : $ARGV[1]\n";
> print "ARGV2 : $ARGV[2]\n";
> $ ls -l temp.pl
> -rwxr--r-- 1 tina users 115 Sep 8 23:27 temp.pl
> $ temp.pl A B C
> bash: temp.pl: command not found
> $ ./temp.pl A B C
> ARGV0 : A
> ARGV1 : B
> ARGV2 : C
>
> hth, tina
Tina,
I am running this on Win 2k, the Perl is Active State 5.2.2.0.
Thks,
Paul
------------------------------
Date: 9 Sep 2003 05:56:24 -0700
From: selwyn.leeke@camcon.co.uk (Selwyn Leeke)
Subject: Perl vs TCL
Message-Id: <f6ba12d3.0309090456.3a61f60e@posting.google.com>
Hi,
I'm thinking about writing a script in either Perl or TCL, but before
I start, I thought it would be a good idea to find out how they
compare to each other, so I can decide which is best for me.
Does anyone have any experience/opinions of TCL or Perl's Maths
functionality? Do you need to install extra modules to make it useful?
What about text manipulation? Is Perl better than TCL? Are there any
modules that improve on the core distribution?
Thanks in advance -
Selwyn
PS. Just out of interest... A lot of modules for perl seem to be
ported from TCL (tk, for example) - are there any that have gone the
other way?
------------------------------
Date: Tue, 9 Sep 2003 11:35:39 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Problem with simple contact script.
Message-Id: <Pine.LNX.4.53.0309091121000.5973@lxplus015.cern.ch>
On Tue, Sep 8, Tom inscribed on the eternal scroll:
> All right, one more time...
With respect, this doesn't seem to be a productive line of
development...
> If this does not meet your approval, next stop... PERL 101 :(
Oh no: you clearly have the ability to string Perl syntax together.
You just don't seem to have the mindset to do it defensively enough
for producing battle-hardened solutions. No shame in that, but there
/are/ ready-made, tested and peer-reviewed solutions available.
Staggering along from draft to draft fixing faults one at a time (and
apparently ignoring other constructive comments that have been
provided on the thread) just isn't going to lead to a quality
solution. You _would_ have to choose one of the most notorious
CGI-type applications for what appears to be more-or-less your debut
here, which is a pity.
Sorry to be so negative, but in real-world terms you really should go
back to the drawing-board with this, rather than fiddling with a
statement here, a statement there. On the other hand, if it was just
a lab experiment, not intended for real-world deployment, there might
be some useful discussion points, but the readers need to be clearly
aware that they're not getting something that it would be safe to
expose on their own web site.
all the best
------------------------------
Date: Tue, 09 Sep 2003 13:05:58 GMT
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Problem with simple contact script.
Message-Id: <Wek7b.533$TC1.156@newsread2.news.atl.earthlink.net>
"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:YTd7b.30$TC1.10@newsread2.news.atl.earthlink.net...
> "Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
> news:bjj0qq$j5lge$1@ID-184292.news.uni-berlin.de...
> > Tad McClellan wrote:
> <snip>
> > > 2) It will function as a mail relay to any address in the whole
> > > wide world!
> >
> > With hardcoded addresses? How?
>
Clarification - On review of Mortgageloan2003's (Scot King's) post, I see
*any* E-mail address could be used because of the incomplete if-elsif-else
control structure.
> Hi, Gunnar.
>
> Remember the discussion we had on the "%0A exploit"? I'm not sure if this
is
> the problem to which Tad had referred;
It appears Tad's comment was directed towards Tom's (also incorrect) version
of OP's script, although both appeared to be missing the "else" in the
if-elsif-else control structure.
> but Tom's script appears to allow
> said exploit.
The same applies to the script the OP posted.
Both Scot (the OP) and Tom have used CGI.pm, the former just for parsing,
and the latter, for shortcuts as well. IMO, they should be aware that their
scripts would not deal correctly with multiple addressees. While the param
method of CGI.pm parses multi-valued params correctly, the scripts posted
would send mail only to the first of multiple addressees with the same name
"towhom", e.g., loanofficer, marketing, and broker because the said feature
of CGI.pm has not been correctly employed.
Bill Segraves
------------------------------
Date: 9 Sep 2003 11:05:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: qr// question
Message-Id: <bjkc5t$1se$1@mamenchi.zrz.TU-Berlin.DE>
Matija Papec <mpapec@yahoo.com> wrote in comp.lang.perl.misc:
> On Mon, 08 Sep 2003 21:19:19 GMT, "John W. Krahn" <krahnj@acm.org>
> wrote:
>
> >> my @arr = ('^match') x 2;
> >
> >In this instance the contents of $arr[0] and $arr[1] are exactly the
> >same.
>
> Yes, but after below line they /somehow/ aren't.
>
> >> $_ = qr/$_/ for $arr[0];
> >>
> >> I wouldn't want to do $_ = qr/$_/ twice on same regex (I guess it's time
> >> consuming?)
> >
> >What do you REALLY want to do?
>
> I want hash/array of regexes but don't want to instantly compile them
> all. I would like to compile them only when some particular is needed
> and that "some particular" may be used more then once for matching,
> while some regexes may not be used at all. If regex compiling is
> significantly time consuming then this matters.
Access the regexes through this routine:
sub to_regex {
ref $_[ 0] ? $_[ 0] : $_[ 0] = qr/$_[0]/;
}
Strings will successively be turned into regexes on first use.
Anno
------------------------------
Date: 09 Sep 2003 12:55:16 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: qr// question
Message-Id: <u9ekyqyy57.fsf@wcl-l.bham.ac.uk>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
> Matija Papec <mpapec@yahoo.com> wrote in comp.lang.perl.misc:
> > On Mon, 08 Sep 2003 21:19:19 GMT, "John W. Krahn" <krahnj@acm.org>
> > wrote:
> >
> > >> my @arr = ('^match') x 2;
> > >
> > >In this instance the contents of $arr[0] and $arr[1] are exactly the
> > >same.
> >
> > Yes, but after below line they /somehow/ aren't.
> >
> > >> $_ = qr/$_/ for $arr[0];
> > >>
> > >> I wouldn't want to do $_ = qr/$_/ twice on same regex (I guess it's time
> > >> consuming?)
> > >
> > >What do you REALLY want to do?
> >
> > I want hash/array of regexes but don't want to instantly compile them
> > all. I would like to compile them only when some particular is needed
> > and that "some particular" may be used more then once for matching,
> > while some regexes may not be used at all. If regex compiling is
> > significantly time consuming then this matters.
And if it isn't then it doesn't.
> Access the regexes through this routine:
>
> sub to_regex {
> ref $_[ 0] ? $_[ 0] : $_[ 0] = qr/$_[0]/;
> }
The text and the subroutine invocation are probably more expensive than the
qr//.
#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;
sub to_regex {
ref $_[ 0] ? $_[ 0] : $_[ 0] = qr/$_[0]/;
}
timethese 10 => {
to_regex => sub {
my $q = q/x..........[yz]+[[:upper:]]*z(?=r)/;
$q = to_regex $q for 0..100000;
},
qr => sub {
my $q = q/x..........[yz]+[[:upper:]]*z(?=r)/;
$q = qr/$q/ for 0..100000;
},
};
__END__
Benchmark: timing 10 iterations of qr, to_regex...
qr: 4 wallclock secs ( 3.52 usr + 0.00 sys = 3.52 CPU) @ 2.84/s (n=10)
to_regex: 6 wallclock secs ( 6.91 usr + 0.00 sys = 6.91 CPU) @ 1.45/s (n=10)
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 9 Sep 2003 12:17:33 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: qr// question
Message-Id: <bjkgct$5l5$2@mamenchi.zrz.TU-Berlin.DE>
Brian McCauley <nobull@mail.com> wrote in comp.lang.perl.misc:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) writes:
>
> > Matija Papec <mpapec@yahoo.com> wrote in comp.lang.perl.misc:
> > > On Mon, 08 Sep 2003 21:19:19 GMT, "John W. Krahn" <krahnj@acm.org>
> > > wrote:
> > >
> > > >> my @arr = ('^match') x 2;
> > > >
> > > >In this instance the contents of $arr[0] and $arr[1] are exactly the
> > > >same.
> > >
> > > Yes, but after below line they /somehow/ aren't.
> > >
> > > >> $_ = qr/$_/ for $arr[0];
> > > >>
> > > >> I wouldn't want to do $_ = qr/$_/ twice on same regex (I guess it's time
> > > >> consuming?)
> > > >
> > > >What do you REALLY want to do?
> > >
> > > I want hash/array of regexes but don't want to instantly compile them
> > > all. I would like to compile them only when some particular is needed
> > > and that "some particular" may be used more then once for matching,
> > > while some regexes may not be used at all. If regex compiling is
> > > significantly time consuming then this matters.
>
> And if it isn't then it doesn't.
>
> > Access the regexes through this routine:
> >
> > sub to_regex {
> > ref $_[ 0] ? $_[ 0] : $_[ 0] = qr/$_[0]/;
> > }
>
> The text and the subroutine invocation are probably more expensive than the
> qr//.
Regex compilation *is* rather expensive. The real reason is that /$re/
doesn't compile the regex again when $re is a single qr//-quoted value.
That would explain your benchmarks. It also makes this a rather futile
exercise.
[snip benchmark]
Anno
------------------------------
Date: Tue, 9 Sep 2003 10:48:38 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: qr// question
Message-Id: <Pine.SGI.3.96.1030909104434.26954A-100000@vcmr-64.server.rpi.edu>
On 9 Sep 2003, Anno Siegel wrote:
>Access the regexes through this routine:
>
> sub to_regex {
> ref $_[ 0] ? $_[ 0] : $_[ 0] = qr/$_[0]/;
> }
>
>Strings will successively be turned into regexes on first use.
... and every time after that. = binds more loosely than ?:
perlmonk:~ $ perl -MO=Deparse,-p -e 'ref $a ? $a : $a = $b'
((ref($a) ? $a : $a) = $b);
It's the same trap as $cond ? $a = $b : $a = $c, which some people use
instead of $a = ($cond ? $b : $c), but always sets $a to $c.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 9 Sep 2003 06:11:50 -0700
From: jrolandumuc@yahoo.com (JR)
Subject: Re: Quotes and circular references
Message-Id: <b386d54b.0309090511.5ae6a573@posting.google.com>
Bob Walton <bwalton@rochester.rr.com> wrote in message news:<3F5D41EF.5060601@rochester.rr.com>...
> JR wrote:
>
> > Hi. I came across an interesting situation today when quoting a
> > circular reference. For some reason, when I quoted the circular
> > reference $a, in the below script, and within the "h2" hash key for an
> > anonymous array, the output was different than when the circular
> > reference wasn't quoted (the output included HASH(0x1abf070) when the
> > circular reference was quoted, and the actual data when it wasn't).
>
>
> Well, I'm having a bit of trouble understanding precisely what you mean
> when you say "when the circular referenece was quoted". A string like
> "HASH(0x1abf070)" is the sort of thing one gets when one stringifies an
> unblessed hash reference. Placing a hash reference in a double-quoted
> string will force a stringification. So it is not surprising that you
> would get the stringification when quoting a hash reference. This has
> nothing to do with circular references. If you are doing something akin to:
>
> $z = "$hashref";
>
> then $z will have something like the string HASH(0x...) as its value.
>
>
> ...
>
>
> > JR
> ...
Thanks much for your response.
[I suppose the it may not matter whether I'm dealing with a circular
reference or not-I just first noticed this situation when I was
dealing with them.]
I guess the reference context for stringification matters in this
case, because the quotes don't appear to matter when simply printing
out the circular reference, but they do when the circular reference is
contained inside in an anonymous array.
## Circular reference
my $a = { name => 'joe', age => 31 };
$a->{circle_me_this} = $a;
print "$a\n"; # prints HASH(0x1abf070)
print $a, "\n"; # print HASH(0x1abf070)
my %h = ( h1 => [ "in_h2", [ "in_h2a" ], $a ], );
print "$_\n" for %{$h{h1}[2]};
## Redefine %h (context of $a)
%h = ( h1 => [ "in_h2", [ "in_h2a" ], "$a" ], );
print "$_\n" for %{$h{h1}[2]};
#Can't use string ("HASH(0x1abf070)") as a
#HASH ref while "strict refs" in use at
#test_data_structure_traversal_v2.pl line 21.
I guess the moral of the story is simply not to force stringification
of unblessed references in any complex data structure, by
double-quoting the reference.
------------------------------
Date: Tue, 09 Sep 2003 11:05:04 GMT
From: Stefan Weiss <spaceman-a299c-20030925@ausgehaucht.sensenmann.at>
Subject: Re: Threads troubles
Message-Id: <1818230.7GhNGJtay6@weyoun.foo.at>
Hi,
many thanks to you and Sam Holden for your fast and very helpful
answers.
Rocco Caputo <troc@pobox.com> wrote:
> Surprise! Linux's "threads" are lightweight processes that share memory
> rather than copy-on-write it.
That explains a lot. I will take Sam's advice and familiarize myself
with the way Linux handles threads before I start using them again.
> Which version of Perl are you using? I have it on good authority that
> version 5.8.0 has a number of leaks that have since been fixed.
Spot on. Perl 5.8.0 running here - I thought that was a reasonably
current version but I guess I'm a bit out of touch.
> Then again, perhaps it's not good to join a thread from itself. I'm not
> familiar enough with the intricacies of iThreads to say for sure.
I'm not saying that I am familiar with iThreads, but calling join from
a thread does not seem to be problematic. I have found this to be the
only way to effectively close the client socket (filehandle), and I
have seen people-who-know-what-they-are-doing detach()ing threads
from inside. But then again, I am just starting to understand Perl
threads.
> You may want to consider a single-process, single-thread design, based
> on four-argument select(), IO::Select, or a higher-level networking
> library like POE.
I am currently downloading POE, and it looks very promising. The reason
why I did not go for a high-level framework in the first place is that
I wanted to understand what exactly was happening, before I use
abstractions and high-level interfaces to hide the gory details :)
>>===[ file svr_thr_x.pl ]==================================================
[..]
> Consider IO::Socket::INET here.
Same reason - understand the low level first, then use a specialized
module.
>> print "connection from $cl_name:$cl_port [", inet_ntoa($cl_addr),
>> "]\n"; autoflush $client 1;
>> for (1 .. 10) {
>
> You don't test whether print() succeeds here. How do you know when the
> client has disconnected?
Point taken.
Thanks again for your advice. I will try multiplexing with select()
now, and then probably use POE.
cheers,
stefan
------------------------------
Date: 9 Sep 2003 07:58:50 -0700
From: ulf.rimkus@gmx.net (Ulf Rimkus)
Subject: Very special: How to get data from rtic (rmds) using TIBCO tibrv-modules?
Message-Id: <108a8553.0309090658.71ad3f87@posting.google.com>
Hallo!
Well, at least I'd like to know, if it is at least possible to get
initial data from a RTIC. I've run through almost all the examples for
C and Perl but the only data I can receive is opaque data in an
update.
If it would be possible to communicate with an RMDS RTIC using tibrv,
then I would enjoy to have an tutorial on this subject.
Regards, Ulf
Using rvd 6.9 and ActiveState Perl 5.8 on win2k
------------------------------
Date: Tue, 9 Sep 2003 08:23:00 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: yEnc decoding
Message-Id: <slrnblrl1k.l3p.tadmc@magna.augustmail.com>
anonymous@coolgroups.com <anonymous@coolgroups.com> wrote:
> Unfortunately, it requires Perl 5.8.0, and I only have
> Perl 5.6.1.
Why can't you upgrade perl?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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.
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 5469
***************************************