[25308] in Perl-Users-Digest
Perl-Users Digest, Issue: 7553 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 22 14:05:36 2004
Date: Wed, 22 Dec 2004 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 22 Dec 2004 Volume: 10 Number: 7553
Today's topics:
Basic CGI.pm question <willh@msoft.com>
Re: Basic CGI.pm question <phaylon@dunkelheit.at>
Re: Basic CGI.pm question <flavell@ph.gla.ac.uk>
Re: Basic CGI.pm question <jgibson@mail.arc.nasa.gov>
Re: Basic CGI.pm question <willh@msoft.com>
Re: Basic CGI.pm question <willh@msoft.com>
Re: Basic CGI.pm question <willh@msoft.com>
Change file creation date? <j.b.l.0.2.@.hotmail.com>
Re: Change file creation date? <x3v0-usenet@yahoo.com>
Re: Change file creation date? <phaylon@dunkelheit.at>
Re: Change file creation date? <jgibson@mail.arc.nasa.gov>
Re: Change file creation date? <bbeaman2@cox.net>
Re: copy mysql database with perl AaronJSherman@gmail.com
Re: input <>; not working? <AaronJSherman@gmail.com>
Re: input <>; not working? <bustanut2020@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Dec 2004 09:50:05 -0800
From: "Will Hartung" <willh@msoft.com>
Subject: Basic CGI.pm question
Message-Id: <32tqeqF3r491uU1@individual.net>
Hi all,
I was trying to write a simple CGI script last night and ran in to some
issues.
use CGI;
my $query = new CGI;
my $vars = $query->Vars;
my $elements;
my $combined;
$elements{abc} = "123";
$elements{xyz} = "qed";
%combined = (%elements, %vars);
print %combined;
When I was first playing with this, I was using Perl 5.005 that was stock
installed in /usr/bin/perl on my Solaris 8 machine. When it started, it
would tell that I was in "standalone mode" or somesuch and to enter in
"name=value" pairs. Later, I discovered that it the CGI.pm version it had
installed didn't support the $query->Vars routine.
So, I upgraded to 5.8 using www.blastwave.com. At first, it didn't work but
then I moved /opt/csw/bin on to the from of my PATH and then it found the
new perl.
Now, CGI no longer prompts me for the name=value pairs. I read some
documentation that said that it should, or that I could add pairs by doing
"x.pl abc=123" on the command line. But that isn't working either.
Now, this quick and dirty script has collapsed into mad, time wasting
struggle. As may be apparent, I'm not really up to speed on Perl (having
last dabbled with Perl 4), but "how hard could this be".
My hope was to basiclly develop, debug, and test the script as much as I
could from the command line before I dumped it onto the web server, but that
seems to be a hope that has been frustrated.
I was thinking this was a installation problem with my machine, but when I
tried in on Cygwin (which is running 5.8.0), I got similar behaviors.
Can someone perhaps nudge me in the right direction on what I'm doing wrong?
Apparently the documenation I've been using is wrong or out of date.
Thanx!
Regards,
Will Hartung
(willh@msoft.com)
------------------------------
Date: Wed, 22 Dec 2004 18:49:25 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: Basic CGI.pm question
Message-Id: <pan.2004.12.22.17.49.24.617198@dunkelheit.at>
Will Hartung wrote:
> Can someone perhaps nudge me in the right direction on what I'm doing
> wrong?
Sorry, no 100 percent sure answer here, but have you tried the -debug
pragma, as mentioned in perldoc CGI?
g,
Robert
--
http://www.dunkelheit.at/
»Better to reign in hell than to serve in heaven«
-- John Milton, »Paradise Lost«
------------------------------
Date: Wed, 22 Dec 2004 18:08:24 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Basic CGI.pm question
Message-Id: <Pine.LNX.4.61.0412221755110.2235@ppepc56.ph.gla.ac.uk>
On Wed, 22 Dec 2004, Will Hartung wrote:
> Now, CGI no longer prompts me for the name=value pairs.
The default behaviour changed, relative to early versions of the
module. Now, if you want this behaviour, you need to ask for it.
Here's the author's own documentation (for the latest version):
http://stein.cshl.org/WWW/software/CGI/#debugging
You should find esentially the same information, albeit in a different
format, via "perldoc CGI.pm" on your system, and this will be for the
version that you actually installed, where there are any differences.
> Now, this quick and dirty script has collapsed into mad, time
> wasting struggle. As may be apparent, I'm not really up to speed on
> Perl (having last dabbled with Perl 4), but "how hard could this
> be".
Well, finding and using the documentation is the key to this, IMHO.
When you're doing CGI, I strongly recommend not only the precautions
mentioned in this group's posting guidelines (i.e use strict and use
warnings) to get all the help that Perl can offer, but also enabling
taint checking (-T) so that there's at least some chance of getting
notified if you dig any large security holes.
It may be unfortunate that the CGI.pm author doesn't tend to include
these in his worked examples.
Google also suggests
http://perlmonks.thepen.com/use%20strict%20warnings%20and%20diagnostics%20or%20die.html
for further consideration.
------------------------------
Date: Wed, 22 Dec 2004 10:16:33 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Basic CGI.pm question
Message-Id: <221220041016333047%jgibson@mail.arc.nasa.gov>
In article <32tqeqF3r491uU1@individual.net>, Will Hartung
<willh@msoft.com> wrote:
> Hi all,
>
> I was trying to write a simple CGI script last night and ran in to some
> issues.
>
[CGI fragment snipped]
>
> Now, CGI no longer prompts me for the name=value pairs. I read some
> documentation that said that it should, or that I could add pairs by doing
> "x.pl abc=123" on the command line. But that isn't working either.
What means "isn't working"?
>
> My hope was to basiclly develop, debug, and test the script as much as I
> could from the command line before I dumped it onto the web server, but that
> seems to be a hope that has been frustrated.
>
> I was thinking this was a installation problem with my machine, but when I
> tried in on Cygwin (which is running 5.8.0), I got similar behaviors.
>
> Can someone perhaps nudge me in the right direction on what I'm doing wrong?
> Apparently the documenation I've been using is wrong or out of date.
Have you looked at the documentation that comes with your perl
installation? Executing 'perldoc CGI' will get you a lengthy document
describing CGI. Search for the "DEBUGGING" section.
I test simple CGI scripts by putting, for example,
if( $test ) {
$ENV{QUERY_STRING} = 'abc=123' unless defined $ENV{QUERY_STRING};
$ENV{REQUEST_METHOD] = 'GET' unless defined $ENV{REQUEST_METHOD};
$ENV{CONTENT_LENGTH} = 0 unless defined $ENV{CONTENT_LENGTH};
}
at the begining of my program, before I create a CGI object instance.
Make sure you are executing the proper version of perl. Use 'perl -v'
and 'which perl' to see which version of perl and
perl -MCGI -e 'print "$CGI::VERSION\n"'
to see which version of CGI you are using.
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: Wed, 22 Dec 2004 10:41:12 -0800
From: "Will Hartung" <willh@msoft.com>
Subject: Re: Basic CGI.pm question
Message-Id: <32ttdlF3p4p1pU1@individual.net>
"Robert Sedlacek" <phaylon@dunkelheit.at> wrote in message
news:pan.2004.12.22.17.49.24.617198@dunkelheit.at...
> Will Hartung wrote:
>
> > Can someone perhaps nudge me in the right direction on what I'm doing
> > wrong?
>
> Sorry, no 100 percent sure answer here, but have you tried the -debug
> pragma, as mentioned in perldoc CGI?
Yea, I saw that reference. I just didn't know what that meant. Well, I
should say I DO know what it means, I just don't know how to use it. The
"-debug pragma" is obivously some kind of switch that's thrown someplace and
associated with CGI, but the detail on how to do that is missing (I should
say missing in me). It's one of those assumed undercurrents thats rocketing
me deeper into the depths of Perl than where I am, but it's still dark and
my flashlight is on the blink.
But thanks for the suggestion! I appreciate it!
Regards,
Will Hartung
(willh@msoft.com)
------------------------------
Date: Wed, 22 Dec 2004 10:57:42 -0800
From: "Will Hartung" <willh@msoft.com>
Subject: Re: Basic CGI.pm question
Message-Id: <32tuctF3pd71iU1@individual.net>
"Alan J. Flavell" <flavell@ph.gla.ac.uk> wrote in message
news:Pine.LNX.4.61.0412221755110.2235@ppepc56.ph.gla.ac.uk...
> The default behaviour changed, relative to early versions of the
> module. Now, if you want this behaviour, you need to ask for it.
>
> Here's the author's own documentation (for the latest version):
>
> http://stein.cshl.org/WWW/software/CGI/#debugging
>
> You should find esentially the same information, albeit in a different
> format, via "perldoc CGI.pm" on your system, and this will be for the
> version that you actually installed, where there are any differences.
Yeah, I read that. That's why I was trying the "x.pl abc=123", but "nothing
was happening". Specifically:
my $vars = $query->Vars;
seemed to net me an empty hash, and it was my understanding that this would
get me all of the parameters (notably abc = 123).
Specifically from the document you linked to (which I assume is the same one
that I had read, it was certainly close):
<quote>
Fetching the Parameter List as a Hash
$params = $q->Vars;
print $params->{'address'};
@foo = split("\0",$params->{'foo'});
%params = $q->Vars;
use CGI ':cgi-lib';
$params = Vars;
Many people want to fetch the entire parameter list as a hash in which the
keys are the names of the CGI parameters, and the values are the parameters'
values. The Vars() method does this. Called in a scalar context, it returns
the parameter list as a tied hash reference. Changing a key changes the
value of the parameter in the underlying CGI parameter list. Called in an
list context, it returns the parameter list as an ordinary hash. This allows
you to read the contents of the parameter list, but not to change it.
</quote>
Since I wasn't planning to change the parameter list, I really didn't care
which version I used, so I used $vars = $query->Vars;
> > Now, this quick and dirty script has collapsed into mad, time
> > wasting struggle. As may be apparent, I'm not really up to speed on
> > Perl (having last dabbled with Perl 4), but "how hard could this
> > be".
>
> Well, finding and using the documentation is the key to this, IMHO.
Yup! I'm with you there!
> When you're doing CGI, I strongly recommend not only the precautions
> mentioned in this group's posting guidelines (i.e use strict and use
> warnings) to get all the help that Perl can offer, but also enabling
> taint checking (-T) so that there's at least some chance of getting
> notified if you dig any large security holes.
>
> It may be unfortunate that the CGI.pm author doesn't tend to include
> these in his worked examples.
>
> Google also suggests
>
http://perlmonks.thepen.com/use%20strict%20warnings%20and%20diagnostics%20or
%20die.html
> for further consideration.
Ah! This is very helpful, I'll toss that in as well. I assume the -T goes on
the command line or the first line of the script?
#!/usr/bin/perl -T ?
I admit that "taint" is something I never dealt with at all 10 years ago
when I last worked with Perl.
Thanx for your help.
Regards,
Will Hartung
(willh@msoft.com)
------------------------------
Date: Wed, 22 Dec 2004 11:01:32 -0800
From: "Will Hartung" <willh@msoft.com>
Subject: Re: Basic CGI.pm question
Message-Id: <32tuk9F3q6rsgU1@individual.net>
"Jim Gibson" <jgibson@mail.arc.nasa.gov> wrote in message
news:221220041016333047%jgibson@mail.arc.nasa.gov...
> In article <32tqeqF3r491uU1@individual.net>, Will Hartung
> > Now, CGI no longer prompts me for the name=value pairs. I read some
> > documentation that said that it should, or that I could add pairs by
doing
> > "x.pl abc=123" on the command line. But that isn't working either.
>
> What means "isn't working"?
Meaning I was unable to populate the parameters for the CGI request either
from the command line or from stdin, as it mentioned in the debug section.
> Have you looked at the documentation that comes with your perl
> installation? Executing 'perldoc CGI' will get you a lengthy document
> describing CGI. Search for the "DEBUGGING" section.
I wasn't aware of "perldoc CGI", I'll try that as well.
> I test simple CGI scripts by putting, for example,
>
> if( $test ) {
> $ENV{QUERY_STRING} = 'abc=123' unless defined $ENV{QUERY_STRING};
> $ENV{REQUEST_METHOD] = 'GET' unless defined $ENV{REQUEST_METHOD};
> $ENV{CONTENT_LENGTH} = 0 unless defined $ENV{CONTENT_LENGTH};
> }
>
> at the begining of my program, before I create a CGI object instance.
It was my understanding that ideally I shouldn't have to do that, but I can
try that next.
> Make sure you are executing the proper version of perl. Use 'perl -v'
> and 'which perl' to see which version of perl and
>
> perl -MCGI -e 'print "$CGI::VERSION\n"'
>
> to see which version of CGI you are using.
I'll do that. Thanx!
Regards,
Will Hartung
(willh@msoft.com)
------------------------------
Date: Wed, 22 Dec 2004 17:40:58 GMT
From: jbl <j.b.l.0.2.@.hotmail.com>
Subject: Change file creation date?
Message-Id: <usbjs0lbadat35614r73qs5jmv9qlfu9eb@4ax.com>
I want to modify the file creation time to syncronize my local dates
with the dates on a server.
I haven't found any way to do that yet
Using File::stat lets me read the file statistics for:
meaning of the fields:
0 dev device number of filesystem
1 ino inode number
2 mode file mode (type and permissions)
3 nlink number of (hard) links to the file
4 uid numeric user ID of file's owner
5 gid numeric group ID of file's owner
6 rdev the device identifier (special files only)
7 size total size of file, in bytes
8 atime last access time since the epoch
9 mtime last modify time since the epoch
10 ctime inode change time (NOT creation time!) since the epoch
11 blksize preferred block size for file system I/O
12 blocks actual number of blocks allocated
but I don't see creation date,
(ctime seems to be last change time)
and I only seem to be able to read these, not change them anyway.
Thanls
jbl
------------------------------
Date: Wed, 22 Dec 2004 12:46:05 -0500
From: Ken <x3v0-usenet@yahoo.com>
Subject: Re: Change file creation date?
Message-Id: <xpiyd.12024$FE.9598@fe37.usenetserver.com>
jbl wrote:
> I want to modify the file creation time to syncronize my local dates
> with the dates on a server.
>
> I haven't found any way to do that yet
> Using File::stat lets me read the file statistics for:
>
> meaning of the fields:
>
> 0 dev device number of filesystem
> 1 ino inode number
> 2 mode file mode (type and permissions)
> 3 nlink number of (hard) links to the file
> 4 uid numeric user ID of file's owner
> 5 gid numeric group ID of file's owner
> 6 rdev the device identifier (special files only)
> 7 size total size of file, in bytes
> 8 atime last access time since the epoch
> 9 mtime last modify time since the epoch
> 10 ctime inode change time (NOT creation time!) since the epoch
> 11 blksize preferred block size for file system I/O
> 12 blocks actual number of blocks allocated
>
> but I don't see creation date,
> (ctime seems to be last change time)
> and I only seem to be able to read these, not change them anyway.
>
> Thanls
> jbl
>
this is actually a FAQ:
--------------------------------------------------------------------
4.60: How can I always keep my hash sorted?
You can look into using the DB_File module and tie() using the
$DB_BTREE
hash bindings as documented in "In Memory Databases" in DB_File. The
Tie::IxHash module from CPAN might also be instructive.
--------------------------------------------------------------------
------------------------------
Date: Wed, 22 Dec 2004 18:51:14 +0100
From: Robert Sedlacek <phaylon@dunkelheit.at>
Subject: Re: Change file creation date?
Message-Id: <pan.2004.12.22.17.51.14.579724@dunkelheit.at>
Ken wrote:
> this is actually a FAQ
Hum, maybe that's not the answer to /all/ questions ;)
scnr,
Robert
--
http://www.dunkelheit.at/
The mind is its own place, and in itself
Can make a heaven of hell, a hell of heaven. -- Milton, »Paradise Lost«
------------------------------
Date: Wed, 22 Dec 2004 10:19:29 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Change file creation date?
Message-Id: <221220041019293572%jgibson@mail.arc.nasa.gov>
In article <usbjs0lbadat35614r73qs5jmv9qlfu9eb@4ax.com>, jbl
<j.b.l.0.2.@.hotmail.com> wrote:
> I want to modify the file creation time to syncronize my local dates
> with the dates on a server.
>
> I haven't found any way to do that yet
> Using File::stat lets me read the file statistics for:
>
> meaning of the fields:
>
[snipped]
> but I don't see creation date,
> (ctime seems to be last change time)
> and I only seem to be able to read these, not change them anyway.
Unix doesn't save a creation date for files, just last access, last
modification, and last status change times.
Look at the utime function to change these times ('perldoc -f utime').
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
-----------== Posted via Newsfeed.Com - Uncensored Usenet News ==----------
http://www.newsfeed.com The #1 Newsgroup Service in the World!
-----= Over 100,000 Newsgroups - Unlimited Fast Downloads - 19 Servers =-----
------------------------------
Date: Wed, 22 Dec 2004 09:53:35 -0600
From: "die" <bbeaman2@cox.net>
Subject: Re: Change file creation date?
Message-Id: <ckjyd.488$4h.334@okepread03>
# This can be tested from the command line.$file2 should be an exact copy of
$file1
# with a current creation time.
# NOTE: Other file statistics would also be changed.
#---------------------------------------------------------------------------
----------
$file1='C:/Perl/eg/temp/file1.html'; # put original files in temporary
folder
$file2='C:/Perl/eg/file1.html'; # copy new files to another
directory
unless(-e "$file2"){ #just a precaution
use File::Copy; #method-use File::Copy;
copy("$file1","$file2");
use File::Compare; #use File::Compare;
if(compare("$file1","$file2")==0){
print"exact copy created\n";
}
}else{
print"file already exists";
}
#---------------------------------------------------------------------------
----------
# cd C:\perl\eg
# perl newsgroup.pl
"jbl" <j.b.l.0.2.@.hotmail.com> wrote in message
news:usbjs0lbadat35614r73qs5jmv9qlfu9eb@4ax.com...
> I want to modify the file creation time to syncronize my local dates
> with the dates on a server.
>
> I haven't found any way to do that yet
> Using File::stat lets me read the file statistics for:
>
> meaning of the fields:
>
> 0 dev device number of filesystem
> 1 ino inode number
> 2 mode file mode (type and permissions)
> 3 nlink number of (hard) links to the file
> 4 uid numeric user ID of file's owner
> 5 gid numeric group ID of file's owner
> 6 rdev the device identifier (special files only)
> 7 size total size of file, in bytes
> 8 atime last access time since the epoch
> 9 mtime last modify time since the epoch
> 10 ctime inode change time (NOT creation time!) since the epoch
> 11 blksize preferred block size for file system I/O
> 12 blocks actual number of blocks allocated
>
> but I don't see creation date,
> (ctime seems to be last change time)
> and I only seem to be able to read these, not change them anyway.
>
> Thanls
> jbl
>
------------------------------
Date: 22 Dec 2004 08:05:51 -0800
From: AaronJSherman@gmail.com
Subject: Re: copy mysql database with perl
Message-Id: <1103731551.626651.17290@f14g2000cwb.googlegroups.com>
Of course, you could do this from the command-line easily enough:
mysqldump --opt -u root a | mysql -u root b
Replace "root" with whatever mysql user you want to do this as, of
course.
------------------------------
Date: 22 Dec 2004 08:41:53 -0800
From: "ajs@ajs.com" <AaronJSherman@gmail.com>
Subject: Re: input <>; not working?
Message-Id: <1103733713.510922.174670@f14g2000cwb.googlegroups.com>
Questions:
1. How do you run this? You're using <>, which will read from files you
provide on the command-line or default to STDIN. <STDIN> might be what
you meant.
2. What's your input when you run this? Are you running it from the
command line, or are you trying to run it from inside something else
(like a Web server, which will not work)?
3. You can re-write your code to tell you a bit more:
warn "STDIN is not a terminal; may not work\n" unless -t STDIN;
print "Enter a number: ";
chomp($number = <STDIN>);
printf "The number is '%s' length %d.\n", $number, length($number);
Hope that helps.
------------------------------
Date: Wed, 22 Dec 2004 18:47:20 GMT
From: "Billy" <bustanut2020@yahoo.com>
Subject: Re: input <>; not working?
Message-Id: <Yijyd.618575$D%.589101@attbi_s51>
"ajs@ajs.com" <AaronJSherman@gmail.com> wrote in message
news:1103733713.510922.174670@f14g2000cwb.googlegroups.com...
> Questions:
>
> 1. How do you run this? You're using <>, which will read from files you
> provide on the command-line or default to STDIN. <STDIN> might be what
> you meant.
Tried it both ways...I thought they were equivelent...
> 2. What's your input when you run this? Are you running it from the
> command line, or are you trying to run it from inside something else
> (like a Web server, which will not work)?
running it from the url line of internet explorer or netscape...
i.e. domainname.com/cgi-bin/test.pl
> 3. You can re-write your code to tell you a bit more:
>
> warn "STDIN is not a terminal; may not work\n" unless -t STDIN;
> print "Enter a number: ";
> chomp($number = <STDIN>);
> printf "The number is '%s' length %d.\n", $number, length($number);
> Hope that helps.
The code above didn't give anymore then before... This has me stumped....
Billy
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7553
***************************************