[12119] in Perl-Users-Digest
Perl-Users Digest, Issue: 5719 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 18 22:07:15 1999
Date: Tue, 18 May 99 19:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 18 May 1999 Volume: 8 Number: 5719
Today's topics:
Re: __END__ in eval (Jed Parsons)
Re: _Please_ improve localtime! (Tad McClellan)
Re: Accents Sensitivity <cassell@mail.cor.epa.gov>
Appending a simple form to end of Search results in pea (Twarren10)
Re: backspace in file output question (Fuzzy Warm Moogles)
Re: backspace in file output question <ebohlman@netcom.com>
dbh->quote problems <hpassaue@indiana.edu>
Re: dbh->quote problems <ebohlman@netcom.com>
Re: Help! cgi and system() failure <cassell@mail.cor.epa.gov>
Re: HELP:Directory or File exists?? (Tad McClellan)
Hiding OLE Object in Perl kgentes@gentek.net
Re: IRIX and Perl Menu (Alastair)
Re: japh tags <*@qz.to>
Re: Linux is just another Unix (yawn) ()
Re: Linux is just another Unix (yawn) <cassell@mail.cor.epa.gov>
Re: OOP and Perl-a good book? (Damian Conway)
perl ISAPI issue <sbansal@roartech.com>
Re: Removing a directory with contents <cassell@mail.cor.epa.gov>
Re: Saving/Reading Hashes <Joe.Kline@sdrc.com>
Re: Saving/Reading Hashes <ebohlman@netcom.com>
Re: Simple Time Manipulation <cassell@mail.cor.epa.gov>
Re: Sorting a colon separated file <cassell@mail.cor.epa.gov>
Re: The Vi Lovers Home Page (Randal L. Schwartz)
Re: Tie Fighter (Fuzzy Warm Moogles)
Re: what's wrong with my head(er)...? <dukat@flash.net>
Re: what's wrong with my head(er)...? <dukat@flash.net>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 May 1999 00:47:53 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: Re: __END__ in eval
Message-Id: <7ht1np$h74$1@agate.berkeley.edu>
Many thanks. That was very helpful.
>> $code .= $_; # this is simplified for the sake of example
>Hopefully, your 'simplified' comment means you elided all
>error checking on the C<open> and C<eval>.
For the record, yes. There won't be any "rm -rf *"s slipping through. :-)
Thanks again,
Jed
--
Jed Parsons jed@socrates.berkeley.edu
http://www.ocf.berkeley.edu/~jparsons/
``Okay. You know, super ideas do not grow on trees!'' -- Supergrover
------------------------------
Date: Tue, 18 May 1999 15:13:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: _Please_ improve localtime!
Message-Id: <d5esh7.73b.ln@magna.metronet.com>
Daniel Pfeiffer (occitan@esperanto.org) wrote:
: Going from 2 to 3 digits in the year returned by localtime is hardly a
: feature
Going from 2 to 3 digits when you increment 99 is
hardly a feature either, but some folks seem to cope...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 18 May 1999 17:41:24 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Accents Sensitivity
Message-Id: <374208B4.E6A5D996@mail.cor.epa.gov>
Yogish Baliga wrote:
>
> You can use Phoenetic searching using the soundex function.
>
> -- Baliga
>
> amenrique@my-dejanews.com wrote:
>
> > I have developed a search engine in Spanish. It works fine. The problem
> > is that users are trying to find words without writing the accents used
> > in spanish, i.e. they search for Maria with no results, as the right
> > spelling is Marma (with an accent on the i)
That may help. But soundex() hashes everything into a teeny
space, leading to unfortunate collisions. Try checking
the soundex values of 'Ellery' and 'Euler'. They're the
same. Probably not what the poster wanted.
The perllocale manpage is a good place to start.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 19 May 1999 00:30:31 GMT
From: twarren10@aol.com (Twarren10)
Subject: Appending a simple form to end of Search results in pearl
Message-Id: <19990518203031.11117.00002435@ng-fr1.aol.com>
I would like to append this simple search again box to end of my search
results.
Does anyone know how this can be done?
<FORM METHOD=POST ACTION="http://mydomain.com/cgi/search.cgi">
<INPUT NAME="searchstring" SIZE="30" MAXLENGTH="30">
<INPUT TYPE=SUBMIT VALUE="Search Again">
</FORM>
------------------------------
Date: Wed, 19 May 1999 00:31:31 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: backspace in file output question
Message-Id: <3742044c.87288898@news.oz.net>
On Tue, 18 May 1999 15:23:55 GMT, Eric Bohlman <ebohlman@netcom.com> wrote:
>1 while $string=~s/[^\008]\cH//g;
>
>'.' needs to be replaced with '[^\008]' because you *don't* want to
>replace two consecutive backspaces with nothing!
Is there a reason you use two different representations of backspaces?
1 while s/[^\cH]\cH//g;
1 while s/[^\010]\010//g; # not "\008"
--
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Wed, 19 May 1999 01:15:15 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: backspace in file output question
Message-Id: <ebohlmanFByGtF.7rC@netcom.com>
Fuzzy Warm Moogles <tgy@chocobo.org> wrote:
: On Tue, 18 May 1999 15:23:55 GMT, Eric Bohlman <ebohlman@netcom.com> wrote:
: >1 while $string=~s/[^\008]\cH//g;
: >
: >'.' needs to be replaced with '[^\008]' because you *don't* want to
: >replace two consecutive backspaces with nothing!
: Is there a reason you use two different representations of backspaces?
: 1 while s/[^\cH]\cH//g;
My perusal of the Camel and perlre didn't show any indication that the
\cX notation was interpreted in character classes, so I avoided this one.
: 1 while s/[^\010]\010//g; # not "\008"
Partially inertia (I had already typed a predecessor of the regex before
I realized that not only did the loop need to be repeated, but that it
was necessary to check for duplicate backspaces) and partially because I
try to avoid octal as much as possible out of a purely personal dislike
(probably acquired 18 years ago when I was revising some embedded Z80
code that used octal notation for packed BCD).
------------------------------
Date: Tue, 18 May 1999 19:36:33 -0500
From: Billy Passauer <hpassaue@indiana.edu>
Subject: dbh->quote problems
Message-Id: <37420791.A5F19FBE@indiana.edu>
I'm trying to quote a string before I insert it into my mysql database
and have run into a problem that I'm not quite sure how to solve.
A quick sample program:
#!/usr/bin/perl
use DBI;
$text = $dbh->quote("Why doesn't this work?");
print $text;
And when I run it, I get:
Can't call method "quote" on an undefined value at ./test.pl line 4.
Anyone have any ideas as to where to begin looking? All of my other
database functions work with no problems (ie. I can connect, do queries,
inserts, etc.). I am using DBI-1.08, perl 5.005_03
------------------------------
Date: Wed, 19 May 1999 01:48:47 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: dbh->quote problems
Message-Id: <ebohlmanFByIDB.A43@netcom.com>
Billy Passauer <hpassaue@indiana.edu> wrote:
: I'm trying to quote a string before I insert it into my mysql database
: and have run into a problem that I'm not quite sure how to solve.
: A quick sample program:
: #!/usr/bin/perl
: use DBI;
: $text = $dbh->quote("Why doesn't this work?");
: print $text;
: And when I run it, I get:
: Can't call method "quote" on an undefined value at ./test.pl line 4.
Where did $dbh come from? Normally, that's the name people use for the
(d)ata(b)ase (h)andle that you get back from connecting to a
DBI-compatible database, but you haven't even tried to *make* a
connection, so $dbh is about as meaningful as $grunkle here. Try
actually connecting to your database first.
BTW, the reason that quote() is a dbh object method rather than a class
method is that different database engines have different requirements for
how things should be quoted, so DBI needs to know what kind of database
you're talking to before it can figure out how to quote your stuff.
------------------------------
Date: Tue, 18 May 1999 17:23:55 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Help! cgi and system() failure
Message-Id: <3742049B.E577B8FE@mail.cor.epa.gov>
Michael Madigan wrote:
>
> Thanks. Actually I tried that, I even gave it the absolute path:
> "/home/httpd/cgi-bin/runscript" both with no success.
> I even tried setting the path in my .cshrc to look in this directory.
> My new theory is that the sh shell does not have the ability to execute
> scripts when called from a browser. Anyone heard of this happening?
Well, I have heard of programs which work fine.. except they don't
run or aren't accessible when called from the browser.
It's not sh so much as the way web servers work. Your server is
probably running as 'nobody' or 'www' or something like that.
And those 'users' may not have the privs needed to run your
program.
Did you check the URLs listed in the answer to the first question
in perlfaq9 ?
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 18 May 1999 15:17:46 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: HELP:Directory or File exists??
Message-Id: <qcesh7.73b.ln@magna.metronet.com>
kgentes@gentek.net wrote:
: Subject: HELP:Directory or File exists??
^^^^^^^^^^^
^^^^^^^^^^^
: How do I test the existance of a directory or
: file in Perl?
You search for the underlined string from your very own
Subject header in the standard perl docs that came with
your perl distribution:
perlfunc.pod: -e File exists.
: thanks
Uh huh.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 18 May 1999 23:52:29 GMT
From: kgentes@gentek.net
Subject: Hiding OLE Object in Perl
Message-Id: <7hsuft$g1$1@nnrp1.deja.com>
Hi there..
I wrote a peice of code that instantiates an
OLE object from the Excel class.. I use it
to open one file format (Lotus 123) and save
it in another (CSV). I have two problems..
#1 When I call the ->New on the Excel.Application
class, it won't instantiate on my work PC
(though it will on my home PC- both of which
have Excel).. what should I be looking for
on my work PC, that seems to be working on
my home PC (home is running NT4.0 server SR4-
work is running NT4.0 Workstation SR3). The
wierd thing is that if I have a instance of
excel already running, I can attach to that
object just fine (my code that too). Should
I be looking at my syntax or installation or
what to find out why I am not instantiating
the OLE Excel object on my work PC?
#2 When I do get the object running, I try to
close it down after saving the file. The problem
is that Excel is so "concerned" about me saving the
file in the non-excel native format, that it
dumps the confirmation dialog to the screen
for me to verify my explicitly demanded request
to close the current document instance in the MDI.
I can do this fine in VB, but some wackyness
with my implementation in Perl seems to
have me missing something..
attached is the code in question ...
please help .. :)
Kim
===========================================================
use Cwd;
use Win32::OLE;
use Win32::OLE::Const 'Microsoft Excel';
$ROOT_SPIN = "C:\\";
$TRUE = 1;
$FALSE = 0;
print "\nEnter the name of the file to convert from wk1 : ";
$filename = <STDIN>;
chomp ($filename);
&Convert_To_CSV ("$ROOT_SPIN\\$filename");
exit;
#
# procedure Convert_To_CSV ( filepath )
#
# in order to parse through the files consistently, we want to
# convert a .wk1 (Lotus 123) or .xls (Excel file) to a .CSV
# (comma delimited) type of file.
#
# to do this stuff, I have to include a type library
# so that I can utilize the Excel constants (for file type
# saving)..
#
sub Convert_To_CSV () {
# check and make sure there is a parameter passed in.
if (@_) {
($wk_filename) = @_;
# use existing instance if Excel is already running
eval {$excel =
Win32::OLE->GetActiveObject('Excel.Application')};
die "Excel not installed" if $@;
unless (defined $excel) {
$excel = Win32::OLE->new('Excel.Application',
sub {$_[0]->Quit;})
or die "Oops, cannot start Excel";
}
# make the excel application be invisible
$excel->{'Visible'} = 0;
# open an existing file as a workbook
$excel->Workbooks->Open( $wk_filename );
# convert the filename to a *.csv file.
$wk_filename =~ s/(.xls|.wk1)$/.csv/;
$formattype = xlCSV;
# save and exit
$excel->ActiveWorkbook->SaveAs( {
FileName => "$wk_filename",
FileFormat => $formattype,
CreateBackup => False} );
$excel->Workbooks->Close();
undef $excel;
}
}
--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---
------------------------------
Date: Wed, 19 May 1999 00:03:04 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: IRIX and Perl Menu
Message-Id: <slrn7k43gl.5o.alastair@calliope.demon.co.uk>
Marco Radaelli <radaelli@digipoint.it> wrote:
>
>
>I tried the perl version 5.00503 in the tardist format and no problems in
>installing and using it.
Maybe a newer (prebullt) Perl will help. Doesn't 6.5 come with Perl 5.005? If
not, check out ;
http://reality.sgi.com/scotth_corp/info/perl5.html
HTH.
--
Alastair
work : alastair@psoft.co.uk
home : alastair@calliope.demon.co.uk
------------------------------
Date: 19 May 1999 00:00:16 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: japh tags
Message-Id: <eli$9905181840@qz.little-neck.ny.us>
In comp.lang.perl.misc, Ronald J Kimball <rjk@linguist.dartmouth.edu> wrote:
> <todd_b_smith@my-dejanews.com> wrote:
> > Let's get a thread going with people's tag lines that print "Just
> > Another Perl Hacker." I've seen lots, but now I want to see them all!
> Here's a one-liner that I use for posts about regexes:
>
> perl -e '$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'
The 'gees' is good. Probably what most people say upon look at it. The
\c trickery is even better. I would have probably used something more like:
perl -e '$_="\052534`!./4(%2`0%2,`(!#+%2j";s/./"qq\\c$&@"/gees;print'
I like lower case.
I've had fun with RE-intensive JAPHs. These were all written when NY.pm
was new (and I was in New York).
This one mostly just plays with delimiters (sorry David, no control
characters in here):
#!/usr/local/bin/perl5 -- # -*- my ny.pm sig -*-
$_=$^ ;s;s;sss;;s^.^ju^&&s&P+&\n&&&(s(_..)(ers)||s|^|^^|)&&s(T)(q(st%eg))eg;
s<.(o).><$& new 1$$>i+s+\dst.+$a--||reverse(q(rep k))+ge;s*%.+u* so+*i;s=\++
="me"=mex&&s%ege%l$"hke%;$a||s/^\S+ /\/\//;s;\d+;yor;;s[KE]<ac$&>i;print $_;
This one minimizes non-alphabetics but otherwise is quite similar:
perl -e 's Y Yreverse q N ny pm srekcah lrep kroy wen emosNYex and s Pmp ynP
P and s MsMjust sMx and print and s NYPM MPYN Nis or reverse and print q qq'
This one *does* use control characters, specifically it has two raw <^H>s
(perl -e 'print "\b"') in it, and uses eval to demonstrate the use of null
as a quoting operator:
perl -e 's ssqqprint qq\0ju\st another new york perl hacker\n\0see'
With some fiddling (no leading or trialing whitespace, including choping
the final newline), this one prints out code that if run will print out
the original code. In this sense it is an imperfect quine.
#!/usr/bin/perl -00-#rekcah lrep NEW YORK rehtona tsuj#_$ esrever ralacs tnirp
open 0;$_=<0>;s/[A-Z\s]*/reverse$&/eg;##;ge/&$esrever/*]s\Z-A[/s;>0<=_$;0 nepo
print scalar reverse $_#just another KROY WEN perl hacker#-00- lrep/nib/rsu/!#
Elijah
------
has written some pretty spiffy c sigs, too
------------------------------
Date: Tue, 18 May 1999 17:20:06 -0700
From: jedi@dementia.mishnet ()
Subject: Re: Linux is just another Unix (yawn)
Message-Id: <slrn7k40tm.bh6.jedi@dementia.mishnet>
On Tue, 18 May 1999 22:42:45 GMT, anonymous <anon@anon.org> wrote:
>In article <slrn7k3p20.ekj.chris@holly.dyndns.org>, chris@holly.dyndns.org (Chris Costello) wrote:
>>In article <7hsm83$ocu$1@bgtnsc03.worldnet.att.net>, anonymous wrote:
>>> >You don't even know if Perl has a debugger? Do you know what percentage of
>>> >CGI's running the WWW are written using Perl? As a user (past) of VB and
>>> >of Perl (current). VB is perhaps 30% as useful as Perl, and that is being
>>> >generous.
>>>
>>> Really? Perl has component abstraction? A windowing interface? An
>>
>> I'm not exactly sure. Yep.
>>
>>> integrated debugger? How about doing something simple, like connecting to a
>>
>> Yep.
>>
>>> database table without writing code? Anything? 30% as useful? No, you are
>>
>> Yep (I assume you mean connecting to a database and selecting
>>from a table). Yep. 3000% as useful.
>>
>
>
>This is COMPLETE crap. Have you EVER even used PERL?? Apparently not.
It sounds like you haven't either.
--
Microsoft subjected the world to DOS until 1995. |||
A little spite is more than justified. / | \
In search of sane PPP Docs? Try http://penguin.lvcm.com
------------------------------
Date: Tue, 18 May 1999 17:46:47 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Linux is just another Unix (yawn)
Message-Id: <374209F7.4EEFE9E7@mail.cor.epa.gov>
anonymous wrote:
>
> In article <slrn7k3p20.ekj.chris@holly.dyndns.org>, chris@holly.dyndns.org (Chris Costello) wrote:
> >In article <7hsm83$ocu$1@bgtnsc03.worldnet.att.net>, anonymous wrote:
> [BIG SNIP]
> > Yep (I assume you mean connecting to a database and selecting
> >from a table). Yep. 3000% as useful.
>
> This is COMPLETE crap. Have you EVER even used PERL?? Apparently not.
Apparently you have *tried* to use Perl [not 'PERL'] and
failed. That hardly means Perl isn't a better language than
the ever-mutating VB. It only means you know VB better than
you know Perl. Leave the language comparisons to the comp
linguistics experts, who *really* know how to program in
multiple languages, and can make fair comparisons.
And why are you posting this in comp.os.linux.advocacy?
Are you trying to tell me that you're writing VB code that
runs in linux?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 19 May 1999 00:20:58 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: Re: OOP and Perl-a good book?
Message-Id: <7ht05a$h6m$1@towncrier.cc.monash.edu.au>
Phil Voris <pvorishatesspam@earthlink.net> writes:
> I've been vainly attempting to learn the practical usage of OO.
> Being as I'm most familiar with Perl, I began a project using OO
> Perl and Perl Tk. I rapidly realized that understanding OO syntax
> was not sufficient: I still had problems implimenting the GUI as a
> separate class from the heart of the application. I apparently
> didn't 'get it.'
Not so much a matter of not "getting it" I suspect. More a matter of
"Okay, so they're the techniques of climbing, now what's this
Everest mountain I've heard about?" You started too ambitiously.
Or maybe, like Michael Jordan playing baseball, you thought expertise
in one domain would map neatly to another.
You need to build up your OO design skills more gradually, starting
with a smaller, more tractable project. My book works that way,
starting with just about the simplest possible OO application (tracking
software bugs) and working up to moderately complex and cunning designs
only in the last 3 or 4 chapters (out of 14). For example, GUI systems
don't get tackled until Chapter 13 (no omen intended :-)
> Do you intend this book to function as an OO instructional in
> addition to a primer in OO Perl. That is, will it address design
> issues like the one which I describe?
It *does* address design issues related to specific topics, but it
isn't a substitute for a book on general OO design. By the time I had
covered OO Perl in reasonable detail I was already over 500 pages.
Adding an extra 1000 to cover OO design as well seemed...impractical :-)
I think most people will be able to learn a great deal about OO design
in Perl from the book (several of the reviewers said they have).
But it's not intended to be a Perl-based alternative to Meyer's "OO
Software Construction" or Booch's "OO Analysis and Design with
Applications".
I *would* be interested in writing such a book, but I suspect my
publisher will first want some evidence that there's a market for even
*one* book on OO Perl before they pay me to write a second ;-)
Damian
------------------------------
Date: Tue, 18 May 1999 21:18:53 -0400
From: Sharad Bansal <sbansal@roartech.com>
Subject: perl ISAPI issue
Message-Id: <3742117D.E196C70A@roartech.com>
I'm configuring IIS 4.0 to use perlIS.dll ( latest build 516). I can get
my simple scripts to run from the browser. However, I'm unable to run
some more complicated scripts .. I have narrowed the problem spot to :
IIS chokes when my perl scripts ( running with the dll) try to set
carpout(LOGFILE) ?
Any insights ?
Thanks,
Sharad
------------------------------
Date: Tue, 18 May 1999 17:19:43 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Jeff Foege <gdnova@enteract.com>
Subject: Re: Removing a directory with contents
Message-Id: <3742039F.81E55C22@mail.cor.epa.gov>
Jeff Foege wrote:
>
> First let me start off by saying I am new to Perl, as I'm sure you know by
> the subject line. I'm having problems with the routine out of the cookbook
> for removing a directory and anything below it.
Actually, your subject line looks good. It doesn't have the
annoying word 'newbie', nor does it have an all-caps desperate
shout for help.
Your text lines are a hair long, though. They really wrapped
when I was writing this response.
> I was looking at Example 9.3 rmtree1 I could type the example but I figured
> I wouldn't waste anyones bandwidth plus I'm sure a lot of people might have
> the cookbook already.
It wouldn't have hurt, since the code is only 15 lines.
Always cut-and-paste, though. Never re-type. If you make a
typo, no one will be able to tell whether it's in your real
code or not.
Now then, let me tell you that TomC's code has a sort of a
bug in it. It's not a bug for the code in the book. It's
a bug for anyone else using it. Change the first line to:
#!/usr/bin/perl -w
This will turn on warnings, which may help you track down
any little typos or glitches.
> I trying to delete a folder : e:\aveenon\base\bldback
>
> That folder contains another folder \disk1 which may contain some files. I
> want Perl to delete the whole bldback folder and anything below it. I guess
> I just wasn't using the example correctly. If someone could point me the
> right direction or maybe explain that example a little more would help a
> great deal.
Well, the code should print out a series of messages, listing the
directories and files that couldn't be removed. What errors did
you get when you tried it?
> Thanks, Jeff
>
> If you could also send your response to jeff_foege@nmss.com
Since you didn't ask for e-mail only, I did it.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 18 May 1999 20:41:07 -0400
From: Joe Kline <Joe.Kline@sdrc.com>
Subject: Re: Saving/Reading Hashes
Message-Id: <374208A2.BBDC0DDA@sdrc.com>
Daniel Grisinger wrote:
> <SNIP>
>
> For single dimensional data structures use Data::Dumper (standard
> with 5.005+, from CPAN for obsolete perls). For multi-dimensional
> structures use MLDBM (from CPAN for all versions of perl).
<SNIP>
I've used Data::Dumper to dump out some rather complex data structures
(hohol, hohoh, ad nauseum).
The one think I like about Data::Dumper over Storable is that is dumps
out the file in human readable format (no offense Randal, I prefer to
look at my data files from time to time).
joe
--
------------------------------
Date: Wed, 19 May 1999 01:32:06 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Saving/Reading Hashes
Message-Id: <ebohlmanFByHLI.8y4@netcom.com>
Randal L. Schwartz <merlyn@stonehenge.com> wrote:
: >>>>> "Daniel" == Daniel Grisinger <dgris@moiraine.dimensional.com> writes:
: Daniel> For single dimensional data structures use Data::Dumper (standard
: Daniel> with 5.005+, from CPAN for obsolete perls). For multi-dimensional
: Daniel> structures use MLDBM (from CPAN for all versions of perl).
: Daniel> Both provide reasonably good persistence mechanisms.
: But both are far slower and less robust than something like Storable
: for large data in keys/values or complicated interrelationships.
use MLDBM qw(DB_File Storable); and get the best of both worlds.
------------------------------
Date: Tue, 18 May 1999 17:03:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Simple Time Manipulation
Message-Id: <3741FFD0.1D19123@mail.cor.epa.gov>
hymie! wrote:
>
> In our last episode, the evil Dr. Lacto had captured our hero,
> Jonathan Stowe <gellyfish@gellyfish.com>, who said:
> >Newsworthy <hannum@ohio.edu> wrote:
> >> Hello,
> >>
> >> I want to be able to add 24 hours to the (timelocal) funciton. Could
> >> somebody tell me how I can best do this?
> >>
> >
> >I assume you mean localtime ?
> >
> >$time = localtime(time + 86400);
> >
> >Which of course might fail at some places at certain times of the year but
> >its usually good enough ;-}
>
> Why will this fail? Daylight savings time doesn't change the fact that
> 24 hours is 86,400 seconds.
But daylight savings time *does* change the 'fact' that days
are 24 hours. In the non-pathological cases [:->] in the U.S.,
you have one day of 23 hours and one day of 25 hours each year.
So.. what happens if you're at 11:50 pm the day before that
lone 23-hour day, and you add 24 hours to get the next day?
What happens if you're at 12:20 am the morning of that lone
25-hour day, and you add 24 hours to get the next day?
That's right. You're off by a day in each case, because
of the way you did the calc. This is a low-probability
case if you're picking a date-time at random. But if
you have a running program which computes this info regularly,
it's more like an inevitability.
And since there is a posted sub to handle this at the website
of dgris, there's no need to stumble over this molehill
while you're studying the horizon.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 18 May 1999 17:34:50 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Sorting a colon separated file
Message-Id: <3742072A.5A4416B8@mail.cor.epa.gov>
Yogish Baliga wrote:
>
> read the man page of "sort" command on UNIX.
>
> -- Baliga
>
> eliot5581@my-dejanews.com wrote:
>
> > Hi,
> >
> > I'm fairly new to perl and have written a script which manipulates a
> > colon separated file of the form;
> > [snip!!]
Yog [if I may be so informal], that's not very helpful if
eliot5581 isn't on a unix system. As you should know, since
you're posting using Nyetscape from an NT box. And since he
needed more processing than jusr a simple sort, that is
unlikely to be sufficient on unix anyway.
Anyway, Perlish answers have already been posted, IIRC.
BTW, are you a student at U of O?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 18 May 1999 17:03:22 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: The Vi Lovers Home Page
Message-Id: <m17lq6hqnp.fsf@halfdome.holdit.com>
>>>>> "Thomer" == Thomer M Gil <tmgil@cs.vu.nl> writes:
Thomer> Please visit the Vi Lovers Home Page. Vi is *the* editor under Unix, Windows
Thomer> 95/98/NT and many other operating systems.
Them's fighting words. Don't make me come over there. Better yet, I
just write an elisp macro to fight you. If you look like a Tower of
Hanoi, I've already won.
You'll have to pry my Emacs from my cold dead oversized
control-pressing left pinky finger.
(I can hear the sounds of 100 people putting that in their .sigs tomorrow. :)
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Wed, 19 May 1999 01:00:18 GMT
From: tgy@chocobo.org (Fuzzy Warm Moogles)
Subject: Re: Tie Fighter
Message-Id: <3744083a.88294931@news.oz.net>
On Tue, 18 May 1999 21:25:34 GMT, pudge@pobox.com (Chris Nandor) wrote:
>Ack, no, that won't work either, because the value is FETCHed. Silly
>little scalars! I guess it is a good reason to not use tied scalars, then
>... I don't think there is a way to pass a tied scalar around, because
>when you do, FETCH is called.
Instead of returning the tied scalar, return a reference to it. Then assign
the reference to a typeglob.
#!/usr/bin/perl -w
for (qw/chocobo moogle/) {
*_ = new Shout "I want a $_ stuffy\n";
s/$/!!!!/;
print;
}
package Shout;
sub new {
my ($class, $scalar) = @_;
tie $scalar, $class, $scalar;
\$scalar;
}
sub TIESCALAR {
my ($class, $scalar) = @_;
bless \$scalar, $class;
}
sub STORE {
my ($self, $scalar) = @_;
$$self = uc $scalar;
}
sub FETCH {
${+shift};
}
--
Fuzzy | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=
------------------------------
Date: Wed, 19 May 1999 01:02:55 GMT
From: Eric Miller <dukat@flash.net>
Subject: Re: what's wrong with my head(er)...?
Message-Id: <37420DCF.A13ACDFE@flash.net>
Tad McClellan wrote:
>
> brent (simp@mail.utexas.edu) wrote:
> : admitted newbie has following headache --
>
> : When I debug it from
> : the command line it keeps closing the <body> & <html> tags before putting
> : any of my content in ... what up with that?
>
> Buffering.
>
It's not due to buffering. If you had noticed, he was formatting his
statements
in such a way that the syntax called for executing the last statement
first.
Eric Miller
------------------------------
Date: Wed, 19 May 1999 01:21:47 GMT
From: Eric Miller <dukat@flash.net>
Subject: Re: what's wrong with my head(er)...?
Message-Id: <37421236.E8A1967B@flash.net>
brent wrote:
> trying to learn some perl for CGI stuff. I've been using variations of the
> following code to print to the browser with no success. When I debug it from
> the command line it keeps closing the <body> & <html> tags before putting
> any of my content in ... what up with that?
>
> print $query->header;
>
> print $query->start_html(-title=>'Votes Returned',
> -BGCOLOR=>'blue');
These statements work fine. Of course, you are simply passing one
argument to
the built-in function print.
>
> h2('Percentages'),
> print p("The percentage of those who answered Yes is :
> $yes_percent."),
> print p("The percentage of those who answered No is :
> $no_percent."),
> print p("The percentage of those who answered Maybe is :
> $maybe_percent."),
> print p("$total people have voted so far."),
> print $query->end_html;
>
That's quite a statement there. Can you see why it's printing all this
backwards? You've passed the successive print calls as arguments to a
call
to the h2() sub. 'Percentages' is never printed in the first place.
As arguments, the calls to print are being executed last to first, so
your HTML is appearing in reverse order.
The correct formatting for your statements should be:
print $query->header;
print $query->start_html(-title=>'Votes Returned',
-BGCOLOR=>'blue');
print h2('Percentages'),
p("The percentage of those who answered Yes is : $yes_percent."),
p("The percentage of those who answered No is : $no_percent."),
p("The percentage of those who answered Maybe is :
$maybe_percent."),
p("$total people have voted so far.");
print $query->end_html;
Note the differences with your code.
Eric Miller
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 V8 Issue 5719
**************************************