[23884] in Perl-Users-Digest
Perl-Users Digest, Issue: 6087 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 6 06:05:50 2004
Date: Fri, 6 Feb 2004 03:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 6 Feb 2004 Volume: 10 Number: 6087
Today's topics:
Re: Access-Zugriff mit Perl (Thomas)
Re: Access-Zugriff mit Perl (Thomas)
Re: Callback during FTP (Yehuda Berlinger)
Re: Can't locate IO/Tty/Constant.pm in @INC <kalinaubears@iinet.net.au>
Re: Clarifications <bik.mido@tiscalinet.it>
Re: Clarifications <bik.mido@tiscalinet.it>
Re: Clarifications <no@spam.for.me.invalid>
Re: DBI::mysql column names as hash keys? <notpublic@restricted.com>
Re: How to execute a command line in Perlscript (Eric SALGON)
Re: how to find the last "new line" in string <krahnj@acm.org>
Image::Magick to DB <lh+canned_pork@tn.no>
Re: Image::Magick to DB <lh+canned_pork@tn.no>
Re: Looking for MD5-like fingerprint for JPG-files (dede)
Mail::Audit::Attach (Ed Mansouri)
Named parameters in method calls <BLOCKSPAMfishfry@your-mailbox.com>
Re: Named parameters in method calls <tassilo.parseval@rwth-aachen.de>
Need help passing arrays by reference pls. (G Klinedinst)
Re: Need help passing arrays by reference pls. (Walter Roberson)
Re: NNTP Subject Parsing <gerardlanois@netscape.net>
perl identifier limits <foof@synthcode.com>
Re: perl identifier limits <uri@stemsystems.com>
Re: perl identifier limits <foof@synthcode.com>
Posting Guidelines for comp.lang.perl.misc ($Revision: tadmc@augustmail.com
Re: Running perl script from command line <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 6 Feb 2004 02:39:59 -0800
From: thomas.taunus@gmx.de (Thomas)
Subject: Re: Access-Zugriff mit Perl
Message-Id: <e08b7f0f.0402060239.3c6f663e@posting.google.com>
"David K. Wall" <dwall@fastmail.fm> wrote in message news:<Xns9474E3B66477Bdkwwashere@216.168.3.30>...
> thomas.taunus@gmx.de (Thomas) wrote:
>
> > ich möchte auf eine Access-DB mit Perl zugreifen.
>
> I don't understand German, but if you want to use Perl to work with MS-
> Access, try http://dbi.perl.org/. There's an introduction to DBI at
> http://www.perl.com/pub/a/1999/10/DBI.html
>
> (I hope you can read English better than I can German)
Thanks David,
i have found the correct information.
Thomas
------------------------------
Date: 6 Feb 2004 02:43:32 -0800
From: thomas.taunus@gmx.de (Thomas)
Subject: Re: Access-Zugriff mit Perl
Message-Id: <e08b7f0f.0402060243.64b0e0f9@posting.google.com>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnc0orp6.aqq.mgjv@verbruggen.comdyn.com.au>...
> On 18 Jan 2004 12:28:19 -0800,
> Thomas <thomas.taunus@gmx.de> wrote:
> > Hallo,
> >
> > ich möchte auf eine Access-DB mit Perl zugreifen.
>
> [translation: OP would like to read a (presumably Microsoft) Access
> database]
>
> I understand that this should be possible with DBI and the DBD::ODBC
> driver. If you use Google to look for these, you should be able to
> find some information.
>
> > Dabei geht es mir in erster Linie darum, Datensätze in die Datenbank
> > zu schreiben. Hintergrund: Ich möchte Systeminformationen auslesen
> > (Auslastungen, Plattenplatz, etc.) und diese in eine Access-Datenbank
> > schreiben um diese anschl. graphisch auszuwerten.
>
> [summary: description of what OP wants to read, with requirement to
> somhow present data graphically. It's unclear to me what that means,
> exactly.]
>
> You, OP, need to specify what that means, exactly.
>
> > Die Datenbank
> > sollte irgenwo auf einem Server-Laufwerk abgelegt werden können.
>
> This confuses me. Are you, OP, saying that you want to store the
> database on a server disk somehow?
>
> If so, why bother with Access alltogether? Why don't you simply get
> one of the free for use (PostgreSQL, MySQL) RDBMses, so you don't have
> to fart around with files?
>
> > Im
> > Forum habe ich schon viele Anregungen zu diesem Thema gefunden, die
> > ich jedoch als Perl-Neuling nicht verstehen, bzw. umsetzen kann. Wenn
> > jemand ein Beispielsprogramm (gespickt mit vielen verständlichen
> > Kommentaren) hätte, wäre ich dankbar.
>
> [OP explains he has found references to this theme in "the forum" (I'm
> assuming that that means this newsgroup), but can't understand them,
> as a Perl newbie]
>
> If you have trouble understanding these references, maybe you're too
> new to tackle this problem? Anyway, if you decide to go with DBI and
> DBD::ODBC, they come with lots of examples, and there's lots of
> information around on the use. There's also a mailing list for DBI
> related issues, which you could check.
>
> Martien
Thanks Martien,
i have found the correct information.
Thomas
------------------------------
Date: 5 Feb 2004 23:57:16 -0800
From: jon@actcom.co.il (Yehuda Berlinger)
Subject: Re: Callback during FTP
Message-Id: <75e50dfd.0402052357.6016e601@posting.google.com>
Ben Morrow <usenet@morrow.me.uk> wrote in message news:<bvp9th$g71$1@wisteria.csv.warwick.ac.uk>...
...
Cool.
Actually, I decided to subclass Net::FTP, copying over the get and put
functions, and adding one parameter $cb, and one line in the
appropriate place:
&{$cb}($buf,$len) if ref $cb eq 'CODE';
For the life of me, I can't figure out why this is not in Net::FTP, as
it is trivial.
Yehuda
------------------------------
Date: Fri, 06 Feb 2004 17:23:29 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Can't locate IO/Tty/Constant.pm in @INC
Message-Id: <402333d8$0$1756$5a62ac22@freenews.iinet.net.au>
Ben Morrow wrote:
> Sisyphus <kalinaubears@iinet.net.au> wrote:
>
>>I can't find any reference to an IO::Tty::Constant module on cpan. Maybe
>>an error in the coding of your script ?
>
>
> Well, I've got one on my machine. It came with IO::Tty.
>
Well - I can't find one that comes with the current version of IO::Tty.
But now that I come to build the module I find that 'Constant.pm' gets
autogenerated and installed as part of the build process - things must
have changed slightly from when Ben built it.
So ... to the OP, we still need to find out what happened to your
'Constant.pm' - and we don't have much to go on at the moment :-)
Did it get autogenerated ? If so did it get installed into the wrong
location, or did it simply not get installed at all ?
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Sat, 07 Feb 2004 09:09:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Clarifications
Message-Id: <j86920p9q87nib5j0hh34meos30kn14ddd@4ax.com>
On Wed, 4 Feb 2004 23:43:30 +0000 (UTC), Ben Morrow
<usenet@morrow.me.uk> wrote:
>> To cut the story down, the point is that both officially and to common
>> people a "thing" like "USA", "CCCP" (i.e. "SSSR", btw!), etc. is a
>> sigla.
>
>So you wouldn't make the distinction between something like 'USA' and
>something like 'NATO'? Interesting.
AFAICT, no! Indeed this is the popular use and I have no indications
that it isn't also the official one. But please do not trust me more
than necessary: as I said I'm not an accademico della Crusca...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Sat, 07 Feb 2004 09:09:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Clarifications
Message-Id: <ae692010pqtfbgvlhauuua644lc7ug9ob6@4ax.com>
On Thu, 05 Feb 2004 01:53:51 GMT, "John W. Kennedy"
<jwkenne@attglobal.net> wrote:
>Michele Dondi wrote:
>> Huh?!? I just don't know it, but in any case you mean *Emanuele*,
>> don't you? Oh, come on, what's its meaning?
>
>Oh how short is human memory!
>
>During the Risorgimento, the graffito "VIVA VERDI!" became wildly
>popular. It stymied the Austrians, for who could complain about the
>popularity of the great composer? But Italian patriots knew that
>"VERDI" was more than "green", and more than a man's name, too, for it
>also stood for "Vittorio Emanuele Re D'Italia".
Ah, OK! I'm also reading soon the link that's been given to me. I
would have never ever imagined that I would have learnt something like
*this* on this ng!
;-)
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Fri, 06 Feb 2004 08:38:46 GMT
From: Nils Petter Vaskinn <no@spam.for.me.invalid>
Subject: Re: Clarifications
Message-Id: <pan.2004.02.06.08.35.25.423446@spam.for.me.invalid>
On Mon, 02 Feb 2004 09:12:16 -0600, Tad McClellan wrote:
> Actually, "PERL" might be called a "bacronym", ie: a backwards acronym.
>
> The name came first, the coming up with words for each letter came
> _after_ choosing the name.
We did that on our programming project in school. Our project involved
getting data from "Geografisk Informasjons Nett" (GIN) so we obviously
constructed the name to have the acronym TONIC.
--
NPV
"the large print giveth, and the small print taketh away"
Tom Waits - Step right up
------------------------------
Date: Fri, 6 Feb 2004 10:54:19 +0100
From: "kz" <notpublic@restricted.com>
Subject: Re: DBI::mysql column names as hash keys?
Message-Id: <wyJUb.153$7M6.99034@news.uswest.net>
"Tony" <hawkmoon1972@hotmail.com> wrote in message
news:c90e5468.0402051317.54ef6dd1@posting.google.com...
> Hello,
[snip]
Sorry for the incorrect line wrapping.
#!/usr/bin/perl
use strict;
use warnings;
use DBI();
my $DBserver= "server";
my $DBname= "dbname";
my $DBuser= "user";
my $DBpassword= "pwd";
my $dbh = DBI->connect("DBI:mysql:database=$DBname;host=$DBserver",
"$DBuser", "$DBpassword",{'RaiseError' => 1});
my %fieldnames;
my $sth = $dbh->prepare("show tables");
$sth->execute();
while (my $refv = $sth->fetchrow_hashref()) {
my $sth2 = $dbh->prepare("describe ".$refv->{"Tables_in_$DBname"});
$sth2->execute();
while (my $refv2 = $sth2->fetchrow_hashref()) {
$fieldnames{$refv->{"Tables_in_$DBname"}.".".$refv2->{Field}} =
$refv->{"Tables_in_$DBname"}.".".$refv2->{Field}; }
$sth2->finish(); }
$sth->finish();
$dbh->disconnect();
foreach my $columns (keys %fieldnames) {
print "$columns\n"; }
exit 0;
D:\>perl t2.pl
testtie.produce_id
testtie.quantity
testtie.price
test.testid
pdata.pfrozen
testtie.description
test.testdata
pdata.pvalue
pdata.pkey
or
use strict;
use warnings;
use DBI();
my $DBserver= "server";
my $DBname= "dbname";
my $DBuser= "user";
my $DBpassword= "pwd";
my $dbh = DBI->connect("DBI:mysql:database=$DBname;host=$DBserver",
"$DBuser", "$DBpassword",{'RaiseError' => 1});
my %HOA;
my $sth = $dbh->prepare("show tables");
$sth->execute();
while (my $refv = $sth->fetchrow_hashref()) {
$HOA{$refv->{"Tables_in_$DBname"}} = [];
my $sth2 = $dbh->prepare("describe ".$refv->{"Tables_in_$DBname"});
$sth2->execute();
while (my $refv2 = $sth2->fetchrow_hashref()) {
push @{$HOA{$refv->{"Tables_in_$DBname"}}},$refv2->{Field}; }
$sth2->finish(); }
$sth->finish();
$dbh->disconnect();
print "Database $DBname\n";
foreach my $table (keys %HOA) {
print "Table $table\n";
print "Fields ",join(",",@{$HOA{$table}}),"\n"; }
exit 0;
D:\>perl test.pl
Database test
Table testtie
Fields produce_id,price,quantity,description
Table pdata
Fields pkey,pvalue,pfrozen
Table test
Fields testid,testdata
There are other (simple) solutions, though, I reckon...
You would also want to read the table_info and column_info section of the
DBI documentation which will answer your questions.
HTH,
Zoltan
------------------------------
Date: Fri, 6 Feb 2004 06:47:44 +0000 (UTC)
From: eric.salgon@mane.com (Eric SALGON)
Subject: Re: How to execute a command line in Perlscript
Message-Id: <bvvdag$t0m$1@s1.read.news.oleane.net>
Thx Chris for your answer,
My question was for "PerlScript" under ASP, and the 'Echo' command was only a
sample.
In fact, my goal is to run the 'dnscmd' command (which is used to manage dns
on w2000/w2003 server) and analyse the result.
Eric
In article <u1vUb.19065$po6.10019@newssvr16.news.prodigy.com>,
ceo@nospan.on.net says...
>
>Eric SALGON wrote:
>> Hi,
>>
>> Is there someone who knows how to execute a command line (such a simple
echo
>> cmd) in PerlScript.
>>
>> I hve tryed '' or system() but the result is the same: no result but no
error
>> !
>>
>> This syntax works fine in a perl program but not in PerlScript
>>
>> An idea ?
>
>Well, to answer your question successfully, I'll have to make some
>assumptions. Some people, when they say "PerlScript," they really mean
>"Perl script." But since there IS a product called "PerlScript," I'll
>answer in that context. And even within THAT, there are two ways this
>could be viewed: PerlScript under ASP and PerlScript under Windows
>Scripting Host. I'll assume the later, but answer both.
>
>PerlScript ASP cannot use 'print' or 'echo' to write to the end client
>browser. You have to use $Response->Write(). Assuming you know that
>already...
>
>...the answer when running PerlScript in a WSH context is:
>
>$WScript->Echo( "This is how to print in PerlScript\n" );
>
>A tip: I personally like Ruby's use of a call named puts() which, named
>in C-style convention, out Puts a string. I've adopted THAT as my
>standard "outputing call" and I write wrappers in each environment I'm
>in to handle it the right way (so I don't have to remember any more how
>to write a string; it gets ridiculously out of hand esp. in the Windows
>world where Microsoft can't get it together and each side of their house
>invents a new standard for something so simple -- in ASP it's
>Response.Write in WSH it's WScript.Echo, in Access it's print.debug or
>whatever...)
>
>So... I recommend this approach and then you never have to remember any
>more:
>
>ASP: sub puts { for (@_) { $Response->Write( "$_\n" ) } }
>WSH: sub puts { for (@_) { $WScript->Echo( "$_\n" ) } }
>
>Chris
>-----
>Chris Olive
>chris -at- --spammers-are-vermen-- technologEase -dot- com
>http://www.technologEase.com
>(pronounced "technologies")
>
------------------------------
Date: Fri, 06 Feb 2004 07:46:58 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: how to find the last "new line" in string
Message-Id: <4023460D.DB525A34@acm.org>
Walter Roberson wrote:
>
> In article <4022E838.33F20CBC@acm.org>, John W. Krahn <krahnj@acm.org> wrote:
> :hshen wrote:
>
> :> If a string contains a few lines, (separated by '\n'), how can I make
> :> a regular expression to replace this '\n' by a space?
>
> :You don't really need a regular expression.
>
> :$string =~ tr/\n/ /;
>
> But the Subject refers to the *last* "new line" in the string;
> your proposed solution would change *all* of them.
Yah, I hate when they put the important information in the subject line
instead of the actual message. :-)
$_ = reverse $string;
s/\n/ /;
$string = reverse $_;
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 06 Feb 2004 10:17:55 +0100
From: Lars Haugseth <lh+canned_pork@tn.no>
Subject: Image::Magick to DB
Message-Id: <m3znbwefcs.fsf@gollum.polygnosis.com>
The Image::Magick module features methods Read() and Write()
for reading/writing image data from and to a file or a file
handle.
I need to read and write data to and from a scalar. Can I do
this with Image::Magick without having to store the image data
in a temporary file?
--
Lars Haugseth
------------------------------
Date: Fri, 06 Feb 2004 10:21:39 +0100
From: Lars Haugseth <lh+canned_pork@tn.no>
Subject: Re: Image::Magick to DB
Message-Id: <m3vfmkef6k.fsf@gollum.polygnosis.com>
* Lars Haugseth <lh+canned_pork@tn.no> wrote:
|
| The Image::Magick module features methods Read() and Write()
| for reading/writing image data from and to a file or a file
| handle.
|
| I need to read and write data to and from a scalar. Can I do
| this with Image::Magick without having to store the image data
| in a temporary file?
I found the answer to this myself. There are methods ImageToBlob()
and BlobToImage() that does exactly this. I'm sorry I wasted your
time.
--
Lars Haugseth
------------------------------
Date: 6 Feb 2004 02:46:02 -0800
From: abrey@gmx.net (dede)
Subject: Re: Looking for MD5-like fingerprint for JPG-files
Message-Id: <166f59a6.0402060246.412948dc@posting.google.com>
Thank you very much guys!
I am all the time impressed about the quick and comprehensive response
I receive from you. I ll try my best "to give something back" :)
Greetings from Paris, France
dede
P.S.: I feel honored by the direct response of Randal himself - Merci!
------------------------------
Date: 5 Feb 2004 22:32:23 -0800
From: emansouri@ucompass.com (Ed Mansouri)
Subject: Mail::Audit::Attach
Message-Id: <a8b9a755.0402052232.422e213b@posting.google.com>
I am hoping someone can provide me a bit of help with something related to
Mail::Audit::Attach.
I have all the methods of Mail::Audit working exactly as I need them to,
except those pertaining to attachments.
For instance in the simple code example below, I simply cannot get the
num_attachments to properly display. It always shows 0 no matter how many
attachments are really affixed to each message:
<perlCode>
#!/usr/local/bin/perl
use Mail::POP3Client;
use Mail::Audit qw(Attach);
my $pop=new Mail::POP3Client(USER => $username,
PASSWORD => $password,
HOST => $host,
AUTH_MODE => "PASS");
for( my $i = 1; $i <= $pop->Count(); $i++ ) {
my @msg = $pop->Retrieve($i);
filter(@msg);
}
$pop->Close();
sub filter {
my @data=@_;
my $mail = Mail::Audit->new(data => \@data, noexit => 1);
print $mail->num_attachments."\n";
}
</perlCode>
------------------------------
Date: Fri, 06 Feb 2004 09:19:45 GMT
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Named parameters in method calls
Message-Id: <BLOCKSPAMfishfry-A4EED1.01194306022004@netnews.comcast.net>
Is the named parameter style of calling methods the officially right way
to do it these days? Or is there some debate? I'm talking about
my $foo = new Foo(FISH => 'tuna', DRESSING => 'mayo');
as opposed to Foo('tuna', 'mayo');
In other words if you do it the old (positional) way, is that considered
either hopelessly old-fashioned and/or bad coding practice?
------------------------------
Date: 6 Feb 2004 09:42:24 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Named parameters in method calls
Message-Id: <bvvni0$8au$1@nets3.rz.RWTH-Aachen.DE>
Also sprach fishfry:
> Is the named parameter style of calling methods the officially right way
> to do it these days? Or is there some debate? I'm talking about
>
> my $foo = new Foo(FISH => 'tuna', DRESSING => 'mayo');
>
> as opposed to Foo('tuna', 'mayo');
>
> In other words if you do it the old (positional) way, is that considered
> either hopelessly old-fashioned and/or bad coding practice?
No, neither of that. Named parameters come in handy to smoothen the
interface a little when you have many arguments. Often I use them for
additional configuration options only:
my $obj = Class->new( $required_arg, -opt1 => 1, -opt2 => 2 );
The implementation of Class::new() would do something like that:
sub Class::new {
my $self = shift;
my $arg = shift;
croak "Required argument missing" if not $arg;
my %opts = @_;
...
}
This allows the user to just write
Class->new( $arg );
instead of the longer
Class->new( arg => $arg );
when he doesn't want to set any additional options.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: 5 Feb 2004 21:46:03 -0800
From: g_klinedinst@hotmail.com (G Klinedinst)
Subject: Need help passing arrays by reference pls.
Message-Id: <168f035a.0402052146.4c5c1df0@posting.google.com>
Hi all. I have a question I have been pulling my hair out all day
over. Can someone tell me what is happening in the following code. The
first print statements create the results I expect. The subroutines
statments print arrays with 1 element but not data in [0]. What gives?
I am passing by reference and then dereferencing in the sub. Can you
point me towards what I am missing? I have looked at the perlfaqs and
read the perldocs on references but it I can't find what I am looking
for. It could also be my sleep deprived mind is seeing it but not
grokking it. TIA.
-Greg
***********CODE****************
#!/usr/local/bin/perl
use strict;
use warnings;
my @arr1;
my @arr2;
$arr1[0] = 1;
print( $arr1[0] . ":" . scalar( @arr1 ) . "\n" );
print( $arr2[0] . ":" . scalar( @arr2 ) . "\n" );
print( "\n\n" );
test( \@arr1, \@arr2 );
sub test
{
my @subArr1 = @$_[0];
my @subArr2 = @$_[1];
print( $subArr1[0] . ":" . scalar( @subArr1 ) . "\n" );
print( $subArr2[0] . ":" . scalar( @subArr2 ) . "\n" );
}
**************/CODE***********
**************OUTPUT*********
1:1
Use of uninitialized value in concatenation (.) or string at
./arrays.pl
line 12.
:0
Use of uninitialized value in concatenation (.) or string at
./arrays.pl
line 22.
:1
Use of uninitialized value in concatenation (.) or string at
./arrays.pl
line 23.
:1
*************/OUTPUT**********
------------------------------
Date: 6 Feb 2004 06:04:24 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Need help passing arrays by reference pls.
Message-Id: <bvvap8$d4q$1@canopus.cc.umanitoba.ca>
In article <168f035a.0402052146.4c5c1df0@posting.google.com>,
G Klinedinst <g_klinedinst@hotmail.com> wrote:
:Hi all. I have a question I have been pulling my hair out all day
:over. Can someone tell me what is happening in the following code.
:test( \@arr1, \@arr2 );
:sub test
:{
: my @subArr1 = @$_[0];
: my @subArr2 = @$_[1];
Looks like you have a precidence problem. @$_[0] is {@{$_}}[0]
Your code will work if you use
my @subArr1 = @{$_[0]};
my @subArr2 = @{$_[1]};
I would, though, recommend using prototypes and declaring sub test
before it is used:
sub test( \@\@ ) {
my @subArr1 = @{$_[0]};
my @subArr2 = @{$_[1]};
# ...
}
test @arr1, @arr2;
Notice there that you do NOT explicitly \ the arrays as you pass them in.
Personally, I wouldn't take a copy of the array in the sub unless
I had a reason to. I would use something akin to
sub test( \@\@ ) {
my ($subArr1_ref, $subArr2_ref) = @_;
print $subArr1_ref->[0] . ':' . scalar( @$subArr1_ref ) . "\n";
print $subArr2_ref->[0] . ':' . scalar( @$subArr2_ref ) . "\n";
}
--
"There are three kinds of lies: lies, damn lies, and statistics."
-- not Twain, perhaps Disraeli, first quoted by Leonard Courtney
------------------------------
Date: Fri, 06 Feb 2004 05:42:54 GMT
From: Gerard Lanois <gerardlanois@netscape.net>
Subject: Re: NNTP Subject Parsing
Message-Id: <ubroc931e.fsf@netscape.net>
$_@_.%_ writes:
> Does anyone know where i could find some information
> about parsing NNTP subject fields?
>
> Psuedo Code and/or RegExp advise would be ideal.
>
> Im looking to parse out multipart messages.
> ie: Test Subject (1/1) - file.bin [01/10]
> Another test.bin (1/2)
>
> Then store them untill all the parts have been gathered.
>
> Thanks any advice is appreciated.
My program doesn't store all the parts, but it will assemble
all the parts if they happen to all be present on the server.
See http://ubh.sourceforge.net/
Here is some code which shows how ubh does this.
# untested code follows...
my $subject = 'Test Subject (1/1) - file.bin [01/10]';
# Does it look like it contains a filename with an extension?
if ($subject =~ /\b(.+\.(\w+))\b/) {
# Is it multipart? [x/y] or (x/y)
# Requires at least 2 chars in extension, this avoids
# problems with people posting with size like "10.4 Meg"
# after the filename, and matching after the .4
if ($subject =~ /^(.+\.(\w\w+))\b.*[\(\[](\d+)\/(\d+)[\)\]]/) {
my ($subject_part, $part, $total) = ($1, $3, $4);
# ... etc.
}
}
-Gerard
------------------------------
Date: Fri, 06 Feb 2004 17:41:42 +0900
From: Alex Shinn <foof@synthcode.com>
Subject: perl identifier limits
Message-Id: <87ptcstxa1.wl@strelka.synthcode.com>
Got quite a surprise today when I encountered an "Identifier too long"
error message. Nothing in the FAQ, but the BUGS section of "perldoc
perl" does include:
While none of the built-in data types have any arbitrary size limits
(apart from memory size), there are still a few arbitrary limits: a
given identifier may not be longer than 255 characters
Not that I'd write such a long identifier, but I've got auto-generated
code that reaches twice that length. Any ideas apart from applying
compression algorithms to the id names? Any plans on fixing this?
--
Alex
------------------------------
Date: Fri, 06 Feb 2004 09:36:23 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: perl identifier limits
Message-Id: <x77jz0tuqw.fsf@mail.sysarch.com>
>>>>> "AS" == Alex Shinn <foof@synthcode.com> writes:
AS> Got quite a surprise today when I encountered an "Identifier too long"
AS> error message. Nothing in the FAQ, but the BUGS section of "perldoc
AS> perl" does include:
AS> While none of the built-in data types have any arbitrary size limits
AS> (apart from memory size), there are still a few arbitrary limits: a
AS> given identifier may not be longer than 255 characters
AS> Not that I'd write such a long identifier, but I've got auto-generated
AS> code that reaches twice that length. Any ideas apart from applying
AS> compression algorithms to the id names? Any plans on fixing this?
fix your code. i can't see any possible reason to generate names that
long. you would have to come up with some amazing reasons to support
your claim that you need it.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 06 Feb 2004 18:50:28 +0900
From: Alex Shinn <foof@synthcode.com>
Subject: Re: perl identifier limits
Message-Id: <87n07wtu3f.wl@strelka.synthcode.com>
At Fri, 06 Feb 2004 09:36:23 GMT, Uri Guttman wrote:
>
> >>>>> "AS" == Alex Shinn <foof@synthcode.com> writes:
>
> AS> Not that I'd write such a long identifier, but I've got auto-generated
> AS> code that reaches twice that length. Any ideas apart from applying
> AS> compression algorithms to the id names? Any plans on fixing this?
>
> fix your code. i can't see any possible reason to generate names that
> long. you would have to come up with some amazing reasons to support
> your claim that you need it.
You obviously don't write Perl with a Lisp mindset. If you
auto-generate code on the fly it is not always easy to design it such
that names won't conflict. In my case I'm working with an application
server which can have a *huge* base of dynamically generated code. A
potential workaround is to use only hashtables and store anonymous
subroutines in them, but this is far from an insignificant rewrite and
looses some flexibility. After googling I find I'm not the only one who
has had this problem:
http://www.gossamer-threads.com/archive/mod_perl_C1/asp_F3/Identifier_Too_Long_Error_with_Long_Pathnames_P480/
It's also a very silly & trivial bug in Perl, which is acknowledged as a
known bug. And Python does it right!
/me ducks and runs
--
Alex
------------------------------
Date: Fri, 06 Feb 2004 02:22:05 -0600
From: tadmc@augustmail.com
Subject: Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
Message-Id: <kemdnSqwYN4w077dRVn-vg@august.net>
Outline
Before posting to comp.lang.perl.misc
Must
- Check the Perl Frequently Asked Questions (FAQ)
- Check the other standard Perl docs (*.pod)
Really Really Should
- Lurk for a while before posting
- Search a Usenet archive
If You Like
- Check Other Resources
Posting to comp.lang.perl.misc
Is there a better place to ask your question?
- Question should be about Perl, not about the application area
How to participate (post) in the clpmisc community
- Carefully choose the contents of your Subject header
- Use an effective followup style
- Speak Perl rather than English, when possible
- Ask perl to help you
- Do not re-type Perl code
- Provide enough information
- Do not provide too much information
- Do not post binaries, HTML, or MIME
Social faux pas to avoid
- Asking a Frequently Asked Question
- Asking a question easily answered by a cursory doc search
- Asking for emailed answers
- Beware of saying "doesn't work"
- Sending a "stealth" Cc copy
Be extra cautious when you get upset
- Count to ten before composing a followup when you are upset
- Count to ten after composing and before posting when you are upset
-----------------------------------------------------------------
Posting Guidelines for comp.lang.perl.misc ($Revision: 1.5 $)
This newsgroup, commonly called clpmisc, is a technical newsgroup
intended to be used for discussion of Perl related issues (except job
postings), whether it be comments or questions.
As you would expect, clpmisc discussions are usually very technical in
nature and there are conventions for conduct in technical newsgroups
going somewhat beyond those in non-technical newsgroups.
The article at:
http://www.catb.org/~esr/faqs/smart-questions.html
describes how to get answers from technical people in general.
This article describes things that you should, and should not, do to
increase your chances of getting an answer to your Perl question. It is
available in POD, HTML and plain text formats at:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
For more information about netiquette in general, see the "Netiquette
Guidelines" at:
http://andrew2.andrew.cmu.edu/rfc/rfc1855.html
A note to newsgroup "regulars":
Do not use these guidelines as a "license to flame" or other
meanness. It is possible that a poster is unaware of things
discussed here. Give them the benefit of the doubt, and just
help them learn how to post, rather than assume
A note about technical terms used here:
In this document, we use words like "must" and "should" as
they're used in technical conversation (such as you will
encounter in this newsgroup). When we say that you *must* do
something, we mean that if you don't do that something, then
it's unlikely that you will benefit much from this group.
We're not bossing you around; we're making the point without
lots of words.
Do *NOT* send email to the maintainer of these guidelines. It will be
discarded unread. The guidelines belong to the newsgroup so all
discussion should appear in the newsgroup. I am just the secretary that
writes down the consensus of the group.
Before posting to comp.lang.perl.misc
Must
This section describes things that you *must* do before posting to
clpmisc, in order to maximize your chances of getting meaningful replies
to your inquiry and to avoid getting flamed for being lazy and trying to
have others do your work.
The perl distribution includes documentation that is copied to your hard
drive when you install perl. Also installed is a program for looking
things up in that (and other) documentation named 'perldoc'.
You should either find out where the docs got installed on your system,
or use perldoc to find them for you. Type "perldoc perldoc" to learn how
to use perldoc itself. Type "perldoc perl" to start reading Perl's
standard documentation.
Check the Perl Frequently Asked Questions (FAQ)
Checking the FAQ before posting is required in Big 8 newsgroups in
general, there is nothing clpmisc-specific about this requirement.
You are expected to do this in nearly all newsgroups.
You can use the "-q" switch with perldoc to do a word search of the
questions in the Perl FAQs.
Check the other standard Perl docs (*.pod)
The perl distribution comes with much more documentation than is
available for most other newsgroups, so in clpmisc you should also
see if you can find an answer in the other (non-FAQ) standard docs
before posting.
It is *not* required, or even expected, that you actually *read* all of
Perl's standard docs, only that you spend a few minutes searching them
before posting.
Try doing a word-search in the standard docs for some words/phrases
taken from your problem statement or from your very carefully worded
"Subject:" header.
Really Really Should
This section describes things that you *really should* do before posting
to clpmisc.
Lurk for a while before posting
This is very important and expected in all newsgroups. Lurking means
to monitor a newsgroup for a period to become familiar with local
customs. Each newsgroup has specific customs and rituals. Knowing
these before you participate will help avoid embarrassing social
situations. Consider yourself to be a foreigner at first!
Search a Usenet archive
There are tens of thousands of Perl programmers. It is very likely
that your question has already been asked (and answered). See if you
can find where it has already been answered.
One such searchable archive is:
http://groups.google.com/advanced_group_search
If You Like
This section describes things that you *can* do before posting to
clpmisc.
Check Other Resources
You may want to check in books or on web sites to see if you can
find the answer to your question.
But you need to consider the source of such information: there are a
lot of very poor Perl books and web sites, and several good ones
too, of course.
Posting to comp.lang.perl.misc
There can be 200 messages in clpmisc in a single day. Nobody is going to
read every article. They must decide somehow which articles they are
going to read, and which they will skip.
Your post is in competition with 199 other posts. You need to "win"
before a person who can help you will even read your question.
These sections describe how you can help keep your article from being
one of the "skipped" ones.
Is there a better place to ask your question?
Question should be about Perl, not about the application area
It can be difficult to separate out where your problem really is,
but you should make a conscious effort to post to the most
applicable newsgroup. That is, after all, where you are the most
likely to find the people who know how to answer your question.
Being able to "partition" a problem is an essential skill for
effectively troubleshooting programming problems. If you don't get
that right, you end up looking for answers in the wrong places.
It should be understood that you may not know that the root of your
problem is not Perl-related (the two most frequent ones are CGI and
Operating System related), so off-topic postings will happen from
time to time. Be gracious when someone helps you find a better place
to ask your question by pointing you to a more applicable newsgroup.
How to participate (post) in the clpmisc community
Carefully choose the contents of your Subject header
You have 40 precious characters of Subject to win out and be one of
the posts that gets read. Don't waste them. Take care while
composing them, they are the key that opens the door to getting an
answer.
Spend them indicating what aspect of Perl others will find if they
should decide to read your article.
Do not spend them indicating "experience level" (guru, newbie...).
Do not spend them pleading (please read, urgent, help!...).
Do not spend them on non-Subjects (Perl question, one-word
Subject...)
For more information on choosing a Subject see "Choosing Good
Subject Lines":
http://www.cpan.org/authors/id/D/DM/DMR/subjects.post
Part of the beauty of newsgroup dynamics, is that you can contribute
to the community with your very first post! If your choice of
Subject leads a fellow Perler to find the thread you are starting,
then even asking a question helps us all.
Use an effective followup style
When composing a followup, quote only enough text to establish the
context for the comments that you will add. Always indicate who
wrote the quoted material. Never quote an entire article. Never
quote a .signature (unless that is what you are commenting on).
Intersperse your comments *following* each section of quoted text to
which they relate. Unappreciated followup styles are referred to as
"top-posting", "Jeopardy" (because the answer comes before the
question), or "TOFU" (Text Over, Fullquote Under).
Reversing the chronology of the dialog makes it much harder to
understand (some folks won't even read it if written in that style).
For more information on quoting style, see:
http://web.presby.edu/~nnqadmin/nnq/nquote.html
Speak Perl rather than English, when possible
Perl is much more precise than natural language. Saying it in Perl
instead will avoid misunderstanding your question or problem.
Do not say: I have variable with "foo\tbar" in it.
Instead say: I have $var = "foo\tbar", or I have $var = 'foo\tbar',
or I have $var = <DATA> (and show the data line).
Ask perl to help you
You can ask perl itself to help you find common programming mistakes
by doing two things: enable warnings (perldoc warnings) and enable
"strict"ures (perldoc strict).
You should not bother the hundreds/thousands of readers of the
newsgroup without first seeing if a machine can help you find your
problem. It is demeaning to be asked to do the work of a machine. It
will annoy the readers of your article.
You can look up any of the messages that perl might issue to find
out what the message means and how to resolve the potential mistake
(perldoc perldiag). If you would like perl to look them up for you,
you can put "use diagnostics;" near the top of your program.
Do not re-type Perl code
Use copy/paste or your editor's "import" function rather than
attempting to type in your code. If you make a typo you will get
followups about your typos instead of about the question you are
trying to get answered.
Provide enough information
If you do the things in this item, you will have an Extremely Good
chance of getting people to try and help you with your problem!
These features are a really big bonus toward your question winning
out over all of the other posts that you are competing with.
First make a short (less than 20-30 lines) and *complete* program
that illustrates the problem you are having. People should be able
to run your program by copy/pasting the code from your article. (You
will find that doing this step very often reveals your problem
directly. Leading to an answer much more quickly and reliably than
posting to Usenet.)
Describe *precisely* the input to your program. Also provide example
input data for your program. If you need to show file input, use the
__DATA__ token (perldata.pod) to provide the file contents inside of
your Perl program.
Show the output (including the verbatim text of any messages) of
your program.
Describe how you want the output to be different from what you are
getting.
If you have no idea at all of how to code up your situation, be sure
to at least describe the 2 things that you *do* know: input and
desired output.
Do not provide too much information
Do not just post your entire program for debugging. Most especially
do not post someone *else's* entire program.
Do not post binaries, HTML, or MIME
clpmisc is a text only newsgroup. If you have images or binaries
that explain your question, put them in a publically accessible
place (like a Web server) and provide a pointer to that location. If
you include code, cut and paste it directly in the message body.
Don't attach anything to the message. Don't post vcards or HTML.
Many people (and even some Usenet servers) will automatically filter
out such messages. Many people will not be able to easily read your
post. Plain text is something everyone can read.
Social faux pas to avoid
The first two below are symptoms of lots of FAQ asking here in clpmisc.
It happens so often that folks will assume that it is happening yet
again. If you have looked but not found, or found but didn't understand
the docs, say so in your article.
Asking a Frequently Asked Question
It should be understood that you may have missed the applicable FAQ
when you checked, which is not a big deal. But if the Frequently
Asked Question is worded similar to your question, folks will assume
that you did not look at all. Don't become indignant at pointers to
the FAQ, particularly if it solves your problem.
Asking a question easily answered by a cursory doc search
If folks think you have not even tried the obvious step of reading
the docs applicable to your problem, they are likely to become
annoyed.
If you are flamed for not checking when you *did* check, then just
shrug it off (and take the answer that you got).
Asking for emailed answers
Emailed answers benefit one person. Posted answers benefit the
entire community. If folks can take the time to answer your
question, then you can take the time to go get the answer in the
same place where you asked the question.
It is OK to ask for a *copy* of the answer to be emailed, but many
will ignore such requests anyway. If you munge your address, you
should never expect (or ask) to get email in response to a Usenet
post.
Ask the question here, get the answer here (maybe).
Beware of saying "doesn't work"
This is a "red flag" phrase. If you find yourself writing that,
pause and see if you can't describe what is not working without
saying "doesn't work". That is, describe how it is not what you
want.
Sending a "stealth" Cc copy
A "stealth Cc" is when you both email and post a reply without
indicating *in the body* that you are doing so.
Be extra cautious when you get upset
Count to ten before composing a followup when you are upset
This is recommended in all Usenet newsgroups. Here in clpmisc, most
flaming sub-threads are not about any feature of Perl at all! They
are most often for what was seen as a breach of netiquette. If you
have lurked for a bit, then you will know what is expected and won't
make such posts in the first place.
But if you get upset, wait a while before writing your followup. I
recommend waiting at least 30 minutes.
Count to ten after composing and before posting when you are upset
After you have written your followup, wait *another* 30 minutes
before committing yourself by posting it. You cannot take it back
once it has been said.
AUTHOR
Tad McClellan <tadmc@augustmail.com> and many others on the
comp.lang.perl.misc newsgroup.
------------------------------
Date: Sat, 07 Feb 2004 09:53:43 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Running perl script from command line
Message-Id: <v78920pg6gdgtl5i2q771rrj6ha1uvsmci@4ax.com>
On 5 Feb 2004 00:47:02 -0800, abhishes@hotmail.com (Abhishek
Srivastava) wrote:
>myscript.pl a b c [here a b c are the parameters to the script]
>
>I have also assosiated *.pl extension with c:\perl\bin\perl.exe (using
>windows explorer file->folder options)
>
>When I run my script something strange happens, the script is run but
>none of the command line parameters are passed to it.
First of all AS Perl comes with extensive documentation that covers
*also* these issues. But how can you tell that cmd line params are not
passed to the script? What does
perl -le "print for @ARGV" <args>
yield? And if you put this code in a file, say myprog.pl, what does
myprog.pl <args>
yield?
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
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 6087
***************************************