[21761] in Perl-Users-Digest
Perl-Users Digest, Issue: 3965 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 14 09:06:08 2002
Date: Mon, 14 Oct 2002 06:05:12 -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 Mon, 14 Oct 2002 Volume: 10 Number: 3965
Today's topics:
Another hash problem <lois@hotmail.com>
Re: Another hash problem <nobull@mail.com>
Archive::Zip - Zip contents empty files. <Dirk.Heitzmann@Triaton.com>
comparing stuff <stuff@nowhere.com>
Re: comparing stuff <krahnj@acm.org>
do I need a demon? <jackkon@ms29.url.com.tw>
Re: Documentation about this \Q \E stuff <mgjv@tradingpost.com.au>
filehandles <kperry01@telus.net>
Re: filehandles <Tassilo.Parseval@post.rwth-aachen.de>
Re: filehandles <kperry01@telus.net>
Re: How about UNIVERSAL::hashkey() ? <nobull@mail.com>
Re: How about UNIVERSAL::hashkey() ? <nobull@mail.com>
Re: How to create a bundle? <enrico@sorcinelli.it>
Re: Installing Perl Modules: What actually happens? (david rayner)
Re: io::select and individual response times <goldbb2@earthlink.net>
Is this the most efficient method <tim@melonhead.remove.net>
Re: Is this the most efficient method <nobull@mail.com>
Re: Multiple Pings/Second <goldbb2@earthlink.net>
Re: Multiple Pings/Second (Damian James)
Re: net::ftp errors <krahnj@acm.org>
Re: Perl script works half the time <mgjv@tradingpost.com.au>
Re: Perl script works half the time <usenet@tinita.de>
Re: Regular Expression (Referer) (David Efflandt)
Re: Regular Expression (Referer) <spam@all.costs.must.die>
Split of very large text file (Ravi)
Re: Split of very large text file <mgjv@tradingpost.com.au>
Re: Split of very large text file <krahnj@acm.org>
Splitting CSV lines (Andrew Cashin)
Re: Switching from Python to Perl <REMOVEsdnCAPS@comcast.net>
Re: What purpose does eval{ ... } server? <comdog@panix.com>
Re: What purpose does eval{ ... } server? <Tassilo.Parseval@post.rwth-aachen.de>
Re: What purpose does eval{ ... } server? <bart.lateur@pandora.be>
Re: Why is 'defined @x' deprecated? <REMOVEsdnCAPS@comcast.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 14 Oct 2002 05:29:51 GMT
From: "Lois" <lois@hotmail.com>
Subject: Another hash problem
Message-Id: <jDsq9.34393$rz6.5191@sccrnsc02>
Hi all,
I have another hash problem which I couldn't visualize if they're the
same
%hits = ( "xxx" => {"WINTER" => 110, "SPRING"=> 51, "SUMMER"=>69,
"AUTUMN=>87" },
"zzz" => {"WINTER" => 20, "SPRING"=> 40, "SUMMER"=>33,
"AUTUMN=>37" } )
and
${hits{$fields[0]}}{WINTER, SPRING, SUMMER, AUTUMN} = @fields[1..4]
Thanks,
lois
------------------------------
Date: 14 Oct 2002 09:27:28 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Another hash problem
Message-Id: <u9elata0i7.fsf@wcl-l.bham.ac.uk>
"Lois" <lois@hotmail.com> writes:
> I have another hash problem which I couldn't visualize if they're the
> same
This is the start of a new thread, with no quoted material from any
previous thread. In this context the above sentence makes no sense.
> %hits = ( "xxx" => {"WINTER" => 110, "SPRING"=> 51, "SUMMER"=>69,
> "AUTUMN=>87" },
> "zzz" => {"WINTER" => 20, "SPRING"=> 40, "SUMMER"=>33,
> "AUTUMN=>37" } )
>
> and
>
> ${hits{$fields[0]}}{WINTER, SPRING, SUMMER, AUTUMN} = @fields[1..4]
The above should probably read
%hits = ( "xxx" => {"WINTER" => 110, "SPRING"=> 51, "SUMMER"=>69,
"AUTUMN" =>87 },
"zzz" => {"WINTER" => 20, "SPRING"=> 40, "SUMMER"=>33,
"AUTUMN"=>37 } )
@{$hits{$fields[0]}}{'WINTER', 'SPRING', 'SUMMER', 'AUTUMN'} = @fields[1..4]
I do not know if this is a transcription error or if this is actually
related to whatever problem you are having.
Please always post the real code you are trying so that we are not
distracted by transcription errors.
Apart from that I only guess what you are talking about.
If you do...
my (%hits,@fields);
@fields = ( xxx => 110, 51, 69, 87);
@{$hits{$fields[0]}}{'WINTER', 'SPRING', 'SUMMER', 'AUTUMN'} = @fields[1..4];
@fields = ( zzz => 20, 40, 33, 37);
@{$hits{$fields[0]}}{'WINTER', 'SPRING', 'SUMMER', 'AUTUMN'} = @fields[1..4];
This will leave the same in %hits as...
my %hits = ( "xxx" => {"WINTER" => 110, "SPRING"=> 51, "SUMMER"=>69,
"AUTUMN" =>87 },
"zzz" => {"WINTER" => 20, "SPRING"=> 40, "SUMMER"=>33,
"AUTUMN"=>37 } );
This that what you were asking?
Please always re-read your posts before you hit send and and yourself
the following two questions:
If someone came along to the newsgroup with the exact same question
and saw a thread with your post's subject line would I realise it was
the same question?
If someone came along to the newsgroup and read your post would they
be able to easily and unambiguously figure out what you were asking?
Unless the answer to both is "yes" do not hit send.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 14 Oct 2002 10:59:04 GMT
From: Dirk Heitzmann <Dirk.Heitzmann@Triaton.com>
Subject: Archive::Zip - Zip contents empty files.
Message-Id: <MPG.1814c1ffb7b91328989683@newsgate.hiserv.com>
Hello.
I've tried to use Archive:Zip.
I could create a new ZIP, add some files and save the ZIP to Disk.
WOW ;-)
But all files, I have added are empty (0 byte). Why ???
My $source :
my $zip = Archive::Zip->new();
$zip->addFile("$inputfile");
$zip->writeToFileNamed("$zipfile");
Thanks,
Dirk
------------------------------
Date: Mon, 14 Oct 2002 14:59:44 +1000
From: "mostuff" <stuff@nowhere.com>
Subject: comparing stuff
Message-Id: <Jcsq9.88$Db.11640@nasal.pacific.net.au>
i'm trying to compare the age of 2 files. 1 of them is on an ftp site. if
the file on the ftp site is newer than the local file then i download it. so
i get the modification time of the local file using stat and localtime -
thats fine, and then i get the modification time of the remote file and then
unpack it into year, month, day, hours, minutes, seconds. i was wondering if
there was any easy way of doing if ((remoteyear > localyear) and
(remotemonth > localmonth)) etc.
thanx in advance
------------------------------
Date: Mon, 14 Oct 2002 06:20:14 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: comparing stuff
Message-Id: <3DAA61F3.6D1F094@acm.org>
mostuff wrote:
>
> i'm trying to compare the age of 2 files. 1 of them is on an ftp site. if
> the file on the ftp site is newer than the local file then i download it. so
> i get the modification time of the local file using stat and localtime -
> thats fine, and then i get the modification time of the remote file and then
> unpack it into year, month, day, hours, minutes, seconds. i was wondering if
> there was any easy way of doing if ((remoteyear > localyear) and
> (remotemonth > localmonth)) etc.
The Net::FTP::mdtm method returns the modification time which can be
compared directly against the modification time of a local file. There
is no need to convert or unpack it.
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 14 Oct 2002 18:10:39 +0800
From: "jackkon" <jackkon@ms29.url.com.tw>
Subject: do I need a demon?
Message-Id: <aoe4sa$egr@netnews.hinet.net>
hi all
I want to execute some perl scripts in the unix server from the remote
program.
I think I must have a demon to receive my remote command.
When the demon receive the command, it call the "system" function to do the
job.
Where can I find the example about the demon?
Thanks a lot.
------------------------------
Date: Mon, 14 Oct 2002 14:36:44 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Documentation about this \Q \E stuff
Message-Id: <slrnaqkies.q36.mgjv@martien.heliotrope.home>
On Sun, 13 Oct 2002 22:11:55 -0400,
some guy <yoman@dude.com> wrote:
> Hi,
>
> can someone point me to a place where I can read about the \Q and \E
> stuff?
I did, in that other thread where you were having problems with a
regular expression. It's in the perlop documentation and in the perlre
documentation
$ perldoc perlre
$ perldoc perlop
If you have ActiveState Perl, they're also installed as HTML.
Martien
--
|
Martien Verbruggen | Make it idiot proof and someone will make a
| better idiot.
|
------------------------------
Date: Mon, 14 Oct 2002 11:49:01 GMT
From: Kelley Perry <kperry01@telus.net>
Subject: filehandles
Message-Id: <3DAAAF30.6060307@telus.net>
Trying to use the append filehandle on an html file and it works but i
would like to somehow keep the last two html(</body></html>) tags at the
end of the file, or for that matter any html code that i need to go
after the data input from the cgi.
------------------------------
Date: 14 Oct 2002 12:05:47 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: filehandles
Message-Id: <aoebur$qdk$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Kelley Perry:
> Trying to use the append filehandle on an html file and it works but i
> would like to somehow keep the last two html(</body></html>) tags at the
> end of the file, or for that matter any html code that i need to go
> after the data input from the cgi.
That means you rather want to insert than to append to a file.
Unfortunately that's not the way file-IO works. Instead, save the stuff
that should remain in the file in some temporary variable, jump to the
spot before this remainder, write the new stuff and append the things
you previously stored in your temporary variable. See 'perldoc -f seek'
for that.
Also, you can treat a file as an array. Adding elements to an array is
much more convenient than adding data to a sequence of bytes (such as a
file). Tie::File will do that for you.
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Mon, 14 Oct 2002 12:16:04 GMT
From: Kelley Perry <kperry01@telus.net>
Subject: Re: filehandles
Message-Id: <3DAAB587.4000807@telus.net>
Tassilo,
Thanks for the extremely prompt and knowledgeable reply! Much appreciated.
Tassilo v. Parseval wrote:
> Also sprach Kelley Perry:
>
>
>>Trying to use the append filehandle on an html file and it works but i
>>would like to somehow keep the last two html(</body></html>) tags at the
>>end of the file, or for that matter any html code that i need to go
>>after the data input from the cgi.
>
>
> That means you rather want to insert than to append to a file.
> Unfortunately that's not the way file-IO works. Instead, save the stuff
> that should remain in the file in some temporary variable, jump to the
> spot before this remainder, write the new stuff and append the things
> you previously stored in your temporary variable. See 'perldoc -f seek'
> for that.
>
> Also, you can treat a file as an array. Adding elements to an array is
> much more convenient than adding data to a sequence of bytes (such as a
> file). Tie::File will do that for you.
>
> Tassilo
------------------------------
Date: 14 Oct 2002 09:00:43 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How about UNIVERSAL::hashkey() ?
Message-Id: <u9k7kla1qs.fsf@wcl-l.bham.ac.uk>
Da Witch <heather710101@yahoo.com> writes:
> In <u9y993u44w.fsf@wcl-l.bham.ac.uk> Brian McCauley <nobull@mail.com> writes:
> >use overload
> > '""' => sub { "In a string context"),
> > '{}' => sub { "In a hash key context" };
>
> >If the '{}' overloading was not specified it should fall-back to the
> >'""' operator.
>
> This is an interesting approach, but the Perl 5.8 man page does not
> mention '{}' as an overloadable operator.
That is to be expected. After all I said if such a feature
_were_to_be_ implemented then this would be the most natural way. I
didn't say is _was_ already implemented.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 14 Oct 2002 09:03:52 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How about UNIVERSAL::hashkey() ?
Message-Id: <u9hefpa1lj.fsf@wcl-l.bham.ac.uk>
Da Witch <heather710101@yahoo.com> writes:
> In <u9y993u44w.fsf@wcl-l.bham.ac.uk> Brian McCauley <nobull@mail.com> writes:
>
> >Da Witch <heather710101@yahoo.com> writes:
>
> >> I think it would be great of a new hash_code() instance method were
> >> added to UNIVERSAL, so that whenever an object $obj is used as a key
> >> to hash, the Perl interpreter would first call $obj->hash_code to get
> >> the appropriate hashkey to use for that object. (This is the same
> >> idea as the hashCode method of Java's Object class). The default
> >> value returned by UNIVERSAL::hash_code() would be the stringified
> >> version of the object that Perl currently uses whenever objects are
> >> used as hash keys. But class programmers could override this method
> >> to gain greater control over hashes that are indexed by objects.
>
> >I do not think that there's a need for this feature as if you want a
> >hash that is keyed on something that's not a simple string I think it
> >makes more sense to think of this as a feature of the hash rather than
> >the things that are to be used as keys. This, of course, can already
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> >be done.
> ^^^^^^^
>
> How?
Tied hashes. For an example see Tie::RefHash. And just in case you
missunderstand again, I'm not saying that Tie::RefHash does what you
want, I'm saying that it illustrates the underlying Perl mechanisms
that could be used to achieve what you want without extending the Perl
core.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 14 Oct 2002 12:46:08 GMT
From: Enrico Sorcinelli <enrico@sorcinelli.it>
Subject: Re: How to create a bundle?
Message-Id: <20021014145809.69edb405.enrico@sorcinelli.it>
On Sun, 13 Oct 2002 09:17:41 -0400
"Domizio Demichelis" <dd@4pro.net> wrote:
> > > I found just a little section in the CPAN pod, nothing at all in the
> faq,
> >
> > Are you sure?
> > See
> > http://www.cpan.org/misc/cpan-faq.html#How_make_bundle
>
> hmmm... I didn't search in that faq :-) (I didn't even know that there was
> different faq than the installed one)
>
Generally, FAQ are sections always work in progress, so
don't consider files installed in your system
the 'ultimate' FAQ. Resync it (some time) :-)
> Grazie ;-)
>
Prego
;-)
- Enrico
------------------------------
Date: 14 Oct 2002 03:08:55 -0700
From: david@tvis.co.uk (david rayner)
Subject: Re: Installing Perl Modules: What actually happens?
Message-Id: <f677762.0210140208.499e086a@posting.google.com>
peter@PSDT.com (Peter Scott) wrote in message news:<Y_Xn9.463155$v53.20337486@news3.calgary.shaw.ca>...
> In article <f677762.0210060145.2db09334@posting.google.com>,
> david@tvis.co.uk (david rayner) writes:
> >Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote in message news:<slrnapqq38.142.bernard.el-hagin@gdndev25.lido-tech>...
> >> In article <f677762.0210040205.7ccec0e6@posting.google.com>, david rayner wrote:
> >> > Obviously it's easiest when PPM does a install for you.
> >> > Occasionally however you are asked to do the following
> >> >
> >> >>perl makefile.pl
> >> >>make
> >> >>make test
> >> >>make install
> >> >
> >> > But my real question is what is actually happenning, what is being
> >> > compiled/installed etc?
> >>
> >> Look in the makefile. It's all in there.
> >
> >Just did, sorry it's double dutch. What I'd like to is the principles
>
> (1) "perl Makefile.PL" - turn a short, platform-independent
> configuration file into a Makefile that works on your system for your
> perl. (cf "imake" if you're familiar with that.) Perl knows about
> all the specifics of your perl installation (like where binaries go,
> how to compile C code, etc) through its Config module. All the module
> developer has to do is fill out a usually simple Makefile.PL which
> covers just the things that are specific to this distribution. But
> they can include arbitrarily complex Perl if necessary.
>
> (2) "make" - this is your system running its make command on the
> Makefile generated in (1). N.B.: If you have a system that includes a
> make command and utilities it depends on, you should be able to use
> CPAN.pm to make these steps as simple as PPM; a module install can be
> just "perl -MCPAN -e 'install Foo'".
>
> (3) "make test" - your system runs its make command on the Makefile
> and finds the "test" target to run the tests the module developer
> thoughtfully included to let you know whether it's working alright.
> CPAN.pm won't let a module install if it fails its tests (unless you
> force it to).
>
> (4) "make install" - runs make command on "install" target which
> copies files from the current location to the place where perl expects
> to find them, i.e., somewhere under @INC.
Thanx Peter, I'm sure I'm not the only one who finds this useful!
Could you now describe the type of files that are copied across/compiled/created
eg for DBD::ODBC (Win32) and what they are used for
Installing C:\usr\local\site\lib\auto\DBD\ODBC\ODBC.bs
Installing C:\usr\local\site\lib\auto\DBD\ODBC\ODBC.dll
Installing C:\usr\local\site\lib\auto\DBD\ODBC\ODBC.exp
Installing C:\usr\local\site\lib\auto\DBD\ODBC\ODBC.lib
Installing C:\usr\local\html\site\lib\DBD\ODBC.html
Installing C:\usr\local\site\lib\DBD\ODBC.pm
Writing C:\usr\local\site\lib\auto\DBD\ODBC\.packlist
------------------------------
Date: Mon, 14 Oct 2002 01:13:31 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: io::select and individual response times
Message-Id: <3DAA527B.E712122F@earthlink.net>
smackdab wrote:
>
> I am sending a couple of non-blocking TCP connect calls at once...
>
> I then do a $select->can_write($timeout) to see how many accepted my
> connection requests...
>
> Is there any way to get timing info from each connection?
>
> I can set a hires time before I send out the connects, but since the
> can_write() blocks I don't know when individual ones came back...
The can_write method should only block until the first one becomes
ready, not until they all become ready.
So, you could do:
my $time = time;
my $sel = IO::Select->new;
# stuff to initiate nonblocking connects.
while( $sel->count ) {
my @w = $sel->can_write;
my $took = time() - $time;
printf "Connection to %s took %f seconds.\n",
inet_ntoa($_->peerhost), $took for @w;
$sel->remove(@w); # this line is important!
}
[untested, error checking ommited for brevity. You ought to check
$socket->sockopt(SO_ERROR) to tell whether it was a successful connect
or an error that caused the select to succeed on that socket.]
> I think I looked through all of the IO::Socket and IO::Select pod
> pages but didn't see anything to do this.
>
> thanks for any suggestions!
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: Mon, 14 Oct 2002 11:36:29 +0100
From: "Melonhead" <tim@melonhead.remove.net>
Subject: Is this the most efficient method
Message-Id: <1034592170.37573.0@dyke.uk.clara.net>
I'd appreciate a little feedback on this one. The code below extracts the
real email address from a string - i.e. "abc, def" abc@xyz.com will become
just abc@xyz.com. It works, but i was just wondering if it is the most
efficient and best way of achieving the end result?
#!c:/perl/bin/perl.exe
$from="\"fname, sname\" <me\@xyz.com>";
print "BEFORE: $from\n";
if (index($from, "<") >= 0) {
$left=index($from, "<");
$right=index($from, ">");
$from=substr($from, ($left+1), ($right-$left-1));
}
print "AFTER: $from\n";
regards,
Tim
------------------------------
Date: 14 Oct 2002 13:27:49 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Is this the most efficient method
Message-Id: <u97kgl9pdm.fsf@wcl-l.bham.ac.uk>
"Melonhead" <tim@melonhead.remove.net> writes:
> Subject: Is this the most efficient method
Please put the subject of your post in the Subject of your post. If
in doubt try this simple test. Imagine you could have been bothered
to have done a search before you posted. Next imagine you found a
thread with your subject line. Would you have been able to recognise
it as the same subject?
Anyhow you fail to define your efficiency metric.
> I'd appreciate a little feedback on this one. The code below extracts the
> real email address from a string - i.e. "abc, def" abc@xyz.com will become
> just abc@xyz.com. It works, but i was just wondering if it is the most
> efficient and best way of achieving the end result?
Your algorith won't work for all valid email address format. I suggest
you get the appropriate module from CPAN even though this is going to
be much slower at run-time it will make development/suport much easier.
> #!c:/perl/bin/perl.exe
>
> $from="\"fname, sname\" <me\@xyz.com>";
> print "BEFORE: $from\n";
> if (index($from, "<") >= 0) {
> $left=index($from, "<");
> $right=index($from, ">");
> $from=substr($from, ($left+1), ($right-$left-1));
> }
Building up pattern matching out of index() and substr() is less
readable (for an experienced Perl programmer) than simply using Perl's
pattern matching operators. It's also rarely significantly (if at
all) faster.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Mon, 14 Oct 2002 00:59:12 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Multiple Pings/Second
Message-Id: <3DAA4F20.1A174817@earthlink.net>
smackdab wrote:
>
> Thanks!!!
>
> I am on Win32 and the $^E was helpful...I made the recv buffer 1500
> and it got farther!
>
> Also, using either of these, allowed the code to send - yea, even
> farther!
> > if( vec $wvec, fileno($socket), 1 ) {
> > Or perhaps to:
> > if( $wvec eq $svec ) {
>
> But,things weren't coming back as a valid packet...
>
> So, after the recv() I added this line to grab the "end" of the string
> to unpack()
> (I think Net::Ping is doing this...)
> ($resp) = $resp =~ m/(.{8})$/;
Actually, you should be getting the *first* 8 bytes, not the last.
I think.
--
my $n = 2; print +(split //, 'e,4c3H r ktulrnsJ2tPaeh'
."\n1oa! er")[map $n = ($n * 24 + 30) % 31, (42) x 26]
------------------------------
Date: 14 Oct 2002 06:49:45 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Multiple Pings/Second
Message-Id: <slrnaqkq88.as1.damian@puma.qimr.edu.au>
On Fri, 11 Oct 2002 14:54:46 -0400, Benjamin Goldberg said:
>Damian James wrote:
>> ...
>> For no particular reason, I tried this verbatim in bash on cygwin on
>> win2k. Of course, the double quotes mean $$ was interpolated in the
>> shell before perl saw it. So obviously it was always the same.
>On windows 95, (to be precise, on the command.com that comes with win95)
>the dollar sign is not what's used to make the shell interpolate
>environment variables -- the % character is.
Indeed. I was admitting to some meaningless behaviour on my part, not
saying that this case was like yours with win95. The win2k case also
yielded the repetition you describe, once I eliminated the shell stuff
above. But I wasn't challenging what you had said :-). Hence my
beginning with "For no particular reason..."
>Your example shows that on other OS's, process-ids aren't reused as they
>are on windows95. In other words, it means just about nothing.
Of course. I wasn't making any point. The two *nix examples showed two
different approaches to this business of allocating PIDs, that's all.
--damian
------------------------------
Date: Mon, 14 Oct 2002 05:01:19 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: net::ftp errors
Message-Id: <3DAA4F77.ED6D2635@acm.org>
mostuff wrote:
>
> hi. i'm using net::ftp to upload file to an ftp site (duh ;)). if it has an
> error connecting $! is always Uknown error. i've noticed that if i use
> win32::getlasterror() it will return the winsock error code (11001 etc.). is
> there any other way of getting a more verbose error message out of net::ftp?
perldoc Net::FTP
[snip]
If the constructor fails undef will be returned and an
error message will be in $@
John
--
use Perl;
program
fulfillment
------------------------------
Date: Mon, 14 Oct 2002 14:07:13 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Perl script works half the time
Message-Id: <slrnaqkgnh.q36.mgjv@martien.heliotrope.home>
On Sun, 13 Oct 2002 21:02:16 -0400,
some guy <yoman@dude.com> wrote:
> On Sun, 13 Oct 2002 21:41:07 -0400, Martien Verbruggen wrote:
>
>> On Sun, 13 Oct 2002 20:08:57 -0400,
>> some guy <yoman@dude.com> wrote:
[ problems with re /[ \w]+\:\:$thePassword\:\:/i at tripod.com ]
>> Could you show us the contents of $thePassword when it fails?
>
> Sure, one of the passwords is "laga" for example(the quotes not included
> of course). So what I do is I type in the password and click send and it
> works. Then I hit the back button and click send again with the same
> password in it, and it works. And I click the back button again and click
> send, sending the same password, but this time it breaks giving the same
> error msg
Buttons. So you're runnig this program as a CGI program, right?
>
> regexp reset interpolation flag trapped by operation mask at grades.cgi line
> 25
>
>
> I can keep doing this and sometimes it works, and sometimes it breaks.
> Even within the same password. I think the tripod.com perl implementation
> is broken.
[I think you use 'implementation' when you mean 'installation']
Well, it is of course possible that tripod is having problems with one
of their installations of perl. It is possible that they have a web
server farm, and only one of them has this behaviour. i don't know
whether they have a farm, but it would explain the symptoms. I find it
slightly hard to believe it would be the case, but the only way you're
going to find out is by contacting tripod, describing the full problem
(including all the information you gave us bit by bit) and asking them
whether it's possible they have a broken installation of perl.
So, my advise would be to create a tiny little program that displays the
problem, send it to the system administrators at tripod, and ask them to
test it on all the machines your program might be running on. a minimal
one could be something like (untested):
#!/usr/local/bin/perl -w
use strict;
use CGI qw/ standard /;
use CGI::Carp qw/ fatalsToBrowser /;
my $thePassword = "laga";
"random string" =~ /[ \w]+::\Q$thePassword\E::/i
print
header(),
start_html('It compiled and ran'),
h1('Seems to have worked'),
end_html();
Install it next to your program, and run it a bundle of times. If this
doesn't fail, then there's something else going on in your program
unrelated to the regular expression, and you need to debug what you're
doing a bit better. If this fails, send it to tripod.
Martien
--
|
Martien Verbruggen | Never hire a poor lawyer. Never buy from a
| rich salesperson.
|
------------------------------
Date: 14 Oct 2002 11:03:25 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Perl script works half the time
Message-Id: <aoe89t$l84qn$1@fu-berlin.de>
some guy <yoman@dude.com> wrote:
> Well I put in the \Q and \E stuff and it is still doing the same thing.
> so for the record right now my regular expression looks like
> $entry =~ /[ \w]+::\Q$thePassword\E::/i
> Does anyone think maybe the tripod.com perl implementation is broken?
at least you don't seem to be the only on with the error message.
search for "regexp reset interpolation flag trapped" (yes,
with double-quotes)
at google; there are at least 4 other tripod-scripts with
that error. contact tripod.
good luck,
tina
--
http://www.tinita.de/ \ enter__| |__the___ _ _ ___
http://Movies.tinita.de/ \ / _` / _ \/ _ \ '_(_-< of
http://PerlQuotes.tinita.de/ \ \ _,_\ __/\ __/_| /__/ perception
------------------------------
Date: Mon, 14 Oct 2002 04:17:30 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Regular Expression (Referer)
Message-Id: <slrnaqkhap.3fe.efflandt@typhoon.xnet.com>
On 13 Oct 2002 17:09:14 -0700, kazchan <kazchan@curio-city.com> wrote:
> When I call my cgi script, I would like to control by referer. Ex: if
> the referer is http://www.domain.com/dir1/dir2/dir3/, I would like to
> display as dir3. I used (.*) to take off the part, but it look like
> dir1 instead of dir3. Please someone tell me how to cut off the part
> which I do not need. $ENV{HTTP_REFERER} =
> http://www.domain.com/dir1/dir2/dir3/, but I do not need
> http://www.domain.com/dir1/dir2// and need dir3.
One thing you need to take into account is that HTTP_REFERER is an
optional variable that may not exist or may be forged. You can usually
use it for non-security purposes if it has a value, but you should have
some method to handle the case that it is undefined.
my $dir;
if ($ENV{HTTP_REFERER} && $ENV{HTTP_REFERER} =~ m|/([^/]+)/[^/]*$|) {
$dir = $1;
} else {
$dir = "default";
}
--
David Efflandt - All spam ignored http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: Mon, 14 Oct 2002 22:29:40 +1000
From: "Tintin" <spam@all.costs.must.die>
Subject: Re: Regular Expression (Referer)
Message-Id: <3daab990$1_1@news.iprimus.com.au>
"kazchan" <kazchan@curio-city.com> wrote in message
news:3baaab4f.0210131609.25650220@posting.google.com...
> When I call my cgi script, I would like to control by referer. Ex: if
> the referer is http://www.domain.com/dir1/dir2/dir3/, I would like to
> display as dir3. I used (.*) to take off the part, but it look like
> dir1 instead of dir3. Please someone tell me how to cut off the part
> which I do not need. $ENV{HTTP_REFERER} =
> http://www.domain.com/dir1/dir2/dir3/, but I do not need
> http://www.domain.com/dir1/dir2// and need dir3.
perldoc -f basename
------------------------------
Date: 13 Oct 2002 21:09:34 -0700
From: ranam@ue.com.au (Ravi)
Subject: Split of very large text file
Message-Id: <66d1df6a.0210132009.61370e3c@posting.google.com>
Hi All,
Here's my problem:
I have a very large file (between 70-110 Mb of Ascii) composed of one
single line, that I need to split into multiple lines. This file is a
log of one of our running daemons and the daemon just appends messages
onto the end of the line.
There is a message header though, (XYZ2000), at the start of each
message that gets appended. What I would like is to be able to split
the line according to that header, so that each new line looks
something like :
XTY2000adasgfsgdsgsd g...
XTY2000gjhfgjfgjhfgjfgjh...
XTY2000qweqeqwreqrq...etc
and so on.
I don't want to read the entire file into a variable and then split by
the XTY2000 pattern as this will tie up memory. Is there a way to
split this file on the fly ? Any suggestions will be appreciated.
Thanks in advance.
ravi...
------------------------------
Date: Mon, 14 Oct 2002 14:51:44 +1000
From: Martien Verbruggen <mgjv@tradingpost.com.au>
Subject: Re: Split of very large text file
Message-Id: <slrnaqkjb0.q36.mgjv@martien.heliotrope.home>
On 13 Oct 2002 21:09:34 -0700,
Ravi <ranam@ue.com.au> wrote:
> Hi All,
>
> Here's my problem:
>
> I have a very large file (between 70-110 Mb of Ascii) composed of one
> single line, that I need to split into multiple lines. This file is a
> log of one of our running daemons and the daemon just appends messages
> onto the end of the line.
I'd say that that is a severely brain-damaged daemon. Are you sure that
you don't have newlines? This is not a Unix text file that you're trying
to work with on a MS platform, right?
> There is a message header though, (XYZ2000), at the start of each
> message that gets appended. What I would like is to be able to split
> the line according to that header, so that each new line looks
> something like :
>
> XTY2000adasgfsgdsgsd g...
> XTY2000gjhfgjfgjhfgjfgjh...
> XTY2000qweqeqwreqrq...etc
I thought it was XYZ2000?
> and so on.
>
> I don't want to read the entire file into a variable and then split by
> the XTY2000 pattern as this will tie up memory. Is there a way to
> split this file on the fly ? Any suggestions will be appreciated.
> Thanks in advance.
One way of doing it (note the flags to perl):
#!/usr/local/bin/perl -wnl
use strict;
BEGIN { $/ = "XTY2000" }
next if $. == 1;
chomp;
print "$/$_";
if you don't really need the XTY2000 bit, and you don't mind an initial
empty line you can simplify it even more:
#!/usr/local/bin/perl -wpl
use strict;
BEGIN { $/ = "XTY2000" }
chomp;
Look up -n, -p and -l in perlrun and $/ in perlvar.
Martien
--
|
Martien Verbruggen | life ain't fair, but the root password helps.
| -- BOFH
|
------------------------------
Date: Mon, 14 Oct 2002 05:23:00 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Split of very large text file
Message-Id: <3DAA548D.230E2302@acm.org>
Ravi wrote:
>
> Here's my problem:
>
> I have a very large file (between 70-110 Mb of Ascii) composed of one
> single line, that I need to split into multiple lines. This file is a
> log of one of our running daemons and the daemon just appends messages
> onto the end of the line.
>
> There is a message header though, (XYZ2000), at the start of each
> message that gets appended. What I would like is to be able to split
> the line according to that header, so that each new line looks
> something like :
>
> XTY2000adasgfsgdsgsd g...
> XTY2000gjhfgjfgjhfgjfgjh...
> XTY2000qweqeqwreqrq...etc
>
> and so on.
>
> I don't want to read the entire file into a variable and then split by
> the XTY2000 pattern as this will tie up memory. Is there a way to
> split this file on the fly ? Any suggestions will be appreciated.
perl -i~ -lpe'BEGIN{$\="\n".($/="XTY2000")}' yourfile
John
--
use Perl;
program
fulfillment
------------------------------
Date: 14 Oct 2002 04:42:15 -0700
From: ajc81@hotmail.com (Andrew Cashin)
Subject: Splitting CSV lines
Message-Id: <49b3792a.0210140342.504a9d07@posting.google.com>
If anyone is interested, or (even better) has suggested improvements,
here is a code fragment which copes (somewhat) with CSV lines where
individual elements may or may not be quoted, but will be quoted if they
contain either quotes (which will be quoted by doubling i.e. "") or commas.
#!/usr/bin/perl -wn
# Copyright notice: Under the terms of my employment contract, I claim
# that, as I have met the terms, this work is an employee invention (meaning
# that I own it). Anyone may freely use it under the same terms
# as perl itself. I don't promise that it will help, and refer all to the
# unsplit_csv perl module on CPAN.
sub split_csv
{
my ($csv_string) = @_;
my (@outels, @elements, $thisel, $nextel, $i, $l);
@elements=split(/,/);
while (@elements) {
$thisel = shift @elements;
if ( $thisel =~ s/^"// ) {
while (@elements) {
if ($thisel =~ m/("+)$/) {
$l=length($1);
if ($l % 2) {
last;
}
}
$nextel = shift @elements;
$thisel = $thisel.",".$nextel;
}
chop $thisel;
$thisel =~ s/""/"/g;
}
unshift (@outels, $thisel);
}
return reverse @outels;
}
print;
@els = split_csv;
$i=0;
foreach $e (@els)
{
print "$i :$e:\n";
$i++;
}
------------------------------
Date: Mon, 14 Oct 2002 05:36:06 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Switching from Python to Perl
Message-Id: <Xns92A74333478B4sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Derek Thomson <derek@wedgetail.com> wrote in news:3da91047$0$23169$afc38c87
@news.optusnet.com.au:
> Why do you ask? Why does it have to be mutually exclusive? Can't you
> like and use both? I am also using, right now, in some capacity, C,
> Java, Tcl, Lisp (my Emacs functions!) and I've done a fair bit of C++ in
> the past.
I agree. I use (mostly) Perl, C, and various webbish languages (html,
javascript, etc); it's pretty obvious which language is appropriate when.
[dons flameproof suit]
I confess my ignorance of python. Every now and then I think "maybe I
should learn it"... but then I think "Perl does everything I can imagine
doing, why bother learning python?"
[for the record, I often think "Maybe I should learn java", then I start to
do so, then I realize "Man! This is hard! Perl does all of this so much
easier!"]
So anyhow, for someone who's ignorant of python, what's it good at? The
same sorts of things as Perl? If so, why bother learning it? If not, what
are its strengths over Perl, and what are Perl's strengths over python?
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPaqeI2PeouIeTNHoEQIbaACg1jQEPjMSN8+Yu3JdcGm79bnGg/AAnRfT
232UnjGmiFddUA4GlqrJ3Lus
=ESYm
-----END PGP SIGNATURE-----
------------------------------
Date: Mon, 14 Oct 2002 03:47:14 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: What purpose does eval{ ... } server?
Message-Id: <141020020347145223%comdog@panix.com>
In article <3DA9D8BB.A7163933@earthlink.net>, Benjamin Goldberg <goldbb2@earthlink.net> wrote:
> Paul Tomlinson wrote:
> > What purpose does eval{ ... } server?
> It catches errors created with die().
a lot of people said that, but it's such a small part of eval {} which
catches a lot more. i mostly use it with division in case the denominator
is zero:
$quotient = eval { $m / $n };
--
brian d foy <comdog@panix.com> - Perl services for hire
The Perl Review - a new magazine devoted to Perl
<http://www.theperlreview.com>
------------------------------
Date: 14 Oct 2002 08:59:05 GMT
From: "Tassilo v. Parseval" <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: What purpose does eval{ ... } server?
Message-Id: <aoe10p$fqb$1@nets3.rz.RWTH-Aachen.DE>
Also sprach brian d foy:
> In article <3DA9D8BB.A7163933@earthlink.net>, Benjamin Goldberg <goldbb2@earthlink.net> wrote:
>
>> Paul Tomlinson wrote:
>
>> > What purpose does eval{ ... } server?
>
>> It catches errors created with die().
>
> a lot of people said that, but it's such a small part of eval {} which
> catches a lot more. i mostly use it with division in case the denominator
> is zero:
>
> $quotient = eval { $m / $n };
But in case the denominator is zero, this will die() so your eval{} does
nothing else than trapping a die(). :-)
Tassilo
--
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;
------------------------------
Date: Mon, 14 Oct 2002 10:39:42 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: What purpose does eval{ ... } server?
Message-Id: <gi7lqu0bn7ectj3o3fnc873a2rvir0iut2@4ax.com>
Tassilo v. Parseval wrote:
[lots of attributions snipped]
>>> > What purpose does eval{ ... } server?
>>
>>> It catches errors created with die().
>>
>> a lot of people said that, but it's such a small part of eval {} which
>> catches a lot more. i mostly use it with division in case the denominator
>> is zero:
>>
>> $quotient = eval { $m / $n };
>
>But in case the denominator is zero, this will die() so your eval{} does
>nothing else than trapping a die(). :-)
Indeed. Just set $SIG{__DIE__} and you'll see it does die():
#! perl -w
$SIG{__DIE__} = sub { die "Oops: @_" };
print $a / $b;
-->
Name "main::a" used only once: possible typo at test.pl line 3.
Name "main::b" used only once: possible typo at test.pl line 3.
Use of uninitialized value in division (/) at test.pl line 3.
Use of uninitialized value in division (/) at test.pl line 3.
Oops: Illegal division by zero at test.pl line 3.
--
Bart.
------------------------------
Date: Mon, 14 Oct 2002 05:40:33 -0500
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Why is 'defined @x' deprecated?
Message-Id: <Xns92A743F4329F8sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Uri Guttman <uri@stemsystems.com> wrote in
news:x7u1jsk7qa.fsf@mail.sysarch.com:
> why do you want to know that difference? defined only reports whether
> the aggregate has ever had some memory allocated for data. it is not
> useful since that is below the hood from the rest of perl. if you
> explain your need for this info and the code around it, i am sure there
> is a better way to do it.
>
> the biggest reason it is bad is that it leads newbies to think defined
> on an aggregate will tell you if it has any elements in it which as you
> seem to know is wrong. this is now deprecated for that reason as no one
> should want to use defined for the allocation reason.
I have often wanted defined(@x) to work, and I find this deprecation
annoying. There have been many times when I have wanted to say "Has this
array been assigned a value, even the empty array value?"
my @arr; # undefined
@arr = (); # defined
Your argument, it seems to me, is tantamount to saying "Why should there be
an undefined state? Just use '' for uninitialized scalar variables; you
don't really need anything else."
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBPaqfLmPeouIeTNHoEQIFBwCggYKWwBU9H7coK6Fy2rFmjRXJ6awAoIZk
Au9qeSsilQMix4SAr+UGRkgN
=9MIM
-----END PGP SIGNATURE-----
------------------------------
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 3965
***************************************