[17807] in Perl-Users-Digest
Perl-Users Digest, Issue: 5227 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 4 15:36:24 2001
Date: Thu, 4 Jan 2001 12:35:56 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <978640556-v9-i5227@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 4 Jan 2001 Volume: 9 Number: 5227
Today's topics:
Re: Comm.pl, pipes, and Open2/3 <bonomo@sal.wisc.edu>
Re: Comm.pl, pipes, and Open2/3 <bonomo@sal.wisc.edu>
command execution timeout rbfitzpa@my-deja.com
Re: command execution timeout <mothra@nowhereatall.com>
Re: command execution timeout (Richard Zilavec)
compare files <me@privacy.net>
Re: compare files (Tad McClellan)
Re: compare files (Tad McClellan)
Re: compare files <peter.sundstrom@eds.com>
Re: compare files msalerno@my-deja.com
complex search and replace <stef@sos.ethz.ch>
Re: complex search and replace (Rafael Garcia-Suarez)
Controlling a serial port nantogue@my-deja.com
Re: convert string to command? <waltman@netaxs.com>
Re: Converting int to bin <Cheng3@email.msn.com>
Re: Converting int to bin <bart.lateur@skynet.be>
CPAN.pm, possible to install a local file from command <nospam@nospam.com>
Re: CPAN.pm, possible to install a local file from comm <randy@theory.uwinnipeg.ca>
CSV record processing tizatron@my-deja.com
Re: CSV record processing <hmerrill@my-deja.com>
Re: CSV record processing <iltzu@sci.invalid>
Data::Dumper::Purity setting to 0 vs 1 <mr_joesixpack@yahoo.com>
Dates and more dates <jbou@bunker79.fsnet.co.uk>
Re: Dates and more dates (Tad McClellan)
Re: Dates and more dates <jbou@bunker79.fsnet.co.uk>
Re: Dates and more dates (Tad McClellan)
Re: Dates and more dates <jhall@ifxonline.com>
Re: Dates and more dates (Tad McClellan)
Re: Dates and more dates (Abigail)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 29 Dec 2000 11:26:41 -0600
From: Richard Bonomo <bonomo@sal.wisc.edu>
Subject: Re: Comm.pl, pipes, and Open2/3
Message-Id: <3A4CC951.72DCF185@sal.wisc.edu>
Tad McClellan wrote:
>
> Richard Bonomo <bonomo@sal.wisc.edu> wrote:
> >
> >I am attempting to write a perl script which will
> >interact with a system untility or any other program,
> >the script taking on the role normally played by
> >the human operator manning the keyboard.
>
> Expect.pm was built for just such a situation. Have you
> looked at that module yet?
I am not yet aware of that one. I'll see if I can
find in on CPAN. I could not find IPC:Chat.
>
> >1. I have seen multiple references to "Comm.pl" being
> >suitef for this, but when I reference it, it reports
> >an error on line 995, which contains, simply <<EOF; .
> ^^^^^^^^
>
> We cannot help with your "mystery error".
>
> If you could give us the verbatim text of the message, then
> we might be able to help.
>
> Error/warning messages are meant to be helpful in debugging
> problems. You should include the message text when seeking
> debugging help. Help the helpers help you (and look up
> the message in perldiag.pod before posting too).
>
OK, here is the verbatim text. This message is repeated
SEVERAL times (not just 3) in succession:
Use of uninitialized value at /usr/share/lib/perl5/Comm.pl line 995.
Use of uninitialized value at /usr/share/lib/perl5/Comm.pl line 995.
Use of uninitialized value at /usr/share/lib/perl5/Comm.pl line 995.
> [
> use PSI::ESP:
>
Now, THAT would be an in interesting module...
> Might there be Carriage Returns or other non-printing characters
> in your source file?
> ]
>
I will follow up on your various suggestions here.
BTW, I am using the Comm.pl library right off CPAN; I
have not modified it.
> See Perl FAQ, part 4:
>
> "Why don't my <<HERE documents work?"
>
> Note also, that the error is likely NOT on line 995, but on
> one of the subsequent lines (before the EOF terminator).
>
> >which operator
> >or technique does one use if a newline is not
> >generated?
>
> perldoc -f read
>
> or
>
> perldoc -f sysread
>
> --
> Tad McClellan SGML consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
Thanks!
Rich
--
************************************************
Richard Bonomo
UW Space Astronomy Laboratory
ph: (608) 263-4683 telefacsimile: (608) 263-0361
SAL-related email: bonomo@sal.wisc.edu
all other email: bonomo@ece.wisc.edu
web page URL: http://www.cae.wisc.edu/~bonomo
************************************************
------------------------------
Date: Tue, 02 Jan 2001 15:16:33 -0600
From: Richard Bonomo <bonomo@sal.wisc.edu>
Subject: Re: Comm.pl, pipes, and Open2/3
Message-Id: <3A524531.A2E6941F@sal.wisc.edu>
Tad McClellan wrote:
>
> Richard Bonomo <bonomo@sal.wisc.edu> wrote:
> >
> >I am attempting to write a perl script which will
> >interact with a system untility or any other program,
> >the script taking on the role normally played by
> >the human operator manning the keyboard.
>
> Expect.pm was built for just such a situation. Have you
> looked at that module yet?
OK, I have managed to locate and load Expect. I think
this will have the necessary functionality. Thanks
a bunch!
(I still don't know what is going on with Comm.pl, but
perhaps this is academic...).
Rich
--
************************************************
Richard Bonomo
UW Space Astronomy Laboratory
ph: (608) 263-4683 telefacsimile: (608) 263-0361
SAL-related email: bonomo@sal.wisc.edu
all other email: bonomo@ece.wisc.edu
web page URL: http://www.cae.wisc.edu/~bonomo
************************************************
------------------------------
Date: Wed, 03 Jan 2001 19:02:16 GMT
From: rbfitzpa@my-deja.com
Subject: command execution timeout
Message-Id: <92vsvh$hps$1@nnrp1.deja.com>
I'm trying to use a command to test if my application is up and running.
The problem is that if my application is down my command does not
respond - it hangs.
Q: Is there a way to execute a commandline command in perl but have perl
'time out' that command?
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 03 Jan 2001 11:26:01 -0800
From: mothra <mothra@nowhereatall.com>
Subject: Re: command execution timeout
Message-Id: <3A537CC9.3725581E@nowhereatall.com>
rbfitzpa@my-deja.com wrote:
>
[snipped]
>
> Q: Is there a way to execute a commandline command in perl but have perl
> 'time out' that command?
>
perldoc -q timeout will give you what you need.
Mothra!!
------------------------------
Date: Wed, 03 Jan 2001 20:49:51 GMT
From: rzilavec@tcn.net (Richard Zilavec)
Subject: Re: command execution timeout
Message-Id: <3a538ed0.23487361@news.tcn.net>
On Wed, 03 Jan 2001 19:02:16 GMT, rbfitzpa@my-deja.com wrote:
>I'm trying to use a command to test if my application is up and running.
>The problem is that if my application is down my command does not
>respond - it hangs.
>
>Q: Is there a way to execute a commandline command in perl but have perl
>'time out' that command?
perldoc -f alarm
--
Richard Zilavec
rzilavec@tcn.net
------------------------------
Date: Thu, 04 Jan 2001 02:59:34 GMT
From: "EM" <me@privacy.net>
Subject: compare files
Message-Id: <qGR46.1206$h06.5455@news.iol.ie>
how do i compare 2 files to see if they are the same?
without installing modules because i dont have root access to the server
-----------
Eric
------------------------------
Date: Wed, 3 Jan 2001 20:30:28 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: compare files
Message-Id: <slrn957khk.lme.tadmc@magna.metronet.com>
EM <me@privacy.net> wrote:
>without installing modules because i dont have root access to the server
That is not a reason for not using modules.
You do not need to be root to install modules.
Perl FAQ, part 8:
"How do I keep my own module/library directory?"
Now you can go to search.cpan.org and type "diff" (without
the quotes) into the little "search" box there :-)
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 3 Jan 2001 20:39:07 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: compare files
Message-Id: <slrn957l1r.lme.tadmc@magna.metronet.com>
EM <me@privacy.net> wrote:
>how do i compare 2 files to see if they are the same?
Get their inode numbers by calling stat() and see
if they are the same:
----------------------------------
my $file1 = (stat 'file1')[1];
my $file2 = (stat 'file2')[1];
if ( $file2 == $file2 )
{ print "the files are the same file\n" }
else
{ print "they are different files\n" }
----------------------------------
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 4 Jan 2001 17:09:41 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: compare files
Message-Id: <930t29$ta4$1@hermes.nz.eds.com>
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn957l1r.lme.tadmc@magna.metronet.com...
> EM <me@privacy.net> wrote:
>
> >how do i compare 2 files to see if they are the same?
>
>
> Get their inode numbers by calling stat() and see
> if they are the same:
>
> ----------------------------------
> my $file1 = (stat 'file1')[1];
> my $file2 = (stat 'file2')[1];
>
> if ( $file2 == $file2 )
> { print "the files are the same file\n" }
> else
> { print "they are different files\n" }
> ----------------------------------
I realise that this is a solution to what the OP asked for, but I'll make a
fair bet that what they really meant was "how do I compare the *contents* of
2 files to see if they are the same"
That being the case, I recommend they search deja for the recent discussion
on this topic.
------------------------------
Date: Thu, 04 Jan 2001 15:22:41 GMT
From: msalerno@my-deja.com
Subject: Re: compare files
Message-Id: <9324fn$cen$1@nnrp1.deja.com>
In article <qGR46.1206$h06.5455@news.iol.ie>,
"EM" <me@privacy.net> wrote:
> how do i compare 2 files to see if they are the same?
> without installing modules because i dont have root access to the
server
>
> -----------
> Eric
>
>
what is wrong with using File::Compare ?
enjoy,
Matt
I used:
#!/usr/bin/perl -w
use strict;
use File::Compare;
my $return = compare("file1", "file2");
print $return;
return will be either 0 (not different) or 1 (different)
I got this from a post by Tom Christiansen.
use File::Compare;
printf "fileA and fileB are %s.\n",
compare("fileA","fileB") ? "different" : "identical";
use File::Compare 'cmp';
sub munge($) {
my $line = $_[0];
for ($line) {
s/^\s+//; # Trim leading whitespace.
s/\s+$//; # Trim trailing whitespace.
}
return uc($line);
}
if (not cmp("fileA", "fileB", sub {munge $_[0] eq munge $_[1]} )
{ print "fileA and fileB are kinda the same.\n"; }
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 4 Jan 2001 18:02:37 +0100
From: Stef <stef@sos.ethz.ch>
Subject: complex search and replace
Message-Id: <3a54acad@pfaff.ethz.ch>
Hi there!
I want to search and replace recursively a multiline string containing
the following special characters: $<>/
I came across something like this:
find . -type f | xargs grep -l -i "$OLD" | xargs perl -p -i.BACKUP -e 's|$OLD|$NEW|gio'
But how do I pack several lines of text containing special characters
into my variables $OLD and $NEW?
Cheers
Stef
--
IT freelancer
President SOS-ETH
ETH Zurich
stef@hoes.li http://hoes.li
------------------------------
Date: Thu, 04 Jan 2001 17:30:53 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: complex search and replace
Message-Id: <slrn959cqh.dfm.rgarciasuarez@rafael.kazibao.net>
Stef wrote in comp.lang.perl.misc:
> Hi there!
>
> I want to search and replace recursively a multiline string containing
> the following special characters: $<>/
>
> I came across something like this:
>
> find . -type f | xargs grep -l -i "$OLD" | xargs perl -p -i.BACKUP -e 's|$OLD|$NEW|gio'
>
> But how do I pack several lines of text containing special characters
> into my variables $OLD and $NEW?
Your shell line raises several problem.
One of them is the interpolation of $OLD and $NEW by the shell. This is
not a Perl problem.
Your perl one-liner will not work with multiline patterns because the
substitution will operate on lines. I suggest to rewrite it as :
perl -pi.BACKUP -0777 -e 's/$ENV{OLD}/$ENV{NEW}/gi'
(The -0777 trick is described in perlrun). Note that the /o is not
useful here.
Another approach is to avoid the shell and to write a perl script that
handles all tasks. This is not necessarily longer (esp. if you use
File::Find).
--
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Fri, 29 Dec 2000 19:22:09 GMT
From: nantogue@my-deja.com
Subject: Controlling a serial port
Message-Id: <92io8q$qf3$1@nnrp1.deja.com>
Okay, first of all let me say I am a total newbie to perl but am very
impressed by what I see of it so far & am eager to use it for my
project over VB. I could code this in VB in no time but am having
difficulty doing the same in perl.
I need to write a fairly basic serial port pgm. I have loaded the
Win23::SerialPort module. I would like to wait until CTS is low, I
assume I do this using the following sample code as provided by the
author:
Operating Methods
($BlockingFlags, $InBytes, $OutBytes, $LatchErrorFlags) =
$PortObj->status
|| warn "could not get port status\n";
if ($BlockingFlags) { warn "Port is blocked"; }
if ($BlockingFlags & BM_fCtsHold) { warn "Waiting for CTS"; }
But I can't get the BM_fCtsHold constant recognised by my perl
interpreter. I guess I am missing some kind of import clause in my
code? Any idea what this might be?
Also, I need to set RTS low. I guess I use the rts_active method? I
can't seem to get this to have any effect either though, it just
returns 1 all of the time.
TIA,
Paul
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 29 Dec 2000 12:30:32 -0500
From: Walt Mankowski <waltman@netaxs.com>
Subject: Re: convert string to command?
Message-Id: <87wvcjm8xz.fsf@netaxs.com>
"Studio 51" <leekembel@hotmail.com> writes:
> "Walt Mankowski" <waltman@netaxs.com> wrote in message
> news:m3ito8sdpa.fsf@netaxs.com...
> > Instead of storing your data as a hash of hashes, try storing it as a
> > reference to a hash of hashes. E.g., instead of $cat{foo}{bar}{baz},
> > use $cat->{foo}{{bar}{baz}. Then you can do something like this:
> >
> > @path = split ('/', $path);
> > $catref = $cat;
>
> I don't have $cat in my program, I have %cat. ?
First of all, I just noticed a typo. I meant to write
$cat->{foo}{bar}{baz}. Sorry if I caused any confusion with the extra
{.
I'm suggesting you change cat from being a hash to being a reference
to a hash. It's not really necessary, but this way each level is
reference and makes it a little easier to deal with. With the
$cat{foo}{bar}{baz} format the first level is a hash and each
subsequent level is a reference.
>
> > foreach $dir (@path) {
> > $catref = $catref->{$dir};
> > }
>
> @path contains the entire path, in other words /$path[0]/$path[1]/$path[2].
> It would seem the above would only work if the path where only 1 deep?
It works a lot like a linked list. The value of each hash is another
reference to a hash. Try it in the debugger and see how it works.
It occurs to me that you might be making this a lot more complicated
that it needs to be. Do you really need a hash for each level of your
path? Could you just get by with using $path as your key?
> Or maybe I'm wrong, I have a poor understanding of references, if you have
> any links to tutorials on this subject they'd b appreciated (I read the the
> applicable perldocs).
Sorry, not that I know of. I picked it up from a combination of the
Camel, the Cookbook, the online docs, and lots of experimentation.
Good luck.
Walt
------------------------------
Date: Fri, 29 Dec 2000 10:24:36 -0500
From: "Liang Cheng" <Cheng3@email.msn.com>
Subject: Re: Converting int to bin
Message-Id: <u9DtkpacAHA.346@cpmsnbbsa09>
If you want to say convert number to a string that is its binary equivalent
you can use the following function.
convert {
local ($num);
my $string;
($num, $string) = @_;
if ($num <= 0) {return;}
$num = int($num/2);
convert($num, $string);
$num = $num%2;
$$string.=$num;
}
call this function with following code:
my ($num, $string);
$num = 40; # or something like that
convert($num, \$string);
this function can't do negative binary, if you want a way to do negative
number, email me.
And again like some poster on this list have said, it is impossible to
implement each and every fuction for everyday use, that is what programming
is for.
Antti-Jussi Korjonen <korjonen@cc.tut.fi> wrote in message
news:3A4C5B46.3D6640F8@cc.tut.fi...
> Hi.
>
> I couldn't find a function that would convert
> integer to binary.
> Instead I had to install Math::BaseCalc.
>
> Didn't I search hard enough or is it really
> true that perl doesn't contain conversion
> to binary form?
>
> version 5.005_03
------------------------------
Date: Fri, 29 Dec 2000 18:36:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Converting int to bin
Message-Id: <p0mp4tgjp0j73fhrkl65avkc568doqr1qq@4ax.com>
Antti-Jussi Korjonen wrote:
>I couldn't find a function that would convert
>integer to binary.
>Instead I had to install Math::BaseCalc.
>
>Didn't I search hard enough or is it really
>true that perl doesn't contain conversion
>to binary form?
It does, but there's a few turns in the road before you get there. One
way to do it is to use pack(), template 'N', to turn an integer into a 4
byte structure (big endian). Using unpack, template "B*", you can turn
this into 1's and 0's.
$int = 1;
print unpack 'B*', pack 'N', $int;
Another way, is to use sprintf with template '%b':
print sprintf '%032b', $int;
You can turn a string of 1's and 0's into an integer, either by doing
the reverse of the pack/unpack sequence; or you can use oct(), provided
that your string starts with '0b':
print oct('0b11');
->
3
--
Bart.
------------------------------
Date: 3 Jan 2001 02:55:06 GMT
From: The WebDragon <nospam@nospam.com>
Subject: CPAN.pm, possible to install a local file from command line?
Message-Id: <92u4aa$aj1$0@216.155.32.238>
can I do something like
perl -MCPAN -e install ./filename.tar.gz
or would it be better to just do the install process manually?
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: Tue, 2 Jan 2001 23:26:54 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: CPAN.pm, possible to install a local file from command line?
Message-Id: <92udhj$g4i$1@canopus.cc.umanitoba.ca>
"The WebDragon" <nospam@nospam.com> wrote in
message news:92u4aa$aj1$0@216.155.32.238...
> can I do something like
>
> perl -MCPAN -e install ./filename.tar.gz
>
> or would it be better to just do the install process manually?
There is a module - CPAN::Site - which can do that sort of
local installation, but this entails creating a couple of
index files with information about the package. If this
is just for a quick one-time one-machine installation,
it's probably just as easy to do it manually.
best regards,
randy kobes
------------------------------
Date: Tue, 02 Jan 2001 18:17:52 GMT
From: tizatron@my-deja.com
Subject: CSV record processing
Message-Id: <92t607$9bb$1@nnrp1.deja.com>
I am converting a php script to perl to take advantage of some
of the mysql db functions in perl.
I have a process that dumps a CSV file. Basically the file is the
record with bunch of different fields on different lines.
Unfortunately the field elements are all over the map. One
line can have five fields and one field can have multiple
lines.
In php we were using the fgetcsv() function to parse the file.
It worked fairly well, dumping each field into an array element.
For perl I seem to be gettimg jammed on the Record Seperator. Perl
naturally wants to parse each line.
How do I change the RS for a perl script?
I was hoping that something simple like this would do the
trick.
open(IN,"< file") || Die "cannot open file";
while(<IN>) {
chomp;
@words = split(/\,/,$_);
}
print $words[0];
But I only get the last line in the file (natch).
I also had a brief look at the CSV module but without
much luck.
-Dean
PS - my data also has those annoying ^M's in it.
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 02 Jan 2001 18:42:37 GMT
From: Hardy Merrill <hmerrill@my-deja.com>
Subject: Re: CSV record processing
Message-Id: <92t7er$ajv$1@nnrp1.deja.com>
In article <92t607$9bb$1@nnrp1.deja.com>,
tizatron@my-deja.com wrote:
> I am converting a php script to perl to take advantage of some
> of the mysql db functions in perl.
>
> I have a process that dumps a CSV file. Basically the file is the
> record with bunch of different fields on different lines.
> Unfortunately the field elements are all over the map. One
> line can have five fields and one field can have multiple
> lines.
>
> In php we were using the fgetcsv() function to parse the file.
> It worked fairly well, dumping each field into an array element.
>
> For perl I seem to be gettimg jammed on the Record Seperator. Perl
> naturally wants to parse each line.
>
> How do I change the RS for a perl script?
The record separator is in Perl system variable $/ - that's
dollar-slash. Recipe 6.7 Reading Records with a Pattern Separator" on
p.176 of The Perl Cookbook by Christiansen and Torkington says that you
can "slurp" the whole contents of a file into a variable(scalar or
array) by undef'ing $/ like this:
undef $/;
@chunks = split(/pattern/, <FILEHANDLE>);
but you could also do this to get the file into one scalar instead of
into an array:
undef $/;
$file_contents = (<FILEHANDLE>);
A caution from the book - "Be aware that this uses a lot of memory if
the file is large...".
This may not answer your whole question, but I hope it helps put you on
the right track.
Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com
>
> I was hoping that something simple like this would do the
> trick.
>
> open(IN,"< file") || Die "cannot open file";
> while(<IN>) {
> chomp;
> @words = split(/\,/,$_);
> }
>
> print $words[0];
>
> But I only get the last line in the file (natch).
>
> I also had a brief look at the CSV module but without
> much luck.
>
> -Dean
>
> PS - my data also has those annoying ^M's in it.
>
> Sent via Deja.com
> http://www.deja.com/
>
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: 2 Jan 2001 20:19:09 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: CSV record processing
Message-Id: <978466384.6156@itz.pp.sci.fi>
In article <92t607$9bb$1@nnrp1.deja.com>, tizatron@my-deja.com wrote:
>
>In php we were using the fgetcsv() function to parse the file.
>It worked fairly well, dumping each field into an array element.
>
>For perl I seem to be gettimg jammed on the Record Seperator. Perl
>naturally wants to parse each line.
You really want to use a module that does this properly. See
http://search.cpan.org/search?mode=module&query=CSV
for a list. Briefly, Text::CSV_XS (or the older Text::CSV) provide
basic CSV parsing like you seem to be talking about, while DBD::CSV
lets you do SQL queries on CSV files.
>I also had a brief look at the CSV module but without
>much luck.
Which one, and what kind of problems did you have?
>PS - my data also has those annoying ^M's in it.
tr/\cM//d gets rid of them quite well, but TIMTOWTDI of course.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post
something, we discuss its implications. If the discussion happens to
answer a question you've asked, that's incidental." -- nobull in clpm
------------------------------
Date: Wed, 03 Jan 2001 20:31:55 GMT
From: Paul Laub <mr_joesixpack@yahoo.com>
Subject: Data::Dumper::Purity setting to 0 vs 1
Message-Id: <93027r$mqc$1@nnrp1.deja.com>
Dear all,
I am writing a wrapper module making Data::Dumper a bit easier for
beginners to use. I expect that occasionally my module will be used to
dump self-referential data structures. Can I make life
easier for everyone involved by setting $Data::Dumper::Purity to 1
in my wrapper? In other words, are there occasions where Purity == 0
is instead preferable? (I assume there must be because Purity == 0
is the default.)
Paul
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 3 Jan 2001 18:30:00 -0000
From: "James Boulter" <jbou@bunker79.fsnet.co.uk>
Subject: Dates and more dates
Message-Id: <92vr4d$3ss$1@news7.svr.pol.co.uk>
Dear all,
I've always had the trouble in CGI of not being able to get a plain and
simple date in the format 01/03/2000 or something like that. I've always
got round it before but now I need to know how to do it.
Thanks in advance
James Boulter
------------------------------
Date: Wed, 3 Jan 2001 12:09:50 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dates and more dates
Message-Id: <slrn956n6u.jl9.tadmc@magna.metronet.com>
James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
>Dear all,
>
>I've always had the trouble in CGI of not being able to get a plain and
>simple date in the format 01/03/2000 or something like that. I've always
^
^ like exactly a year ago? :-)
>got round it before but now I need to know how to do it.
my ($day, $mon, $year) = (localtime())[3, 4, 5];
printf "%02d/%02d/%d\n", $mon+1, $day, $year+1900;
perldoc -f localtime
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 3 Jan 2001 19:28:13 -0000
From: "James Boulter" <jbou@bunker79.fsnet.co.uk>
Subject: Re: Dates and more dates
Message-Id: <92vuig$ni2$1@news8.svr.pol.co.uk>
Thank you very much for your help
James
"James Boulter" <jbou@bunker79.fsnet.co.uk> wrote in message
news:92vr4d$3ss$1@news7.svr.pol.co.uk...
> Dear all,
>
> I've always had the trouble in CGI of not being able to get a plain and
> simple date in the format 01/03/2000 or something like that. I've always
> got round it before but now I need to know how to do it.
>
> Thanks in advance
> James Boulter
>
>
>
>
------------------------------
Date: Wed, 3 Jan 2001 13:16:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dates and more dates
Message-Id: <slrn956r30.jr6.tadmc@magna.metronet.com>
James Boulter <jbou@bunker79.fsnet.co.uk> wrote:
>Thank you very much for your help
^^^
You should not thank yourself in public.
If that "you" was someone other than you, then your post
would have had an entry in its References header referring
to some earlier post. But it didn't.
(your newsreader should do that for you if you "followup" to
the article that you are commenting on instead of following
up to the root of the thread.
)
Please learn how to properly participate on Usenet.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 03 Jan 2001 23:55:51 GMT
From: "John Hall" <jhall@ifxonline.com>
Subject: Re: Dates and more dates
Message-Id: <b_O46.130321$I5.3257067@news1.rdc1.sdca.home.com>
"Tad McClellan" <tadmc@metronet.com> wrote in message
> my ($day, $mon, $year) = (localtime())[3, 4, 5];
> printf "%02d/%02d/%d\n", $mon+1, $day, $year+1900;
What is the proper term to reference the %02d etc portion of this code? I
would like to read about it in perldoc.
I am new to perl [and programming in general] and when faced with this
problem last week I solved it in a rather unsightly way;
sub whats_today {
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
$cy="0".($year-100);
$cd=$mday;
}
if ($mon =~ /\d\d/) {
$cm=($mon + 1);
} else {
$cm="0".($mon + 1);
}
if ($mday =~ /\d\d/) {
$cd=($mday);
} else {
$cd="0".($mday);
}
print "$cy", "$cm", "$cd", "\n";
------------------------------
Date: Wed, 3 Jan 2001 17:28:39 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Dates and more dates
Message-Id: <slrn9579sn.l56.tadmc@magna.metronet.com>
John Hall <jhall@ifxonline.com> wrote:
>
>"Tad McClellan" <tadmc@metronet.com> wrote in message
>
>> my ($day, $mon, $year) = (localtime())[3, 4, 5];
>> printf "%02d/%02d/%d\n", $mon+1, $day, $year+1900;
>
>
>
>What is the proper term to reference the %02d etc portion of this code?
I call it a "format specifier".
>I
>would like to read about it in perldoc.
perldoc -f printf
says it does a "print sprintf", so then:
perldoc -f sprintf
Or any C programming book.
>I am new to perl [and programming in general] and when faced with this
>problem last week I solved it in a rather unsightly way;
>
>sub whats_today {
>
>($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
>$cy="0".($year-100);
You have introduced a year 2100 bug.
You should read up on the functions that you use:
perldoc -f localtime
shows how to properly get a 2-digit year, including the sprintf() part.
You have worked stupid.
Work smart, use the docs that shipped with the software that you are using.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 4 Jan 2001 00:52:22 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Dates and more dates
Message-Id: <slrn957ia6.5lq.abigail@tsathoggua.rlyeh.net>
John Hall (jhall@ifxonline.com) wrote on MMDCLXXXII September MCMXCIII in
<URL:news:b_O46.130321$I5.3257067@news1.rdc1.sdca.home.com>:
``
`` "Tad McClellan" <tadmc@metronet.com> wrote in message
``
`` > my ($day, $mon, $year) = (localtime())[3, 4, 5];
`` > printf "%02d/%02d/%d\n", $mon+1, $day, $year+1900;
``
``
``
`` What is the proper term to reference the %02d etc portion of this code? I
`` would like to read about it in perldoc.
conversions.
Abigail
--
use lib sub {($\) = split /\./ => pop; print $"};
eval "use Just" || eval "use another" || eval "use Perl" || eval "use Hacker";
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 5227
**************************************