[12780] in Perl-Users-Digest
Perl-Users Digest, Issue: 190 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 19 15:07:14 1999
Date: Mon, 19 Jul 1999 12:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Jul 1999 Volume: 9 Number: 190
Today's topics:
Re: almost a perl question <swiftkid@bigfoot.com>
CGI database question <mlopresti@bigfoot.com>
Comparing a Hash value to a string <blair.kissel@mts.mb.ca>
Re: Comparing a Hash value to a string <swiftkid@bigfoot.com>
cron and perl.. <marshalc@americasm01.nt.com>
Re: cron and perl.. <tturton@ntx.waymark.net>
Re: cron and perl.. (I R A Darth Aggie)
FTP and HEAD wired2000@my-deja.com
Re: How do I do a date string (ala from strftime) conve (Larry Rosler)
Re: lexical $_ with threads question? <derek_sherlock@hp.com>
Need help with socket loop! <dbohling@pacbell.net>
Re: Network disk <swiftkid@bigfoot.com>
New Page <devries-devries@wxs.nl>
padding a number skyfaye@my-deja.com
Re: padding a number <uri@sysarch.com>
Re: padding a number <laurens@bsqaure.com>
Re: padding a number (I R A Darth Aggie)
Re: padding a number (Larry Rosler)
Re: padding a number (Larry Rosler)
Re: padding a number <uri@sysarch.com>
Re: Padding numbers with 0's skyfaye@my-deja.com
Re: Padding numbers with 0's (Larry Rosler)
Perl created web page wont display images (Jeremy Webster)
Problem with PWS/NT/open command in Perl johncogan@geocities.com
Re: Problem with PWS/NT/open command in Perl <swiftkid@bigfoot.com>
read/write images to sql server using perl/ADO randy@vin.com
Re: reading from a file and THEN! (Tad McClellan)
SSLeay for HP-UX greg@nworks.net
String...part 2 <marc.barieux@t-online.de>
Re: String...part 2 (Tad McClellan)
Re: TPJ/Earthweb junk mail? <sanderson@earthweb.com>
Re: TPJ/Earthweb junk mail? <uri@sysarch.com>
Re: using multiple array fields in foreach (Michel Dalle)
Re: using multiple array fields in foreach (Tad McClellan)
Re: using multiple array fields in foreach <aperrin@mcmahon.qal.berkeley.edu>
Re: using multiple array fields in foreach <marshalc@americasm01.nt.com>
Re: using multiple array fields in foreach <marshalc@americasm01.nt.com>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 19 Jul 1999 21:11:38 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: almost a perl question
Message-Id: <7n0m1p$acg1@news.cyber.net.pk>
: Approach one: write a (extensive) perl script to generate and process an
: html form:
:
: if( $cgi->param() ) {
: process form
: }
: else {
: print form
: }
:
: Approach two: write an html page with form tags and a perl script to
: process it.
:
: I have currently used approach one, and the perl script is about 400 lines
: or so. Honestly I personally don't care about the length, but I want to be
: 'industry' compliant, if there is such a thing. i.e. Am I going to kill my
: web server this way ?
It depends, if you got a form that is made dynamically thorugh a text file
or something, you better stick to perl, or else there is no reason to use
CGI to pust print out the form!
You could just:
print ( <<EOT ) , exit unless $cgi -> param;
Hi dude, you must fill out the <a href=form.html>form<a> out there!
EOT
------------------------------
Date: Mon, 19 Jul 1999 14:11:44 -0400
From: matt <mlopresti@bigfoot.com>
Subject: CGI database question
Message-Id: <37936A60.3B992E10@bigfoot.com>
I am trying to create a dropdown list box using the following code. This
script queries a database and returns the results, but I want the
results placed in an option box on a web page. The following code
returns an error premature end of script headers. Any ideas?
Thanks in advance
#!/perl/bin/perl # needed for my apache server config
use Win32::ODBC;
print "Content-type: text/html\n\n";
print "<FORM.................................>";
print "<SELECT NAME = "xxxxxxx">";
$DSN ="xxxxxxxx";
if (!($db = new Win32::ODBC("DSN=sxxxxxxxx;"))) {
print STDOUT "Error connecting to $DSN\n";
print STDOUT "Error: " . Win32::ODBC::Error() . "\n"; exit;
}
$SqlStatement = "SELECT company_dtl.company_name
FROM company_dtl;";
if ($db->Sql($SqlStatement)) {
print "SQL failed- Cannot find xxxxxxx.company_dtl\n";
print "Error: ". $db->Error(). "\n"; $db->Close();
exit;
}
@FieldNames = $db->FieldNames();
while ($db -> FetchRow()) {
undef %Data;
%Data = $db->DataHash();
$co_name = $Data{$FieldNames[0]};
print "<OPTION>$co_name";
}
print "</SELECT>";
print "</FORM>";
$db->Close();
------------------------------
Date: Mon, 19 Jul 1999 12:26:32 -0500
From: Blair Kissel <blair.kissel@mts.mb.ca>
Subject: Comparing a Hash value to a string
Message-Id: <37935FC7.3F835D2D@mts.mb.ca>
I need to test if a value in a hash is equal to a specific string. For
instance:
if($Hash{KEY} eq "Yes")
I have tried all sorts of combinations and comparisons and it either
always enters the if statement or never enters the if statement,
regardless of the value of $Hash{KEY}. Any suggestions would be
appreciated...
Thank you,
Blair Kissel
------------------------------
Date: Mon, 19 Jul 1999 23:45:37 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Comparing a Hash value to a string
Message-Id: <7n0v2h$cnm1@news.cyber.net.pk>
: I need to test if a value in a hash is equal to a specific string. For
: instance:
:
: if($Hash{KEY} eq "Yes")
Whats wrong? It should work. (if the KEY is valid, and contains "Yes"
without quotes)
:
: I have tried all sorts of combinations and comparisons and it either
: always enters the if statement or never enters the if statement,
: regardless of the value of $Hash{KEY}. Any suggestions would be
: appreciated...
This works for me, perhaps will give you some hint.
$hash { 'faisal' } = 'cool';
print 'wow' if $hash { faisal } eq 'cool';
:
: Thank you,
:
: Blair Kissel
:
------------------------------
Date: Mon, 19 Jul 1999 12:22:58 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: cron and perl..
Message-Id: <37935EF1.BDEFAAB@americasm01.nt.com>
Hey group...I'm having a problem with one of the scripts i've written
and cron...here's the synopsis:
The script is supposed to retrieve information from an external mail
program that is command line driven...
When I run the script manually it does its job clean and great, but when
I run it with cron (every hour) It no longer works...I've piped the
output to a file so that I can see if it's doing its job...(which it's
not) any help would be greatly appreciated, thanks!
~Marshall
----------------------------------
just another guy trying to save the world
----------------------------------
------------------------------
Date: Mon, 19 Jul 1999 12:59:30 -0500
From: Tom Turton <tturton@ntx.waymark.net>
Subject: Re: cron and perl..
Message-Id: <37936782.E03FEA01@ntx.waymark.net>
No idea what particular problem you are having, but in the past,
the biggest problem I've had with scripts running manually, but
failing in cron, is that the runtime environment settings are
different. Particularly, if you are trying to make system calls
to things like tar, gzip, ftp(?)... some of these require you to
fully qualify the path to these utilities which. If you are
running any system calls (or back quotes to these) try fully
qualifying them.
---Tom Turton
Marshall Culpepper wrote:
>
> Hey group...I'm having a problem with one of the scripts i've written
> and cron...here's the synopsis:
> The script is supposed to retrieve information from an external mail
> program that is command line driven...
> When I run the script manually it does its job clean and great, but when
> I run it with cron (every hour) It no longer works...I've piped the
> output to a file so that I can see if it's doing its job...(which it's
> not) any help would be greatly appreciated, thanks!
> ~Marshall
>
> ----------------------------------
> just another guy trying to save the world
> ----------------------------------
------------------------------
Date: 19 Jul 1999 18:03:56 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: cron and perl..
Message-Id: <slrn7p6q8k.gjg.fl_aggie@thepentagon.com>
On Mon, 19 Jul 1999 12:59:30 -0500, Tom Turton <tturton@ntx.waymark.net>, in
<37936782.E03FEA01@ntx.waymark.net> wrote:
+ No idea what particular problem you are having, but in the past,
+ the biggest problem I've had with scripts running manually, but
+ failing in cron, is that the runtime environment settings are
+ different.
Yes. Just print out the environment and compare & contrast with your own.
foreach $key ( keys %ENV) {
print "$key $ENV{$key}\n";
}
I suspect that PATH is one problem.
James
------------------------------
Date: Mon, 19 Jul 1999 17:04:04 GMT
From: wired2000@my-deja.com
Subject: FTP and HEAD
Message-Id: <7mvlpq$1hg$1@nnrp1.deja.com>
Hi,
I want to setup a script which will take as input a list of ftp sites:
ie: ftp://USERID:PASSWD@hostname.com:PORT
And will connect to the site and just CHECK (something similar to the
HEAD method with web requests) if a file exists and can be downloaded
without actually downloading. Best example I can think of is like an
FTP checked, where it will scan a list of ftp sites if the file to be
downloaded is valid or not.
I'm trying to do it with LWP::Simple, but unfortunetly, the Timeout
method does not work and the script can take up to 5 minutes to scan
for those FTP sites which timeout. Can anyone think of a good way to
implement this? If your going to suggest Net::FTP, please let me know
how to implement the idea of just getting the HEAD or checking if its
valid, as I'm stuck :(
Thanks
Charles
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 19 Jul 1999 11:14:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I do a date string (ala from strftime) conversion to time_t?
Message-Id: <MPG.11fd0afcb73b2466989cf8@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <3793247c.508741461@news.supernews.com> on Mon, 19 Jul 1999
16:28:11 GMT, Gabriel Russell <grussell@hushmail.com> says...
> How do I do a date string (ala strftime) to time (ala gmtime)
> conversion? I would guess that this is a faq but was unable to find
> it.
Your guess is correct, and you didn't look all that hard. In the
section Dates in perlfaq4: "How can I take a string and turn it into
epoch seconds?"
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 19 Jul 1999 12:47:30 -0600
From: Derek Sherlock <derek_sherlock@hp.com>
Subject: Re: lexical $_ with threads question?
Message-Id: <379372C2.F69ACA88@hp.com>
Hi,
Thanks. That explains it. Sort of.
But, despite the paragraph you quoted, experimentation shows that
you CAN local() $_. The effect on visibility and lifetime seems
to be identical to that of local()'ing a true global, except that
it does not use the global namespace (i.e. it remains separate &
distinct from $main::_). But the local()'d value is still visible
to subroutines you call, so the localization is temporal (like
local()), and not lexical (like my()).
use Thread;
local $_;
$_ = 'hey';
$main::_ = 'there';
print "$_ $main::_\n";
Output:
hey there
Compare with usual localization of a global:
use Thread;
local $a;
$a = 'hey';
$main::a = 'there';
print "$a $main::a\n";
Output:
there there
This is wierd stuff!
I've also experimented with separate threads, and am convinced
that the sort-of-lexical sort-of-global $_ really is thread
safe.
I hope $_ does some day become a true per-thread global, as you
suggest it might. It would make all of this stuff much less
confusing!
I wish there were a thread-centric perl book available.
Derek
dan@tuatha.sidhe.org wrote:
>
> Derek Sherlock <derek_sherlock@hp.com> wrote:
>
> > Hi,
>
> > Despite reading many man/perldoc pages and searching dejanews,
> > I still haven't found a good explaination of the behavior of
> > the "lexical" $_ and @_ in threaded perl. Can someone
> > recommend what I should read?
>
> Sure. Read this:
>
> In perl built for threading, $_ and @_ are lexical. Basically all
> this means is that you you can't local() them. In all other ways
> they act just like they do in non-threaded perl.
>
> There's a lot of magic attached to $_ and @_. They're just barely
> lexical, and they may get switched over to per-thread globals at some
> point. (Most of the globals already are per-thread, but $_ and @_ have
> huge amounts of magic attached to them already so it's not quite as easy.
> Plus $_ and @_ were the first globals to get dealt with, so the
> implementation is really first generation, while the one handling $/ and
> friends is second gen.
>
> Dan
------------------------------
Date: Mon, 19 Jul 1999 10:53:50 -0700
From: Daniel <dbohling@pacbell.net>
Subject: Need help with socket loop!
Message-Id: <3793662E.D2491E24@pacbell.net>
Hi all. I'm trying to adapt the unix domain client/server found
in the
camel book. I'm simply trying to get the client and server to "chat" at
this point. They connect to one another just fine and will send single
messages but if i try to make them loop while reading from STDIN (on
client) to STDOUT (on server) it just sits. I assume it has something to
do with buffering?
Also is it possible to have two loops running at the same time?
Maybe
more clearer -- is there a non-forking, non-shell, non(cmd &) way to
launch a loop within a singular perl program that can get STDIN and
STDOUT while another loop does likewise?
I guess i mean a subroutine that runs parrallel with the main program.
Here's my code -- okay the camel book's, but butchered by me...And
thanks for even looking at it!
=======================client=================================
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#$| = 1;
my ($rendezvous, $linein, $lineout);
$rendezvous = shift || '/home/httpd/html/img/streamsocket';
socket(SOCK, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
connect(SOCK, sockaddr_un($rendezvous)) || die "Connect: $!\n";
print SOCK "Connected here";
print STDOUT "Connected here\n";
while ($linein = <SOCK>) {
print STDOUT $linein;
}
#while ($lineout = <STDIN>) {
# print SOCK $lineout;
#}
#$linein = <SOCK>;
#print $linein;
close SOCK;
exit 0;
=====================server===========
#!/usr/bin/perl -w
use diagnostics;
use CGI qw(param);
use Socket;
use strict;
#######################this is the server -- we only want one to feed
numerous clients and to clean up the disk
#######PREPARE USER DEFINED FUNCTIONS
sub logmsg;
#######BEGIN BODY
#$| = 1;
my $NAME = '/home/httpd/html/img/streamsocket';
my $uaddr = sockaddr_un($NAME);
my $proto = getprotobyname('tcp');
socket(Server, PF_UNIX, SOCK_STREAM, 0) || die "Socket: $!\n";
unlink($NAME);
bind(Server, $uaddr);
listen(Server, SOMAXCONN);
logmsg "Server started on $NAME";
my $waitpid = 0;
my $paddr;
#$SIG{CHLD} = \&REAPER; ###IF I FORK IS THIS A LOOPING FORMULA ALLOWING
THE REST OF PROGRAM TO CONTINUE?
for ( ; $paddr = accept(Client,Server); ) {
logmsg "connection on $NAME";
my $in;
print Client "Hey there bonehead\n";
#print Client $in;
while ($in = <STDIN>) {
#print STDOUT "$in\n";
print Client "$in\n";
}
}
################################SUBROUTINES FROM HERE ON DOWN
#sub REAPER {
#$waitpid = wait;
#$SIG{CHLD} = \&REAPER;
#logmsg "reaped $waitpid" . ($? ? "with exit $?" : "");
#}
########LOGMSG
sub logmsg {
open(LOG, ">>/home/httpd/html/img/logserver.txt"); #GONNA HAVE TO FLOCK
HERE|| die "Cant do any logging because: $!\n";
print LOG "$0 $$: @_ at ",scalar localtime, "\n";
print STDOUT "$0 $$: @_ at ",scalar localtime, "\n";
}
------------------------------
Date: Mon, 19 Jul 1999 21:08:18 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Network disk
Message-Id: <7n0lrh$b3t3@news.cyber.net.pk>
: I am writing some CGI perl (ActiveState, IIS).
: Suddenly, I find out that my perl doesn't see network disks.
: Does anybody have idea how I can see network disks.
: (As I understand I should logon to another user, but I didn't find any
: way do it.)
: Thanks for your assistance.
I am not sure about network stuff on Win, but checkout the Win32::*
modules!
------------------------------
Date: Mon, 19 Jul 1999 19:58:07 +0200
From: "S.L. de Vries" <devries-devries@wxs.nl>
Subject: New Page
Message-Id: <3793672F.21870060@wxs.nl>
Hi,
Finally, my page is presentable.
I'd love to hear your comments.
My emailadres is: visitorstc@softhome.net
My url is: http://visitorstc.webjump.com
------------------------------
Date: Mon, 19 Jul 1999 17:11:46 GMT
From: skyfaye@my-deja.com
Subject: padding a number
Message-Id: <7mvm85$1p6$1@nnrp1.deja.com>
I know this probably is a FAQ but I couldn't find it there. So here's
the simple question: How do you pad a number with a single '0' (zero)?
Thanks,
Hung
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 19 Jul 1999 13:39:28 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: padding a number
Message-Id: <x7r9m4fsj3.fsf@home.sysarch.com>
>>>>> "s" == skyfaye <skyfaye@my-deja.com> writes:
s> I know this probably is a FAQ but I couldn't find it there. So
s> here's the simple question: How do you pad a number with a single
s> '0' (zero)?
it IS in the FAQ. how hard did you search? did you look for the words
pad or padding? it is online at www.perl.com. you posibly have an old
perl with an out of date faq.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Mon, 19 Jul 1999 10:38:41 -0700
From: "Lauren Smith" <laurens@bsqaure.com>
Subject: Re: padding a number
Message-Id: <7mvnri$pcs$1@brokaw.wa.com>
skyfaye@my-deja.com wrote in message <7mvm85$1p6$1@nnrp1.deja.com>...
>I know this probably is a FAQ but I couldn't find it there. So here's
>the simple question: How do you pad a number with a single '0' (zero)?
>
$num *= 10;
Lauren
------------------------------
Date: 19 Jul 1999 18:10:24 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: padding a number
Message-Id: <slrn7p6qko.gjg.fl_aggie@thepentagon.com>
On Mon, 19 Jul 1999 10:38:41 -0700, Lauren Smith <laurens@bsqaure.com>, in
<7mvnri$pcs$1@brokaw.wa.com> wrote:
+ > How do you pad a number with a single '0' (zero)?
+ $num *= 10;
It really does pay off to test you code to see if it does what you claim it
will...
% perl
$num=0;
$num *= 10;
print q|Lauren's Method: |,$num,"\n";
printf "James' Method: %.2d\n",$num;
Results:
Lauren's Method: 0
James' Method: 00
James
------------------------------
Date: Mon, 19 Jul 1999 11:27:08 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: padding a number
Message-Id: <MPG.11fd0dd4bc215ba8989cf9@nntp.hpl.hp.com>
In article <x7r9m4fsj3.fsf@home.sysarch.com> on 19 Jul 1999 13:39:28 -
0400, Uri Guttman <uri@sysarch.com> says...
> >>>>> "s" == skyfaye <skyfaye@my-deja.com> writes:
>
> s> I know this probably is a FAQ but I couldn't find it there. So
> s> here's the simple question: How do you pad a number with a single
> s> '0' (zero)?
>
> it IS in the FAQ. how hard did you search? did you look for the words
> pad or padding? it is online at www.perl.com. you posibly have an old
> perl with an out of date faq.
I searched from www.perl.com and couldn't find it in:
<URL:http://www.perl.com./pub/doc/manual/html/pod/perlfaq4.html>
But I did find it here:
<URL:http://language.perl.com/newdocs/pod/perlfaq4.html>
But that version is still incorrect! The latest posting of the correct
version is here:
<URL:http://x38.deja.com/[ST_rn=ps]/getdoc.xp?AN=496416946>
Let's have a little sympathy for the users of the FAQ, as well as for
the overburdened maintainer.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 19 Jul 1999 11:31:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: padding a number
Message-Id: <MPG.11fd0edfee7988c6989cfa@nntp.hpl.hp.com>
In article <7mvnri$pcs$1@brokaw.wa.com> on Mon, 19 Jul 1999 10:38:41 -
0700, Lauren Smith <laurens@bsqaure.com> says...
>
> skyfaye@my-deja.com wrote in message <7mvm85$1p6$1@nnrp1.deja.com>...
> >I know this probably is a FAQ but I couldn't find it there. So here's
> >the simple question: How do you pad a number with a single '0' (zero)?
>
> $num *= 10;
GASP!!! Words fail me.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 19 Jul 1999 14:59:33 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: padding a number
Message-Id: <x7n1wsfotm.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> In article <7mvnri$pcs$1@brokaw.wa.com> on Mon, 19 Jul 1999 10:38:41 -
LR> 0700, Lauren Smith <laurens@bsqaure.com> says...
>>
>> skyfaye@my-deja.com wrote in message <7mvm85$1p6$1@nnrp1.deja.com>...
>> >I know this probably is a FAQ but I couldn't find it there. So here's
>> >the simple question: How do you pad a number with a single '0' (zero)?
>>
>> $num *= 10;
LR> GASP!!! Words fail me.
it pads on the right if the number is not zero.
$num .= '0' ;
will work for all numbers.
:-)
should this be in the faq? actually padding on the right is covered (but
in the latest but unpublished version). maybe 5.006 will get the new pods.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Mon, 19 Jul 1999 18:07:39 GMT
From: skyfaye@my-deja.com
Subject: Re: Padding numbers with 0's
Message-Id: <7mvpgv$3cd$1@nnrp1.deja.com>
In article <7moa8j$oc9$1@bayer.itron.com>,
"TravisC" <travis.cox@itron.com> wrote:
>
> Jason Stapels wrote in message <7mo0cr$l5p$1@campus1.mtu.edu>...
> >
> >Forgive me for what seems like such a simple question, but whats
> >an easy way to pad 0 (zero)'s infront of a number.
>
> The simplest way to create a fixed length number with leading zeros
> would be to do something like.
> printf "%04d%02d%02d\n",$year,$month,$day;
>
>
How do you assign that formatted date to a variable?
Thanks,
Hung
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 19 Jul 1999 11:32:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Padding numbers with 0's
Message-Id: <MPG.11fd0f1639b62336989cfb@nntp.hpl.hp.com>
In article <7mvpgv$3cd$1@nnrp1.deja.com> on Mon, 19 Jul 1999 18:07:39
GMT, skyfaye@my-deja.com <skyfaye@my-deja.com> says...
> In article <7moa8j$oc9$1@bayer.itron.com>,
> "TravisC" <travis.cox@itron.com> wrote:
> > Jason Stapels wrote in message <7mo0cr$l5p$1@campus1.mtu.edu>...
> > >Forgive me for what seems like such a simple question, but whats
> > >an easy way to pad 0 (zero)'s infront of a number.
> >
> > The simplest way to create a fixed length number with leading zeros
> > would be to do something like.
> > printf "%04d%02d%02d\n",$year,$month,$day;
>
> How do you assign that formatted date to a variable?
sprintf
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Mon, 19 Jul 1999 18:21:04 GMT
From: fake@email.address (Jeremy Webster)
Subject: Perl created web page wont display images
Message-Id: <932408464.257.35@news.remarQ.com>
I have a web page that I'm creating with perl script. The problem is
that images dont load correctly. I get a "you don't have permission ..."
error. The pictures have the same permissions (OS is red hat linux) as all
the other pics on pages that aren't created by perl.
Anyway, I suppose I'm asking if there is something special I need to know
about setting permissions for pics in this situation?
Thanks in advance
Jeremy
jwebster@olemiss.edu
------------------------------
Date: Mon, 19 Jul 1999 17:31:43 GMT
From: johncogan@geocities.com
Subject: Problem with PWS/NT/open command in Perl
Message-Id: <7mvndu$2b2$1@nnrp1.deja.com>
I'm using PWS running on an NT workstation.
open(LOG, ">>survey/survey.csv") || &Error($!);
This command give a Permission denied error.
I have tried setting the permissions of all the directories but to no
avail.
Any suggestions would be very welcome.
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 19 Jul 1999 23:43:37 +0500
From: "Faisal Nasim" <swiftkid@bigfoot.com>
Subject: Re: Problem with PWS/NT/open command in Perl
Message-Id: <7n0uuq$acg2@news.cyber.net.pk>
: I'm using PWS running on an NT workstation.
:
: open(LOG, ">>survey/survey.csv") || &Error($!);
:
: This command give a Permission denied error.
not sure about NT, but the scripts runs as nobody, atleast
on my Linux box.
Try giving full path of the file and set "survey" directory
to READ/WRITE all... (777 equivalent that is)
And survey.csv to 666 (its nt equivalent of course)
------------------------------
Date: Mon, 19 Jul 1999 10:18:09 -0700
From: randy@vin.com
Subject: read/write images to sql server using perl/ADO
Message-Id: <37935DD1.DBBB5801@vin.com>
Hi,
I was wondering if the gurus out there could help me out with my code
and tell me what I'm doing wrong.
We have a SQL database that we are serving to the web via perl
cgi-scripts. I want to be able to have users
upload/download images to the database. After reading various FAQs and
documentation, this is the code
I've come up with, but it doesn't quite work. Any ideas?
Thanks in advance,
Randy Castro (randy@vin.com)
code follows:
=====================================================
$SQLFuncConn = CreateObject OLE "ADODB.Connection";
$SQLFuncConn->{CommandTimeout} = 60;
$SQLFuncConn->Open("DSN=<myDSN>; UID=<myUID>; PWD=<myPWD>");
$SQLRecordSet = CreateObject OLE "ADODB.Recordset";
$Condition = "<insert query here>";
$SQLRecordSet = $SQLFuncConn->Execute("SELECT * FROM <myTable> WHERE
$Condition;");
$PictureFile = "<temporary file where image is saved>";
open (PICTURE,$PictureFile);
binmode(PICTURE);
undef $BytesRead;
undef $Buffer;
while ($Bytes = read(PICTURE,$Buffer,4096))
{
$BytesRead += $Bytes;
$SQLRecordSet->Fields(Picture)->AppendChunk($Buffer);
}
close(PICTURE);
$SQLRecordSet->Update;
------------------------------
Date: Mon, 19 Jul 1999 08:21:42 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: reading from a file and THEN!
Message-Id: <m85vm7.533.ln@magna.metronet.com>
Larry Rosler (lr@hpl.hp.com) wrote:
: In article <37933652@newsread3.dircon.co.uk> on 19 Jul 1999 15:29:38
: +0100, Jonathan Stowe <gellyfish@gellyfish.com> says...
: > Knuth Posern <posern@Mathematik.Uni-Marburg.de> wrote:
: > > was deleted (e.g. with "rm bla") and NEW created...
: I don't understand what is meant by 'NEW created'.
I think he means something like:
the file has a different inode (assuming Unix) than it had
when I read it.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 19 Jul 1999 18:44:41 GMT
From: greg@nworks.net
Subject: SSLeay for HP-UX
Message-Id: <7mvrmm$4cs$1@nnrp1.deja.com>
Has anyone successfully build the SSLeay shared library on HP-UX 10.x?
TIA,
Greg
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Mon, 19 Jul 1999 18:51:41 +0200
From: "Marc" <marc.barieux@t-online.de>
Subject: String...part 2
Message-Id: <7mvlkj$llv$1@news00.btx.dtag.de>
Hi,
Thanks to those who gave me an answer... I still have a question.
I have a string $string (containing HTML) with multiple lines, and I want to
take all the lines between two tags. I have for example :
<span class="table-row">
<a href=blablabla>
blablabla
</a>
</span>
I want to take everything between <span> and </span>. I can get to the
<span> line by doing :
foreach my $line ($string =~ m/(<span\sclass=\"table\srow\">)/sig)
but I can't figure out how to tell him to take the 3 next lines...
Any ideas ??
Thanks.
Marc
------------------------------
Date: Mon, 19 Jul 1999 08:39:35 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: String...part 2
Message-Id: <7a6vm7.a43.ln@magna.metronet.com>
Marc (marc.barieux@t-online.de) wrote:
: I have a string $string (containing HTML) with multiple lines, and I want to
: take all the lines between two tags.
: I want to take everything between <span> and </span>.
: Any ideas ??
while ( $html =~ m#(<span.*?</span>)#sg ) {
print "$1\n---------\n";
}
You realize that "parsing" HTML with a regex is going to *for sure*
be broken?
It might work sometimes, but you can always make a case where
it will stop working.
Decide if working right "sometimes" is "good enough" for
your application.
If not, then give up on regexen, and get one of the HTML::
parsing modules.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Jul 1999 13:07:26 -0500
From: "Scott Anderson & Mike Green" <sanderson@earthweb.com>
Subject: Re: TPJ/Earthweb junk mail?
Message-Id: <37935b4e@discussions>
Brian,
Mike Green and I saw your posting this
morning and we’d like to let you know what
we’re actually doing (and not doing) with
regard to TPJ subscriber information.
When EarthWeb acquired the publication and
subscriber list from Jon Orwant, we sent the
file to our list management company for
general cleansing, de-duping and
safe-keeping. Yes, we rent out our snail
mail house file to other marketers, but that
file *only* includes people who have opted
in.
We are currently *not* renting out the TPJ
names, nor will we, until such time as these
people have opted in for such mailings.
There are two exceptions:
1. We took the liberty of sending the
ITKnowledge online reference library mailer
you received to our entire house list. It
has been our experience that users of various
EarthWeb services find ITK to be a useful
adjunct to their physical library.
2. Jon made a deal with O’Reilly several
months ago that includes occasional list
usage. We can think of no one who respects
the Perl community more than O’Reilly; we
trust them implicitly.
Again, the TPJ list has not been – and will
not be -- rented to anyone else. We will
soon be offering these subscribers the
opportunity to opt-in to receive pertinent
marketing materials.
We hope this adequately addresses your
concern.
Scott Anderson
VP Worldwide Marketing
sanderson@earthweb.com
Mike Green
Publisher, The Perl Journal
mgreen@earthweb.com
brian@pm.org (brian d foy) wrote:
>>i've started to get junk snail mail from
Earthweb (the new publisher
>of TPJ) at home which is strange because the
only technology-related
>mailing list that has that address is TPJ.
i've checked with a few
>other TPJ subscribers, and they have
received similar junk mail.
>furthermore, i've all of a sudden starting
receiving various computer
>catalogs at home. coincidence?
>
>i'm starting to suspect that Earthweb wasn't
as interested in TPJ
>as much as the TPJ subscriber list. they
certainly haven't cared to
>make a useful online version of the magazine
which looks more like
>a billboard for the other projects they have
assimilated and then
>neglected.
>
>i tried email to Mike Green
<mgreen@earthweb.com> (the publisher),
>and after much noise making through other
channels, he left a cursory
>message on my voice mail, but has yet to
answer other email. although
>i can't confirm it (since the publisher
doesn't answer email), i
>suspect that TPJ subscriber data is not only
being used for Earthweb
>junk mail, but is being sold.
>
>i invite Mike Green <mgreen@earthweb.com> to
publically clarify TPJ's
>privacy policy and allow subscribers to
choose not to have their
>information resold.
>
>--
>brian d foy
>CGI Meta FAQ
<URL:http://www.smithrenaud.com/public/CGI_Me
taFAQ.html>
>Perl Monger Hats!
<URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: 19 Jul 1999 13:37:00 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: TPJ/Earthweb junk mail?
Message-Id: <x7vhbgfsn7.fsf@home.sysarch.com>
>>>>> "SA&MG" == Scott Anderson & Mike Green <sanderson@earthweb.com> writes:
SA&MG> Mike Green and I saw your posting this
SA&MG> morning and we’d like to let you know what
SA&MG> we’re actually doing (and not doing) with
SA&MG> regard to TPJ subscriber information.
how can you trust a web company where users have to share email
addresses? these are the geniuses who bought tpj? i have seen this type
of account for home users, but NEVER for a business address.
and on top of it they post with redmondware funny chars and with a
bizarre short line wrap (which is better than no line wrap at all!)
jon, i am sorry to hammer you, but ya could been a contendah!!
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
"F**king Windows 98", said the general in South Park before shooting Bill.
------------------------------
Date: Mon, 19 Jul 1999 17:27:32 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: using multiple array fields in foreach
Message-Id: <7mvn9q$d00$1@news.mch.sbs.de>
In article <3793541e.154114969@news.enteract.com>, syarbrou@nospam.enteract.com (Steve .) wrote:
>Say I have the following:
>
>@dir = ("1" , "2" , "3");
>@dir2 = ("one" , "two" , "three");
>
>I then do a:
>
>foreach $dir (@dir)
> {
> ....
> }
>
>What I now want to do is have the @dir2 parse thru along with the
>@dir. So when $dir is equal to "1", then $dir2 would be equal to
>"one", and when $dir1 equals "2" $dir2 would be "two". Kind of a
>double foreach at the same time. How would you go about doing that?
>Thanks
By using one of the following approaches :
1) change the foreach to use array indices :
foreach $idx (0 .. $#dir) {
$dir_item = $dir[$idx];
$dir2_item = $dir2[$idx];
}
2) use a hash instead of two arrays, and walk through the keys :
@dir3{@dir} = @dir2;
..
foreach (keys %dir3) {
}
or :
while (($key,val) = each %dir3) {
}
3) Other approaches include using shift (or pop) on both arrays
until both are empty, using array slices, ...
I probably forgot 10 other ways to do it, but this should be enough
for a start...
Have some fun, read a book :-)
Michel.
------------------------------
Date: Mon, 19 Jul 1999 08:29:40 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: using multiple array fields in foreach
Message-Id: <kn5vm7.533.ln@magna.metronet.com>
Steve . (syarbrou@nospam.enteract.com) wrote:
: Say I have the following:
: @dir = ("1" , "2" , "3");
: @dir2 = ("one" , "two" , "three");
: I then do a:
: foreach $dir (@dir)
: {
: ....
: }
: What I now want to do is have the @dir2 parse thru along with the
: @dir.
: How would you go about doing that?
Sometimes you _do_ want to explicitly index an array in Perl.
This could be one of those times.
# UNTESTED
die "arrays don't match up" unless @dir == @dir2;
foreach my $i ( 0..$#dir ) {
print "$dir[$i] ==> $dir2[$i]\n";
}
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 19 Jul 1999 10:22:27 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: using multiple array fields in foreach
Message-Id: <37935ED2.B5A245A0@mcmahon.qal.berkeley.edu>
Steve . wrote:
> @dir = ("1" , "2" , "3");
> @dir2 = ("one" , "two" , "three");
>
> What I now want to do is have the @dir2 parse thru along with the
> @dir. So when $dir is equal to "1", then $dir2 would be equal to
> "one", and when $dir1 equals "2" $dir2 would be "two". Kind of a
> double foreach at the same time. How would you go about doing that?
>
Sounds like a job for a hash to me; something like:
%dir = (
1 => one,
2 => two,
3 => three
);
foreach (keys %dir) {
...do your stuff here with $_ and $dir{$_}...
}
--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting -
aperrin@mcmahon.qal.berkeley.edu
I'M LOOKING FOR ANOTHER EXPERIENCED ACCESS
DEVELOPER - CONTACT ME IF INTERESTED.
http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------
------------------------------
Date: Mon, 19 Jul 1999 12:30:57 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Re: using multiple array fields in foreach
Message-Id: <379360D0.B1D48516@americasm01.nt.com>
Steve these works:
@dir=(1,2,3);
@dir2=('one','two','three');
foreach (@dir){$DIR{$_}=$dir2[$_-1];}
--
----------------------------------
just another guy trying to save the world
----------------------------------
------------------------------
Date: Mon, 19 Jul 1999 12:34:42 -0500
From: Marshall Culpepper <marshalc@americasm01.nt.com>
Subject: Re: using multiple array fields in foreach
Message-Id: <379361B2.4F8CB8B4@americasm01.nt.com>
> Steve these works:
>
> @dir=(1,2,3);
> @dir2=('one','two','three');
> foreach (@dir){$DIR{$_}=$dir2[$_-1];}
>
>
oops forgot one thing:
now you can access the values through a hash! :)
i.e $DIR{'1'}='one';
$DIR{'2'}='two';
...
hope that helps you out.
~Marshall
--
----------------------------------
just another guy trying to save the world
----------------------------------
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 190
*************************************