[23891] in Perl-Users-Digest
Perl-Users Digest, Issue: 6094 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 8 03:05:36 2004
Date: Sun, 8 Feb 2004 00:05:07 -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 Sun, 8 Feb 2004 Volume: 10 Number: 6094
Today's topics:
=> operator, not just fancy comma <perl@my-header.org>
Re: => operator, not just fancy comma <tadmc@augustmail.com>
Re: Clarifications <Joe.Smith@inwap.com>
Re: converting scalar to an array of elements <krahnj@acm.org>
Getting CGI to read from a different STDIN source (Bill Gerba)
How do i get the column 'NAMES' from fetchrow_hashref ? (Tommo)
Re: How do i get the column 'NAMES' from fetchrow_hashr <tadmc@augustmail.com>
Re: How do i get the column 'NAMES' from fetchrow_hashr <bart.lateur@pandora.be>
Re: Need help passing arrays by reference pls. <kuujinbo@hotmail.com>
Re: Novice - help with pattern matching needed <gnari@simnet.is>
Re: Novice - help with pattern matching needed <noreply@gunnar.cc>
perl and internt functions (dana livni)
Re: perl and internt functions <tadmc@augustmail.com>
Re: perl identifier limits (Alex Shinn)
Re: Reference overloading helps inheritance (Anno Siegel)
Re: Reference overloading helps inheritance <uri@stemsystems.com>
Re: Reference overloading helps inheritance (Anno Siegel)
Time with Epoch earlier than 1970 question <tylercruz@hotmail.com>
Re: Time with Epoch earlier than 1970 question <noreply@gunnar.cc>
Re: Time with Epoch earlier than 1970 question (Sam Holden)
Re: Time with Epoch earlier than 1970 question <kuujinbo@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 07 Feb 2004 14:32:01 +0100
From: Matija Papec <perl@my-header.org>
Subject: => operator, not just fancy comma
Message-Id: <qmm920lbpm5iimji5rp68jksefono38cp9@4ax.com>
Clearly, it tries to quote its left side so third example goes apart from my
expectations and I'm wandering when should I worry over this arrow style.
original | B::Deparse
-------------------------------------------------------------
@files = grep -d, @files; @files = grep(-d($_), @files);
@files = grep -d $_ => @files; @files = grep(-d($_), @files);
@files = grep -d => @files; @files = grep((-'d'), @files);
perl is v5.8.0
--
Matija
------------------------------
Date: Sun, 8 Feb 2004 00:50:12 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: => operator, not just fancy comma
Message-Id: <slrnc2bn14.4lh.tadmc@magna.augustmail.com>
Matija Papec <perl@my-header.org> wrote:
>
> Clearly, it tries to quote its left side
Just like the docs say it does:
perldoc perldata
The C<< => >> operator is mostly just a more visually
distinctive synonym for a comma, but it also arranges for
its left-hand operand to be interpreted as a string--if
it's a bareword that would be a legal identifier.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 08 Feb 2004 05:14:27 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: Clarifications
Message-Id: <TAjVb.202937$nt4.975314@attbi_s51>
Uri Guttman wrote:
> JS> Real programmers use EDIT or vi or emacs or TECO. :-)
>
> ever do teco on a la-50?
Yep. At 300 baud, it was a lot faster than running TECO on an
ASR-33 Teletype. Freshmen were forced to use punched cards for
a few more years, until there were enought LSI ADM-3 terminals
to go around.
-Joe
------------------------------
Date: Sat, 07 Feb 2004 23:54:20 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: converting scalar to an array of elements
Message-Id: <40257AAB.4FBEC5FA@acm.org>
Chuckb wrote:
>
> I should know this but, what is the quickest way to convert a scalar value
> into an array?
> Ex: $name="Fred";
> so that
> $arrayname[0]="F";
> $arrayname[1]="r";
> $arrayname[2]="e";
> $arrayname[3]="d";
I don't know which is the quickest, you'll have to use Benchmark for that.
my @arrayname = split //, $name;
my @arrayname = $name =~ /./sg;
my @arrayname = unpack 'a' x length $name, $name;
my @arrayname = map substr( $name, $_, 1 ), 0 .. length( $name ) - 1;
TMTOWTDI :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: 7 Feb 2004 21:00:04 -0800
From: junkmail@wirespring.com (Bill Gerba)
Subject: Getting CGI to read from a different STDIN source
Message-Id: <7f2e88c6.0402072100.5a2b84b0@posting.google.com>
Hi,
I've run into a problem with CGI.pm. I want to use my own generic
code to actually capture the raw POST data from a form submission and
store the whole thing to a file. After I've caught the entire POST
stream, I then want to load all of the data from the file back into
STDIN and create a new CGI object that will read the data in there and
parse it out for me. Attached is the code that I'm using, and I'm
submitting from a very simple HTML form with a few text boxes and
select widgets (Perl 5.6.1 and Apache on Linux, if it's important).
#!/usr/bin/perl -w
use strict;
use Data::Dumper;
use CGI;
# First, grab the HTTP POST stream and dump it into a file.
my ($TMP,$DATA);
open($TMP,">","posted_data.txt");
while (read STDIN, $DATA, 1024) {
print $TMP $DATA;
}
close $TMP;
# Next, open the file into STDIN so CGI.pm can read it
open(STDIN,"posted_data.txt") or die "can't open temp file: $!";
$| = 1;
# Print out the data from the HTTP POST as CGI sees it.
my $cc = new CGI;
my %v = $cc->Vars;
print $cc->header();
print Dumper(\%v);
When I run this, it saves the file correctly (all of the data and
headers are there), but I get a cryptic error message: "Filehandle
STDOUT opened only for input at test.cgi line 22."
AFAIK, I'm not doing anything at all to STDOUT, and CGI doesn't seem
to think that there's anything in STDIN at all. But if I don't make
the CGI object and just do a while (<STDIN>) { print; } I get all of
my data out fine. What am I doing wrong, and how can I get CGI to see
the data in STDIN?
TIA,
Bill
------------------------------
Date: 7 Feb 2004 16:15:41 -0800
From: mark.thompson@talk21.com (Tommo)
Subject: How do i get the column 'NAMES' from fetchrow_hashref ????
Message-Id: <24bbe2a9.0402071615.3359e465@posting.google.com>
Hello,
I am stuck trying to get the column names (Keys) from a MYSQL
table using the Perl fetchrow_hashref method. I can get the values for
the keys OK.
while ($column = $sth2->fetchrow_hashref())
{
$test = $column->{Wins};
print "$test\n"; ## value of the column 'Wins' is printed.
}
I need to print/store the actual column name, in my scenario I will
not know what the column names are going to be nor how many .....
------------------------------
Date: Sat, 7 Feb 2004 18:46:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How do i get the column 'NAMES' from fetchrow_hashref ????
Message-Id: <slrnc2b1nl.45j.tadmc@magna.augustmail.com>
Tommo <mark.thompson@talk21.com> wrote:
> I am stuck trying to get the column names (Keys) from a MYSQL
> table using the Perl fetchrow_hashref method.
^^^
^^^
Have you read perlreftut.pod yet?
> I can get the values for
> the keys OK.
>
> while ($column = $sth2->fetchrow_hashref())
> {
Apply "Use Rule 1" from the above std doc:
foreach my $colname ( keys %hash ) # pretend it is a regular hash
foreach my $colname ( keys %{ } ) # replace hash _name with a block...
foreach my $colname ( keys %{ $column } ) # ... that returns a hash ref
Then print the key and value inside the foreach loop's body:
print "$colname ==> $column->{$colname}\n";
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sun, 08 Feb 2004 01:41:20 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: How do i get the column 'NAMES' from fetchrow_hashref ????
Message-Id: <9n4b2017j6jtd54p45aupfm682n1n06mbu@4ax.com>
Tommo wrote:
> I am stuck trying to get the column names (Keys) from a MYSQL
>table using the Perl fetchrow_hashref method. I can get the values for
>the keys OK.
>
>while ($column = $sth2->fetchrow_hashref())
Actually, you should try to get the column names out of $sth2, via the
NAME attribute. It's an array reference. so:
@names = @{$sth2->{NAME}};
Best do this once, before the loop -- the column names won't change with
every record.
See the DBI docs, section "Statement Handle Attributes", item "NAME". It
has a few siblings.
--
Bart.
------------------------------
Date: Sun, 08 Feb 2004 15:51:30 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Need help passing arrays by reference pls.
Message-Id: <c04m9n$6mf$1@pin3.tky.plala.or.jp>
Ben Morrow wrote:
[snip]
> A tool I like for answering this sort of question is B::Graph, which
> produces a graph of the optree. It seems that
>
> print "a", "b";
>
> becomes
>
> nextstate -> pushmark -> const -> const -> print
>
> (nextstate starts a new statement. pushmark makes a mark in the Perl
> stack to show where the arguments for the print begin. The consts push
> items onto the stack, the print takes them off down to the mark and
> prints them) whereas
>
> print "a" . "b";
>
> becomes
>
> nextstate -> pushmark -> const -> print
>
> ie. perl will perform the concatenation at compile time, and thus it
> must be more efficient. However,
>
> print "a", $x;
>
> becomes
>
> nextstate -> pushmark -> const -> padsv -> print
>
> as before (padsv gets the value of the variable and pushes it onto the
> stack) whereas
>
> print "a" . $x;
>
> becomes
>
> nextstate -> pushmark -> const -> padsv -> concat -> print
>
> ie. the concatenation is done as a separate step before the print, so
> it may well be slower (this depends on whether printing several items
> as opposed to one is slower or faster than concatenating them).
>
> Certainly it is not true that they are the same
[snip]
Perl's internals are over my head, but thank you for providing a simple,
concise explanation that makes sense. Have never used any of the B
modules and tried to play around with B::Graph, but couldn't figure out
how to get output like yours :( . But there's a link at the bottom of
the documentation, so I'll look at that and at perlguts.
keith
------------------------------
Date: Sat, 7 Feb 2004 22:59:03 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: Novice - help with pattern matching needed
Message-Id: <c03qhu$aed$1@news.simnet.is>
"Robert Day" <robertday@hotmail.com> wrote in message
news:63f953b1.0402071404.3dcb30f3@posting.google.com...
> ... the value I seek is that between the date on
> the left and the "UV Port" on the right.
>
> Enter bookmobile session location code (or NONE) : NONE 06 FEB 2004
> March Mobile A UV Port 51
> Circulation
> 06 FEB 2004 Papworth Library
> UV Port 50
>
> The section of code dealing with this is currently
>
> if(/UV/) {
> $library = $`;
> $library =~ s/^\s+\d{2}\s\w{3}\s\d{4}\s+//;
are you sure about the '^' here?
> $library =~ s/- CAMBOOK//g;
> $library =~ s/(\w+)/\u\L$1/g;
> print "$library\n";
> }
I just would do somethng like:
if ( ($library)=/\d\d \w\w\w \d{4} (.*?)(- CAMBOOK)? UV/ ) {
print "$library\n";
}
gnari
------------------------------
Date: Sun, 08 Feb 2004 01:00:05 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Novice - help with pattern matching needed
Message-Id: <c03u4u$107mv3$1@ID-184292.news.uni-berlin.de>
Robert Day wrote:
> I am using a very basic Perl script to parse a file and extract
> just the elements I need ...
<snip>
> I don't know how to get rid of "Enter bookmobile session location
> code (or NONE) : NONE" when it appears (as it does on a few
> entries). i have tried various patterns and I am sure the solution
> is simple but it eludes me at present. Can anyone help?
As regards the approach I have to ask: If you want to extract
something, why do you not write code that does just that rather than
deleting everything that you do not want to keep?
$library =~ s/^\s+\d{2}\s\w{3}\s\d{4}\s+//;
----------------------^
What's your considerations behind beginning the pattern with the ^
metacharacter?
perldoc perlvar points out that the $` variable "anywhere in a program
imposes a considerable performance penalty on all regular expression
matches". There appears not to be any reason to use it here.
> $library = $`;
> $library =~ s/^\s+\d{2}\s\w{3}\s\d{4}\s+//;
> $library =~ s/- CAMBOOK//g;
You may want to replace those three lines with:
my ($library) = /\d{2} \w{3} \d{4}\s+(.+?)(?:- CAMBOOK)?\s+UV/;
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 7 Feb 2004 17:06:12 -0800
From: dana_livni@hotmail.com (dana livni)
Subject: perl and internt functions
Message-Id: <1596f85c.0402071706.2f6ddc3b@posting.google.com>
i need to connect a certain url and save his source in a directory on
my personal computer.
how do i do it?
hoping someone could help me
------------------------------
Date: Sat, 7 Feb 2004 19:14:42 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl and internt functions
Message-Id: <slrnc2b3c2.49t.tadmc@magna.augustmail.com>
dana livni <dana_livni@hotmail.com> wrote:
> i need to connect a certain url and save his source in a directory on
> my personal computer.
>
> how do i do it?
use LWP::Simple; # untested
get_store 'http://www.perl.org', 'some/dir/perl_org.html';
See also this Perl FAQ:
How do I fetch an HTML file?
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 7 Feb 2004 22:31:30 -0800
From: google-maps@synthcode.com (Alex Shinn)
Subject: Re: perl identifier limits
Message-Id: <dc6cff67.0402072231.4f9d131c@posting.google.com>
Rocco Caputo <troc@pobox.com> wrote in message news:<slrnc29n95.eu.troc@eyrie.homenet>...
> On 7 Feb 2004 01:39:19 -0800, Alex Shinn wrote:
> > Rocco Caputo <troc@pobox.com> wrote in message news:<slrnc27h3p.eu.troc@eyrie.homenet>...
>
> So the generated source is full of symAAAAAA, symAAAAAB, or something
> you like better. It's not as meaningful as your intepretation, but it's
> less ugly and certainly faster at runtime.
OK, but I want to try to keep meaningful names if at all possible. You're right
though, the hash tables would be an unacceptable performance loss.
> Debugging generated code sucks. At least generate well commented code
> if you can't avoid it.
The generated code is already well commented and has special hooks built-in
when I need to debug it. It's well designed so that when I need to debugging
it is quite easy.
> It says something bad about your program if patching Perl is easier than
> maintaining it.
Don't be a jerk. You know nothing about my code. The Perl patch, however,
should be relatively trivial, since Perl itself has no problems reading/hashing
arbitrary length strings.
And it's a BUG!!! Apparently Perl hackers are so insecure about their language
that you can't ask for help with a workaround for a Perl bug without them
trying to convince you that YOU are the one in the wrong. Nevermind, I'll
figure it out on my own and never write to this group again.
--
Alex
------------------------------
Date: 7 Feb 2004 23:02:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reference overloading helps inheritance
Message-Id: <c03qqp$onj$1@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
>
> AS> Inheritance in Perl OO has its difficulties when it comes to data
> AS> encapsulation. Basically, it can't be done without a peek at the
> AS> implementation of the superclass.
>
> some modules will do this for you. see the class:: modules by damian conway.
>
> AS> A frequent situation is that the inheriting class contains an object
> AS> of the superclass (or, more generally, has a method that returns a
> AS> superclass object), and you want it to respond to the methods of the
> AS> superclass. But let me use a concrete example, the generalization
> AS> will be obvious.
>
> AS> Now I want Tape to respond to the methods of Time::Piece, that is, I
> AS> want to put "Time::Piece" on @Tape::ISA. (Because of the overloading
> AS> Time::Piece does, this means I can compare tapes with each other, or
> AS> with other dates (Time::Piece objects) to see which is older. Handy
> AS> when deciding which tape to overwrite.)
>
> this is done by damian's class::delegate module. it can make methods in
> the owner (the object that has the other object) that call through to
> the owned object.
Yes, it does, and it does a lot more than "my" method, and also some less
(it only works with hash objects). It uses the time-honored AUTOLOAD
to do run-time delegation, with its own method-caching and more. BTW,
the author seems to be Kurt Starsinic, not Damian.
However, the point of my posting was to show how to make Perl's native
inheritance (through @ISA) work if your object happens to contain (or
otherwise create) a superclass object. The point is that you can turn
an existing HAS-A relation into a working inheritance relation in two
statements (if applicable). It is a method that an OO programmer in
Perl should know about. That some modules do a more profound job (like
establishing the HAS-A relation in the first place), is irrelevant.
Anno
------------------------------
Date: Sat, 07 Feb 2004 23:35:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Reference overloading helps inheritance
Message-Id: <x7oesampia.fsf@mail.sysarch.com>
>>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
AS> Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
>> this is done by damian's class::delegate module. it can make methods in
>> the owner (the object that has the other object) that call through to
>> the owned object.
AS> Yes, it does, and it does a lot more than "my" method, and also some less
AS> (it only works with hash objects). It uses the time-honored AUTOLOAD
AS> to do run-time delegation, with its own method-caching and more. BTW,
AS> the author seems to be Kurt Starsinic, not Damian.
i am farily sure damian wrote it originally and gave it to kurt to
maintain. he has done that with a bunch of his modules. he doesn't have
the time to maintain all of them once he has created them.
AS> However, the point of my posting was to show how to make Perl's
AS> native inheritance (through @ISA) work if your object happens to
AS> contain (or otherwise create) a superclass object. The point is
AS> that you can turn an existing HAS-A relation into a working
AS> inheritance relation in two statements (if applicable). It is a
AS> method that an OO programmer in Perl should know about. That some
AS> modules do a more profound job (like establishing the HAS-A
AS> relation in the first place), is irrelevant.
i like HAS-A more than ISA and use it a fair amount but i don't always
do direct delegation. i will take another peek at your stuff and see if
it is worth stealing. one side issue it that overloading is slower AFAIK
(like tying is very slow we know).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 8 Feb 2004 01:34:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Reference overloading helps inheritance
Message-Id: <c043np$ec$1@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@stemsystems.com> wrote in comp.lang.perl.misc:
> >>>>> "AS" == Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> writes:
> AS> However, the point of my posting was to show how to make Perl's
> AS> native inheritance (through @ISA) work if your object happens to
> AS> contain (or otherwise create) a superclass object. The point is
> AS> that you can turn an existing HAS-A relation into a working
> AS> inheritance relation in two statements (if applicable). It is a
> AS> method that an OO programmer in Perl should know about. That some
> AS> modules do a more profound job (like establishing the HAS-A
> AS> relation in the first place), is irrelevant.
>
> i like HAS-A more than ISA and use it a fair amount but i don't always
> do direct delegation. i will take another peek at your stuff and see if
> it is worth stealing. one side issue it that overloading is slower AFAIK
> (like tying is very slow we know).
Overloading is slightly slower than a plain method call (about a third is
what I benchmarked, though these small differences are hard to measure).
That's nowhere near the loss you deal with in a typical tie.
Anno
------------------------------
Date: Sun, 08 Feb 2004 05:35:29 GMT
From: "Tyler Cruz" <tylercruz@hotmail.com>
Subject: Time with Epoch earlier than 1970 question
Message-Id: <BUjVb.429122$X%5.269055@pd7tw2no>
Hi,
I have a database where a date is entered through a form via a user in the
format (YYYY-MM-DD) format and then converted to epoch, and stored in a
MySQL database. The reverse is done when extracting this information from
the database and posting it to the web.
However, since epoch is measured from January 1, 1970, I cannot enter dates
earlier than that period. I had wanted to store the dates in epoch as it
makes for easy parsing with the POSIX module, as well as allowing MySQL to
sort by date through epoch. This is why I didn't want to simply return a
string as a date; sorting would be out of the question.
Could somebody please help me?
Thanks,
Tyler Cruz
------------------------------
Date: Sun, 08 Feb 2004 06:42:33 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Time with Epoch earlier than 1970 question
Message-Id: <c04i78$12atbj$1@ID-184292.news.uni-berlin.de>
Tyler Cruz wrote:
> This is why I didn't want to simply return a string as a date;
> sorting would be out of the question.
Why would sorting be out of the question if the format is YYYY-MM-DD?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 8 Feb 2004 06:57:22 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: Time with Epoch earlier than 1970 question
Message-Id: <slrnc2bnei.3nv.sholden@flexal.cs.usyd.edu.au>
On Sun, 08 Feb 2004 05:35:29 GMT, Tyler Cruz <tylercruz@hotmail.com> wrote:
> Hi,
>
> I have a database where a date is entered through a form via a user in the
> format (YYYY-MM-DD) format and then converted to epoch, and stored in a
> MySQL database. The reverse is done when extracting this information from
> the database and posting it to the web.
>
> However, since epoch is measured from January 1, 1970, I cannot enter dates
> earlier than that period. I had wanted to store the dates in epoch as it
> makes for easy parsing with the POSIX module, as well as allowing MySQL to
> sort by date through epoch. This is why I didn't want to simply return a
> string as a date; sorting would be out of the question.
>
> Could somebody please help me?
Mysql has a number of date types which can handle earlier dates, and all
of them can be sorted just fine by mysql.
In fact the date type is exactly the format you use for I/O and supports
dates ranging from years 1000-9999, so why bother with converting to and
from an unsuitable epoch format (the 'date' type I mention is in fact an
epoch format, but it starts at 1000-01-01).
A simple roll your own day+month*32+year*(31+12*32+1) will give you over
10 million years of dates. If you prefer bitshifting to multiplies and
modulus operations then allocating 5 bits for the day, 4 bits for the
year, and the remaining 23 bits for the year gives over 8 million years
of dates. Since there are always 12 months in a year, you could also use
day+yearmonth*32 and say year=yearmonth/12, month=yearmonth%12 giving
over 11 million years of dates. (Note I haven't checked any of my logic
or math, so I may have introduced an unworkable system which maps two
different dates to the same number - it's easy enough to check, but I
don't care enough to do so).
Of course the mysql is implemented in C and hence it's date
conversion functions will almost certainly be faster than a roll your
own done in perl.
But really, this isn't a perl issue.
--
Sam Holden
------------------------------
Date: Sun, 08 Feb 2004 15:55:53 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: Time with Epoch earlier than 1970 question
Message-Id: <c04mhq$6mf$2@pin3.tky.plala.or.jp>
Tyler Cruz wrote:
> Hi,
>
> I have a database where a date is entered through a form via a user in the
> format (YYYY-MM-DD) format and then converted to epoch, and stored in a
> MySQL database. The reverse is done when extracting this information from
> the database and posting it to the web.
>
> However, since epoch is measured from January 1, 1970, I cannot enter dates
> earlier than that period. I had wanted to store the dates in epoch as it
> makes for easy parsing with the POSIX module, as well as allowing MySQL to
> sort by date through epoch. This is why I didn't want to simply return a
> string as a date; sorting would be out of the question.
>
> Could somebody please help me?
>
> Thanks,
>
> Tyler Cruz
The following links have nothing to do with Perl, but they should help:
http://www.mysql.com/doc/en/Date_and_time_types.html
http://www.mysql.com/doc/en/Date_and_time_functions.html
http://www.mysql.com/doc/en/Date_calculations.html
http://www.mysql.com/doc/en/MySQL_indexes.html
If you use the MySQL functions you won't need to do any conversion on
the data as specified, and if you put an index on the date column in
question you don't have to worry about sorting either.
HTH - keith
------------------------------
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 6094
***************************************