[17115] in Perl-Users-Digest
Perl-Users Digest, Issue: 4527 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 5 09:05:48 2000
Date: Thu, 5 Oct 2000 06:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <970751112-v9-i4527@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 5 Oct 2000 Volume: 9 Number: 4527
Today's topics:
[Fwd: reading a secret] <lists@a1.org.uk>
Re: a 14 day counter <godzilla@stomp.stomp.tokyo>
Re: a 14 day counter <simonis@myself.com>
Re: a 14 day counter <bart.lateur@skynet.be>
Re: Add on kily@my-deja.com
Re: advise on how to set bugging on in perl file (Mark-Jason Dominus)
Common constants in a separate file <james@nospam.demon.co.uk>
Re: Common constants in a separate file (Clay Irving)
Re: Common constants in a separate file <jeffp@crusoe.net>
Re: Cookie problem ghorghor@my-deja.com
counter can't be dispalyed amy_v@my-deja.com
date conversion <heisyili@bellatlantic.net>
Re: date conversion (Clay Irving)
Re: Easy installation of modules <pete@popcornwebdesign.co.uk>
Re: embedding in HTML <ebenezer@mosi.is>
Re: error in mapping array slice (Martien Verbruggen)
Re: Formating output to be read in a form. <verybig@thebedroom.co.uk>
Re: Formating output to be read in a form. <verybig@thebedroom.co.uk>
Function jump table (CDM)
Re: Function jump table <bart.lateur@skynet.be>
Re: Function jump table (CDM)
Re: Help ! DBI error : SOLVED !!! <NDQ@iris.ltas.ulg.ac.be>
Help ! DBI error <NDQ@iris.ltas.ulg.ac.be>
Re: Help ! DBI error <chris@infostream.no>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 05 Oct 2000 11:23:22 +0100
From: Bap <lists@a1.org.uk>
Subject: [Fwd: reading a secret]
Message-Id: <39DC569A.6CD09F1E@a1.org.uk>
This is a multi-part message in MIME format.
--------------D5C3AE4D8A408BBFC1A22EC0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
I am resending this as it seems that only the most recent postings get
looked at!
Bap.
--------------D5C3AE4D8A408BBFC1A22EC0
Content-Type: message/rfc822
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Path: insnet.net!not-for-mail
From: Bap <lists@a1.org.uk>
Newsgroups: comp.lang.perl.misc
Subject: Re: reading a secret
Date: Wed, 04 Oct 2000 10:17:11 +0100
Organization: City Netgates Account
Message-ID: <39DAF596.11BA5B3F@a1.org.uk>
References: <39DA16AA.3843978D@a1.org.uk> <XUoC5.136$UW.9540@news010.worldonline.dk>
NNTP-Posting-Host: chronicles.netgates.co.uk
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Trace: starburst.uk.insnet.net 970651035 19943 194.105.64.28 (4 Oct 2000 09:17:15 GMT)
X-Complaints-To: abuse@insnet.net
NNTP-Posting-Date: 4 Oct 2000 09:17:15 GMT
X-Mailer: Mozilla 4.72 [en] (X11; I; Linux 2.2.12 i386)
X-Accept-Language: en
Cache-Post-Path: chronicles.netgates.co.uk!unknown@martha.netgates.co.uk
X-Cache: nntpcache 2.3.2 (see http://www.nntpcache.org/)
Xref: insnet.net comp.lang.perl.misc:229701
X-Cache: nntpcache 2.3.2 (see http://www.nntpcache.org/)
Anders Lund wrote:
> Bap wrote:
>
> > Hello all,
> > can any one help me with this one?
> > I need to somehow flush the input buffer immediately before I ask for a
> > password,
> > so that when I read the input, I only get what is typed after the prompt
> > is output.
> >
> > This is for an install script for a database ap. which if is not
> > supplied with uname and
> > passwd, will default to the current EUID and ask for their pg password.
> > The sleep is
> > there so that I can enter chars into the buffer while I try to get this
> > to work.
> >
> > sub askForPass{
> > my( $key, $pass );
> > sleep 5;
> > ReadMode 2;
> > while( defined( $key = ReadKey( -1 ) ) ){
> > # I hoped this would clear it, but, no.
> > }
> > #my $term = Term::ReadLine->new();
> > #$term->OUT;
> > print "Enter postgres password for $USERNAME:";
> > until( ( $key = ReadKey( 0 ) ) eq "\n" ){
> > $pass .= $key;
> > }
> > #$pass = ReadLine 0;
> > #$pass = $term->readline( "Enter postgres password for $USERNAME:" );
> > ReadMode 0;
> > print "\n$pass\n";
> > }
> >
> > Thanks in advance for any help,
> > Bap.
> >
>
> ??
>
> print "hello, how are you? ";
> $answer = <STDIN>;
> chop $answer;
> print "Sorry, why don't you take the rest of the day of!\n" unless $answer;
> for ($answer) {
> print "nice\n", last if /fine/i;
> #...
> }
>
> -anders
>
> --
> [ the word wall - and the trailing dot - in my email address
> is my _fire_wall - protecting me from the criminals abusing usenet]
I have the "sleep" in there to allow me to put some chars into the input
buffer.
I don't want to echo the entered text, that is why I have used ReadMode 2
STDIN would work OK if there were no chars entered in the input during the
sleep.
If you try the sub I posted, you will see what I mean ( you could replace the
until loop
with $pass = <STDIN>; if you want, but the effect is the same.
--------------D5C3AE4D8A408BBFC1A22EC0--
------------------------------
Date: Thu, 05 Oct 2000 01:21:17 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: a 14 day counter
Message-Id: <39DC39FD.934D30BF@stomp.stomp.tokyo>
jtjohnston wrote:
> I'm looking for ideas. I'm running a webring. I would like to create a
> two week counter subroutine that would calculate how many times my
> jump.cgi is hit over a period of the last two weeks. I call the sub from
> my jump.cgi to do this:
> today 5 hits
> yesterday 10 hits
> 2 days ago 5 hits
> 7 days ago 9 hits
> 14 days 11 hits
Easier on your script and your brain not to print
your data backwards, this is, in reverse order.
For what you want to do, this is not needed.
> There can be only a maximum of 14 days.
How about a maximum of 365 days, give or take
a handful of hours? Break this down into 52
weeks, 52.1428 plus a bit actually. Why bother
with 14 day intervals when you can group your
data based on 52 weeks?
> How would I write the sub?
In Perl?
> Where do I start?
First line of your code?
A possible approach to this would be to grab
your timelocal and convert your time stamp to
year day; 1 to 365 inclusive. Write your data
base per seven day intervals, using year days.
01 (data entries) 07
08 (data entries) 14
15 (data entries) 21
Now you have clear identifiable lines in which
to write data, or to create a new line. Easy to
write, easy to access and, uses a minimum of drive
space for storage. No need to hassle with what month,
how many days in a month and lots of calculations to
have everything just right.
KISS: Keep It Simple Silly.
Godzilla!
--
Dr. Kiralynne Schilitubi ¦ Cooling Fan Specialist
UofD: University of Duh! ¦ ENIAC Hard Wiring Pro
BumScrew, South of Egypt ¦ HTML Programming Class
------------------------------
Date: 05 Oct 2000 09:10:33 GMT
From: Drew Simonis <simonis@myself.com>
Subject: Re: a 14 day counter
Message-Id: <39DC42F4.1848D660@myself.com>
jtjohnston wrote:
>
> I'm looking for ideas. I'm running a webring. I would like to create a
> two week counter subroutine that would calculate how many times my
> jump.cgi is hit over a period of the last two weeks. I call the sub from
> my jump.cgi to do this:
>
> today 5 hits
> yesterday 10 hits
> 2 days ago 5 hits
> ...
> 7 days ago 9 hits
> 14 days 11 hits
>
> There can be only a maximum of 14 days.
>
> How would I write the sub? Where do I start?
Use Julian days and your life becomes simple.
------------------------------
Date: Thu, 05 Oct 2000 10:06:40 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: a 14 day counter
Message-Id: <6lkots0sc6oqlslt20msgvg9vlts29cshf@4ax.com>
Drew Simonis wrote:
>Use Julian days and your life becomes simple.
What is this "Julian Days" thing that keeps popping up? Why is it better
than, say, days since Jan 1 1970?
--
Bart.
------------------------------
Date: Thu, 05 Oct 2000 09:08:28 GMT
From: kily@my-deja.com
Subject: Re: Add on
Message-Id: <8rhge9$lvj$1@nnrp1.deja.com>
In article <u9snqdokyr.fsf@wcl-l.bham.ac.uk>,
nobull@mail.com wrote:
> kily@my-deja.com writes:
> >
> > Now the line: perl -pe "s/.*\s+..(.*)/\L$1/" <infile.txt >
outfile.txt
> > works at prompt line, but when I try to put: 's/.*\s+..(.*)/\L$1/'
in
> > file like somthing.pl and then at DOS prompt type:
> > perl somthing.pl <infile.txt > outfile.txt, I find the file
outfile.txt
> > is empty. Can you explain what wrong?
>
> Did you perhaps ignore the bit where I showed you to put a -p in the
> shebang line?
>
Hello AGAIN!
I puting the my file thing.pl is now:
#!perl -p
's/.*\s+..(.*)/\L$1/'
But at DOS prompt perl thing.pl <infile.txt>outfile.txt only copy
infile.txt as it into outfile.txt without making any changement.
-What is the problem?
It is possible to put completely the in and out file in thing.pl
and only type at DOS prompt: perl thing.pl?
Thanks
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 04:52:24 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: advise on how to set bugging on in perl file
Message-Id: <39dc2e53.1c60$117@news.op.net>
Keywords: Peale, byway, gait, gobbledygook
In article <Pine.A41.4.21.0010040959030.12946-100000@ginger.libs.uga.edu>,
Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
>Hmmm. A language with no bugs.
Jeremy Kahn and I once tried to invent a programming language in which
all strings were syntactically correct programs and which was
Turing-complete. It turned out to be a lot easier than we initially
supposed.
------------------------------
Date: Thu, 5 Oct 2000 13:09:18 +0100
From: James Taylor <james@nospam.demon.co.uk>
Subject: Common constants in a separate file
Message-Id: <ant051218f7ffNdQ@oakseed.demon.co.uk>
I'm sure this is something very simple that I ought to know, but
I just can't get it to work, so I turn to this group for help.
I want to keep a set of constants which are common to several scripts
in a separate file in the same directory as the scripts themselves.
The scripts are CGI programs running with Apache on UNIX, and the
constants are things like the admin email and domain name that the
scripts are running under. The scripts have strict and taint checking
turned on.
I did not want to go to the lengths of writing a full .pm module and
reading up on how to use the Exporter, but I had heard of things like
"do" and "require" so I created a separate file for the constants which
looked a bit like this:
my $DOMAIN = 'doesnotwork.com';
my $ADMIN_EMAIL = 'me@itwillneverwork.com';
# etc...
Then I tried to execute this in each script using "do 'myconstants';"
(after fixing @INC so that it looked in the current directory).
However, I found that this doesn't work. I also tried placing a
"package main;" at the top of the myconstants file, using "require
'myconstants'", fully qualifying each variable in the myconstants
file, dropping the "my" in the myconstants file, using "local" instead,
using "use vars qw(...)" in the scripts, reading the myconstants file
into a string and eval'ing it, etc, etc. Absolutely none of these
approaches seem to work, by which I mean they all fail to import the
constants into the scope of the main script.
This must be a common requirement with a widely known solution, so
please could someone tell me the correct way to do what I want when
running in strict mode and taint checking (preferably without the
need to write a full module for the sake of a few constants). I've
read through most of the Perl documentation so if the answer is there
it has probably gone over my head. A simple example would be much
appreciated. Thanks.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: 5 Oct 2000 12:43:16 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Common constants in a separate file
Message-Id: <slrn8totr4.jvl.clay@panix3.panix.com>
On Thu, 5 Oct 2000 13:09:18 +0100, James Taylor <james@nospam.demon.co.uk>
wrote:
>I'm sure this is something very simple that I ought to know, but
>I just can't get it to work, so I turn to this group for help.
>
>I want to keep a set of constants which are common to several scripts
>in a separate file in the same directory as the scripts themselves.
>The scripts are CGI programs running with Apache on UNIX, and the
>constants are things like the admin email and domain name that the
>scripts are running under. The scripts have strict and taint checking
>turned on.
>
>I did not want to go to the lengths of writing a full .pm module and
>reading up on how to use the Exporter, but I had heard of things like
>"do" and "require" so I created a separate file for the constants which
>looked a bit like this:
>
>my $DOMAIN = 'doesnotwork.com';
>my $ADMIN_EMAIL = 'me@itwillneverwork.com';
># etc...
Someone already went to the lengths of writing a full module:
App::Config
App::Config is a Perl5 module to handle global configuration
variables for perl programs. The advantages of using such a
module over the standard "global variables" approach include:
* Reduction of clutter in the main namespace.
* Default values can be specified.
* Multiple names (aliases) can refer to the same variable.
* Configuration values can be set directly from config files
and/or command line arguments.
* Data values can be automatically validated by pattern matching
(e.g. "\d+" to accept digits only) or through user-supplied
routines.
* User-defined routines can be called automatically when
configuration values are changed.
http://www.perl.com/CPAN/modules/by-module/App/
There's also another module called ConfigFile.pm:
http://www.biostat.wisc.edu/~annis/creations/ConfigFile.html
--
Clay Irving <clay@panix.com>
COMMENDATION, n. The tribute that we pay to achievements that resembles,
but do not equal, our own.
- Ambrose Bierce
------------------------------
Date: Thu, 5 Oct 2000 08:49:55 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: Common constants in a separate file
Message-Id: <Pine.GSO.4.21.0010050824430.14163-100000@crusoe.crusoe.net>
[posted & mailed]
On Oct 5, James Taylor said:
>I did not want to go to the lengths of writing a full .pm module and
>reading up on how to use the Exporter, but I had heard of things like
>"do" and "require" so I created a separate file for the constants which
>looked a bit like this:
>my $DOMAIN = 'doesnotwork.com';
>my $ADMIN_EMAIL = 'me@itwillneverwork.com';
All my() variables are local to the file/block they are created in. So
my() is not the way to go.
[other ways tried...]
local() won't help either, for the same reason.
require()d files are executed in a TOTALLY different scope than the file
doing the require()ing. That means that if foo.pl has strict on, and it
require()s bar.pl, bar.pl is not automatically under the effect of strict.
Here are a couple approaches:
#!/usr/bin/perl
# main.pl
use strict;
use vars qw( $model );
require "values.pl";
print "Model: $model\n";
and:
# values.pl
$model = 'QRX-1800';
In the main program, we still have to declare '$model' because it is going
to be used as a global. We can't my() it in main.pl, because that
wouldn't be fetching $main::model, it would be fetching the local $model
we just created. We can't my() it in values.pl, because that would make
it not visible to main.pl.
You can, however, use another package:
#!/usr/bin/perl
# main.pl
use strict;
require "values.pl";
print "Model: $Values::model\n";
and:
# values.pl
package Values;
$model = 'QZF-19';
You needn't declare $Values::model, since it already has an explicit
package name.
Now for the beauty:
#!/usr/bin/perl
# main.pl
use strict;
BEGIN { require "values.pl" }
print "Model: ", MODEL, "\n";
and:
# values.pl
use constant MODEL => 'LVV-489';
The reason values.pl is require()ed inside a BEGIN block is so that it
happens at compile-time, like use would. This makes the 'use constant'
lines in values.pl ALSO happen at compile-time. The constant.pm module
makes "constants" via subroutines. It's useful.
I hope this helps and clears things up for you.
--
Jeff "japhy" Pinyan japhy@pobox.com http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc. http://www.perlarchive.com/
CPAN - #1 Perl Resource (my id: PINYAN) http://search.cpan.org/
------------------------------
Date: Thu, 05 Oct 2000 07:54:34 GMT
From: ghorghor@my-deja.com
Subject: Re: Cookie problem
Message-Id: <8rhc3o$ir5$1@nnrp1.deja.com>
Thx to all you say :)
i ll read that shortly to help me understand
Bye
In article <J6IC5.1002$UW.34248@news010.worldonline.dk>,
Anders Lund <anders@wall.alweb.dk> wrote:
> ghorghor@my-deja.com wrote:
> > thx to answer me,
> > i have tried a lot of things and that didn't help me
> > after i found an exemple that works that is the code :
> >
>
> Your'e wellcome..
> I'll give a few comments on your code.
>
> > use strict;
> Good!
> > use CGI qw/:standard/;
> You don't seem to make use of any of the methods that you import into
the
> namespace of oyur script here. after saying "use CGI qw(standard);",
Iød
> expect you to do like
>
> print header, starthtml,h1(Cool stuff);
>
> etc. Look at some of the examples that comes with CGI.
>
> > use CGI::Carp qw/fatalsToBrowser/;
> > use CGI::Cookie;
>
> You allready got CGI::Cookie support by using CGI, so this is really
> unnessecary. Look at the CGI docs to see how Lincoln Stein sugests
that
> cookies are used with the CGI module..
> >
> > # Define all variables "with use vars" #
> >
> > use vars qw(
> > $scriptname $version $ver_date $authors $company
> > $address1 $city $state $zipcode
> > $phone $email $main_page $copy $design
> > $c $r1 $r2 $b1 $b2 $c1 $c2 $rc
> > $title $header
> > $query
> > $your_cookie
> > %get_cookies
> > $new_cookie
> > $retreived_cookie
> > $current_time
> > );
> >
> > $scriptname = "tcookie2.cgi";
> > $version = "1.00.00";
> > $ver_date = "06-08-00";
> > $authors = "Dave Van Abel";
> > $company = "Dave Van Abel";
> > $address1 = "2131 S. Allison Court";
> > $city = "Lakewood";
> > $state = "CO";
> > $zipcode = "80227";
> > $phone = "303-989-6481";
> > $email = "dvanabel\@vanabel.com";
> > $main_page = "<a href='http://www.vanabel.com' TARGET='_top'>Main
> > Page for vanabel.com</font></a>";
> > $copy = "<FONT size='2'>\© 2000, Dave Van Abel";
> > $design = "<a href='http://vanabel.com/'
TARGET='_top'>Design
> > by Dave Van Abel</font></a>";
> >
> > $c = "<font color=red>*</font>";
> > $r1 = "<font color=red>";
> > $r2 = "</font>";
> > $b1 = "<font color=blue>";
> > $b2 = "</font>";
> > $c1 ="<center>";
> > $c2 ="</center>";
>
> You dion't seem to use all theese, using the w switch or the warnings
> pragma (in perl 5.6) will give you an idear.
>
> > $title = "Page 2 of Cookie Testing Script!"; #HTML TITLE
> > $header = "Page 2 of Cookie Testing Script!"; #HTML HEADER
> >
> > $query = new CGI();
> No needs for () here, to me
> $q = new CGI;
> looks cool ;-))
>
> >
> > # Retreive Info for Cookie #
> >
> > $new_cookie = $query->param('new_cookie');
> > # Retreive the Existing Cookie #
>
> This is a bit weird, you don't have a HTML FORM element which could
provide
> your CGI object with parameters. for retrieving your cookie values,
CGI
> docs states
>
> To retrieve a cookie, request it by name by calling
> cookie() method without the -value parameter:
>
> use CGI;
> $query = new CGI;
> %answers = $query->cookie(-name=>'answers');
> # $query->cookie('answers') will work too!
>
> >
> > #%get_cookies = fetch CGI::Cookie;
> > # retreive all cookies ??
> > #$retreived_cookie = $get_cookies{'dva'}->value; # bad when
none
> > existed!!
> > $retreived_cookie = cookie('dva');
> >
> > if ($new_cookie eq "") {
> > $new_cookie = localtime;
> > }
> > $your_cookie = new CGI::Cookie(
> > -name=>'dva',
> > -value=>$new_cookie,
> > -expires=>'+30d'
> > );
> >
> > print $query->header(-cookie=>$your_cookie);
> > print $query->start_html(
> > -title=>$title,
> > -bgcolor=>'white',
> > -text=>'#000000'
> > ),
> >
> > # Header #
> >
> > "<CENTER><font color=blue><H3>$header</H3></font></CENTER>",
> >
> > "<P><CENTER><TABLE CELLPADDING=4 CELLSPACING=2 BORDER=1
> > bgcolor='#CfCfCf'>",
> >
> > # New Info #
> >
> > "<TR>",
> > "<TD colspan='2' bgcolor='#FF2F2F' height=5'><STRONG>$c1 Cookie
> > Information</STRONG></TD>",
> > "</TR>",
> >
> > "<TR>",
> > "<TD>Your Previous Cookie was</TD>",
> > "<TD>$r1 $retreived_cookie $r2</TD>",
> > "</TR>",
> > "<TR>",
> > "<TD>Your New Cookie now is</TD>",
> > "<TD> $r1 $new_cookie $r2</TD>",
> > "</TR>",
> > "</TABLE></CENTER><P>",
> >
> > "<p>",
> > $c1,
> > "$main_page<p>",
> > "$copy<p>",
> > $c2,
> > $query->end_html;
>
> Else, your code is OK, I like utilizing print as a list operator very
much.
> However, you could improve performance by using HERE documents for
some of
> that, and you should avoid importing functions that you don't use.
> Personally, I allways use an object ($obj = new CLASS(params)), but
if you
> look at osme of the examples for CGI, you'll see that importing can
be cool
> too...
>
> -anders
> --
> [ the word wall - and the trailing dot - in my email address
> is my _fire_wall - protecting me from the criminals abusing usenet]
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 07:33:17 GMT
From: amy_v@my-deja.com
Subject: counter can't be dispalyed
Message-Id: <8rhart$hva$1@nnrp1.deja.com>
Hy all,
I've had a CGI script that has to display a counter on my web page. The
program works fine creating a file in the cgi-bin directory on my
server. I've tried to put the counter on my page using an image with
src=http://my server/cgi-bin/counter.pl, but it doen't work. What should
I do???
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Thu, 05 Oct 2000 12:19:41 GMT
From: "Yi Li" <heisyili@bellatlantic.net>
Subject: date conversion
Message-Id: <xl_C5.7996$4i5.408571@typhoon2.ba-dsg.net>
I have a date/time like this:
03/Sep/2000:00:00:33
How can I convert this to the number of seconds since mid night 1/1/1970?
Thanks.
------------------------------
Date: 5 Oct 2000 12:56:54 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: date conversion
Message-Id: <slrn8toukm.jvl.clay@panix3.panix.com>
On Thu, 05 Oct 2000 12:19:41 GMT, Yi Li <heisyili@bellatlantic.net> wrote:
>I have a date/time like this:
>
>03/Sep/2000:00:00:33
>
>How can I convert this to the number of seconds since mid night 1/1/1970?
>Thanks.
An easy way:
#!/usr/local/bin/perl
use Date::Manip;
$date = ParseDate("03/Sep/2000:00:00:33");
$sec = UnixDate(ParseDate("03/Sep/2000:00:00:33"), "%s");
print "$date - $sec\n";
Result:
2000090300:00:33 - 967964433
--
Clay Irving <clay@panix.com>
What makes resisting temptation difficult, for many people, is that they
don't want to discourage it completely.
- Franklin P. Jones
------------------------------
Date: Thu, 5 Oct 2000 09:53:27 +0100
From: "Pete Smith" <pete@popcornwebdesign.co.uk>
Subject: Re: Easy installation of modules
Message-Id: <kqXC5.944$_B5.10620@NewsReader>
"Andrew N. McGuire " <anmcguire@ce.mediaone.net> wrote in message
news:Pine.LNX.4.21.0010031834550.7834-100000@hawk.ce.mediaone.net...
> On Tue, 3 Oct 2000, zoo.tv@btinternet.com quoth:
> > Can you put any module as the script you are calling from, or do they
have
> > to be installed properly?
> I guess I am a bit unclear on the concept of what you are asking, can you
> clarify your question?
Yeah, sorry.
What I meant to say was:
Can you put any module *in the same directory* as the script you are calling
from, or do they have
to be installed properly?
Guess thats what happens when you post drunk :#)
Pete (zoo.tv)
------------------------------
Date: Thu, 5 Oct 2000 12:27:08 -0000
From: "Ebenezer Bodvarsson" <ebenezer@mosi.is>
Subject: Re: embedding in HTML
Message-Id: <39dcd858.0@news.isholf.is>
Check out embperl http://perl.apache.org/embperl/ works great!
Ebenezer Bodvarsson
jason <elephant@squirrelgroup.com> wrote in message
news:MPG.14468f77e4aaf18c9897fa@localhost...
> N wrote ..
> >Is there a way you embed perl script in the html files like PHP's <?php
....
> >> method besides using SSI's? If it is too complicated an answer I would
be
> >happy with the name of this function (if exists) so I could look it up.
>
> several .. take a look at the large number of modules at CPAN
>
> http://search.cpan.org/
>
> and search for embed*HTML in the Documentation
>
> see the Help for more information on how to use this tool
>
> --
> jason -- elephant@squirrelgroup.com --
------------------------------
Date: Thu, 5 Oct 2000 22:11:14 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: error in mapping array slice
Message-Id: <slrn8tooei.jr6.mgjv@martien.heliotrope.home>
On Wed, 04 Oct 2000 08:36:54 +0800,
Tk Soh <r28629@email.sps.mot.com> wrote:
>
> Actually I am not new to c.l.p.m, just got a bit disconnected lately
> (about a year :-) Appreciate the reminder though.
The name looked familiar, but the posting style didn't :)
> the original intention was to build an array from another with a minimum
> number of elements, or "pre-fill" with "" if element value is undefined.
> My two-line alternative works, but I thought using map would make the
> code more perl'ish:
>
> @this_array = map {defined? $_ : ''} @that_array[-10, -1];
I'm still not entirely clear why you need the negative subscripts. Or
indeed what it is you are trying to achieve. Are you trying to add a
number of elements before the elements that you have in your array? all
with "" as the value? Why not something like:
@this_array = (("") x 10, @that_array);
or if you can do it to the same array:
unshift @this_array, "" for (1..10);
unshift @this_array, ("") x 10;
splice @this_array, 0, 0, ("") x 10;
Or am I totally misunderstanding what you're trying to achieve?
Martien
PS. The trick with ${ = -10 is not as reliable as I thought. I guess
it's not for nothing that its use is deprecated.
# perl
$[ = -10;
@foo = (1 .. 5);
for $i (-10 .. 1) { print "$i=$foo[$i], " }
print "\n";
__END__
-10=, -9=, -8=, -7=, -6=, -5=1, -4=2, -3=3, -2=4, -1=5, 0=1, 1=,
Not what I expected. Especially index 0 is surprising.
--
Martien Verbruggen |
Interactive Media Division | Begin at the beginning and go on
Commercial Dynamics Pty. Ltd. | till you come to the end; then stop.
NSW, Australia |
------------------------------
Date: Thu, 5 Oct 2000 12:44:50 +0100
From: "Phil Latio" <verybig@thebedroom.co.uk>
Subject: Re: Formating output to be read in a form.
Message-Id: <8rhp12$3q2$1@uranium.btinternet.com>
>Ooh.. what a clever name and email address. Did you have to think long
>before you came up with that?
I am glad your impressed. Most people think I am just a twat with a stupid
name.
>Learn to type, at your shell prompt, commands starting with perldoc
I don't have shell access.
------------------------------
Date: Thu, 5 Oct 2000 12:54:01 +0100
From: "Phil Latio" <verybig@thebedroom.co.uk>
Subject: Re: Formating output to be read in a form.
Message-Id: <8rhpib$4u7$1@uranium.btinternet.com>
Jeff Zucker wrote in message <39DC029D.27565FA@vpservices.com>...
>Phil Latio wrote:
>>
>> <input type=hidden name="price" value="$Price">
>>
>> How would this be written in perl ?
>
>print qq(
> <input type="hidden" name="price" value="$Price">
>);
>
>OR
>
>print <<EOH;
> <input type="hidden" name="price" value="$Price">
>EOH
>
>OR
>
>use CGI qw(:standard);
># ...
>print
den(
> -name => "price",
> -value => $Price
>);
>
>Note that it is not a mistake that there are quotes around $Price in the
>first two examples and none in the last example. Also note that some
>folks shudder when one uses a capitalized variable name and would prefer
>to write it $price.
>
>--
>Jeff
Many thanks for this.
I kept getting "Warning: Failed opening 'validate_pay.pht' for inclusion include_path='.:/home/malstewa/www/phplib') in /home/********/www/s****e/**/pay.cfm on line 131"
However the problem was with the not with my script but the file "pay.cfm" was not on the server.
------------------------------
Date: Thu, 5 Oct 2000 11:11:11 +0200
From: cdemaeyer1@mmm.com (CDM)
Subject: Function jump table
Message-Id: <8rhgkq$i4d$1@magnum.mmm.com>
Hi,
How to build a function jump table? If say, a list of commands into a hash:
eg. quit userQuit
help helpHim
showvar showVar
display showRows
and want the parser to jump to the right function. How to build/reference
it?
Mvg.
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: Thu, 05 Oct 2000 10:03:58 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Function jump table
Message-Id: <28kots4r82g1den9jrvbs8h626eo5et3p3@4ax.com>
CDM wrote:
>How to build a function jump table? If say, a list of commands into a hash:
>eg. quit userQuit
> help helpHim
> showvar showVar
> display showRows
>
>and want the parser to jump to the right function. How to build/reference
>it?
\&func
gives you a reference to your sub. You can call it through
$subref->(@args)
%dispatch = (
quit => \&userQuit,
help => \&helpHim,
showvar => \&showVar,
display => \&showRows,
);
sub helpHim {
print "Oh, you poor devil, you. You're lost?\n";
}
$todo = 'help';
($dispatch{$todo} || sub { die "What is '$todo'?\n" })->();
The "|| sub {...}" part provides a catch-all (default), in case the user
requests something that is not implemented.
--
Bart.
------------------------------
Date: Thu, 5 Oct 2000 12:13:11 +0200
From: cdemaeyer1@mmm.com (CDM)
Subject: Re: Function jump table
Message-Id: <8rhk92$ia9$1@magnum.mmm.com>
Works, thanks a lot!!!
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:28kots4r82g1den9jrvbs8h626eo5et3p3@4ax.com...
> CDM wrote:
Opinions expressed herein are my own and may not represent those of my employer.
------------------------------
Date: Thu, 05 Oct 2000 13:31:09 +0200
From: NDQ <NDQ@iris.ltas.ulg.ac.be>
Subject: Re: Help ! DBI error : SOLVED !!!
Message-Id: <39DC667D.1475258A@iris.ltas.ulg.ac.be>
NDQ wrote:
>
> Hi,
> I'm newbie with DBI. My test is :
> -------------------------------------------
> #!/usr/bin/perl
>
> use DBI;
> $driver = "mysql";
> $database = 'toto';
> $hostname = 'localhost';
> $port = '';
> $dsn = "DBI:$driver:database=$database;host=$hostname";
>
> $user= 'foo';
> $password = 'bla';
>
> $dbh = DBI->connect($dsn, $user, $password);
>
> $sth = $dbh->prepare("SELECT name,email FROM vietlug");
> $sth->execute;
> $numRows = $sth->rows;
> print "num of row = $numRows\n";
> $numFields = $sth->{'NUM_OF_FIELDS'};
> while(my @row = $sth->fetchow_array()){
My error is here ^^^^^^^^^ ;-)
> for (my $i = 0; $i < $numFields; $i++) {
> print $row[$i],($i ? "," : "");
> }
> print "\n";
> }
> $sth->finish;
> $dbh->disconnect();
>
> I got result always with error :
>
> num of row = 116
> Can't locate object method "fetchow_array" via package "DBI::st" at
> ./test-DBI.pl line 22
>
> I'm under RH6.1/DBI-1.14/MySQL-3.22.32/Perl-5.00503.
>
> Thanks in advance,
> --
> NGUYEN-DAI Quy
------------------------------
Date: Thu, 05 Oct 2000 13:11:15 +0200
From: NDQ <NDQ@iris.ltas.ulg.ac.be>
Subject: Help ! DBI error
Message-Id: <39DC61D3.FDCA27EC@iris.ltas.ulg.ac.be>
Hi,
I'm newbie with DBI. My test is :
-------------------------------------------
#!/usr/bin/perl
use DBI;
$driver = "mysql";
$database = 'toto';
$hostname = 'localhost';
$port = '';
$dsn = "DBI:$driver:database=$database;host=$hostname";
$user= 'foo';
$password = 'bla';
$dbh = DBI->connect($dsn, $user, $password);
$sth = $dbh->prepare("SELECT name,email FROM vietlug");
$sth->execute;
$numRows = $sth->rows;
print "num of row = $numRows\n";
$numFields = $sth->{'NUM_OF_FIELDS'};
while(my @row = $sth->fetchow_array()){
for (my $i = 0; $i < $numFields; $i++) {
print $row[$i],($i ? "," : "");
}
print "\n";
}
$sth->finish;
$dbh->disconnect();
I got result always with error :
num of row = 116
Can't locate object method "fetchow_array" via package "DBI::st" at
./test-DBI.pl line 22
I'm under RH6.1/DBI-1.14/MySQL-3.22.32/Perl-5.00503.
Thanks in advance,
--
NGUYEN-DAI Quy
------------------------------
Date: 05 Oct 2000 13:23:04 +0200
From: Chris Searle <chris@infostream.no>
Subject: Re: Help ! DBI error
Message-Id: <xmw4s2ry1k7.fsf@feynman.oslo.infostream.no>
<snip>
> while(my @row = $sth->fetchow_array()){
<snip>
> I got result always with error :
> num of row = 116
> Can't locate object method "fetchow_array" via package "DBI::st" at
> ./test-DBI.pl line 22
Shouldn't that be fetchrow_array instead of fetchow_array?
Regards
--
Chris Searle <chris@infostream.no>
------------------------------
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 V9 Issue 4527
**************************************