[13390] in Perl-Users-Digest
Perl-Users Digest, Issue: 800 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 15 00:07:28 1999
Date: Tue, 14 Sep 1999 21:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 14 Sep 1999 Volume: 9 Number: 800
Today's topics:
"POW: domain error" ??? hurley_j_f@my-deja.com
Re: And the band played Waltzing Matilda (Kirrily 'Skud' Robert)
Re: can't install activeperl on nt <kangaruu@hotmail.com>
CGI /PL permissions <gdentNOeoSPAM@salinas.net>
Re: concurrent GDBM_File access? <Tim.Potter@anu.edu.au>
Re: cookbook: nonforker <rick.delaney@home.com>
Error in "Learning Perl, 2nd Edition" or Error in Perl (Brian)
Re: Error in "Learning Perl, 2nd Edition" or Error in P <wyzelli@yahoo.com>
Re: Error in "Learning Perl, 2nd Edition" or Error in P <jgrot@spam.off.tso.cin.ix.net>
File Locking and File Deletion <master@openendon.com>
Re: File Locking and File Deletion (Martien Verbruggen)
Re: Filter::decrypt assistance required. (Martien Verbruggen)
Re: funky explicit package name variable problem <madebeer@igc.apc.org>
Re: is this object a child of this class? <mike@yawp.com>
Re: is this object a child of this class? (Martien Verbruggen)
Re: libwww-perl <madebeer@igc.apc.org>
Re: Newbe question on Substitution (Martien Verbruggen)
Re: Searching by date problem. (Sam Holden)
Re: trimming spaces from a string (Kragen Sitaker)
Re: trimming spaces from a string (elephant)
Re: trimming spaces from a string (elephant)
Re: UNCRAP project proposal (Chris Nandor)
Re: Unix and Perl script <nelski@corecomm.net>
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 15 Sep 1999 01:40:52 GMT
From: hurley_j_f@my-deja.com
Subject: "POW: domain error" ???
Message-Id: <7rmtf2$g38$1@nnrp1.deja.com>
I just did a search and didn't find it in
the archives.
So, I get this error when trying to run
my script only on NT. The error is displayed
about twelve times requiring an OK button
press, and then the script completes with
no problems.
Anybody?
TIA,
-J
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 15 Sep 1999 02:27:58 GMT
From: skud+usenet@netizen.com.au (Kirrily 'Skud' Robert)
Subject: Re: And the band played Waltzing Matilda
Message-Id: <slrn7tu11e.7s2.skud+usenet@hiro.netizen.com.au>
In article <37e055b7.39615744@news.ozemail.com.au>, Excession wrote:
>The same cannot be said for my poor suffering 'run by volunteers' ISP, which
>has had mondo problems since someone posted an URL relating to moi, into that
>den of indecent sycophants and wannabe godlets, #perl.
Why thank you, I'm flattered.
K.
--
Kirrily 'Skud' Robert - skud@netizen.com.au - http://netizen.com.au/
"Attitude without substance is just plain bitterness." --Unknown
------------------------------
Date: Tue, 14 Sep 1999 21:57:07 -0600
From: <kangaruu@hotmail.com>
Subject: Re: can't install activeperl on nt
Message-Id: <7rn4tg$pja$1@dagger.videotron.ab.ca>
help?
<kangaruu@hotmail.com> wrote in message
news:_4zD3.2274$Y6.268594@news1.telusplanet.net...
> during extraction of the installshield exe, i gives an:
>
> "unable to execute!" error, it can't seem to run:
>
> "C:\TEMP\pft183~tmp\setup.exe" /SMS
>
> PackageforTheWeb error, unable to execute the specified command line
>
> aagh, any help?
>
> thanks in advance.
>
>
------------------------------
Date: Tue, 14 Sep 1999 19:58:21 +1700
From: Gary <gdentNOeoSPAM@salinas.net>
Subject: CGI /PL permissions
Message-Id: <136f266c.5916f150@usw-ex0108-057.remarq.com>
First...I am not a programer and need to learn at the"basic"
level. I am just starting to use .cgi and .pl scripts and I
am having a really hard time finding any information about
how to set the permissions. The word "permission" does not
appear in any of my CGI books. I am using a Windows program
called WS_FTP Pro. My ISP does not authorize Telnet and
tells me I can set the permissions using this software. The
script calls for a setting of "755" and my software will
allow me to enter "_rwx_rwd_" type of permissions, but I do
not know what equates to 755. Can anyone provide me any
assistance with setting permissions with WS_FTP Pro?? Many
thanks!!!
* Sent from RemarQ http://www.remarq.com The Internet's Discussion Network *
The fastest and easiest way to search and participate in Usenet - Free!
------------------------------
Date: 15 Sep 1999 13:07:24 +1000
From: Tim Potter <Tim.Potter@anu.edu.au>
Subject: Re: concurrent GDBM_File access?
Message-Id: <6yvh9c7tzn.fsf@acronym.anu.edu.au>
Joern Reder <joern@netcologne.de> writes:
> my %hash;
> tie ( %hash, 'GDBM_File', $filename,
> &GDBM_File::GDBM_WRCREAT, 0660)
> or croak "can't tie $filename: $!";
To concurrently access a GDBM database with multiple readers, use
GDBM_READER with your tie() command. GDBM_WRITER will only allow one
access (the writer) to the database. GDBM_WRCREAT opens the database
for writing and creates it if it doesn't already exist.
As the other respondent mentioned, check the GDBM info files for more
information.
Tim.
--
Tim Potter, System Admin/Programmer "Disco Stu doesn't advertise"
Advanced Computational Systems CRC, RSISE Bldg Australian National University,
Canberra 0200, AUSTRALIA Ph: +61 2 62798813 Fax: +61 2 62798602
------------------------------
Date: Wed, 15 Sep 1999 03:59:55 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: cookbook: nonforker
Message-Id: <37DF19B2.4917B34A@home.com>
[posted & mailed]
Benjamin Schweizer wrote:
>
> I´ve got a non forking daemon which is pretty nice. If I mark the
> following code as a comment it runs pretty nice, else Perl reports
> that IO::Select has no method has_exception.
If you want that method then you should upgrade your version of
IO::Select to the one that has that method. Better yet, upgrade your
perl since this is a standard module.
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Wed, 15 Sep 1999 02:27:36 GMT
From: perl@bjclark.com (Brian)
Subject: Error in "Learning Perl, 2nd Edition" or Error in Perl port specific to Windows or ?
Message-Id: <37defe31.11724132@news.greenwood.net>
Hello:
I apologize for the long subject line; I'm new to perl, and I really
don't know how I should label my problem.
I have this program, taken directly from _Learning Perl, Second
Edition_, page 216:
#!/usr/bin/perl
chomp(@words = <STDIN>);
foreach $word (@words) {
$count{$word} = $count{$word} + 1;
}
foreach $word (keys %count) {
print "$word was seen $count{$word} times!\n";
}
Now, in Windows it takes my input, then it prints only the number of
times the first string that was entered was seen, and only the first
string. In other words, if I enter:
C:>perl c52.pl
me
you
me
you
me
ok
you
^Z
It returns: me was seen 3 times!
However, on my BSDI box, the same program works correctly. In other
words, if I enter:
% ./c52.pl
me
you
me
you
me
ok
you
^D
It returns:
ok was seen 1 times!
me was seen 3 times!
you was seen 3 times!
Anyone? :-)
BTW, my perl builds are:
Windows:
c:>perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-1999, Larry Wall
Binary build 515 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 19:53:14 Apr 9 1999
Unix BSDI 4.0.1:
% perl -v | grep 'version'
This is perl, version 5.005_03 built for i386-bsdos
------------------------------
Date: Wed, 15 Sep 1999 12:28:18 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Error in "Learning Perl, 2nd Edition" or Error in Perl port specific to Windows or ?
Message-Id: <eXDD3.14$_k6.4886@vic.nntp.telstra.net>
Brian <perl@bjclark.com> wrote in message
news:37defe31.11724132@news.greenwood.net...
>
> Hello:
>
> #!/usr/bin/perl
>
> chomp(@words = <STDIN>);
> foreach $word (@words) {
> $count{$word} = $count{$word} + 1;
> }
> foreach $word (keys %count) {
> print "$word was seen $count{$word} times!\n";
> }
>
> C:>perl c52.pl
> me
> you
> me
> you
> me
> ok
> you
> ^Z
>
> It returns: me was seen 3 times!
>
Cut and paste of the above script and input works OK on my win98 PC running
Activestate Perl 5.005_02 so no clues from me....
Wyzelli
------------------------------
Date: Tue, 14 Sep 1999 23:57:17 -0400
From: "Ishmael" <jgrot@spam.off.tso.cin.ix.net>
Subject: Re: Error in "Learning Perl, 2nd Edition" or Error in Perl port specific to Windows or ?
Message-Id: <rtu61aj71iv59@corp.supernews.com>
Brian,
The script as copied from your message worked as advertised for me. See
sample output below. I am using version 5.005_03 ActiveState build 518.
Jeff
chomp(@words = <STDIN>);
foreach $word (@words) {
$count{$word} = $count{$word} + 1;
}
foreach $word (keys %count) {
print "$word was seen $count{$word} times!\n";
}
F:\Perl>perl wordcnt.pl
hi
hello
hi
hello
yo
hi
^Z
yo was seen 1 times!
hi was seen 3 times!
hello was seen 2 times!
F:\Perl>perl -v
This is perl, version 5.005_03 built for MSWin32-x86-object
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-1999, Larry Wall
Binary build 518 provided by ActiveState Tool Corp.
http://www.ActiveState.com
Built 13:14:00 Jun 24 1999
Brian wrote in message <37defe31.11724132@news.greenwood.net>...
>
>Hello:
>
>I apologize for the long subject line; I'm new to perl, and I really
>don't know how I should label my problem.
>
>I have this program, taken directly from _Learning Perl, Second
>Edition_, page 216:
>
------------------------------
Date: Wed, 15 Sep 1999 02:04:41 GMT
From: Jordan DeLozier <master@openendon.com>
Subject: File Locking and File Deletion
Message-Id: <937360845.513000073@news.tds.net>
Hello,
I have about 6 different perl scripts that access the same flat file
and are used by around 200-300 users and is on there web sites and each time
they have a visitor, it is used. Every once in a while, it will delete data out
of the file.. Today I have 16 in the datafile when it was suppose to be 247.
Another time it had increased itself to over 1 meg in size, and I was
told that my file locking wasn't correct and to use the code below instead. Any
ideas why the code is being delete or duplicated?
I've considered using SQL but my server does not support any of these
so I'm stuck with flat file for now.
I have file locking in place on every file, this is a snipplet:
&lock_file ($all, 5) || die "Can't lock $all";
unless ( open(FILE,">$datapath/all.txt") ) {
&unlock_file ($all);
die "Can't open $all for appending.";
}
print FILE (@data);
close(FILE);
&unlock_file ($all);
And this is lock_file and unlock_file:
sub lock_file {
local ($all, $numtries) = @_;
local ($keen);
for ($keen = 1; $keen <= $numtires; ++$keen) {
if ( symlink ($all, $all . ".lck") ) {
return 1;
}
sleep 1;
}
return 0;
}
sub unlock_file {
local ($all) = @_;
unlink ($all . ".lck");
}
Thanks for all of your help,
Jordan DeLozier
------------------------------
Date: Wed, 15 Sep 1999 03:11:48 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: File Locking and File Deletion
Message-Id: <U7ED3.174$LN1.8721@nsw.nnrp.telstra.net>
In article <937360845.513000073@news.tds.net>,
Jordan DeLozier <master@openendon.com> writes:
> &lock_file ($all, 5) || die "Can't lock $all";
> sub lock_file {
[snip of broken code]
Not atomic. Race conditions. Broken code.
# perldoc perlfaq5
[snip]
How can I lock a file?
[snip]
What [WHY] can't I just open(FH, ">file.lock")?
[snip]
# perldoc -f flock
http://www.stonehenge.com/merlyn/WebTechniques/
look at col04
Martien
--
Martien Verbruggen |
Interactive Media Division | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd. | again. Then quit; there's no use being
NSW, Australia | a damn fool about it.
------------------------------
Date: Wed, 15 Sep 1999 03:03:29 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Filter::decrypt assistance required.
Message-Id: <50ED3.171$LN1.8721@nsw.nnrp.telstra.net>
In article <37DEECC6.DB57333F@bofh.com.au>,
Karl Hanmore <karl@bofh.com.au> writes:
> Good Day,
> I am interested in learning to make use of the Filter::decrypt module,
> but can find no "simple" documentation on it. I am fairly well versed
> in perl in general, but this is proving a major stumbling block for me.
Did you have a look at the examples that come with the distribution?
Martien
--
Martien Verbruggen |
Interactive Media Division | I'm just very selective about what I
Commercial Dynamics Pty. Ltd. | accept as reality - Calvin
NSW, Australia |
------------------------------
Date: Tue, 14 Sep 1999 16:50:30 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: funky explicit package name variable problem
Message-Id: <APC&1'0'50775da9'c9e@igc.apc.org>
jerrad wrote:
>$val = 'something';
>$main::{$var} = eval($val)
>Which seems as though it should be the same equates too:
>*main::bar = 'quux'
>making bar a reference to the value in quux.
>Hardly the same
I think you want
$val = 'bar';
$$main::var = eval($val);
print $$main::var . "\n";
>I've tried all sorts of stuff but can't get an expression which does
>the same thing while specifying the package
I think the above suits your needs. It prints out 'bar' in any case.
You got to put the '$$' (deference a pointer as scalar) before the
package name.
If I misunderstood and you want '$main::' to refer to a package
specified by the variable $main, then you'll need perldoc -f eval
-Michael
------------------------------
Date: Tue, 14 Sep 1999 22:35:46 -0500
From: <mike@yawp.com>
To: buddachile@yahoo.com
Subject: Re: is this object a child of this class?
Message-Id: <Pine.NEB.3.96.990914215049.11532A-100000@www.yawp.com>
> how can i test if an object is a child of a particular class in Perl?
the ugly way is:
$class = ref $object;
@super = @{"${class}::ISA"};
$isa_whatever = (grep {/$whatever/} @super) ? 1 : 0;
but you can achieve the same effect more cleanly by adding a new method to
the child class:
sub super {
return @ISA;
}
or to be more complete:
sub isa {
my $self = shift;
my $type = shift;
my $isa = (grep {/$type/} @ISA) ? 1 : 0;
return ($isa);
}
that said, switching on classname usually isn't all that great an idea.
it creates a dependency on the classname as a literal string. if you
rename a class, or worse yet a whole heirarchy, you suddenly break all the
tests distributed throughout your code.
when you get right down to it, you're probably not testing the classname
because you need to know the name itself. more than likely, you're just
using the classname as a convenient way of finding out what J. Random
Object can do. that's a one-off solution.. it injects unnecessary
parameters into your code, and forces you to do a bunch of extra work.
a better solution would be to create a new method which basically means
"can this object do X?", and call that for each operation you want to
verify. better still is to define your class interfaces so that all the
objects you're handling use the same method to do whatever it is they're
supposed to in the given context:
package thing1;
sub new { return bless {}, shift }
sub execute { print "this does what thing1 likes.\n" }
package thing2;
sub new { return bless {}, shift }
sub execute { print "this does what thing2 likes.\n" }
package thing3;
sub new { return bless {}, shift }
sub execute {} # null method.. thing3 doesn't do anything
# in this context.
package main;
srand (time);
for (1..5) {
$n = int (rand(3)) + 1;
$t = "thing$n";
push @objs, new $t;
}
for $obj (@objs) {
$obj->execute ();
}
--
mike
------------------------------
Date: Wed, 15 Sep 1999 03:49:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: is this object a child of this class?
Message-Id: <AHED3.194$LN1.8721@nsw.nnrp.telstra.net>
In article <Pine.NEB.3.96.990914215049.11532A-100000@www.yawp.com>,
<mike@yawp.com> writes:
[no attribution]
>
>> how can i test if an object is a child of a particular class in Perl?
> sub isa {
Euhmmm... Why do you write this sub?
# perldoc UNIVERSAL
NAME
UNIVERSAL - base class for ALL classes (blessed references)
SYNOPSIS
$io = $fd->isa("IO::Handle");
$sub = $obj->can('print');
In other words.... Every blessed reference in Perl has a method isa.
Martien
--
Martien Verbruggen |
Interactive Media Division | Useful Statistic: 75% of the people
Commercial Dynamics Pty. Ltd. | make up 3/4 of the population.
NSW, Australia |
------------------------------
Date: Tue, 14 Sep 1999 17:00:38 -0700 (PDT)
From: Michael de Beer <madebeer@igc.apc.org>
Subject: Re: libwww-perl
Message-Id: <APC&1'0'50775daa'026@igc.apc.org>
perldoc -q module
This has some helpful answers.
The stuff on 'make' is only for unix computers.
On Windows (I think) it is a little different.
-Mike
------------------------------
Date: Wed, 15 Sep 1999 03:28:26 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Newbe question on Substitution
Message-Id: <unED3.178$LN1.8721@nsw.nnrp.telstra.net>
In article <37DED5CE.AED570DC@ncgr.org>,
wih <wih@ncgr.org> writes:
> Mike wrote:
>
>> $test = "Test string with path= c:\\path\\sub1\\sub2\\file.exe";
>> $lookfor = "c:\\path\\sub1\\sub2";
>> $subwith = "c:\\testpath";
>>
>> $test=~s/$lookfor/$subwith/;
>>
>> print $test;
>>
>> which outputs: Test string with path= c:\path\sub1\sub2\file.exe
>
> It's substituting just fine.
No, it's actually not. It's not substituting anything, because it
can't match anything.
> In your case, when you print out the string contained in $test. The
> interpreter actually sees the string $test as: Test string with path=
> c:\\path\\sub1\\sub2\\file.exe
You are correctly identifying that the problem lies with the
backwhacks, but you seem to be misunderstanding why and where.
After the assignment to $test, $test actually contains
Test string with path= c:\path\sub1\sub2\file.exe
(which, incidentally, is exactly what print will spit out)
The double backwhacks have been replaced by singles because of the
double quotes. That's why they had to be double in the first place.
The same goes for $lookfor and $subwith.
If the original code had used single quotes, there would not have been
a need for doubling of backwhacks at all.
> with the correct number of backslashes. BUT since you've fed the $test to a
> print statement, it will interpret the \\ to mean print a single \ ...
Again: wrong. print does not do anything with backwhacks. Double
quotes and double-quotish operators do. And so do regular expressions.
And that is where the problem lies. Not in the print statement.
# perldoc perlop
# perldoc perlre
# perldoc -f print
Martien
--
Martien Verbruggen |
Interactive Media Division | Think of the average person. Half of
Commercial Dynamics Pty. Ltd. | the people out there are dumber.
NSW, Australia |
------------------------------
Date: 15 Sep 1999 01:34:03 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Searching by date problem.
Message-Id: <slrn7tttsb.cda.sholden@pgrad.cs.usyd.edu.au>
On Tue, 14 Sep 1999 13:31:59 GMT, Benjamin Franz
<snowhare@long-lake.nihongo.org> wrote:
>In article <slrn7tr7ba.pi.sholden@pgrad.cs.usyd.edu.au>,
>Sam Holden <sholden@cs.usyd.edu.au> wrote:
>>
>>If I say my sister was born in /76 then you should assume I mean 1976. Either
>>because she's probably around my age and I'm probably not over 120. Or because
>>if she was born in 1876 I would have said /1876 because /76 is just short-hand
>>for 1976 (for the moment, in the future it will be shorthand for 2076).
>
>Only if the operators know _how big your window is_. And they probably don't.
>You've created a 'magical fixer upper' that will break without warning.
>The operator wants to enter historical, current and future events on a timeline.
In my example there was an obvious window. Did you actually read what I wrote?
>(Lets say visits of a comet). The last was in 1940. The next was 1990 and
>the one after that will be 2040. Today is 1999. Which date should '40'
>refer to. Operators will form 'operational guesses' - which quite
>likely will not match what your code does. The _closest_ date is 2040.
>The _intuitive_ date could be either.
If they enter 40 the system will accept it and change it before their eyes to
be 1940 or 2040 whichever is _documented_ behaviour. If that is not what
they meant they go back and change it.
Of course that won't happen because the operator will know how the interface
works because they will have read the documentation.
>
>>>
>>>In those cases where shorter dates are apparently used, the four digit
>>>dates appear much like 'reference frames' in a compressed video - they
>>>appear _explicitly_ somewhere else to unambiguously frame the date.
>>>And the text itself goes down to the _month_ and day. Thus I have
>>>a ledger for _1998_. The entire ledger is _1998_. And the data within
>>>says 'January', 'March' etc. With _no_ year immediately adjecent.
>>
>>That's right in a two digit date is the latest date that it could mean before
>>the current date for date inputs for past dates, and the closest date it could
>>mean after the current date for inputs for future dates.
>
>Ah. That's a _new_ variation of 'intuitive' that never would have occured
>to me. That makes three _different_ variations of what you might do with
>a two digit date:
If the system asks you for your birthdate and you enter /60 it will assume
you mean 1960 - since it is a date in the past.
If the system asks you for the expiry date on your credit and you enter /10 it
will assume you mean 2010 - since it is a date in the future.
Not just intuitive - bloody obvious.
>'Intuitive behavior 1') Prepend the current century.
>'Intuitive behavior 2') Prepend the century that would make the date _closest_ to now.
>'Intuitive behavior 3') Prepend the century that will place the date _before_ now.
>
>Great. Now which one does the _operator_ guess you did? Remember you wrote the
>code 15 years ago, left the company 14 years ago, your manager moved on to
>greener pastures 5 years ago and the tech writer for the manual joined the
>company 2 years ago. And some idiot lost the source code. (Been there - I
>wrote a package for a company on contract and two months later they managed
>to blow away the source completely. Still wanted the software though.)
>
>>I have never written a four digit year on a cheque I've filled out, or on
>>a deposit slip, or on my tax form. There is no need.
>
>Funny. _ALL_ my checks going back the last 20 years have four digits.
>Either pre-printed with the century and a blank for the decade and year
>until about 5 years ago or completely written out starting a few years ago
>(when the check companies quit printing the century on the check to prevent
>century errors starting next year).
Fine. I have only ever written two digits on a cheque. I have never written
four. Sure some cheques had '19' written for me. Some didn't. The same
for deposit slips - the one I filled out last week didn't have the '19'. I
sill wrote 99. The bank accepted the slip. The money is now in my account.
Seemed to work fine.
>
>>>Unambiguous - and with four digit dates.
>>
>>Two digit years are unambiguous as well.
>>
>>It lets computers do the work and people be lazy. This is the way it should
>>be. 10/10/73 is a valid date. It means 1973 not 2073, or 1873 or 0073. If I
>>wanted one of the other ones I would have written them out as above.
>>
>>Short-cuts are a good thing. They make interfaces easier to use. They make
>>poeple more efficient. They save money.
>
>Y2K is costing _tens of billions of dollars_. Funny kind of 'saving time
>and money'. I could quite reasonably lay at least a few of those billions
>of dollars of _cost_ at the feet of the unknown person who thought 'y-1900'
>(two digits for 'convienence' on the short term) in tm_struct. A decision
>that is unlikely to have _saved_ anything close to what it _cost_.
Y2K is caused by _storing_ 2 digit years. Did you read what I wrote?
>People don't quite as neatly compartmentize what they do as you and
>Larry suggest. And the person writing a user interface spec may
>not even be talking to the final coder. "Ah. A two digit date field.
>Ok." There are mis-communications, failure to ask the right questions,
>and endless other things that interfere with the creation of useful
>software.
>
>The guy asking his question provided no context for his date usage.
>_YOU AND I DON'T KNOW_ what date ranges his users will enter.
>But you want to suggest it is _ok_ in general to use two digit
>dates on user interfaces.
>
>It isn't. "Hey George, what major events happened in 58 AD"?
>
>"Uh....I don't know. The computer won't let me list it. It keeps
>trying to start at 1958....."
The fact he was using two digit years, indicated to me that he only cared
about 'current' dates. But I'm not really interested in the original post,
I'm replying to your assertions that two digit dates can not be used safely.
>
>><snippage>
>>
>>>These are all side points. The _right thing_ remains four digit years.
>>>Two digit years and long term data processing are inherently incompatible.
>>>If you want to argue against long term information processing - fine.
>>
>>Two digit dates for data storage are evil. For data input though they are
>>exremely useful. That is how people write dates on a peice of paper, that's
>>how they should be able to enter dates into a computer. Of course four digit
>>dates are acceptable too, they should not be forced upon the user however.
>>
>>If I enter 10/10/73 into my application it accepts it just fine, it converts
>>it to 10/10/1973 on the screen in front of me. This is how it should be. There
>>is no problem caused by this.
>>
>>Being able to use a two digit year just lets me enter dates faster and takes a
>>few more cpu cycles away from seti-at-home or whatever - the way computers
>>should work.
>
>And how do you enter 99 AD?
You delete the 19 that was added. The program doesn't add it back since you
changed its attempted correction. This is good, unless you enter the year 99
more often than 1999 - which is unlikely in most circumstances. If it was
the case then the program wouldn't be adding the century for you anyway.
Or you type 099 (or 0099). Which is a magic incantation in the same way as
pressing Alt-F4 is a magic way of closing a window on some systems. The magic
makes it faster, but is not needed.
>Now consider a form that pre-fills today's century and positions the cursor
>for typing the remaining two digits. Ah. I type two digits almost all
>the time - _but can type any four digit date_. With no inaccessible
>dates. Four digit dates on entry _take no more time on average than
>two digit dates_.
That's exactly the same. You add them first, I added them later. Both
solutions allow for correction. I use my method because filling in the
century would make the entry field very hard to use.
It's blank I enter 23/5/99. The system changes it to 23/5/1999. I'm happy.
The field contains //19. I enter 23 then look at the keyboard then 5,
then find the right arrow again, then 99. I'm not happy. It would have been
easier to type in 23/5/1999 completely myself. I don't want to have to press
the arrow key. I also don't want to enter 05 since that is not natural. I also
want to be able to enter a time in the field as well... sometimes - can't do
that sorry, it's not a free text field.
I might like to enter the date as 'today'. Or maybe 'next monday'. My simple
interface for my metadata allows all of these. It changes the date before the
users eyes. So far no one has complained.
>
>The idea that you 'save' _anything_ by 'magically' processing two digit
>dates into four digit gates (there-by preventing certain dates from entry)
>is fallacious from the word go. It is a _failure_ of the programmer to
>think it through that results in that kind of 'solution'. It increases
>the number of ways software can break - which is _ALWAYS_ a bad thing.
It does not make it impossible to enter certain dates. It makes it faster to
enter common dates. And _slower_ to enter uncommon dates. I'm willing to pay
the price for the uncommon dates. This is a standard principle of interface
design.
It's even embedded in the interface between perl and the programmer. Easy things
are easy... hard things are possible (but you have to explicitly override the
defaults).
If I want to split $_ I save lots of time by not having to enter it. I also
increase readability because I am doing a 'normal' thing. If I want to split
something else I have to give some extra arguments. That's the price for
the shortcut.
--
Sam
Some of you know what the Perl slogan on Windows is, and you can say it
with me: "It's a good thing there's more than one way to do it, because
most of them don't work." --Larry Wall
------------------------------
Date: Wed, 15 Sep 1999 01:46:00 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: trimming spaces from a string
Message-Id: <sTCD3.11312$N77.862822@typ11.nn.bcandid.com>
In article <7rmr41$4lv$1@bgtnsc01.worldnet.att.net>,
Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote:
>$s=' aa bcdef ';
>$t='aa bcdef';
$s =~ s/^\s*(.*?)\s*$/$1/;
>$sep='*'; # $sep may vary, and asterisk is a candidate.
>@flds=split /$sep/, $s; # This won't split on * but works for non-spcl
>chars
perldoc -f quotemeta
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 15 Sep 1999 12:58:18 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: trimming spaces from a string
Message-Id: <MPG.12499a3574a3215b989ccb@news-server>
Dolly & Will Cardwell FAQ the following ..
>Subject: trimming spaces from a string
perldoc -q "strip.*space"
>$s='abc*def * ghi';
>$sep='*'; # $sep may vary, and asterisk is a candidate.
>@flds=split /$sep/, $s; # This won't split on * but works for non-spcl
>chars
perldoc -q "variable.*regex"
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Wed, 15 Sep 1999 13:32:29 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: trimming spaces from a string
Message-Id: <MPG.12499b7e96f8a656989ccc@news-server>
Kragen Sitaker writes ..
>In article <7rmr41$4lv$1@bgtnsc01.worldnet.att.net>,
>Dolly & Will Cardwell <wellhaven@worldnet.att.net> wrote:
>>$s=' aa bcdef ';
>>$t='aa bcdef';
>
>$s =~ s/^\s*(.*?)\s*$/$1/;
>
>>$sep='*'; # $sep may vary, and asterisk is a candidate.
>>@flds=split /$sep/, $s; # This won't split on * but works for non-spcl
>>chars
>
>perldoc -f quotemeta
two perfectly demonstrated arguments for why the FAQ documentation
should always be preferred over usenet answers *B^)
--
jason - elephant@squirrelgroup.com -
------------------------------
Date: Wed, 15 Sep 1999 02:55:03 GMT
From: pudge@pobox.com (Chris Nandor)
Subject: Re: UNCRAP project proposal
Message-Id: <pudge-1409992255060001@192.168.0.77>
In article <slrn7tt8vf.g83.abigail@alexandra.delanet.com>,
abigail@delanet.com wrote:
# Chris Nandor (pudge@pobox.com) wrote on MMCCV September MCMXCIII in
# <URL:news:pudge-1409990753040001@192.168.0.77>:
# <>
# <>
# <> <CENTER></CENTER> is now illegal HTML (in 4.0).
#
# That is an strange statement.
No, it isn't.
# There isn't just "HTML 4.0", there are 3
# versions of HTML 4.0. CENTER deprecated in both the HTML 4.0 transitional,
# and HTML 4.0 frameset DTDs. It's not present in the HTML 4.0 strict DTD.
I happen to think it is reasonable to assume that "HTML 4.0" unqualified
is speaking about the strict DTD. Next time I'll consider being more
specific.
--
Chris Nandor mailto:pudge@pobox.com http://pudge.net/
%PGPKey = ('B76E72AD', [1024, '0824090B CE73CA10 1FF77F13 8180B6B6'])
------------------------------
Date: Tue, 14 Sep 1999 21:28:19 -0500
From: "Jonel Rienton" <nelski@corecomm.net>
Subject: Re: Unix and Perl script
Message-Id: <9rDD3.1787$NW5.146606@news.corecomm.net>
hi,
i don't know what exactly you're trying to accomplish, the way i understand
it, here's a one-liner.
perl -wle '@_=qx(ls /usr/bin);open(A,">files.lst");foreach(@_){chomp;print
A};close(A)'
this one-liner will create a file files.lst and it'll contain the filenames
in /usr/bin, good luck.
cheers,
Jonel
Trevor Osatchuk <fybar@junctionnet.com> wrote in message
news:37dee0b6.441742882@news.telusplanet.net...
> I am trying to write a backup script for a Unix machine using Perl as
> I can only pass a finite number of filenames to a tar at a time. The
> Unix command that I want to use is:
>
> find ./usr -name "bin" -print > files.list
>
> The best I can come up with is this:
>
> open (FILES_LIST,"|find ./usr -name "bin" -print >files.list");
>
> I have used the same type of command with an ls, but I cannot get the
> syntax right for the find.
>
> trev
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu.
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 800
*************************************