[22713] in Perl-Users-Digest
Perl-Users Digest, Issue: 4934 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 5 00:05:53 2003
Date: Sun, 4 May 2003 21:05:07 -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 Sun, 4 May 2003 Volume: 10 Number: 4934
Today's topics:
Re: Adding time in perl <budman@intergrafix.net>
Re: calculating wait time <kalinabears@hdc.com.au>
Calling subs using '&' form <stevenm@bogus.blackwater-pacific.com>
Re: Calling subs using '&' form <stevenm@bogus.blackwater-pacific.com>
Re: Calling subs using '&' form <abigail@abigail.nl>
Re: converting a perl script into an exe file <pilsl_usenet@goldfisch.at>
Re: converting a perl script into an exe file (The Mosquito ScriptKiddiot)
Re: get most recent file with net::ftp <kalinabears@hdc.com.au>
Re: get most recent file with net::ftp <kalinabears@hdc.com.au>
Re: Get somthing between ( ) from a long string - how - (Damian James)
Re: How to compress and uncompress the files using the (Vinod. K)
Howto auth passwords <patrickm@troop98.org>
Re: Howto auth passwords <abigail@abigail.nl>
Ideas where to find tutorials for coding traffic trade <webmasterhcmf@yahoo.com>
Re: Ideas where to find tutorials for coding traffic tr <jkeen@concentric.net>
Re: Ideas where to find tutorials for coding traffic tr <webmasterhcmf@yahoo.com>
Re: Ideas where to find tutorials for coding traffic tr <jkeen@concentric.net>
Re: Ideas where to find tutorials for coding traffic tr <jkeen@concentric.net>
Re: Ideas where to find tutorials for coding traffic tr <webmasterhcmf@yahoo.com>
Re: Ideas where to find tutorials for coding traffic tr <jurgenex@hotmail.com>
Re: mod_perl subroutine/modules and variables problem <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Passing hash and string to subroutine <richp1234@hotmail.com>
Re: Passing hash and string to subroutine <jurgenex@hotmail.com>
Re: Passing hash and string to subroutine <noreply@gunnar.cc>
Re: Passing hash and string to subroutine <bob@nowhere.com>
Re: Passing hash and string to subroutine <jkeen@concentric.net>
Re: Quickie about a $scalar - convert it <anthony@no_spam.movielink.net.au>
Re: sending username and password for rsync <galenmenzel@yahoo.com>
Re: Sort array of numbers <abigail@abigail.nl>
Re: Sort array of numbers <noreply@gunnar.cc>
Re: Sort array of numbers <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 04 May 2003 22:40:42 -0400
From: RJones <budman@intergrafix.net>
To: ajmiller@crutchfield.com (AJ Miller)
Subject: Re: Adding time in perl
Message-Id: <pan.2003.05.05.02.40.31.657219@intergrafix.net>
On Fri, 02 May 2003 13:34:35 -0700, AJ Miller wrote:
> Hello,
>
> I have a list of start times and the duration of the event in the
> format
>
> start time duration
> 8:00 am 1000
> 10:00 am 800
> 1:30 pm 1030
>
Just adding time... sometimes it better to use the DateManip module
DateCalc. Also, ParseDate for time entry is a great tool.
Things to keep in mind, Time Zone changes (Daylight Savings Time),
and midnight wrap over.
The DateCalc can even do the math for you:
perl -MDate::Manip -e 'print DateCalc("8pm","+5hr"),"\n";'
perl -MDate::Manip -e 'print DateCalc("8pm","+3000sec"),"\n";'
perl -MDate::Manip -e
'$i=DateCalc("8pm","+3000sec");@p=$i=~/(\d{8})(.*)/;print "$p[0] $p[1]\n";'
20030504 20:50:00
Hope it helps,
Rich
------------------------------
Date: Mon, 5 May 2003 12:14:42 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: calculating wait time
Message-Id: <3eb5ca19$0$31078@echo-01.iinet.net.au>
"Jürgen Exner" <jurgenex@hotmail.com> wrote in message
news:1reta.11417$gf3.6804@nwrddc03.gnilink.net...
> Lee&James wrote:
> > This only gives me a granularity of seconds. Can someone tell me how
> > to get a granularity of milliseconds?
>
> The FAQ can: "perldoc -q second"
> How can I measure time under a second?
>
> jue
>
>
On win32 (which I think you're using, going by an earlier post), you could
also use the Win32 module function 'Win32::GetTickCount()' instead of
'time()'.
There may be other win32-specific solutions, too.
Cheers,
Rob
------------------------------
Date: Sun, 04 May 2003 19:10:19 -0700
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Calling subs using '&' form
Message-Id: <b94gri$ebk$1@quark.scn.rain.com>
I've recently noted with interest responses to posts indicating that the
'&' form of calling subs is a bad thing.
Hmmmm. I've been doing this for years, primarily because it is easy for
me to identify what is going on. And too, scripts broke in the past
when I tried to do it in the apparently approved method....
Being as I'm mostly self-mistaught, except for those perls of wisdom
(sorry) I pick up here and elsewhere I've been trying to understand what
the issue is and where my misunderstanding is.
Reading the camel book tells me that using that form will cause the
current args to be sent to the called subs unless the programmer
supplies some. Ok, but I don't see this as a problem for what I
normally do. The Camel book also talks about the '&' form disabling
prototyping, which (again) doesn't seem to be much of a problemm for
what I normally do. Am I totally wrong here? (wouldn't surprise me)
On the other hand, NOT using the '&' form will cause Perl to break in
certain cases.
Consider:
]# perl -v
This is perl, v5.6.0 built for i386-linux
# START FILE test_sub.pl (main executable)
#! /usr/bin/perl -w
use strict;
my $val = 'Hello World';
require "./test_sub_lib.pl" or die "can't require file: $!\n";
print_string( do_something );
exit 0;
sub print_string{
my $string = shift;
print $string;
}
# END FILE
# START FILE test_sub_lib.pl
sub do_something{ return 'Hello World'; }
1;
# END FILE
# at the command line:
]# ./test_sub.pl
Bareword "do_something" not allowed while "strict subs" in use <snip>
Execution of ./test_sub.pl aborted due to compilation errors.
If this is rewritten to use the '&' form it works fine.
Hmmmm.... again.
So, probably someone has written a clear and succinct explanation that
I've missed or there is a page somewhere that I could be pointed to
which would help me clarify my thinking on this?
Because at this point I see no good reason to change my habits and at
least one good one to continue as always...
tia,
s.
------------------------------
Date: Sun, 04 May 2003 19:12:26 -0700
From: Steve May <stevenm@bogus.blackwater-pacific.com>
Subject: Re: Calling subs using '&' form
Message-Id: <b94gvk$ec2$1@quark.scn.rain.com>
Steve May wrote:
> I've recently noted with interest responses to posts indicating that the
> '&' form of calling subs is a bad thing.
>
> Hmmmm. I've been doing this for years, primarily because it is easy for
> me to identify what is going on. And too, scripts broke in the past
> when I tried to do it in the apparently approved method....
>
> Being as I'm mostly self-mistaught, except for those perls of wisdom
> (sorry) I pick up here and elsewhere I've been trying to understand what
> the issue is and where my misunderstanding is.
>
> Reading the camel book tells me that using that form will cause the
> current args to be sent to the called subs unless the programmer
> supplies some. Ok, but I don't see this as a problem for what I
> normally do. The Camel book also talks about the '&' form disabling
> prototyping, which (again) doesn't seem to be much of a problemm for
> what I normally do. Am I totally wrong here? (wouldn't surprise me)
>
>
> On the other hand, NOT using the '&' form will cause Perl to break in
> certain cases.
>
> Consider:
>
> ]# perl -v
> This is perl, v5.6.0 built for i386-linux
>
>
> # START FILE test_sub.pl (main executable)
>
> #! /usr/bin/perl -w
> use strict;
>
> my $val = 'Hello World';
^^^^^ Leftover trash, please ignore....
> require "./test_sub_lib.pl" or die "can't require file: $!\n";
>
> print_string( do_something );
>
> exit 0;
>
> sub print_string{
> my $string = shift;
> print $string;
> }
>
> # END FILE
>
> # START FILE test_sub_lib.pl
>
> sub do_something{ return 'Hello World'; }
>
> 1;
> # END FILE
>
>
> # at the command line:
>
> ]# ./test_sub.pl
> Bareword "do_something" not allowed while "strict subs" in use <snip>
> Execution of ./test_sub.pl aborted due to compilation errors.
>
>
> If this is rewritten to use the '&' form it works fine.
>
> Hmmmm.... again.
>
> So, probably someone has written a clear and succinct explanation that
> I've missed or there is a page somewhere that I could be pointed to
> which would help me clarify my thinking on this?
>
> Because at this point I see no good reason to change my habits and at
> least one good one to continue as always...
>
> tia,
>
> s.
>
------------------------------
Date: 05 May 2003 02:21:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Calling subs using '&' form
Message-Id: <slrnbbbikj.fj.abigail@alexandra.abigail.nl>
Steve May (stevenm@bogus.blackwater-pacific.com) wrote on MMMDXXXIV
September MCMXCIII in <URL:news:b94gri$ebk$1@quark.scn.rain.com>:
() I've recently noted with interest responses to posts indicating that the
() '&' form of calling subs is a bad thing.
Blah. There are a lot of people who consider coding Perl to be a cult,
for which you shall follow certain rituals, or else you will be doomed
or not. Use of '&' is such a thing. As you have already analized yourself,
there are some differences between using '&sub', '&sub ()', 'sub ()'
and 'sub'. As long as you are aware of the differences, feel free to
use '&' in front of user subroutines.
Personally, I never used them, except in a few cases when dealing with
code references. As direct subroutine calls, I won't. But it doesn't
bother me if someone does - I certainly won't consider it a "bad thing".
Abigail
--
$"=$,;*{;qq{@{[(A..Z)[qq[0020191411140003]=~m[..]g]]}}}=*_;
sub _ {push @_ => /::(.*)/s and goto &{ shift}}
sub shift {print shift; @_ and goto &{+shift}}
Hack ("Just", "Perl ", " ano", "er\n", "ther "); # 20030505
------------------------------
Date: Mon, 5 May 2003 00:12:30 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: converting a perl script into an exe file
Message-Id: <3eb590ac$1@e-post.inode.at>
The Mosquito ScriptKiddiot wrote:
> hey,
>
> i need to write a perl script and convert it into an exe which can be then
> be either linked to or called by my program...what program do i need to do
> this?
>
for really compiling your perl script into byte-code, you can look at the
faq (perldoc -f compile), but I doubt if this is what you really want.
If you want to create a perl-script that can be executed from everywhere
you need to assign the script-extension (pl) to your perl-interpreter on
windows and put the script in a path where it can be found. (c:\windows is
a first step, but look at the PATH environment-variable)
See 'assign /?'
Or you simply call 'perl script' from your program.
peter
--
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: 05 May 2003 00:24:13 GMT
From: anotherway83@aol.comnospam (The Mosquito ScriptKiddiot)
Subject: Re: converting a perl script into an exe file
Message-Id: <20030504202413.08359.00000606@mb-m04.aol.com>
thanks, but i think i found what i was looking for, its called perl2exe =)
--The Mosquito Scriptkiddiot.
"There are two sides to every story...and then there is what really happened."
;p
------------------------------
Date: Mon, 5 May 2003 12:31:07 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: get most recent file with net::ftp
Message-Id: <3eb5cdf2$0$31089@echo-01.iinet.net.au>
"jdlail" <jdlail@hotmail.com> wrote in message
news:e32bb269.0305040622.d6b566e@posting.google.com...
> How do retrieve only the most recent file from an ftp directory usint
net::ftp?
>
> I need to get the most recent file with a *.zip extension.
>
> -- jack lail
Only possibility I can see from the docs is 'mdtm', and I don't know if
that's reliable (and universally available).
Try along the lines of (untested):
.
.
my @files = (#all of the *.zip files);
my $t = 0;
my $select;
for(@files) {
my $modification_time = ftp->mdtm($_);
if($modification_time > $t) {
$t = $modification_time;
$select = $_;
}
}
ftp->get($select);
.
.
Hth.
Cheers,
Rob
------------------------------
Date: Mon, 5 May 2003 12:55:12 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: get most recent file with net::ftp
Message-Id: <3eb5d397$0$31072@echo-01.iinet.net.au>
"Sisyphus" <kalinabears@hdc.com.au> wrote in message
>
> Try along the lines of (untested):
> .
> .
> my @files = (#all of the *.zip files);
> my $t = 0;
> my $select;
> for(@files) {
> my $modification_time = ftp->mdtm($_);
> if($modification_time > $t) {
> $t = $modification_time;
> $select = $_;
> }
> }
> ftp->get($select);
> .
> .
Probably better if you 'use strict;' and 'use warnings;' ..... and put a '$'
symbol in front of every occurrence of 'ftp'.
Hope that's *all* I missed :-)
Cheers,
Rob
------------------------------
Date: 4 May 2003 22:34:20 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Get somthing between ( ) from a long string - how - newbie Q
Message-Id: <slrnbbb5bc.5ka.damian@puma.qimr.edu.au>
On Fri, 2 May 2003 18:00:04 GMT, Michael P. Broida said:
>Damian James wrote:
>> ...
>> But then you have to worry about embedded commas. Do you want to
>> allow them if escaped (\,)? Does every field have quotes around it?
>
> Oops, you're correct. I hadn't even thought about
> commas inside the quotes. I guess his solution will
> depend on just what those strings CAN have in them.
> If their content is limited, then he can use a
> simpler solution.
Yes, but CSV fields are a solved problem. Since there are many
possiblities with the content of the fields, parsing them with REs is
unwieldly and likely to lead to subtle and maddening bugs down the
track. Much better to use a module like Text::CSV, or any of the other
parsing modules available from CPAN.
Cheers,
Damian
------------------------------
Date: 4 May 2003 20:52:00 -0700
From: pkvinu@indiatimes.com (Vinod. K)
Subject: Re: How to compress and uncompress the files using the perl program
Message-Id: <bde4ceed.0305041952.86e54d1@posting.google.com>
anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message news:<b8l8gb$226$1@mamenchi.zrz.TU-Berlin.DE>...
> Vinod. K <pkvinu@indiatimes.com> wrote in comp.lang.perl.misc:
> > anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> > news:<b8ir0k$bl2$2@mamenchi.zrz.TU-Berlin.DE>...
> > > Vinod. K <pkvinu@indiatimes.com> wrote in comp.lang.perl.misc:
> > > > Hello All,
> > > >
> > > >
> > > > I am having a bunch of compressed files(database files, i.e .dbf files
> > > > whose size is more than 1GB) in one area. All these files need to be
> > > > uncompressed one after the other and put them in other location using
> > > > perl script. presently I used - system "uncompress" - statement in my
> > > > perl script which is consuming considerably more time. Just I want
> > > > know is there any module or any other command in perl which will
> > > > perform the above said activity in lesser time???
> > >
> >
> >
> >
> > > There may be such modules, but they won't run significantly faster.
> > > All you can save is the call time for an external program. The time-
> > > consuming expansion will be the same in both cases.
> > >
> > > Anno
> >
> >
> > Hi Anno,
> > Thanks for ur immediate response. Do you have any idea about those modules ???
>
> Do a CPAN search at http://theoryx5.uwinnipeg.ca/CPAN/cpan-search.html.
>
> Anno
I didn't get any modules/scripts which satisfies my requirements.
Anyway ,thanks,anno.
- Vinod.
------------------------------
Date: Mon, 05 May 2003 00:23:07 GMT
From: Patrick McDonnell <patrickm@troop98.org>
Subject: Howto auth passwords
Message-Id: <L9ita.492445$Zo.108422@sccrnsc03>
Hi - I'm working on a chat server/client in Perl. The server (cut&pasted
below) I just copied from a chat server tutorial. The client I am writing
my self using Tk and Net::Telnet. I don't want to allow anyone to connect
to the server, however - only the users listed in /etc/passwd. Therefore,
I would have to have the client send a username/pw combo and the server
would have to authenticate it. But, I how can get this kind of
communication to occur? I know how to check the passwords once the server
has them, but I don't know how to send the username/pw to the server, and
for the server to send back a permission granted/denied to the client. If
anyone could direct me to any resources, I'd appreciate it very much.
Thanks!
-Server.pl-
#!/usr/bin/perl
use IO::Socket;
use IO::Select;
$max_msglen = 1024;
$max_clients = 20;
$port = 7070;
$new_client = IO::Socket::INET->new(Proto=>"tcp", LocalPort=>$port,
Listen=>$max_clients, Reuse=>1);
$sel = IO::Select->new($new_client);
print "listening at port $port\n";
while (@ready = $sel->can_read) {
foreach $client (@ready) {
if ($client == $new_client) {
$add = $client->accept;
$add->blocking(0);
$sel->add($add);
$message = "[Welcome user ".$add->peerhost.":".$add->peerport."! You can
leave the chat by entering \"quit\" | ".($sel->count - 1)." user(s)
online]\n\n";
sendall($message);
} else {
$msg = "";
$nread = sysread($client, $msg, $max_msglen);
chop($msg); chop($msg);
if ($msg eq "quit") {
$message = "[User ".$client->peerhost.":".$client->peerport." left |
".($sel->count - 2)." user(s) online]\n\n";
sendall($message);
$sel->remove($client);
close $client;
} elsif ($nread) {
$message = "[".$client->peerhost.":".$client->peerport."] ".$msg."\n";
sendall($message);
}
}
}
}
sub sendall {
my ($msg) = @_;
foreach ($sel->can_write) { syswrite($_, $msg, length($msg)) }
}
sub getmsg {
my ($handle) = @_;
my $msg = "";
do {
$nread = sysread($handle, $in, 1024);
$msg .= $in;
} while ($nread > 0);
return($msg);
}
------------------------------
Date: 05 May 2003 00:50:19 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Howto auth passwords
Message-Id: <slrnbbbdab.fj.abigail@alexandra.abigail.nl>
Patrick McDonnell (patrickm@troop98.org) wrote on MMMDXXXIV September
MCMXCIII in <URL:news:L9ita.492445$Zo.108422@sccrnsc03>:
%% Hi - I'm working on a chat server/client in Perl. The server (cut&pasted
%% below) I just copied from a chat server tutorial. The client I am writing
%% my self using Tk and Net::Telnet. I don't want to allow anyone to connect
%% to the server, however - only the users listed in /etc/passwd. Therefore,
%% I would have to have the client send a username/pw combo and the server
%% would have to authenticate it. But, I how can get this kind of
%% communication to occur? I know how to check the passwords once the server
%% has them, but I don't know how to send the username/pw to the server, and
Is it that you don't know how to send anything to the server?
Because, sending a username or password is just the same as sending
"I am a test message" - it's just data.
%% for the server to send back a permission granted/denied to the client. If
unless (ok ($user, $password)) {
print $sock "Permission denied\x0D\x0A";
close $sock;
exit;
}
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
------------------------------
Date: Sun, 04 May 2003 23:58:33 GMT
From: "hobgoblin" <webmasterhcmf@yahoo.com>
Subject: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <JOhta.37194$D%4.35751@nwrdny03.gnilink.net>
My friend and I are newer to the language and thus far have successfully put
together a basic toplist in Perl.
Any suggestions or helpful flames would be greatly appreciated.
Kind Regards,
Hobgoblin
------------------------------
Date: 05 May 2003 02:38:14 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <b94iqm$2m4@dispatch.concentric.net>
"hobgoblin" <webmasterhcmf@yahoo.com> wrote in message
news:JOhta.37194$D%4.35751@nwrdny03.gnilink.net...
> My friend and I are newer to the language and thus far have successfully
put
> together a basic toplist in Perl.
>
> Any suggestions or helpful flames would be greatly appreciated.
>
What do you mean by 'traffic trade script'? By 'toplist' do you mean topic
list?
------------------------------
Date: Mon, 05 May 2003 03:00:08 GMT
From: "hobgoblin" <webmasterhcmf@yahoo.com>
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <Yskta.42478$xw4.23644@nwrdny01.gnilink.net>
Thanks for taking the time to respond.
Sorry for being so unclear.
My friend and I are new to the language but have already been able to create
a very basic toplist that ranks referrer data using flat files. We're just
unsure where to look or
what to look for to learn how to proceed in expanding and/or improving
it's functionality in general.
We just wanted to be directed to relevant tutorials or resources in regards
to coding "traffic trading" scripts with Perl in a broader sense.
Specifically, we're interested in functions such as "updating stats in real
time", "skimming", "productivity tracking", and adjustable referrer "in/out
ratio's". We don't necessarily want to add these features, but we are
curious enough to want to take a look at how they work.
Kind Regards,
hobgoblin
"James E Keenan" <jkeen@concentric.net> wrote in message
news:b94iqm$2m4@dispatch.concentric.net...
>
> "hobgoblin" <webmasterhcmf@yahoo.com> wrote in message
> news:JOhta.37194$D%4.35751@nwrdny03.gnilink.net...
> > My friend and I are newer to the language and thus far have successfully
> put
> > together a basic toplist in Perl.
> >
> > Any suggestions or helpful flames would be greatly appreciated.
> >
> What do you mean by 'traffic trade script'? By 'toplist' do you mean
topic
> list?
>
>
------------------------------
Date: 05 May 2003 03:00:32 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <b94k4g$25@dispatch.concentric.net>
"hobgoblin" <webmasterhcmf@yahoo.com> wrote in message
news:JOhta.37194$D%4.35751@nwrdny03.gnilink.net...
>
> Any suggestions or helpful flames would be greatly appreciated.
>
Many people find cross-posting annoying. I've seen virtually the same
message on 3 different lists tonight.
------------------------------
Date: 05 May 2003 03:09:23 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <b94kl3$pf@dispatch.concentric.net>
"hobgoblin" <webmasterhcmf@yahoo.com> wrote in message
news:Yskta.42478$xw4.23644@nwrdny01.gnilink.net...
> Thanks for taking the time to respond.
>
> Sorry for being so unclear.
>
> My friend and I are new to the language but have already been able to
create
> a very basic toplist that ranks referrer data using flat files. We're just
> unsure where to look or
> what to look for to learn how to proceed in expanding and/or improving
> it's functionality in general.
>
> We just wanted to be directed to relevant tutorials or resources in
regards
> to coding "traffic trading" scripts with Perl in a broader sense.
>
> Specifically, we're interested in functions such as "updating stats in
real
> time", "skimming", "productivity tracking", and adjustable referrer
"in/out
> ratio's". We don't necessarily want to add these features, but we are
> curious enough to want to take a look at how they work.
>
Okay, now you've given us more to go on. Unfortunately, I don't have a
ready response. Google searches for the comp.lang.perl.* family of Usenet
groups shows no matches for 'traffic trading' and 'Perl'. But if you are
extracting data from flat files, you should probably be studying the
Perl::DBI interface. Either go to search.cpan.org or get the O'Reilly book
of that title.
------------------------------
Date: Mon, 05 May 2003 03:15:57 GMT
From: "hobgoblin" <webmasterhcmf@yahoo.com>
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <NHkta.42481$xw4.41566@nwrdny01.gnilink.net>
Sorry for my poor NG posting etiquette. I admit that I have posted this
request for a point-to on several Groups.
Apologies if I have offended or annoyed those who subscribe across multiple
groups which happen to be the same as those I posted similar topics in.
If it's necessary, please flame away.
Kind Regards,
hobgoblin
"James E Keenan" <jkeen@concentric.net> wrote in message
news:b94k4g$25@dispatch.concentric.net...
>
> "hobgoblin" <webmasterhcmf@yahoo.com> wrote in message
> news:JOhta.37194$D%4.35751@nwrdny03.gnilink.net...
> >
> > Any suggestions or helpful flames would be greatly appreciated.
> >
> Many people find cross-posting annoying. I've seen virtually the same
> message on 3 different lists tonight.
>
>
------------------------------
Date: Mon, 05 May 2003 03:29:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Ideas where to find tutorials for coding traffic trade scripts in Perl ?
Message-Id: <RUkta.13010$gf3.8522@nwrddc03.gnilink.net>
James E Keenan wrote:
> "hobgoblin" <webmasterhcmf@yahoo.com> wrote in message
> news:JOhta.37194$D%4.35751@nwrdny03.gnilink.net...
>>
>> Any suggestions or helpful flames would be greatly appreciated.
>>
> Many people find cross-posting annoying. I've seen virtually the same
> message on 3 different lists tonight.
Actually cross-postings wouldn't have been that bad, in particular if they
would have had a F'up.
But he multi-posted and that ist much more annoying.
jue
------------------------------
Date: Mon, 5 May 2003 00:52:38 +0200
From: "alex" <ntnewsNOSPAM@hrz3.hrz.tu-darmstadt.de>
Subject: Re: mod_perl subroutine/modules and variables problem
Message-Id: <b945jn$h2r$00$1@news.t-online.com>
hi
how to correct all this things? in the past this wasn't inside the script. i
have realy only tryed/played with this "package"... without any knowledge
about the real function behind this. i have read a docu about mod_perl
specific problems with subs in other scripts and i need to give teh package
name with it... realy - i'd like to get this running without any errors. i
have changed in the last weeks many things and one of it is the "our" for
all vars - and it has realy worked without any errors in strict and
warnings - bit since i have moved the app to mod_perl - nothing will work
:-(((
Alex
------------------------------
Date: Sun, 04 May 2003 17:34:15 -0700
From: Rich Pasco <richp1234@hotmail.com>
Subject: Passing hash and string to subroutine
Message-Id: <3EB5B187.3040501@hotmail.com>
Is it possible in Perl to pass two parameters to a subroutine,
one of which is a hash and one of which is a string? It sounds
easy enough but the example below doesn't work (it doesn't print
anything for $body):
#pass both a hash and a string
my (%criterion, $text);
$criterion{'a'} = 'AAA';
$criterion{'b'} = 'BBB';
$text = 'The Quick Brown Fox';
process_events(%criterion,$text);
exit;
sub process_events {
my(%criteria, $body) = @_;
print "a=$criteria{'a'}\n";
print "b=$criteria{'b'}\n";
print "\nbody = $body\n";
}
------------------------------
Date: Mon, 05 May 2003 00:49:09 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Passing hash and string to subroutine
Message-Id: <9yita.11968$gf3.5755@nwrddc03.gnilink.net>
Rich Pasco wrote:
> Is it possible in Perl to pass two parameters to a subroutine,
> one of which is a hash and one of which is a string? It sounds
> easy enough but the example below doesn't work (it doesn't print
> anything for $body):
You must have missed the thread
"Is it possible to pass @somethig and $something_else to sub"
which was discussed here in this very NG over the last 2 weeks.
jue
------------------------------
Date: Mon, 05 May 2003 03:16:19 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Passing hash and string to subroutine
Message-Id: <b94e79$fe9kd$1@ID-184292.news.dfncis.de>
Rich Pasco wrote:
> Is it possible in Perl to pass two parameters to a subroutine,
> one of which is a hash and one of which is a string? It sounds
> easy enough but the example below doesn't work (it doesn't print
> anything for $body):
The subroutine receives a list of elements, without knowing whether
the elements were originaly stored in scalars, arrays, or hashes. Your
example works if you pass and grab them in the opposite order:
sub process_events {
my($body,%criteria) = @_;
print "a=$criteria{'a'}\n";
print "b=$criteria{'b'}\n";
print "\nbody = $body\n";
}
#pass both a hash and a string
my (%criterion, $text);
$criterion{'a'} = 'AAA';
$criterion{'b'} = 'BBB';
$text = 'The Quick Brown Fox';
process_events($text,%criterion);
exit;
Your originally posted code resulted in the variable
$criteria{'The Quick Brown Fox'}
being declared, but without any value. If you had run your code with
warnings enabled, Perl would have warned you about assigning an odd
number of elements to the hash.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 04 May 2003 21:37:18 -0500
From: bob <bob@nowhere.com>
Subject: Re: Passing hash and string to subroutine
Message-Id: <3eb5ce4e$1_1@127.0.0.1>
2 Ways:
1:
Pass the scalars first, then the hash:
process_events($text, %criterion);
sub process_events {
my($body,%criterion) = @_;
# etc.
2: Pass the hash by reference:
process_events(\%criterion,$text);
# ^ takes reference
sub process_events {
my($ref_criteria, $body) = @_;
print "a=$ref_criteria->{'a'}\n";
# ^^ uses reference ("dereferences")
print "b=$ref_criteria->{'b'}\n";
# ^^ uses reference ("dereferences")
# etc.
More info in 'perldoc perlref'
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
------------------------------
Date: 05 May 2003 02:38:16 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: Passing hash and string to subroutine
Message-Id: <b94iqo$2m4@dispatch.concentric.net>
"Rich Pasco" <richp1234@hotmail.com> wrote in message
news:3EB5B187.3040501@hotmail.com...
> Is it possible in Perl to pass two parameters to a subroutine,
> one of which is a hash and one of which is a string?
Pass the hash by reference:
process_events(\%criterion,$text);
------------------------------
Date: Mon, 05 May 2003 10:57:46 +1000
From: "Tony" <anthony@no_spam.movielink.net.au>
Subject: Re: Quickie about a $scalar - convert it
Message-Id: <pan.2003.05.05.00.57.45.458480@no_spam.movielink.net.au>
On Fri, 02 May 2003 03:44:06 +0200, Gunnar Hjalmarsson wrote:
> Tony wrote:
>> The "substr" in your split did it - I have some catching up
>> to do on regexes, they are a bit hard to get around.
>
> Well, when I saw Tad's solution, I realized that it can easily be both
> simplified and improved:
>
> @ar = split /"\s*,\s*"/, substr $scalar, 2, -2;
Thanks for that Gunnar (And Tad) for the help...
(Tested the above, works fine).
I do not expect people to "serve things on a silver platter"
but to point me in the right direction for solving things.
The only way to learn is to try to construct things based
on the docs + understanding rather than just "copying" stuff.
The little project I am doing looked daunting at first but
my decission to use perl has probably saved me some grief.
Originally it was suggested I use Visual Basic (Argh...) but
with all the perl stuff around and the need to manipulate
text strings made it easy to decide...
VB would have "forced" me to "that other platform"....
> perlfaq, in this case perlfaq4, is always good when you are asking
> yourself "How do I...".
Good idea - will look there next.
> And modules, of course. Tad pointed you to Text::ParseWords, for instance.
>
>> For a beginner it seems that a lot of the DOCS are a bit
> No need to tell me. I'm also at a beginner level; just trying to help
> out with a few questions which I feel comfortable with. ;-)
Now to complete my program I am doing some "fork" and PID's
A bit teious - have got some suggestions here before on that. Now that
my program is fundamentally functional I just need to add these things.
Best regards
Tony
--
--------------------------------------------------------------
To reply directly send to: anthony AT movielink DOT net DOT au
Replace AT and DOT with @ and . and mail will get through.
Any spammers will be persued until they get booted off the net
------------------------------
Date: 5 May 2003 00:50:42 GMT
From: Galen Menzel <galenmenzel@yahoo.com>
Subject: Re: sending username and password for rsync
Message-Id: <slrnbbbdhg.e3b.galenmenzel@localhost.localdomain>
Amit Kaushal wrote:
> Hi,
>
> what i want to do is automate/ cron the rsync login. The rsync version
> is rsync version 2.5.6 protocol version 26.
>
> I have to, from my machine, initiate the rsync protocoal and log in to
> another machine on a different network. Right now i am doing it
> manually.
> The steps are as follows:
>
> 1) rsync -avvv -e ssh rsync@xxx.xxx.xxx.xxx:files_outgoing/
> /home/amit/files/UPLOADED/
>
> The screen output is as follows:
>
> opening connection using ssh xxx.xxx.xxx.xxx -l rsync rsync --server
> --sender -vvvlogDtpr . files_outgoing/
> rsync@xxx.xxx.xxx.xxx's password:
>
> Now at this point i have to manually enter the password.
>
> I want to cron this activity, for doing that i need to send the step 1
> and the password in step two. As i am trying to cron it, i am unable
> to pass the password. I have been told that i can do it using perl.
>
> Will someone point me in the correct direction or post a generic
> script so that after reading it i would be in a position to write the
> script.
There's a perl module called Expect that will do what you need. It
depends on the IO::Pty module and the author recommends that you also
install the IO::Stty module with it. If you're using the CPAN module,
you can get everything at once by installing the Bundle::Expect
module. Otherwise you'll have to install each one by hand.
Note that the Expect module's interface is based on the original
Tcl/Expect tool available here:
http://expect.nist.gov/
I haven't used the perl module, but Tcl/Expect for something like this
is dirt simple. I'd probably be inclined to use it over perl since
this is what it's made for, and my guess is that it's simpler to
install and use if you're new to both. Of course if you just want to
use perl because it's so fun, I'm sure it'll work.
Make sure you really want to have the rsync password sitting in a
script somewhere.
Hope this helps.
galen
------------------------------
Date: 04 May 2003 23:27:42 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Sort array of numbers
Message-Id: <slrnbbb8fe.fj.abigail@alexandra.abigail.nl>
012 (motis@lyciumnetworks.com) wrote on MMMDXXXIII September MCMXCIII in
<URL:news:3eb4d870@news.012.net.il>:
-: Hi
-: I'm looking for a way to sort aray of numbers. When I use the regular sort I
-: get:
-: 0 1 10 11 2 3 4 5 6 7 8 9
-:
-: Is there a simple way to handle that?
No, it's really, really complicated. It involves getting permission from
the prime ministers of at least a dozen countries, on four continents.
And you have to pass a medical exam.
You could have read all of the requirements in the manual page.
Abigail
--
BEGIN {$^H {join "" => ("a" .. "z") [8, 13, 19, 4, 6, 4, 17]} = sub
{["", "Just ", "another ", "Perl ", "Hacker"] -> [shift]};
$^H = hex join "" => reverse map {int ($_ / 2)} 0 .. 4}
print 1, 2, 3, 4, "\n";
------------------------------
Date: Mon, 05 May 2003 02:07:36 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Sort array of numbers
Message-Id: <b94a6b$dv8r3$1@ID-184292.news.dfncis.de>
Abigail wrote:
> 012 (motis@lyciumnetworks.com) wrote on MMMDXXXIII September
> MCMXCIII in <URL:news:3eb4d870@news.012.net.il>:
> -: Hi
> -: I'm looking for a way to sort aray of numbers. When I use the
> -: regular sort I get:
> -: 0 1 10 11 2 3 4 5 6 7 8 9
> -:
> -: Is there a simple way to handle that?
>
> No, it's really, really complicated. It involves getting permission
> from the prime ministers of at least a dozen countries, on four
> continents. And you have to pass a medical exam.
>
> You could have read all of the requirements in the manual page.
Sam Holden wrote:
> For goodness sake, it is one of the examples in the sort
> documentation.
>
> perldoc -f sort
>
> Is it that hard to read a couple of pages of documentation on the
> function you are using, before you waste the time of thousands of
> people around the world?
Jürgen Exner wrote:
> Did you bother to have even a cursory glance at the documention for
> the functions that you are using?
>
> Is there anything in the examples
> # sort lexically
> [...]
> # sort numerically ascending
> [...]
> # sort numerically descending
> [...]
> that you don't understand or have problems with?
>
> If yes then please ask more specifically and everyone will be happy
> to explain.
> If no then READ THE F****** MANUAL!
I have a confession to make: When checking for guidance about this
problem in perlfunc and the sort docs, the solution wasn't immediately
apparent to me. You need to know the exact meaning of "sort lexically"
respective "sort numerically" in order to find the answer via the
docs. I don't know about you guys, but I was not born with that
knowledge...
Message: No need to be rude or sarcastic. Not this time either.
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 05 May 2003 00:45:42 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Sort array of numbers
Message-Id: <slrnbbbd1m.fj.abigail@alexandra.abigail.nl>
Gunnar Hjalmarsson (noreply@gunnar.cc) wrote on MMMDXXXIV September
MCMXCIII in <URL:news:b94a6b$dv8r3$1@ID-184292.news.dfncis.de>:
&&
&& I have a confession to make: When checking for guidance about this
&& problem in perlfunc and the sort docs, the solution wasn't immediately
&& apparent to me. You need to know the exact meaning of "sort lexically"
&& respective "sort numerically" in order to find the answer via the
&& docs. I don't know about you guys, but I was not born with that
&& knowledge...
Well, even if you don't know what "numerically" means, if you ask
"how do I sort numbers", and then look up the manual page, finding
something labelled "numerically" should ring a bell. But even so,
if you grasp how sort works, seeing 'sort {$a <=> $b}' should tell
you that's how to use sort to sort numbers.
&& Message: No need to be rude or sarcastic. Not this time either.
Well, it's not that the poster gave any hints (s)he even bothered
to look up the manual page. Remember, this isn't comp.lang.perl.spoon-feed-me.
Abigail
--
$_ = "\x3C\x3C\x45\x4F\x54";
print if s/<<EOT/<<EOT/e;
Just another Perl Hacker
EOT
------------------------------
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 4934
***************************************