[19482] in Perl-Users-Digest
Perl-Users Digest, Issue: 1677 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Sep 1 21:05:43 2001
Date: Sat, 1 Sep 2001 18: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)
Message-Id: <999392707-v10-i1677@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 1 Sep 2001 Volume: 10 Number: 1677
Today's topics:
Re: a mystery to me: EOF <Juha.Laiho@iki.fi>
ActivePerl says Out of Memory, but I'm not out of memor (Jonadab the Unsightly One)
Re: Alternations in Parse::RecDescent (Damian Conway)
Re: Check for valid hex value <hekker@hoppa.la>
file tests and split match (dburch)
Re: file tests and split match <krahnj@acm.org>
Re: file tests and split match (E.Chang)
Re: file tests and split match (dburch)
Re: geting data with in two points. (F. Xavier Noria)
Re: getting ip <gnarinn@hotmail.com>
Re: home directory in use lib (Marty Jones)
Re: Net::Telnet.pm and the Escape Key (Garry Williams)
Re: Net::Telnet.pm and the Escape Key <krahnj@acm.org>
Re: Pause for time. <bla@bla.bla>
Re: Perl Project <somewhere@in.paradise.net>
Re: Posting a pre-existing cookie using LWP? <gnarinn@hotmail.com>
run a function in a different file. <mario.lat@libero.it>
Re: run a function in a different file. (Garry Williams)
Re: run a function in a different file. <pilsl_@goldfisch.at>
Re: Script Error? (Tim Hammerquist)
Re: sharing sockets between processes <bla@bla.bla>
Simple RegExp Question (Sam)
Using less memory for hashes <somewhere@in.paradise.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 1 Sep 2001 06:20:41 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: a mystery to me: EOF
Message-Id: <9mpunp$kr0$1@ichaos.ichaos-int>
ziegler@algorilla.de (Joachim Ziegler) said:
>reading the documentation of Perl's eof(), i'm wondering what EOF
>really is.
I think this is already covered by others; a special condition
indicating to the program that there's no more data to read.
But I hope some of my other comments below contribute something
to this thread.
>pressing CTRL-D on my keyboard is said to generate an
>"end-of-file-character". so is this a legal ASCII-character?
On Unix-like systems, Ctrl-D is typically handled by the
tty (terminal) driver to cause an EOF condition. But
(on Unix) the actual character causing the EOF condition
can be changed, and the "EOF character" can also appear
within the data (and be interpreted as data).
>(btw, how do i generate this character by a keyboard-stroke under
>Windows?)
DOS-derived systems (and before that, CP/M and VMS, perhaps also
RSX) use Ctrl-Z as the end-of-file indicator.
>i'm conjecturing the following:
>
>the EOF-character is *not* the last character of any file, right?
System-dependent, and still false for text files in DOS-derived systems.
If you open a file in "text mode", you'll be able to read only up to
the first Ctrl-Z appearing in the file, regardless of how much data
actually is in the file. Reading in binary mode will allow you to read
up to the true length (as indicated by the filesystem) of the file.
>the EOF returned by C's getc() is *not* the same as the above
>character generated by a keyboard-stroke, but a symbolic constant
>(usually negative) returned by this function to indicate, that there
>are no more characters left in a file/stream... right?
Correct, and this is exactly because in C (as in many other languages)
EOF is a condition, not something that can be read from within the data
stream, but something coming from outside the stream -- and as all positive
values can be assigned to characters, typically a negative value is chosen
to indicate end-of-file to the program(mer). Admittedly this can cause some
confusion, as two different things are returned in a single variable.
>but internally, where does getc() know from that the stream is empty?
>it's system-dependent, right?
Yep. F.ex. on Unix systems, the lowest-level file reading call an
application programmer can use (and which is used in the higher-level
file reading callslike getc()) is read(). Arguments for read() are the
file descriptor, a pointer to buffer to which the data should be placed,
and maximum byte count to read. The return value of read() is the number
of bytes actually read from the stream. If no additional error condition
is set (in a global variable errno), and the number of bytes read was
smaller than the number of bytes desired, then the read() encountered the
end of file.
>the last line read by a <FILEHANDLE>-construct in Perl does *never*
>contain any special EOF-character at the end, right?
It can, if you're reading the stream in binary mode. But if reading the
stream in binary mode, you can get the "EOF characters" anywhere. If
reading in text mode, I recall Ctrl-Z is not returned even for Windows
text files (on Win* platforms). On Unix platforms real files don't have
any special end-of-file character, as the file length is stored in the
filesystem control structures.
--
Wolf a.k.a. Juha Laiho Espoo, Finland
(GC 3.0) GIT d- s+: a C++ UH++++$ UL++++$ P++@ L+++ E(-) W+$@ N++ !K w !O
!M V PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h--- r+++ y+++
"...cancel my subscription to the resurrection!" (Jim Morrison)
------------------------------
Date: Sat, 01 Sep 2001 19:56:15 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: ActivePerl says Out of Memory, but I'm not out of memory? Is this a limitation in the Perl build I have?
Message-Id: <3b913624.75727596@news.bright.net>
I have a Perl script that, admittedly, uses a substantial amount
of memory. (It's using a recursive algorithm to solve a problem
that, while finite, can involve some fairly deep recursion.)
I've come to the point now where Perl tells me it's
"Out of memory!" and the script bails. However, I'm
not out of memory. if I run mem *just* before the
bail, I get this:
Memory Type Total Used Free
---------------- -------- -------- --------
Conventional 640K 60K 580K
Upper 0K 0K 0K
Reserved 0K 0K 0K
Extended (XMS) 65,472K 14,924K 50,548K
---------------- -------- -------- --------
Total memory 66,112K 14,984K 51,128K
Total under 1 MB 640K 60K 580K
There's almost 50MB free still, and that's not
even counting virtual memory.
If I run mem right *after* Perl bails, I get this:
Memory Type Total Used Free
---------------- -------- -------- --------
Conventional 640K 60K 580K
Upper 0K 0K 0K
Reserved 0K 0K 0K
Extended (XMS) 65,472K ? 162,572K
---------------- -------- -------- --------
Total memory 66,112K ? 163,152K
Total under 1 MB 640K 60K 580K
So Perl was using about 112024K of RAM, give or
take a couple of megs. Probably most of that is
the recursion in my script -- but there should be
more available yet.
I'm using ActivePerl under Win95 OSR2.
Is there something else I need to do to get Perl
to use available memory, even swap to disk as
necessary? Should I try running Perl with the
Windows GUI and stuff not loaded? Will it make
a difference to use a different Perl build? Is
there something I can configure differently in
Windows, or should I try with a different OS?
I have access to a PC with more RAM, but if Perl
won't even use what's there... I'm willing to
upgrade to a newer/different Perl if it will
help. I have cygwin, but the cygwin build of
Perl isn't currently installed. Should I try
that route, or some other Perl build? The
latest ActiveState release?
C:\>perl -v
This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2000, Larry Wall
Binary build 617 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 20:32:54 Aug 31 2000
I can post my script if it will make any difference.
It's just over 300 lines long, and I'm not at all
sure I have it quite right yet. (I've been in the
process of debugging it, then this happened.)
TIA,
- jonadab
------------------------------
Date: 1 Sep 2001 23:47:48 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: Alternations in Parse::RecDescent
Message-Id: <9mrs34$g19$1@towncrier.cc.monash.edu.au>
Randal wrote:
> use Parse::RecDescent;
> use Data::Dumper; $|++;
> my $parser = Parse::RecDescent->new(q{
>
> line: word(s) /\z/ {
> my @words = @{$item[1]};
> my %count;
> (grep ++$count{$_} > 1, @words) ? undef : \@words;
> }
>
> word: "one" | "two" | "three"
>
> }) or die;
>
> for ("one two", "one one", "two three one", "three one two one") {
> print "$_ =>\n";
> print Dumper($parser->line($_));
> }
Furthermore, if uniqueness was something you needed to enforce more widely
in your grammar, you could factor it out into a parametric rule:
use Parse::RecDescent;
use Data::Dumper; $|++;
my $parser = Parse::RecDescent->new(q{
line: unique['word'] /\z/ { $return = $item[1] }
unique: <matchrule: $arg[0]>(s)
{
my %seen;
foreach (@{$item[1]}) { undef $item[1] and last if $seen{$_}++ }
$return = $item[1];
}
word: "one" | "two" | "three"
}) or die;
for ("one two", "one one", "two three one", "three one two one") {
print "$_ =>\n";
print Dumper($parser->line($_));
}
Damian
------------------------------
Date: 1 Sep 2001 22:05:06 GMT
From: Heinz Ekker <hekker@hoppa.la>
Subject: Re: Check for valid hex value
Message-Id: <9mrm2i$toc$1@news.netway.at>
Edward J. D'Avignon <davignon@vitesse.com> wrote:
> How can I check that a value entered is a valid hex value?
<snip>
map { print "$_: invalid\n" unless eval "0x$_" } qw(
8a
4711
gh
b
deadbeef
9g
);
</snip>
But you should check for '$@' to make sure that '0' doesn't throw up
errors.
> Thanks for the help,
> Ed
Heinz
------------------------------
Date: 1 Sep 2001 11:52:10 -0700
From: dburchm1@quik.com (dburch)
Subject: file tests and split match
Message-Id: <d8632ff5.0109011052.4b313673@posting.google.com>
I wrote this little script to search though a file that has address
information and select lines by zipcode that match. The lines of data
look like:
Wilderness Sports|266 Summit Place|Dillon|CO|80435|970-468-5687||
Bob's Sports|96 Park Street|New Canaan|CT|06840|203-966-1646||
North Cove Outfitters|75 Main Street|Old
Saybrook|CT|06475|860-388-6585||
Outdoor Sports Center|80 Danbury Street|Wilton|CT|06897|203-762-8324||
The first time through it opens a file named by a random number and
then if it finds any exact matches it writes them to the file. It
works to that point. The next thing it does is tests the file to see
if it is empty(-z $new_file), but the file test doesn't seem to work.
Even if the file is not empty it moves on with the if statement. The
next thing is it is suppose to do if it doen't find an exact match is
split the zipcode and match the first two, but that doesn't seem to
work.
It's a short script so I'll paste it in below. Any ideas would be
greatly appreciated.
#!/usr/local/bin/perl -w
use strict;
use CGI;
my $query = new CGI();
my $search = $query->param("search");
my $nbr = int(rand 1000) +1;
my $store_name;
my $address;
my $city;
my $state;
my $zip;
my $phone;
my $extra;
my $url;
my $header;
my $addresses = "/www/htdocs/domains/s9/01365/www.crescentmoonsnowshoes.com/webdocs/proto/cgi/crestent";
my $new_file = "/www/htdocs/domains/s9/01365/www.crescentmoonsnowshoes.com/webdocs/proto/cgi/$nbr";
chomp $search;
open FILE, "$addresses" || die "cant open crestent";
open FILE2, ">$new_file" || die "cant open random file";
foreach(<FILE>)
{
chomp;
my @list = split (/\|/, $_);
if ( $search =~ /\b$list[4]\b/)
{
print FILE2 "$_\n";
}
}
if (-s $new_file)
{
$header = "Stores That Match The Zipcode";
close FILE;
close FILE2;
}
elsif (-z $new_file)
{
my @zip_1 = split (//, $search);
my $s2 = ("$zip_1[0]" . "$zip_1[1]");
foreach(<FILE>)
{
chomp;
my @list = split (/\|/, $_);
my @zip_2 = split (//, $list[4]);
my $f2 = ("$zip_2[0]" . "$zip_2[1]");
if ( $s2 =~ /$f2/)
{
print FILE2 "$_\n";
}
}
close FILE;
close FILE2;
if (-s $new_file)
{
$header = "No Store Matched Exactly, But These May Be
Closeby";
}
else
{
$header = "No Store Matched Your Search";
}
}
open FILE2, "$new_file" || die "cant open random file";
print "Content-type: text/html\n\n";
print "$header\n";
foreach(<FILE2>)
{
chomp;
($store_name,$address,$city,$state,$zip,$phone,$extra,$url)
= split (/\|/, $_);
print "<p>$store_name\n";
print "<br>$address\n";
print "<br>$city, $state $zip\n";
print "<br>$phone\n";
if ($extra ne "")
{
print "<br>$extra\n";
}
if($url ne "")
{
print qq(<a herf="$url">Link<a>\n);
}
}
close FILE2;
unlink ($new_file);
------------------------------
Date: Sat, 01 Sep 2001 21:50:38 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: file tests and split match
Message-Id: <3B91589D.D8AD00BE@acm.org>
dburch wrote:
>
> I wrote this little script to search though a file that has address
> information and select lines by zipcode that match. The lines of data
> look like:
>
> Wilderness Sports|266 Summit Place|Dillon|CO|80435|970-468-5687||
> Bob's Sports|96 Park Street|New Canaan|CT|06840|203-966-1646||
> North Cove Outfitters|75 Main Street|Old
> Saybrook|CT|06475|860-388-6585||
> Outdoor Sports Center|80 Danbury Street|Wilton|CT|06897|203-762-8324||
>
> The first time through it opens a file named by a random number and
> then if it finds any exact matches it writes them to the file. It
> works to that point. The next thing it does is tests the file to see
> if it is empty(-z $new_file), but the file test doesn't seem to work.
> Even if the file is not empty it moves on with the if statement. The
> next thing is it is suppose to do if it doen't find an exact match is
> split the zipcode and match the first two, but that doesn't seem to
> work.
>
> It's a short script so I'll paste it in below. Any ideas would be
> greatly appreciated.
Yes, don't save the matches to a file, store the matches in an array.
#!/usr/local/bin/perl -w
use strict;
use CGI;
my $addresses =
'/www/htdocs/domains/s9/01365/www.crescentmoonsnowshoes.com/webdocs/proto/cgi/crestent';
my @close;
my @exact;
my $query = new CGI();
chomp( my $search = $query->param( 'search' ) );
open FILE, "< $addresses" or die "cant open 'crestent': $!";
while ( <FILE> ) {
chomp;
my $zip = (split /\|/)[4];
if ( $search eq $zip ) {
push @exact, $_;
}
elsif ( !@exact and substr( $search, 0, 2 ) eq substr( $zip, 0, 2 )
) {
push @close, $_;
}
}
close FILE;
print "Content-type: text/html\n\n";
my $found;
if ( @exact ) {
print "Stores That Match The Zipcode\n";
$found = \@exact;
}
elsif ( @close ) {
print "No Store Matched Exactly, But These May Be Close by\n";
$found = \@close;
}
else {
print "No Store Matched Your Search\n";
@$found = ();
}
for ( @$found ) {
my ( $store_name, $address, $city, $state, $zip, $phone, $extra,
$url ) = split /\|/;
print "<p>$store_name\n";
print "<br>$address\n";
print "<br>$city, $state $zip\n";
print "<br>$phone\n";
length $extra and print "<br>$extra\n";
length $url and print qq(<a herf="$url">Link<a>\n);
}
__END__
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 01 Sep 2001 22:41:36 GMT
From: echang@netstorm.net (E.Chang)
Subject: Re: file tests and split match
Message-Id: <Xns910FBEEEA1091echangnetstormnet@207.106.92.86>
dburchm1@quik.com (dburch) wrote in
<d8632ff5.0109011052.4b313673@posting.google.com>:
>I wrote this little script to search though a file that has address
>information and select lines by zipcode that match. The lines of
>data look like:
>
>Wilderness Sports|266 Summit Place|Dillon|CO|80435|970-468-5687||
>Bob's Sports|96 Park Street|New Canaan|CT|06840|203-966-1646||
>North Cove Outfitters|75 Main Street|Old
>Saybrook|CT|06475|860-388-6585||
>Outdoor Sports Center|80 Danbury
>Street|Wilton|CT|06897|203-762-8324||
>
>The first time through it opens a file named by a random number and
>then if it finds any exact matches it writes them to the file. It
>works to that point. The next thing it does is tests the file to
>see if it is empty(-z $new_file), but the file test doesn't seem to
>work. Even if the file is not empty it moves on with the if
>statement.
I'm not sure what you mean by this - there are a lot of if statements
in the script.
>The next thing is it is suppose to do if it doen't find
>an exact match is split the zipcode and match the first two, but
>that doesn't seem to work.
>
>It's a short script so I'll paste it in below. Any ideas would be
>greatly appreciated.
Both of the problems (as I understand them) result from not closing the
input file. I've made a few additonal suggestions to simplify the code
a little bit without changing the basic approach.
[Initial code snipped]
my $store_name, my $address, $city, $state, $zip, $phone, $extra, $url,
$header;
No need for all those separate lines.
>my $addresses =
>"/www/htdocs/domains/s9/01365/www.crescentmoonsnowshoes.com/webdocs/p
roto/cgi/crestent";
>my $new_file =
>"/www/htdocs/domains/s9/01365/www.crescentmoonsnowshoes.com/webdocs/pr
oto/cgi/$nbr";
> chomp $search;
> open FILE, "$addresses" || die "cant open crestent";
> open FILE2, ">$new_file" || die "cant open random file";
'||' has higher precedence than the comma operator. (See the perlop
manpage.) Either use 'or' instead, or parenthesize your intended
arguments (or both).
open FILE, "$addresses" or die "cant open crestent";
open FILE2, ">$new_file" or die "cant open random file";
> foreach(<FILE>)
This reads the entire contents of FILE into a temporary array in
memory. You would use less memory with
while (<FILE>)
though it is not a problem if your file is small.
> {
> chomp;
> my @list = split (/\|/, $_);
>
> if ( $search =~ /\b$list[4]\b/)
> {
> print FILE2 "$_\n";
> }
> }
You have read all the way through FILE at this point; this is where you
should be closing it.
close FILE;
> if (-s $new_file)
You say this test is failing? You didn't close the file, so the
directory entry isn't complete yet and the size is still 0.
> {
> $header = "Stores That Match The Zipcode";
> close FILE;
Closing FILE won't be necessary here if done above.
> close FILE2;
> }
>
> elsif (-z $new_file)
The condition isn't necessary in this case. Just use
else
> {
open FILE, "$addresses" or die "cant open crestent";
Open the FILE again, so you can rewad from the beginning.
> my @zip_1 = split (//, $search);
> my $s2 = ("$zip_1[0]" . "$zip_1[1]");
These two lines can be replaced with
my $s2 = substr $search, 0, 2;
> foreach(<FILE>)
This section didn't find any matches Because you didn't close FILE
after reading all the way to its end. There was nothing left to read.
You needed to close the file and then reopen it. The previous comment
about while versus foreach still applies.
> {
> chomp;
> my @list = split (/\|/, $_);
> my @zip_2 = split (//, $list[4]);
> my $f2 = ("$zip_2[0]" . "$zip_2[1]");
> if ( $s2 =~ /$f2/)
> {
> print FILE2 "$_\n";
> }
You can replace the above 6 lines (counting the brackets) with
print FILE2 "$_\n" if $s2 eq substr $list[4], 0, 2;
> }
>
> close FILE;
> close FILE2;
>
> if (-s $new_file)
> {
> $header = "No Store Matched Exactly, But These May
> Be Closeby";
> }
> else
> {
> $header = "No Store Matched Your Search";
> }
>
> }
>
>
>
> open FILE2, "$new_file" || die "cant open random file";
Use 'or' or parenthesize the arguments.
[remainder of code snipped]
--
EBC
------------------------------
Date: 1 Sep 2001 17:17:51 -0700
From: dburchm1@quik.com (dburch)
Subject: Re: file tests and split match
Message-Id: <d8632ff5.0109011617.6e84c04c@posting.google.com>
Thanks, you guys rock.
------------------------------
Date: 1 Sep 2001 18:19:19 GMT
From: fxn@retemail.es (F. Xavier Noria)
Subject: Re: geting data with in two points.
Message-Id: <9mr8r7$21v183@news1s.iddeo2.es>
On Sat, 1 Sep 2001 07:57:14 -0400, Tad McClellan <tadmc@augustmail.com> wrote:
: F. Xavier Noria <fxn@retemail.es> wrote:
:>
:> ($data) = $text =~ /<start>(.*)?<end>/s;
:>
:>assigns `yeah' to $data,
:
:
: It assigns 6 characters, not 4: "\nyeah\n"
Yes, it was wrong.
: Please test your code before posting. Your question mark is
: in the wrong place. It is a no-op where you have it, but I think
: you want non-greedy...
Yes, thank you for correcting my message.
-- fxn
------------------------------
Date: Sat, 1 Sep 2001 18:23:15 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: getting ip
Message-Id: <999368595.130185119342059.gnarinn@hotmail.com>
In article <3b9094b7$1_4@news.chariot.net.au>,
Matthew Frick <mfrick@chariot.net.au> wrote:
>I have a webpage calling a script on another server and I need the script to
>be able to get the ip of the webpage not of the person navigating. Does
>anyone know how I would go about this??
i really think you should try to explain what you are trying to do.
if you are talking about wanting to know on what page the link to your
script was, then an incomplete answer is $ENV{HTTP_REFERER}
gnari
------------------------------
Date: 1 Sep 2001 15:46:46 -0700
From: jones1ai14@yahoo.com (Marty Jones)
Subject: Re: home directory in use lib
Message-Id: <cb844878.0109011446.7c24d009@posting.google.com>
<snip>
> I think my second attempt didn't work because perl wasn't evaluating
> the line 'my $home = (....' until after it tried to load MyLib.
>
> After more searching of perldoc pages, I came across BEGIN. So I did:
>
> #!/usr/bin/perl
>
> BEGIN { $home = (getpwnam('jones'))[7]; }
> use lib "$home/perl/lib";
> use MyLib;
<snip>
Tad and Philip,
Thanks for the info and the suggestions, unfortunately, it is the web
server, running as user nobody, that runs this script so using
$ENV{'HOME'} or $ENV{'LOGDIR'} won't be effective.
However, what you had to say led me to the perl function glob() which
I think may be even better than using getpwnam:
#!/usr/bin/perl -w
use strict;
use diagnostics;
my $home;
BEGIN { $home = glob("~jones"); }
use lib "$home/perl/lib";
use MyLib;
Thanks!
Best Regards,
Marty
------------------------------
Date: Sat, 01 Sep 2001 19:36:13 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Net::Telnet.pm and the Escape Key
Message-Id: <slrn9p2e5d.sv1.garry@zfw.zvolve.net>
On Sat, 01 Sep 2001 18:35:31 +0200, Matthias Wegener
<matze@e-travel.de> wrote:
> is it possible to emulate a stroke on the escape key on the keyboard via
> the Telnet.pm? I mean, what (and how escaped) string is to be send to
> accomplish this?
> $telnet->cmd('???');
> I sniffed the traffic between the telnet-server and an ordinary
> telnet-client and learned that in hex it looks something like 0x1b when
> I hit the escape key, but I dont know how to encapsulate this to put it
> in an ordinary Telnet.pm-like command-string : (
What's wrong with $telnet->cmd(chr 0x1b); ?
--
Garry Williams
------------------------------
Date: Sat, 01 Sep 2001 20:33:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Net::Telnet.pm and the Escape Key
Message-Id: <3B91468A.481ADCF2@acm.org>
Matthias Wegener wrote:
>
> is it possible to emulate a stroke on the escape key on the keyboard via
> the Telnet.pm? I mean, what (and how escaped) string is to be send to
> accomplish this?
> $telnet->cmd('???');
> I sniffed the traffic between the telnet-server and an ordinary
> telnet-client and learned that in hex it looks something like 0x1b when
> I hit the escape key, but I dont know how to encapsulate this to put it
> in an ordinary Telnet.pm-like command-string : (
my $ESC = "\x1b";
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 01 Sep 2001 22:19:44 GMT
From: "ninpo" <bla@bla.bla>
Subject: Re: Pause for time.
Message-Id: <4adk7.129638$SC.2942897@amsnews02.chello.com>
and if you want to wait less than a whole second,
you could use
select undef,undef,undef,0.25;
for 1/4 second
from the cookbook:
3.10. Short Sleeps
Problem
You need to sleep for less than a second.
Solution
Use the select() function, if your system supports it:
select(undef, undef, undef, $time_to_sleep);
Some systems don't support a four-argument select. The Time::HiRes module
provides a sleep function that takes a floating point number of seconds:
use Time::HiRes qw(sleep);
sleep($time_to_sleep);
greetz,
Ninpoka
"Joe Schaefer" <joe+usenet@sunstarsys.com> wrote in message
news:m3pu9bjawf.fsf@mumonkan.sunstarsys.com...
> Julia Kempe <kempe@uclink4.berkeley.edu> writes:
>
> > How do I make perl pause between steps in a program?
> >
> > For example, I want it to output a series of notices, but with a, say,
> > one or two second pause in between.
>
> In *nix, you'd be looking for sleep(1)-
>
> % man sleep
>
> On linux, the info pages are often more comprehensive:
>
> % info sleep
>
> > Is there some sort of pause for time funtion I can invoke, or any
> > module I can use??
> >
>
> Perl provides the same function:
>
> % perldoc -f sleep
>
> HTH
> --
> Joe Schaefer "The surest protection against temptation is
cowardice."
> --Mark Twain
>
------------------------------
Date: Sun, 2 Sep 2001 10:10:30 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Re: Perl Project
Message-Id: <zPek7.4$wC3.231542@news.interact.net.au>
"renntech" <renntech750@yahoo.com> wrote in message
news:674fb37c.0109010559.5910007@posting.google.com...
> I'm bouncing around the perl discussion boards today looking for
> someone I can hire to write a perl script for me. Is anyone out there
> interested, or know someone who is?
You could try alt.comp.perlcgi.freelance if you have a Perl CGI requirement.
However, be warned that the quality and relevance of the group is a little
dubious.
------------------------------
Date: Sat, 1 Sep 2001 23:39:33 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Posting a pre-existing cookie using LWP?
Message-Id: <999387573.048127400688827.gnarinn@hotmail.com>
In article <3B911083.1E127F64@mail.verizon.net>, <vze2nddi@verizon.net> wrote:
>I am writing a bot that I want to gather all the information I have
>access to on a particular site, but the site wants to see a cookie
>validating me.
>
>I want to copy the existing cookie from my Netscape cookie file rahter
>than setting up a cookie jar with LWP and having the server generate a
>new cookie from scratch. How can I specify a cookie as a string, without
>waiting to see what the server wants to set?
did you look at the HTTP::Cookies::Netscape subclass of HTTP::Cookies
the docs seem to indicate that such an object can read netscape cookie files.
gnari
------------------------------
Date: Sat, 01 Sep 2001 19:14:21 GMT
From: "_Mario Latens" <mario.lat@libero.it>
Subject: run a function in a different file.
Message-Id: <20010901.211152.1977648522.2834@localhost.localdomain>
I'd like to run a function in a file from more files,
So whe I have to cance this function I have to change only once!!!
How can I do that?!?!?
Thank you in advance, Mario.
------------------------------
Date: Sat, 01 Sep 2001 19:40:19 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: run a function in a different file.
Message-Id: <slrn9p2ed3.sv1.garry@zfw.zvolve.net>
On Sat, 01 Sep 2001 19:14:21 GMT, _Mario Latens <mario.lat@libero.it> wrote:
> I'd like to run a function in a file from more files,
> So whe I have to cance this function I have to change only once!!!
> How can I do that?!?!?
You can find out by checking the FAQ. Look at the perlfaq7 manual
page for "How do I create a module?"
--
Garry Williams
------------------------------
Date: Sun, 2 Sep 2001 00:39:54 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: run a function in a different file.
Message-Id: <3b9163bb@e-post.inode.at>
_Mario Latens wrote:
> I'd like to run a function in a file from more files,
> So whe I have to cance this function I have to change only once!!!
> How can I do that?!?!?
>
> Thank you in advance, Mario.
>
insert this in your mainprogram:
require 'myfunc.pl';
and in the seperate file myfunc.pl, you put your function.
IIf you need this more often, a module - like recommended my Garry - would
be the better way.
hope this helps,
peter
--
mag. peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: Sat, 01 Sep 2001 19:37:31 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Script Error?
Message-Id: <slrn9p2eum.s2.tim@vegeta.ath.cx>
Me parece que WHW <us@webhostwatch.co.ukNOSPAM> dijo:
> Hi,
>
> > It should be $sth
>
> Thanks, Im also getting the following error on the same piece of perl:
>
> Undefined subroutine &main::phpSP_users
>
> On the line referencing to the table 'phpSP-users'. Any ideas?
Try wrapping your SQL statement in quotes (apparently you want
double-quotes) and assigning it to $stmt.
Also, why are both $stmt and $dbh double-referenced in the
$dbh->prepare() line? So far as your posted code shows, $stmt doesn't
even exist, yet your treating it as a reference to a scalar. $dbh is
treated properly in all your other DBI methods, but not this one.
Did you cut and paste original code?
--
If you do not climb, you will not fall. This is true.
But is it that bad to fail, that hard to fall?
-- Morpheus, The Sandman
------------------------------
Date: Sat, 01 Sep 2001 22:14:00 GMT
From: "ninpo" <bla@bla.bla>
Subject: Re: sharing sockets between processes
Message-Id: <I4dk7.129540$SC.2941034@amsnews02.chello.com>
Aha, another juicy chunk of knowledge poured out before me. I shall go
consume it. thanks...........
<we would not be human without giving in to our desires, for they are what
form us>
http://somafm.com
"Chris Fedde" <cfedde@fedde.littleton.co.us> wrote in message
news:qf6k7.52$Owe.171079168@news.frii.net...
> In article <Ob2k7.116365$SC.2684851@amsnews02.chello.com>,
> ninpo <bla@bla.bla> wrote:
> >
> >In that way, only communication between parents and children is
> >possible,right?,
> >but i'm looking for a way to have the children chatter amongst eachother.
> >Every forked process gets its own socket. a newly spawned child has no
> >knowledge of other clients and hence, their sockets.
> >I've read perlipc again, maybe I'm missing something ?
> >
>
> Look at the exampls that are in the IO::Select and IO::Socket::INET manual
> pages. I think you will like what you see.
>
> Good Luck!
> --
> This space intentionally left blank
------------------------------
Date: Sat, 01 Sep 2001 19:43:05 -0500
From: sam_5_5_5_0@REMOVEyahoo.com (Sam)
Subject: Simple RegExp Question
Message-Id: <sam_5_5_5_0-0109011943070001@dialup-721.deskmedia.com>
I need a regular expression to help analize a file that contains
statistics for game. The data contains a level name and a number, as
follows (for example):
Hawthorne 3 Zamboni 1
Heimdall 1
Note that there are two ways it could be on a line:
-2 on a line
-1 on a line
Here's the script (part of it):
while() {
chomp($in = <>);
if ($in =~ /<exp1>/) {
$levels{$1}+=$2;
$levels{$3}+=$3;
} elsif ($in =~ /<exp2>/) {
$levels{$1}+=$2;
} elseif ($in =~ /^$/) {
print "end of list";
last;
}
}
where <exp1> and <exp2> are the regular expressions. In the first, $1 and
$3 are level names, and $2 and $4 are the numbers. In the second, $1 is
the name and $2 is the number.
Note that level names can contain pucuation, spaces, ect.
Any help would be nice. Thanks.
--
Remove "REMOVE" for address to reply.
I don't check that mailbox very often.
Replies to the newsgroup are best.
------------------------------
Date: Sun, 2 Sep 2001 10:32:20 +1000
From: "Tintin" <somewhere@in.paradise.net>
Subject: Using less memory for hashes
Message-Id: <08fk7.6$4y3.206907@news.interact.net.au>
I'm interested in various techniques to reduce memory usage using hashes.
Typcially, I'm talking about where a large file (say >1Gb) is read into a
hash and then sorted.
I read the FAQ about reducing memory usage, but is mainly talks about
arrays. One method I was thinking of using is a tied DBM hash (is that the
right term?). I'm not so worried about the slow down in performance, more
about getting a file processed without the server swapping like crazy.
------------------------------
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 1677
***************************************