[18371] in Perl-Users-Digest
Perl-Users Digest, Issue: 539 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 21 03:05:43 2001
Date: Wed, 21 Mar 2001 00:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985161911-v10-i539@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 21 Mar 2001 Volume: 10 Number: 539
Today's topics:
  being replaced by space?? (cRYOFAN)
[ANNOUNCE] DBD::Chart 0.30 <darnold@earthlink.net>
Re: [Q] Avoid stripping of command line quotes <kevin@vaildc.net>
[RFC] A proposal for changes to Net::Ping <bitbucket@jenovaproject.org>
Re: accessing variable in string context (Jay Tilton)
ANNOUNCE: DDL::Oracle v1.06 <rvsutherland@yahoo.com>
ANNOUNCE: Perl/Tk binary packages <rkiesling@mainmatter.com>
Re: Hash Problem Redux <mjcarman@home.com>
Re: Hash question <persicom@acedsl.com>
Re: Hash question <thomastk@prodigy.net>
Re: How to sort ? <VincentMurphy@mediaone.net>
Re: How to sort ? (Gwyn Judd)
IO::Select sel->add and array references <mathias@koerber.org>
Re: New Perl Bulletin Board available <gtoomey@usa.net>
perl Online/Offline status indicator needed dbe_odinson@yahoo.com
Re: perl Online/Offline status indicator needed (Gwyn Judd)
Re: perl Online/Offline status indicator needed <gtoomey@usa.net>
Re: Print "tar" Success or Failure (Garry Williams)
Script mysteriously erases file it's supposed to append <hayati@math.uiuc.edu>
small question - reading/writing data structures to/fro <none@none.com>
Re: STDERR redirect to system log? (Todd H.)
Re: STDERR redirect to system log? <krahnj@acm.org>
Re: Still can't die with Tar <peter.sundstrom-eds@eds.com>
Re: substitution/pattern matching -- setting the positi <krahnj@acm.org>
time calculation (Ebonyxman)
Re: time calculation <persicom@acedsl.com>
Re: time calculation <gtoomey@usa.net>
Re: time calculation (Garry Williams)
Re: upload a whole directory <dmarvo@yahoo.com>
Re: usernames & passwords - how to ??? <yhaili@21cn.com>
Re: win32: accessing file in same Drive where cgi-bin r <kellyboy@nospanner>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 21 Mar 2001 06:41:47 GMT
From: cryofan@mylinuxisp.com (cRYOFAN)
Subject:   being replaced by space??
Message-Id: <3ab84cbb.572681187@news3.mylinuxisp.com>
I am losing part of my regex, namely the " " part when I
use my file manager to FTP (?) my perl cgi script up to my website.
ANy clues?
------------------------------
Date: Wed, 21 Mar 2001 05:34:17 GMT
From: "Dean Arnold" <darnold@earthlink.net>
Subject: [ANNOUNCE] DBD::Chart 0.30
Message-Id: <tbgfptmefo9ld0@corp.supernews.com>
DBD::Chart 0.30 is now available from either
CPAN or at http://home.earthlink.net/~darnold/dbdchart/.
Changes from 0.20:
- strip newlines from SQL for prepare()
- add BACKGROUND property to set background color,
incl. transparent background
- add FORMAT property to select PNG or JPEG
- add X-ORIENT property to set X-tick label orientation
- add LOGO property to set a background image
- add SIGNATURE property to set a signature string in image
- add placeholder support in SELECT WHERE clause
- add KEEPORIGIN property to force (0,0) in the graph
- auto-skip symbolic X-axis vertical tick labels when they overlap
- add parameterized chart datasource
(i.e., SELECT BARCHART FROM ? WHERE...)
FYI: DBD::Chart is a Perl DBI driver abstraction for rendering charts
and graphs using a variant of SQL. Review the DBD::Chart homepage at
http://home.earthlink.net/~darnold/dbdchart/ for detailed
information.
Regards,
Dean Arnold
------------------------------
Date: Tue, 20 Mar 2001 21:26:14 -0500
From: Kevin Michael Vail <kevin@vaildc.net>
Subject: Re: [Q] Avoid stripping of command line quotes
Message-Id: <kevin-D109C3.21260220032001@vienna7.his.com>
In article <998t9f$92$1@mozo.cc.purdue.edu>,
jonesbr@roger.ecn.purdue.edu (Brian R. Jones) wrote:
> I'm probably missing something absolutely trivial, but how does
> one tell perl _not_ to strip double quotes out of command line
> arguments? For example, say I have the following script called
> tst.pl:
>
> #!/usr/bin/perl -w
> foreach (@ARGV) { print "$_\n" }
> exit;
>
> Execute script: tst.pl "hello"
> Actual output: hello
> Desired output: "hello"
>
> I can't use \Q\E because @ARGV has already stripped the quotes
> before I can ever access it... what simple trick am I missing?
If you're running under Unix, the shell has already removed the quotes
before Perl sees the text. If you want to send "hello" (with the
quotes), you have to type '"hello"' or something else that will quote
the double quotes.
If you're not running under Unix (and you didn't say, he said
pointedly), then hmmm.
--
Kevin Michael Vail | a billion stars go spinning through the night,
kevin@vaildc.net | blazing high above your head.
. . . . . . . . . | But _in_ you is the presence that
. . . . . . . . . | will be, when all the stars are dead. (Rainer Maria Rilke)
------------------------------
Date: Wed, 21 Mar 2001 01:50:03 -0600
From: Colin McMillen <bitbucket@jenovaproject.org>
Subject: [RFC] A proposal for changes to Net::Ping
Message-Id: <999mf2$8o6$1@laurel.tc.umn.edu>
I posted this to comp.lang.perl.modul a few days ago, but received no
replies; I'm posting it again here in the hope that it generates some
discussion....
The following is a request for comments on a list of proposed changes
to the Net::Ping module. After doing some basic searching of the web,
and taking a look at the actual source code, I've come up with a list
of problems and changes that I am interested in implementing. I would
appreciate any comments or suggestions you may have on this
matter. References to web sites where I have found descriptions of
some problems are given within square brackets; see the footnotes at
the bottom of this message for the links. A quick search on
http://groups.google.com for "Net::Ping Problems" on comp.lang.perl.*
will turn up a host of problems that could be resolved if the changes
listed below were made. Without further ado, here goes:
- Summary -
Already implemented changes:
1. Removal of alarm() function
2. TCP ping now functional on MSWin32 systems
3. Incorrect returns of "false" removed from TCP ping
4. Removal of unneeded warning in the module's POD
To be (possibly) implemented:
5. Creation of a new "external" protocol
6. Creation of a new "auto" protocol
7. Documentation update
8. Change in the default ping protocol
9. Allowing for user-specified port in TCP ping
10. UDP ping fixes?
- Detail -
This first group of details pertains to changes I have already
implemented to Net::Ping. A second group, below, discusses potential
changes that I've not implemented yet.
1. The alarm() function is currently used to implement timeouts on a
TCP ping. This makes Net::Ping unusable in systems which do not
implement alarm() (i.e. MSWin32), [1] and may also cause problems with
scripts that use alarm() or sleep(). I've re-written the TCP ping
code to use a non-blocking connect() and select() to implement the
timeout instead.
2. On the other hand, the use of non-blocking connect() is not
supported on MSWin32 either. So, I've added special code to handle
TCP pings on Windows platforms. It uses Win32::Process::Create (if
it exists on the system) to spawn a child process, which attempts to
do a (blocking) TCP connect to the appropriate host. If the new
process does not return before the timeout has passed, it is killed
off, and false is returned.
3. The TCP pinging function, ping_tcp(), currently returns false
negatives when the remote host responds with "Connection refused"
(which will happen for any live machine that's not listening on the
TCP echo port). [2] In this case, the call to connect() in the
current Net::Ping fails, so Net::Ping returns false. However, if
the error given is connection refused, this implies that there is
indeed a host at the other end of the pipe, which sent the
"connection refused" message. Hence, ping_tcp() should return true
in this case. The changes described above in item #1 have the
side-effect of removing this false negative on systems that support
non-blocking connect(); specific logic written into the Win32 TCP
ping handles this case for MS platforms.
4. I've also removed the POD that warns about the use
of alarm() in conjunction with Net::Ping, since the warning is no
longer necessary. [3]
The following are potential additional changes. Comments on these
would definitely be appreciated. They are ordered in roughly the order
in which I would want to implement them. (In other words, easy and/or
more useful things are listed first).
5. It is well-known that the most accurate method of pinging is an
ICMP ping. [2] Unfortunately, ICMP ping from native perl requires
privileged (AKA "root") access on all systems but VMS. To remedy
this, I've written a module, Net::Ping::External [4], which interfaces
with the native system's "ping" command for a variety of operating
systems. The "ping" system utility always (AFAIK) uses an ICMP
ping, so the results of Net::Ping::External are probably more
reliable than Net::Ping's TCP and UDP pinging modes. Hence, I
propose that a new protocol be made available to Net::Ping, called
"external", which uses Net::Ping::External to do a ping. This will
allow for the accuracy of an ICMP ping without the user needing
privileges to run the script as root or administrator. If the user
does not have Net::Ping::External installed, Net::Ping will simply
croak() about the "external" protocol being currently available on
their system, much like it already does if a non-root user attempts
an ICMP ping.
6. I propose another protocol be added, called "auto", which is meant
for "newbie" use. "auto" would automatically determine the most
accurate pinging method available on the current system in the
following way:
* If the script is running under root privileges, the "icmp"
protocol is used.
* Otherwise, we check to see if Net::Ping::External is available;
if so, the "external" protocol is used.
* If neither of these is available, TCP ping is used.
* If there is some sort of error with TCP ping, we finally fall
back to UDP ping.
The "auto" protocol has the main advantage of providing accurate
results to people who don't care to learn about the various pinging
methods and choosing the best one. A new Net::Ping object that is
constructed with a protocol of "auto" would find out the
appropriate protocol on the first call to the ping() method, and
use that method for puture calls; hence, these checks would not
need to be made for every single ping.
7. The documentation needs updating. The current Net::Ping
documentation gives no explanation of why certain pinging strategies
are better than others, or any explanation of why the module is
prone to giving "incorrect" results.
8. The default pinging method is to use UDP. Since UDP seems to be the
most inaccurate way of getting results, I'm not at all sure why this
was made the default in the first place. On the other hand, I'm not
sure that I want to mess with the default that's been in place for
years; there could be scripts out there that depend on it. If I
were to change the default, I'd probably change it to the "auto"
method, since the purpose of this method is to always return the
most accurate results.
9. The TCP protocol could possibly be improved by allowing the user to
specify a specific port to connect() to. If it is known that the
remote host is, for example, a web server, we are more likely (due
to remote firewall rules) to get an accurate result by trying a
connect() to port 80 than a connect() to port 7.
10. I've not even looked at UDP ping's code yet, but there are
obviously fixes that need to be made. One known issue is that UDP
pings appear to not play nicely with the Socket.pm module on Linux
[5].
Please let me know what thoughts you have on this proposal. I've tried
contacting Net::Ping's maintainer, Russell Mosemann, for a couple weeks
now, but have gotten no response. Since the module has not been
updated since 1996, and Russell has not (to my knowledge) posted to
comp.lang.perl.* since that time, I'm assuming he's gone incognito. I
would like to know who I need to contact, in lieu of Russell Mosemann,
to submit patches to. If there is no currently-interested maintainer
of Net::Ping, I think I would like to apply for maintainership of this
module; who would I contact to discuss this?
- Colin McMillen (CPAN ID: COLINM)
References:
1.
http://groups.google.com/groups?hl=en&lr=&group=comp.lang.perl.*&safe=off&ic=1&th=a31c97fe6d948cc4&seekd=952924081#952924081
2. http://www.perlmonks.org/index.pl?node_id=42739
3. http://search.cpan.org/doc/RMOSE/Net-Ping-2.02/Ping.pm
4. http://search.cpan.org/search?dist=Net-Ping-External
5. http://www.perlmonks.org/index.pl?node_id=55508
------------------------------
Date: Wed, 21 Mar 2001 02:53:26 GMT
From: tiltonj@erols.com (Jay Tilton)
Subject: Re: accessing variable in string context
Message-Id: <3ab81526.80655138@news.erols.com>
On Tue, 20 Mar 2001 22:57:50 GMT, "John Hall" <jhall@ifxonline.com>
wrote:
>I have x number of entries in a hash.
>For each of those entries I try retrieving a param() with a corresponding
>name.
>I have a list of names, some of those names would be used as a
>param('namehere') - and when I get the param I'd like to be able to
>associate it with the name again. The easiest way is to be able to take the
>variable i'm working with and grab it's name like a string.
>Here's some sample code to give you the idea; imaging $bob, $dick, etc are
>param('bob') and param('dick') instead, and that I have a hash somewhere
>that has those names in it, which is how I looked for them as param()'s in
>the first place...
Do you have a question?
It's not at all clear what your goal is. Including some examples that
show what the code is doing and what you want it to do would help,
e.g.
I have:
(brief sample of the original contents of %sitedb)
I get:
(actual contents of %sitedb when finished)
I want:
(desired contents of %sitedb when finished)
Urgently suggested reading:
perldoc -q "How can I use a variable as a variable name?"
------------------------------
Date: Mon, 19 Mar 2001 21:19:04 -0500
From: "Richard Sutherland" <rvsutherland@yahoo.com>
Subject: ANNOUNCE: DDL::Oracle v1.06
Message-Id: <tbgfpkqrpk74c8@corp.supernews.com>
===========================================================================
Release of DDL::Oracle, Version 1.06
===========================================================================
CHANGES
Added a new instance method -- 'show_space' -- which displays a report
such as the following:
Space analysis for: [schema.]<object name>
BYTES BLOCKS
============ =========
Used BELOW the high water mark 1325056 647
Free ABOVE the high water mark 716800 350
Free BELOW the high water mark 6144 3
------------ ---------
TOTAL in segment 2048000 1000
FILE_ID BLOCK_ID BLOCK_NBR
======= ======== =========
Last extent having data 9 10287 150
For partitioned tables, it displays a section for each partition,
followed by totals for the table/index. The user must have EXECUTE
privileges on package sys.DBMS_SPACE for this method to respond.
Fixed bug #408724, by upgrading CREATE TRIGGER statements to distinguish
between Oracle8i and earlier versions. THANKS to Martin Drautzburg for
reporting this error!
SYNOPSIS
use DBI;
use DDL::Oracle;
my $dbh = DBI->connect(
"dbi:Oracle:dbname",
"username",
"password",
{
PrintError => 0,
RaiseError => 1
}
);
# Use default resizing and schema options.
# query default DBA_xxx tables (could use USER_xxx for non-DBA types)
DDL::Oracle->configure(
dbh => $dbh,
);
# Create a list of one or more ob
jects
my $sth = $dbh->prepare(
"SELECT
owner
, name
FROM
dba_tables
WHERE
tablespace_name = 'MY_TBLSP' -- your millage may vary
"
);
$sth->execute;
my $list = $sth->fetchall_arrayref;
my $obj = DDL::Oracle->new(
type => "table",
list => $list, );
);
my $ddl = $obj->create; # or $obj->resize; or $obj->drop; etc.
print $ddl; # Use STDOUT so user can redirect to desired file.
AUTHOR
Richard V. Sutherland
rvsutherland@yahoo.com
COPYRIGHT
Copyright (c) 2000, 2001 Richard V. Sutherland. All rights reserved.
This module is free software. It may be used, redistributed, and/or
modified under the same terms as Perl itself. See:
http://www.perl.com/perl/misc/Artistic.html
===========================================================================
AVAILABILITY
===========================================================================
DDL::Oracle is available from the CPAN, and from:
http://sourceforge.net/projects/ddl-oracle/
------------------------------
Date: Mon, 19 Mar 2001 20:17:16 GMT
From: Robert Kiesling <rkiesling@mainmatter.com>
Subject: ANNOUNCE: Perl/Tk binary packages
Message-Id: <tbgfomrfl2gfb5@corp.supernews.com>
I've uploaded Sparc Solaris7 and Red Hat Linux 6.2 binary packages of
the Perl/Tk 800.022 distribution to CPAN, as well as to my Perl/Tk
page.
They were all build with GCC against the standard OS libraries and
Perl run-time distributions
At the moment, the packages available are:
Red Hat Linux 6.2 Binary RPM:
http://www.mainmatter.com/perltk/perltk-800.022_5.00503-1.i386.rpm
http://www.cpan.org/authors/id/R/RK/RKIES/perltk-800.022_5.00503-1.i386.rpm
Red Hat Linux 6.2 Source SRPM
http://www.mainmatter.com/perltk/perltk-800.022_5.00503-1.src.rpm
http://www.cpan.org/authors/id/R/RK/RKIES/perltk-800.022_5.00503-1.src.rpm
Sparc Solaris 7 PKG
http://www.mainmatter.com/perltk/perltk-800.022_5.005-sol7-sparc-local.tar.gz
http://www.cpan.org/authors/id/R/RK/RKIES/perltk-800.022_5.005-sol7-sparc-local.tar.gz
I'll upload packages for other systems as I have time for building them.
Thanks to everyone who has provided feedback so far on the library
modules that I've uploaded to CPAN and www.mainmatter.com.
Robert Kiesling
--
Robert Kiesling
Linux FAQ Maintainer
rkiesling@mainmatter.com
http://www.mainmatter.com/linux-faq/toc.html http://www.mainmatter.com/
---
Tired of spam? Please forward messages to uce@ftc.gov.
------------------------------
Date: Wed, 21 Mar 2001 04:10:43 GMT
From: Michael Carman <mjcarman@home.com>
Subject: Re: Hash Problem Redux
Message-Id: <3AB82A16.F626C770@home.com>
Jason wrote:
>
> Well, we got the file into a hash using the code snippit that
> Ciaran McCreesh posted (thanks), but now we have a new problem.
> As soon as we exit that while loop, the variable is lost.
Which variable? The hash?
> Is this problem addressed somewhere? I would think it to
> be a scoping issue,
That's what it sounds like, but without seeing some code, I can't tell
you for sure. Can you post a small snippet that exhibits the problem?
> but when we do research on scoping, it only ever mentions
> subroutines and foreach loops.
The highly abridged story is that a lexical (my()) variable is only
visible within its enclosing block (or file). See the perlsub manpage
and look for the section called "Private Variables via my()" for the
details.
-mjc
------------------------------
Date: Tue, 20 Mar 2001 21:46:41 -0500
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Hash question
Message-Id: <3AB81611.3B8E8E9B@acedsl.com>
Ciaran McCreesh wrote:
>
> In article <tbf90mh8m69jb7@news.supernews.com> (whatever that means),
> Jason <jason.baker@stdbev.com> writes
> >Pardon the newbie question. Im trying to read a file into a hash, the file
> >is setup like
> >key = value
> >key1 = value1
> >etc...
> >and I would like that information placed into a hash. I have figured out a
> >way to do this, but it entails first reading everything into an array and
> >then putting it into the hash. Their must be a better way. ANy
> >suggestions?
>
> while (<FILE>) {
> ($key, $value) = split /=/;
> $hash($key} = $value;
> }
>
> or something along those lines...
Such as
%hash = map {split /=/} <FILE>;
> HTH,
> Ciaran
>
> --
> Ciaran McCreesh
> mail: keesh@users.sourceforge.net
> web: http://www.opensourcepan.com/
--
Matthew O. Persico
http://www.acecape.com/dsl
AceDSL:The best ADSL in Verizon area
------------------------------
Date: Sun, 18 Mar 2001 23:31:29 -0600
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Hash question
Message-Id: <999la3$6b16$1@newssvr06-en0.news.prodigy.com>
May be something like the following:
my %hash;
open(FIL,$file) or die "$! etc...";
while (<FIL>) { if (/(^.+?)=(.+)/) {$hash{$1} = $2}}
close(FIL);
Jason <jason.baker@stdbev.com> wrote in message
news:tbf90mh8m69jb7@news.supernews.com...
> Pardon the newbie question. Im trying to read a file into a hash, the
file
> is setup like
> key = value
> key1 = value1
> etc...
> and I would like that information placed into a hash. I have figured out
a
> way to do this, but it entails first reading everything into an array and
> then putting it into the hash. Their must be a better way. ANy
> suggestions?
>
>
> Jason
> www.cyborgworkshop.com
> ...and the geek shall inherit the earth...
>
>
------------------------------
Date: Wed, 21 Mar 2001 02:33:35 GMT
From: Vinny Murphy <VincentMurphy@mediaone.net>
Subject: Re: How to sort ?
Message-Id: <m3snk7onpw.fsf@vmurphy-hnt1.athome.net>
>>>>> "Waarddebon" == Waarddebon <Waarddebon@chello.nl> writes:
Waarddebon> I've got a script that loads a text file in, which contains
Waarddebon> something like this
Waarddebon> 101,blablabla,blablabla 105,blablabla,blablabla
Waarddebon> 103,blablabla,blablabla 104,blablabla,blablabla
Waarddebon> 100,blablabla,blablabla and so on....
Waarddebon> Here is my problem, as you can see the numbers each line
Waarddebon> begins with aren't sorted ascended. Does anyone know how I
Waarddebon> can build a sort function in ?
Just use
$str='101,blablabla,blablabla
105,blablabla,blablabla
103,blablabla,blablabla
104,blablabla,blablabla
100,blablabla,blablabla
';
print map{$_->[1],"\n"}sort{$a->[0]<=>$b->[0]}map[/^(\d+)/,$_],split/\n/,$str;
perldoc -q sort
perldoc -f map
perldoc -f sort
BTW, if you have a lot of sorting you should use something like the
Rosler-Guttman pack sort or is it called the packed default sort?
HTH.
--vjm
------------------------------
Date: Wed, 21 Mar 2001 03:31:55 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: How to sort ?
Message-Id: <slrn9bg85a.e3n.tjla@thislove.dyndns.org>
I was shocked! How could Vinny Murphy <VincentMurphy@mediaone.net>
say such a terrible thing:
>Just use
>
>$str='101,blablabla,blablabla
>105,blablabla,blablabla
>103,blablabla,blablabla
>104,blablabla,blablabla
>100,blablabla,blablabla
>';
>
>perldoc -q sort
>perldoc -f map
>perldoc -f sort
>
>BTW, if you have a lot of sorting you should use something like the
>Rosler-Guttman pack sort or is it called the packed default sort?
Yeah, it's called the Guttman-Rosler transform. It goes like this (with
the users data):
@sorted = sort split /\n/, $str;
A trifle simpler and faster :)
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Don't force it; use a bigger hammer.
------------------------------
Date: Wed, 21 Mar 2001 11:59:55 +0800
From: Mathias Koerber <mathias@koerber.org>
Subject: IO::Select sel->add and array references
Message-Id: <uh9gbtsuiq5b10f4f8a7hqi97s9gt9tfi0@4ax.com>
I am trying use IO::Select to handle a number of
sockets. I need to keep additional information
for each socket used in the select.
man IO::Select says under 'add':
...
Each handle can be an `IO::Handle' object, an
integer or an array reference where the first element is a
`IO::Handle' or an integer.
So how do I hand an array reference to $sel->add. Like this?
while (..) {
# function returns (socket, name, time) in one array
my (@INFO) = function(...);
$sel->add(\*INFO);
}
Will I be able to use my for @INFO?
thanks
------------------------------
Date: Wed, 21 Mar 2001 14:41:09 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: New Perl Bulletin Board available
Message-Id: <s5Wt6.244$45.1305@newsfeeds.bigpond.com>
The future date is to push the spam to the top of your viewer.
SPAM OFF!
-------------
"Dave Brondsema" <brondsema@my-deja.com> wrote in message
news:I2St6.79728$W05.16043535@news1.rdc1.mi.home.com...
> > Date: Sat, 18 Aug 2001 00:56:19 -0400
>
> How about fixing your date?
>
> "necro" <necrorising@hotmail.com> wrote in message
> news:tatrntorqhh6euddn6cg280m23pu72s3cb@4ax.com...
> > New Perl Bulletin Board available
> >
> > The MotherBoard is now available! Get the freedom and versatility of a
> > high end bulletin board, at cut rate prices.
> >
> > http://www.worldwidecreations.com
>
>
------------------------------
Date: Tue, 20 Mar 2001 20:45:24 -0600
From: dbe_odinson@yahoo.com
Subject: perl Online/Offline status indicator needed
Message-Id: <ua5gbtod7662hvmu2n0fmd0qgm3e8hliea@4ax.com>
I have a requirement to put an online/offline status on a web-page
that tells the visitors when the admin is online or not (displays an
online/offline message). It is acceptable if the admin has to execute
a manual process (he executes a script or whatever), to turn this flag
on/off. But the visitors to the site need to see whether he is online
or offline.
If you could let me know about both sides of the question (the visitor
side & admin side) that would be perfect.
Thanks in advance...
Thought for the day: Beware of Gods who cannot laugh...
P.S. if you could e-mail the answers I would appreciate it. I do not
get a chance to check the groups every day...
------------------------------
Date: Wed, 21 Mar 2001 05:12:58 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: perl Online/Offline status indicator needed
Message-Id: <slrn9bge2p.eel.tjla@thislove.dyndns.org>
I was shocked! How could dbe_odinson@yahoo.com <dbe_odinson@yahoo.com>
say such a terrible thing:
>I have a requirement to put an online/offline status on a web-page
>that tells the visitors when the admin is online or not (displays an
>online/offline message). It is acceptable if the admin has to execute
>a manual process (he executes a script or whatever), to turn this flag
>on/off. But the visitors to the site need to see whether he is online
>or offline.
>
>If you could let me know about both sides of the question (the visitor
>side & admin side) that would be perfect.
This sounds like a CGI question rather than a Perl question. The
distinction can be subtle at times. Please ask this question again in a
group with the word "cgi" in the name, such as
comp.infosystems.www.authoring.cgi.
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
The following statement is not true:
------------------------------
Date: Wed, 21 Mar 2001 15:13:07 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: perl Online/Offline status indicator needed
Message-Id: <qzWt6.257$45.1646@newsfeeds.bigpond.com>
Just create a file in a directory when the file is online.
e.g. create /usr/loca/online when online; remove the file when offline
Use the -e operator to check to see whether the file exists
eg. if (-e "/usr/local/online") { ... };
gtoomey
-------------
<dbe_odinson@yahoo.com> wrote in message
news:ua5gbtod7662hvmu2n0fmd0qgm3e8hliea@4ax.com...
> I have a requirement to put an online/offline status on a web-page
> that tells the visitors when the admin is online or not (displays an
> online/offline message). It is acceptable if the admin has to execute
> a manual process (he executes a script or whatever), to turn this flag
> on/off. But the visitors to the site need to see whether he is online
> or offline.
>
> If you could let me know about both sides of the question (the visitor
> side & admin side) that would be perfect.
>
> Thanks in advance...
>
> Thought for the day: Beware of Gods who cannot laugh...
>
> P.S. if you could e-mail the answers I would appreciate it. I do not
> get a chance to check the groups every day...
>
------------------------------
Date: Wed, 21 Mar 2001 05:13:01 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Print "tar" Success or Failure
Message-Id: <slrn9bge2s.e1j.garry@zfw.zvolve.net>
On Tue, 20 Mar 2001 19:09:45 -0600 (CST), BUCK NAKED1
<dennis100@webtv.net> wrote:
>> peter.sundstrom-eds@eds.com
>> *All* Unix commands return a status
>> code. They do *not* return nothing for
>> success, they generally return 0.
>
> Thank You!!! That's one of the first things that I needed to know. Now
> why didn't someone just say that as plainly as you did? :) That I can
> understand. So... tar returns 0 if successful. Then, it seems only
> logical that tar would return a nonzero value when unsuccessful. Now, at
> least, I'm on first base. :-)
But you've been told this already in
<slrn9bdf4n.dni.garry@zfw.zvolve.net>:
>On Mon, 19 Mar 2001 23:11:08 GMT, What A Man ! <whataman@home.com>
>wrote:
>>> Run the command from the command line and examine the exit code.
>> I've been thru this with another poster. Tar returns nothing on
>> success, which would be false or 0. Is an exit value different than
>> a return value?
>The other poster was *wrong*.
>
>Every command returns an exit value. (There is no way for a command
>to return "nothing".) You can print it by using the following command
>from most shells:
>
> echo $?
>
>A command's exit status has nothing to do with what it happens to
>print to its STDOUT or its STDERR.
I am done with this thread. (My head hurts.)
--
Garry Williams
------------------------------
Date: Tue, 20 Mar 2001 22:28:47 -0600
From: Katia Hayati <hayati@math.uiuc.edu>
Subject: Script mysteriously erases file it's supposed to append to
Message-Id: <Pine.GSO.4.32.0103202220080.19833-100000@u05.math.uiuc.edu>
Hello,
Consider the following short script:
==========
#!/usr/local/bin/perl -w
use strict;
use Fcntl ':flock';
print "Content-type:text/plain\n\n";
my $logfile = "uiuc.log";
my $fool = $ENV{'QUERY_STRING'} ? $ENV{'QUERY_STRING'} : '';
if (($fool eq 'index') or ($fool eq 'pers')) {
my $when = localtime();
my $where = $ENV{'HTTP_REFERER'};
my $what = $fool;
my $who = $ENV{'REMOTE_ADDR'};
open(LOG, ">>$logfile") or die "Could not open log file $logfile: $!\n";
flock(LOG, LOCK_EX);
print LOG "$who | $when | $what | $where\n";
close LOG or die "Could not close log file $logfile: $!\n";
}
print "\n";
====================
Now most of the time, and all the times I've tested it, this works fine,
and appends to the logfile. I've also tested it with two browsers
simultaneously requesting the script, and that works fine too. But
sometimes, I check the log file and it doesn't exist. Any clues as to
why? I'm baffled.
Thanks in advance,
KH
------------------------------
Date: Wed, 21 Mar 2001 04:52:19 GMT
From: "Stan" <none@none.com>
Subject: small question - reading/writing data structures to/from file?
Message-Id: <7sWt6.54359$zV3.4509921@news1.frmt1.sfba.home.com>
Can anyone please give me a little example of how to read a data structure
from a file, and also write this structure to the file. I mean a basic
example.
This can be the example structure:
firstname (string)
lastname (string)
interests:
1 (yes/no)
2 (yes/no)
3 (yes/no)
4 (yes/no)
5 (yes/no)
for the interest part, its really five parts, each one is like a boolean (or
int).
I hope I"m not asking too much. I really am just learning this. I am coming
from a c background.
Thanks so much for any help.
-Stan
------------------------------
Date: 20 Mar 2001 20:32:07 -0600
From: comphelp@toddh.net (Todd H.)
Subject: Re: STDERR redirect to system log?
Message-Id: <ly7l1jx36g.fsf@k2.onsight.com>
"John W. Krahn" <krahnj@acm.org> writes:
> "Todd H." wrote:
> >
> > I'm writing a script for AIX that traps various error conditions and
> > prints to STDERR. Is there a way I can globally redirect STDERR to
> > the system log?
>
> About midway through the open function documentation is an example of
> redirecting STDERR and STDOUT.
> perldoc -f open
Unfortunately, this documentation (as well as the venerable Camel and
Ram) all show how to redirect STDERR to a file, but not to a pipe.
A kind colleague shared this syntax with me which seems to work well:
open(STDERR, "|/usr/bin/logger -p daemon.err -t mytag -i")
or die "Could not open logger for STDERR redirect ";
#disable buffering of the stderr
select(STDERR); $|=1; select(STDOUT);
--
Todd H.
http://www.toddh.net/
------------------------------
Date: Wed, 21 Mar 2001 04:30:51 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: STDERR redirect to system log?
Message-Id: <3AB83018.93DC04C8@acm.org>
"Todd H." wrote:
>
> "John W. Krahn" <krahnj@acm.org> writes:
> > "Todd H." wrote:
> > >
> > > I'm writing a script for AIX that traps various error conditions and
> > > prints to STDERR. Is there a way I can globally redirect STDERR to
> > > the system log?
> >
> > About midway through the open function documentation is an example of
> > redirecting STDERR and STDOUT.
> > perldoc -f open
>
> Unfortunately, this documentation (as well as the venerable Camel and
> Ram) all show how to redirect STDERR to a file, but not to a pipe.
>
> A kind colleague shared this syntax with me which seems to work well:
>
> open(STDERR, "|/usr/bin/logger -p daemon.err -t mytag -i")
> or die "Could not open logger for STDERR redirect ";
> #disable buffering of the stderr
> select(STDERR); $|=1; select(STDOUT);
perldoc Sys::Syslog
It's probably already on your system, if not do a search on CPAN for
"syslog"
"32 modules found in 13 distributions matching 'syslog'"
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 21 Mar 2001 16:13:22 +1200
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Still can't die with Tar
Message-Id: <9999pf$3d6$1@hermes.nz.eds.com>
"BUCK NAKED1" <dennis100@webtv.net> wrote in message
news:11237-3AB7F985-124@storefull-246.iap.bryant.webtv.net...
> Thanks to all of you who have spent time trying to help me on this...
>
> However, I've been working on this for 12 hours since yesterday and
> still can't figure it out after re-studying all the suggested docs. I've
> tested, and tested, and tested, and tested.
>
> I understand that I need to use system to get the return value of tar,
> and the child return value is in $?, but I never could get qw to work
> with tar after testing it for awhile. Maybe I don't need to use qw
> anyway.
>
> Anyhow, it looks like the value of tar is 0 when it is successful, and 1
> when tar fails. If this is incorrect, please tell me what the value of
> tar is on success and on failure because I could not get those shell
> commands that were suggested to give a proper value in some instances.
>
> Finding the value of tar and printing success or failure messages
> accordingly, appears to be a child problem. Can someone please just give
> me a good example, and explain why the example works? That's how I learn
> best, and I can't find even one good example on the net anywhere,
> including the perl docs.
>
> FWIW... Here's where I'm still at... if you're still willing to help.
>
> !(system("tar -zxf file.tar.gz")) and print "SUCCESS: $?\n" || print
> "FAILURE: $?\n"; unlink $tmpfile; exit 1;
>
> Note: the suggestions used above... "!" used to negate tar; "system"
> used instead of backticks to get the value; "$?" to see what the value
> of the child process returns; and an "exit 1" (my idea) so that it will
> exit the program if tar fails.
Why not expand it out a bit to make it a little more readable.
system("tar -zxf file.tar.gz");
if ($? == 0) {
print "SUCCESS\n";
}
else {
unlink $tmpfile or die "Can not unlink $tmpfile $!\n";
die "FAILURE\n";
}
If you want to capture the output, just change system to:
my $output=`tar -zxf file.tar.gz 2>&1`;
The '2>&1' ensures that stderr is directed to stdout.
------------------------------
Date: Wed, 21 Mar 2001 05:46:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: substitution/pattern matching -- setting the position...
Message-Id: <3AB841D1.809ABE64@acm.org>
"J.B. Moreno" wrote:
>
> John W. Krahn <krahnj@acm.org> wrote:
>
> > "J.B. Moreno" wrote:
> > >
> > > Is there any way to tell a global substition to start the next search at
> > > the same place it started the last one when it has made a SUCCESSFUL
> > > match?
> > >
> > > In this particular case I am trying to join several lines together, and
> > > the only way I've found to do that is with a while statement.
> -snip example-
> > > works, but, using 5.004, if at all possible I'd like to do it without
> > > the loop (it slows things down).
AFAIK you can't do it without the loop because of the name change from
"john" to "sally". If all the lines began with the same name a simple
s/// would work.
> Sorry, changed the data set just before posting, and didn't change the
> regex...
>
> $chat = qß
> john random blahness
>
> john more random blah
>
> john yet more blah
>
> john hasn't any more blah for now
>
> sally has random blah
>
> sally has even more random blah
>
> sally yet more blahß;
>
> while ($chat =~ s/\n([js][^ ]+ )(.+)\n\n\1/\n\1\2 /ig) {
> };
>
> print $chat;
>
> Compiles, works and shows what I'm looking for...
This version runs a bit faster :-)
#!/usr/bin/perl -w
use strict;
use Benchmark;
my $chat = qß
john random blahness
john more random blah
john yet more blah
john hasn't any more blah for now
sally has random blah
sally has even more random blah
sally yet more blahß;
sub Moreno {
$_ = $chat;
while ( s/\n([js][^ ]+ )(.+)\n\n\1/\n$1$2 /ig ) {};
}
sub Krahn {
$_ = $chat;
1 while s/^([JSjs][^ ]+ )(.+)\n\n\1/$1$2 /mg;
}
timethese( 50_000, {
'Moreno' => \&Moreno,
'Krahn' => \&Krahn,
} );
__END__
Benchmark: timing 50000 iterations of Krahn, Moreno...
Krahn: 18 wallclock secs (17.23 usr + 0.00 sys = 17.23 CPU)
Moreno: 25 wallclock secs (25.48 usr + 0.01 sys = 25.49 CPU)
John
--
use Perl;
program
fulfillment
------------------------------
Date: 21 Mar 2001 03:21:20 GMT
From: ebonyxman@aol.com (Ebonyxman)
Subject: time calculation
Message-Id: <20010320222120.27536.00000129@ng-mj1.aol.com>
Can anyone point me in the right direction? I need to calculate the number of
minutes between two date/time fields in the form "03/20/01 12:30 PM". Does
PERL have any help in this area?
Thanks for any help anyone can provide....
------------------------------
Date: Tue, 20 Mar 2001 22:42:14 -0500
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: time calculation
Message-Id: <3AB82316.64B65500@acedsl.com>
Ebonyxman wrote:
>
> Can anyone point me in the right direction? I need to calculate the number of
> minutes between two date/time fields in the form "03/20/01 12:30 PM". Does
> PERL have any help in this area?
>
> Thanks for any help anyone can provide....
If you have a 'C' compiler, try:
http://www.cpan2.org/Asset/display?dist=Date-Calc
If not (maybe it's a pre-built binary you're using) try:
http://www.cpan2.org/Asset/display?dist=DateManip
When asking the question "Can perl do this?", you should look at
http://www.cpan2.org. A search on 'Date' would have yielded 39 related
modules and you'd have gotten an answer much faster.
HTH
--
Matthew O. Persico
http://www.acecape.com/dsl
AceDSL:The best ADSL in Verizon area
------------------------------
Date: Wed, 21 Mar 2001 15:05:15 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: time calculation
Message-Id: <2sWt6.253$45.908@newsfeeds.bigpond.com>
This should be of use:
1. The two routines below work out days between dates and days of the week
Q.How may days between 15-jan-1999 and 5-jul-2001
A. date_ymd("20010715") - date_ymd("19990105");
Q . What day is 21-mar-2001.
A. weekday(date_ymd("20010321"));
2. To answer your original question, you may want to create a function along
the following lines:
Input :
date1 as dd1-mm1-yyyy1 HH1:MM1:SS1 (HH=0..23)
date2 as dd2-mm2-yyyy2 HH2:MM2:SS2 (HH=0..23)
Algortihm:
sec1= date_ymd(yyyy1.mm1.dd1)*24*60*60 + HH1*60*24 +MM1*60+SS1;
sec2= date_ymd(yyyy2.mm2.dd2)*24*60*60 + HH2*60*24 +MM2*60+SS2;
return sec2-sec1;
Getting this to work is left as an excercise to the reader!
gtoomey
----
date_ymd {
my($year)=substr($_[0],0,4);
my($month)=substr($_[0],4,2);
my($day)=substr($_[0],6,2);
my(@months) = (0,31,59,90,120,151,181,212,243,273,304,334);
return $year*365+int(($year-1)/4)+$months[$month-1]+$day +
($year%4==0&&
$month>=3?1:0)+5;
}
sub weekday {
my ($offset)=@_;
my(@wday) = ( "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" );
return $wday[$offset%7];
}
-------------------
"Ebonyxman" <ebonyxman@aol.com> wrote in message
news:20010320222120.27536.00000129@ng-mj1.aol.com...
> Can anyone point me in the right direction? I need to calculate the number
of
> minutes between two date/time fields in the form "03/20/01 12:30 PM".
Does
> PERL have any help in this area?
>
> Thanks for any help anyone can provide....
------------------------------
Date: Wed, 21 Mar 2001 07:10:43 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: time calculation
Message-Id: <slrn9bgkvi.e1j.garry@zfw.zvolve.net>
On 21 Mar 2001 03:21:20 GMT, Ebonyxman <ebonyxman@aol.com> wrote:
> Can anyone point me in the right direction? I need to calculate the number of
> minutes between two date/time fields in the form "03/20/01 12:30 PM". Does
> PERL have any help in this area?
No, but Perl has. :-)
You want to use the Time::Local module. It's included with the
standard perl distribution. Check the manual page for Time::Local.
You may want to investigate the Date::Manip module if your date/time
values aren't as regular as I have assumed below. See CPAN for even
more date/time modules.
Your problem breaks down to converting each date/time field to epoch
seconds and then subtracting the two to find the difference.
Here's an example using the format you've shown. You may want to
expand on the error checking. I also assume that the date/time values
are in the local time zone:
#!/usr/bin/perl -w
use strict;
use Time::Local;
my $time_0 = "03/20/01 12:30 PM";
my $time_1 = "03/21/01 12:30 AM";
die "invalid date/time: $time_0" unless my $t0 = dt_conv($time_0);
die "invalid date/time: $time_1" unless my $t1 = dt_conv($time_1);
print "difference (in minutes) between $time_0 and $time_1 is ",
($t1 - $t0)/60, "\n";
exit 0;
sub dt_conv
{
# Extract the various fields and validate them
return unless
$_[0] =~ m!^(\d+)/(\d+)/(\d+)\s+(\d+):(\d+)\s+(AM|PM)!;
my ($mo, $da, $yr, $hh, $mm, $pm) = ($1, $2, $3, $4, $5, $6);
return if $hh > 12 or $hh == 0;
return if $mm > 59;
return if $mo > 12 or $mo == 0;
return if $da > 31 or $da == 0;
# Disambiguate the year
if ( $yr < 50 ) {
$yr += 2000;
}
else {
$yr += 1900;
}
# Normalize the hour
if ( $pm eq "PM" ) {
if ( $hh != 12 ) {
$hh += 12;
}
}
else {
if ( $hh == 12 ) {
$hh -= 12;
}
}
# Normalize the month
$mo--;
# Return epoch seconds
return timelocal 0, $mm, $hh, $da, $mo, $yr;
}
__END__
--
Garry Williams
------------------------------
Date: Tue, 20 Mar 2001 22:19:30 -0600
From: "dmarvo" <dmarvo@yahoo.com>
Subject: Re: upload a whole directory
Message-Id: <KPVt6.93$WQ4.18840@elnws01>
LWP and other modules can be found at www.cpan.org
Christian Gersch <c.gersch@team.isneurope.com> wrote in message
news:971bj3$sj7$05$1@news.t-online.com...
> Hi there!
>
> I want to transfer a whole directory from one server to another FTP
server.
> I'm really a Perl Newbie - is there perhaps an example or a workaround?
>
> By the way: Where will I be able to download the 'LWP module'?
>
> Thanks!!!
>
> -Chris
> --
> Christian Gersch, chris@team.isneurope.com
> :: www.neukunden.myisn.de - Geld für Ihre Startseite ::
>
>
------------------------------
Date: Wed, 21 Mar 2001 11:08:07 +0800
From: "Long" <yhaili@21cn.com>
Subject: Re: usernames & passwords - how to ???
Message-Id: <9996gv$d7f$2@mail.cn99.com>
You may need to use ASP. Javascript can't do it alone!
Best regards from China!
Francois Richard <richard@science.uottawa.ca> wrote in message
news:997t3t$99k3@mercury.cc.uottawa.ca...
> (sorry for cross-posting, but I'm really shooting in the dark: I have no
> idea where to start with this!)
------------------------------
Date: Wed, 21 Mar 2001 00:37:42 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Re: win32: accessing file in same Drive where cgi-bin reside return different result
Message-Id: <tbgisjams5atdc@corp.supernews.com>
Ohhh..that solve it.... I didn't even thought about that...
thanks...now I can continue learning Perl::win32
kellyboy
--
"Dave VP" <me@my_no_spam.org> wrote in message
news:3AB786EC.798AA5CA@my_no_spam.org...
>
>
> kellyboy wrote:
>
> > See code below which I got from some perl tutorial website.
> >
> > This perl , thru browser, list files and directory in the path with
$path
> > set .
> >
> > If is set $path to "C:", it list the file/directory in that directory .
If I
> > set "M:"(network map), it list file/directory in that directory as well.
> > Even If I set $path to "D:\\somedir", still successful.
> >
> > But if I set $path to "D:" It only list file/directory in
> > "D:\perl\cgi-bin\". I wanted the script to print from "D:" not
> > "D:\perl\cgi-bin"
> >
> > On my personal web server on win98, the /cgi-bin/ for perl is set to
> > "D:\perl\cgi-bin".
> > The perl script reside in that directory. So script recognize "D:\" as
> > "D:\perl\cgi-bin" instead of "D:" How do I get script to recognize "D:"
as
> > "D:" ?.
> >
> > What give??
> >
> > here s the script:
> > #!/usr/bin/perl
> >
> > print "Content-type: text/html\n\n";
> >
> > print "<html><head>\n";
> > print "<title>Hello, world!</title></head>\n";
> > print "<body bgcolor=\"#FFFFFF\" text=\"#000000\" link=\"#FF0000\"
> > vlink=\"#800000\">\n";
> > print "<BR>";
> > $path = "c:\\My Documents";
> > $path = "." unless $path;
> >
> > opendir( DIR, $path ) or die "Can't open $path: $!";
> >
> > while ( $entry = readdir( DIR ) )
> > {
> > $type = ( -d "$path\\$entry" ) ? "dir" : "file"; # $path is
crucial!
> >
> > print "$type\t$entry\n<BR>";
> > }
> >
> > closedir( DIR );
> >
> > print "</body></html>\n";
> > --
> >
> > kellyboy
>
> Your problem lies in the current (DOS) directory. If you want to see the
> contents of the root directory on the C: or D: drives, specify the path as
> "C:\\" or "D:\\".
>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 539
**************************************