[12952] in Perl-Users-Digest
Perl-Users Digest, Issue: 362 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 4 10:07:13 1999
Date: Wed, 4 Aug 1999 07:05:09 -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 Wed, 4 Aug 1999 Volume: 9 Number: 362
Today's topics:
Re: $/ for cross platform text files? <rolf@parallax.co.uk>
Re: $/ for cross platform text files? <flavell@mail.cern.ch>
[Offtopic] Re: Perl or CGI <jcreed@cyclone.jprc.com>
Re: Autovivification? (Anno Siegel)
Re: Can I use a variable as a file descriptor ? (Anno Siegel)
Re: download available (Anno Siegel)
Re: download available <gellyfish@gellyfish.com>
Re: HELP: How to program command line args (Michel Dalle)
Re: HELP: How to program command line args alexander.zinniker@trivadis.com
Re: HELP: How to program command line args (Abigail)
Re: High demand for Perl programmers? (brian d foy)
Re: mySql & Perl -> Something simple (Malcolm Ray)
Re: Newbie Q: How to check if invoked as CGI program (Steve van der Burg)
Re: Newbie question about hashes <rhrh@hotmail.com>
Perl counter muckup <ralawrence@my-deja.com>
Re: revert gmtime() (I R A Darth Aggie)
Re: Special delete <tchrist@mox.perl.com>
Re: Special delete <alex@kawo2.rwth-aachen.de>
Re: Strange STDOUT on script, any ideas? (Anno Siegel)
Re: thanks for nothing everybody - POINTERS ? (Michel Dalle)
Re: Use of uninitialized value .... <ron_savage@non-hp-australia-om5.om.hp.com>
Re: Useless error when {} unbalanced <alex@kawo2.rwth-aachen.de>
Re: Useless error when {} unbalanced (brian d foy)
Re: Using CGI.pm to Retrieve Image <alex@kawo2.rwth-aachen.de>
Re: Web Startup Seeks Help, Programmer <crt@kiski.net>
Re: Web Startup Seeks Help, Programmer <alex@kawo2.rwth-aachen.de>
Re: Web Startup Seeks Help, Programmer <pheuvel@optusnet.com.au>
Re: Whitespace <ron_savage@non-hp-australia-om5.om.hp.com>
Why is it.... <archer7@mindspring.com>
Re: Why is it.... (Michel Dalle)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 04 Aug 1999 13:30:50 +0100
From: Rolf Howarth <rolf@parallax.co.uk>
Subject: Re: $/ for cross platform text files?
Message-Id: <37A83279.6297378B@parallax.co.uk>
"Alan J. Flavell" wrote:
>
> On Wed, 4 Aug 1999, Rolf Howarth wrote:
>
> > are certainly lots of situations where Unix or Windows versions of Perl
> > might encounter a Mac text file. Think HTML and HTTP for example, all
> > the relevant RFCs state that any of \012, \015 or \015\012 are equally
> > valid as end of line delimiters.
>
> You're not comparing like with like.
>
> It is (or at least it _should_ be) quite a different situation whether
> you are processing a properly-formed text file[1] on your platform (in
> which case you _should_ be opening it in text mode and applying
> constructs like \n for newlines - irrespective of their physical
> representation on your platform) on the one hand, or on the other hand
> you are processing network-format datastreams, where the sequences of
> \015 and \012 characters should be handled for what they are, and not
> under some platform-dependent semantics[2].
If only things were that simple! When I move files between platforms I
nearly always need to run tr or something myself to convert my text
files to the correct native representation (or use an editor that
handles the different formats), I rarely have the luxury of being able
to depend on getting a properly formed file.
But I guess I was really talking about your second case, where I want to
process an arbitrary network-format text data stream one line at a time.
There's no trivial way of doing this in Perl, certainly nothing as
convenient as
while (<STDIN>) { ... }
Programmers being lazy, they usually end up writing simple code like
this, perhaps putting in a call to 'chomp' to handle any DOS-formatted
files they might encounter, but on the 2% or so of Mac-format files they
encounter (which are perfectly legal according to the RFCs) the scripts
just fall over.
-Rolf
------------------------------
Date: Wed, 4 Aug 1999 14:56:31 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: $/ for cross platform text files?
Message-Id: <Pine.HPP.3.95a.990804143833.4048F-100000@hpplus03.cern.ch>
On Wed, 4 Aug 1999, Rolf Howarth wrote:
(about platform formats and network formats)
> If only things were that simple!
Well, if people would only RTFM and develop their software accordingly,
it would be. But I know it isn't that simple, and you know it isn't
that simple.
Over and over on the WWW (seems to be today's horror story) we get
someone who's transferred an 8-bit Mac text file in binary mode to an
incompatible system. And then thinks, as like as not, that just adding
charset=iso-8859-1 to their content-type is going to make everything
nice again for them. Mumble.
> When I move files between platforms I
> nearly always need to run tr or something myself to convert my text
> files to the correct native representation (or use an editor that
> handles the different formats), I rarely have the luxury of being able
> to depend on getting a properly formed file.
But if every damned piece of text handling software has its own ideas of
what it can tolerate on its input, and just how non-canonically it can
get away with generating its output, then we're making things a great
deal worse.
> But I guess I was really talking about your second case, where I want to
> process an arbitrary network-format text data stream one line at a time.
Yes, it looks that way, but how you gonna work out whether those 8-bit
characters are in Mac code or in iso-8859-1? (for example).
> Programmers being lazy, they usually end up writing simple code like
> this,
Dare I suggest that if they were _really_ lazy, they'd write all their
apps to handle only a properly formed file, and would do the necessary
reverse-engineering of broken data in a single, well-debugged,
well-understood text repair/sanitise application or module.
This is all a great shame, really, because the WWW has exactly what is
needed for this: a properly-defined Content-type advertisement, with a
properly-defined (though sadly misnamed) character coding attribute,
and a clearly-specified canonical newline format.
Trouble is, hardly anyone seems to understand how to use it properly,
and that includes the major applications (browsers etc.).
all the best
------------------------------
Date: 04 Aug 1999 09:16:36 -0400
From: Jason Reed <jcreed@cyclone.jprc.com>
Subject: [Offtopic] Re: Perl or CGI
Message-Id: <a1aes7sn2j.fsf_-_@cyclone.jprc.com>
dha@panix.com (David H. Adler) writes:
> Hmm... Babelfish doesn't do Esperanto, does it? :-/ Of course, if it
> did, I'm not sure we'd get anything useful... :-)
Roughly (and I really only know about enough Esperanto cold to make
snide remarks :)
> >Laux mia kompreno, "perlcoder" simple konstatas, ke la angla mutle pli
The way I see it, PerlCoder simply notes that English is much more
> >disvastigxas ol E-o, k en tre diversaj sferoj, k do sekve, proporcie pli
widespread[1] than Esperanto, and in many diverse spheres, and so is that
much more
> >utila. Kompreneble, al mi sxajnas iom artajxa tiu kontrauxstaro de la
useful. Understandably, it seems to me somewhat artificial[2] to debate
> >angla "kontraux" E-o; kial ne lerni ambaux la du lingvojn? Unue E-on,
English 'vs.' Esperanto; Why not learn both languages? First, Esperanto,
> >cxar gxi estas relative multe pli lernebla, ecx por eneuxroplingvano,
since it is easier to learn, even[3] for native speakers of european
languages,
> >due (gxis la atingebla nivelo) la anglan lingvon. Tamen cxu io simila
Second, (up to an acceptable level) English. But whether this has
> >eblas, rilate al Perl k Python, mi ne pretas sugesti! ;-)
anything to do with Perl and Python, I can't say[4]...
[1] I kept confusing 'dis-' and 'mal-' on this.
[2] 'artajxa' eq 'artistic'? 'artificial'? Not sure.
[3] I may be erroneously reversing the sense of this, or of
eneuxroplingvano.
[4] Literally 'I am not ready to suggest'?
---Jason
------------------------------
Date: 4 Aug 1999 13:45:41 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Autovivification?
Message-Id: <7o9g65$cee$1@lublin.zrz.tu-berlin.de>
Makarand Kulkarni <makarand_kulkarni@my-deja.com> wrote in comp.lang.perl.misc:
>[ Neal Sanche <neal@nsdev.org> wrote: ]
>> think this 'effect' still exists. It is similar to some entries in the
>
>What 'effect' exists ?
Makarand now posts his replies below the original. There's even an
attribution. Halleluja, another soul saved!
Anno
------------------------------
Date: 4 Aug 1999 13:29:20 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Can I use a variable as a file descriptor ?
Message-Id: <7o9f7g$cdm$1@lublin.zrz.tu-berlin.de>
dja7 <dja7@jps.net> wrote in comp.lang.perl.misc:
>If so, do I have to do anything more than define the variable ?
>
>e.g. local($fd); ??
>
>
>Here is a paraphrased snippet of code from
>"Programming Perl" by Wall, Schartz
>published by O'Reilly & Assoc 1992
Which edition of the Camel are you using?
>This is supposed to be a server daemon that listens on sockets and
>spawns services as client connections come in
>
>sub spawn{
>local($service)=@_;
>local($fd);
>accept($fd,$service);
>$pid=fork;
>..
>..
>}
>
>It always fails on the accept statement. Carp says, "Bad symbol for
>filehandle"
I asked about the edition because the spawn subroutine I find in mine
(there seems to be only one) looks very different. Your code is not
a paraphrase by the most liberal interpretation.
In any case, accept is more likely to carp about the second parameter,
which must be a valid filehandle to a socket. The first one ($fd) is
set by accept on a successful call. Speaking of which, a successful
call is recognized by a true return value, which isn't checked in
your code.
>What gives ? Can I get away with using a literal here or would I have
>to fork first ? should I or can I localize a literal filehandle ?
>like, local(FD) ? wouldn't that literal be pointing to the same
>filehandle everytime the spawn subroutine is called ?
I don't think that would help, since accept fills in a filehandle
for you.
>Why do they publish an example that doesn't work ? Can anyone recommend
>some books on using Perl to implement socket connections ?
I have successfully used the Camel for that purpose. The Perl Cookbook
(also O'Reilly) is another good source.
Anno
------------------------------
Date: 4 Aug 1999 12:21:53 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: download available
Message-Id: <7o9b91$cam$1@lublin.zrz.tu-berlin.de>
Joel <joel@dalleyjo.user.msu.edu> wrote in comp.lang.perl.misc:
>The Goods is a cool web application that runs on UNIX systems. It comes
>
>with an installer script to basically automate the install process,
>which
>is very painless. I wrote it in Perl, so you can always go into the
>program file ...
I don't go into perl files anymore. I was in one of Abigail's. Man,
I could hardly breathe.
Anno
------------------------------
Date: 4 Aug 1999 14:15:17 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: download available
Message-Id: <37a83ce5_1@newsread3.dircon.co.uk>
Joel <dalleyjo@pilot.msu.edu> wrote:
> The Goods is a cool web application that runs on UNIX systems.
>
>
> http://dalleyjo.user.msu.edu/cgi-bin/goods/goods_home.cgi
>
Ooh. no -w, no 'strict', hand-rolled parameter decoding, no check on the
success of file opens -
system "mkdir $user_path/$new_user";
open (FILE, ">$user_path/$new_user/$new_user.dat");
print FILE $confirm_password;
close (FILE);
system "chmod -R 700 $user_path/$new_user";
Ooh ...
$test_time_check_time = localtime(time);
$test_new_time1 = substr($test_time_check_time, 11,2);
$test_new_time2 = substr($test_time_check_time, 14,2);
$test_time_check_time = $test_new_time1.$test_new_time2;
All topped off with hundreds and hundreds of print statements with nary
a here document ...
This could be the evil twin of Matt Wright.
/J\
--
"When the boys in the playground found out that I had a potentially
fatal peanut alergy they would shove me up against a wall and make me
play Russian roulette with a bag of Revels" - Milton Jones
------------------------------
Date: Wed, 04 Aug 1999 12:06:59 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: HELP: How to program command line args
Message-Id: <7o9ai4$5pd$1@news.mch.sbs.de>
In article <7o96f7$5so$1@nnrp1.deja.com>, jarral@my-deja.com wrote:
>I am fairly new to PERL and quite a competent Shell Scripter and in
>shell scripts you have $1 to $n for positional parameters on the command
>line, how is this done in PERL? I have had a look at the FAQ but to no
>avail and my PERL book (PERL from the Ground Up by Michael McMillan,
>Osbourne) doesn't seem to mention it.
>
>Any help will be much appreciated.
>
>Regards
>
>Masud
You probably encountered the following while reading your book : @ARGV.
Look at the index, under @ARGV or 'command line'.
If it's not there, find another book :-)
Here's what perlvar has to tell about @ARGV :
The array @ARGV contains the command line arguments intended for the script.
Note that $#ARGV is the generally number of arguments minus one, because
$ARGV[0] is the first argument, NOT the command name. See ``$0'' for the
command name.
Michel.
------------------------------
Date: Wed, 04 Aug 1999 12:50:45 GMT
From: alexander.zinniker@trivadis.com
Subject: Re: HELP: How to program command line args
Message-Id: <7o9cv2$a86$1@nnrp1.deja.com>
command line parameters are included in @ARGV. $ARGV[0] represents the
first, $ARGV[1] the second parameter... $ARGV[n].
If you want to use something like "myscript -l <bla> -p <blabla>" then
you can use Getopts::Std, which looks like this:
-------------------------
#!/usr/bin/perl
use Getopt::Std;
use vars qw($opt_l $opt_p $oopt_q); #-- there is no , between
the #-- identifiers
getopts("l:p:q"); #-- the : means that there should be passed a value
#--print out the parameters specified
print $opt_l, "\n";
print $opt_p, "\n";
..
--------------------------------------
--Alex
In article <7o96f7$5so$1@nnrp1.deja.com>,
jarral@my-deja.com wrote:
>
>
> Hi,
>
> I am fairly new to PERL and quite a competent Shell Scripter and in
> shell scripts you have $1 to $n for positional parameters on the
command
> line, how is this done in PERL? I have had a look at the FAQ but to no
> avail and my PERL book (PERL from the Ground Up by Michael McMillan,
> Osbourne) doesn't seem to mention it.
>
> Any help will be much appreciated.
>
> Regards
>
> Masud
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 4 Aug 1999 09:02:58 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: HELP: How to program command line args
Message-Id: <slrn7qghvc.t9b.abigail@alexandra.delanet.com>
jarral@my-deja.com (jarral@my-deja.com) wrote on MMCLXIV September
MCMXCIII in <URL:news:7o96f7$5so$1@nnrp1.deja.com>:
[]
[] I am fairly new to PERL
As we can see, because you don't seem to be able to spell the name
of the language correctly. And we're supposed to believe you that you
looked at the FAQ?
[] and quite a competent Shell Scripter and in
[] shell scripts you have $1 to $n for positional parameters on the command
[] line, how is this done in PERL? I have had a look at the FAQ but to no
[] avail and my PERL book (PERL from the Ground Up by Michael McMillan,
[] Osbourne) doesn't seem to mention it.
But the perl man page about special variables might have something
to say about it.
Abigail
--
sub f{sprintf'%c%s',$_[0],$_[1]}print f(74,f(117,f(115,f(116,f(32,f(97,
f(110,f(111,f(116,f(104,f(0x65,f(114,f(32,f(80,f(101,f(114,f(0x6c,f(32,
f(0x48,f(97,f(99,f(107,f(101,f(114,f(10,q ff)))))))))))))))))))))))))
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Wed, 04 Aug 1999 09:35:55 -0400
From: brian@pm.org (brian d foy)
Subject: Re: High demand for Perl programmers?
Message-Id: <brian-0408990936390001@rtp-cr45-dhcp-147.cisco.com>
In article <37a7f94a$1_2@newsread3.dircon.co.uk>, Jonathan Stowe
<gellyfish@gellyfish.com> wrote:
>See the Perlmongers Jobs Mailing Lists described at :
you mean "Perl Mongers". it's two words. ;)
> <http://www.pm.org/mailing_lists.shtml>
>
>/J\
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: 4 Aug 1999 12:08:16 GMT
From: M.Ray@ulcc.ac.uk (Malcolm Ray)
Subject: Re: mySql & Perl -> Something simple
Message-Id: <slrn7qgb9g.3de.M.Ray@carlova.ulcc.ac.uk>
On Wed, 04 Aug 1999 18:26:37 GMT, hoz <hoz@rocketmail.com> wrote:
>I think maybe your problem is your $statement and your PREPARE
>try...
>
>1. putting quotes around your $codeQuery
>2. put quotes around your prepare
>
>see below...
>
>>$statement = "SELECT Part_Number, Description, Price \
>> from master \
>> where code = \"$codeQuery\"";
Don't do that. Think about the SQL statement which would result if
the value of $codeQuery contained a double-quote. Instead, use DBI's
quote method, which is guaranteed to do the right thing.
>>$sth = $dbh->prepare(qq{$statement});
That's a pointless change.
--
Malcolm Ray University of London Computer Centre
------------------------------
Date: 4 Aug 1999 12:39:43 GMT
From: steve.vanderburg@lhsc.on.ca (Steve van der Burg)
Subject: Re: Newbie Q: How to check if invoked as CGI program
Message-Id: <8E1859275stevevanderburglhsco@newshost.uwo.ca>
rhrh@hotmail.com (Richard H) wrote in
<37A54D97.39A1EDAF@hotmail.com>:
>Andrew Fry wrote:
>>
>> In article <7nqsf2$oo06@news.cyber.net.pk>, Faisal Nasim
>> <swiftkid@bigfoot.com> writes
>> >: The question is ... is there a foolproof way of being able to
>> >: detect how the program was invoked ? ... and thus determine the
>> >: appropriate mode to adopt.
>> >
>> >Check out the contents of %ENV in both cases.
>>
>> And what would I expect to find ?
>>
[ snip ]
>
>youd expect to find HTTP_REFERRER variable and others relating to
>http that would give you an idea of how it was called.
>
>Richard H
Actually, checking HTTP_REFERER isn't such a great idea, since it's
set by the web browser. GATEWAY_INTERFACE, one of the SERVER_*
variables, or something like HTTP_HOST would be much better, since
they're all set by the web server that's launched your program. If
you don't trust any of those (they can be set manually by anyone
launching your program from a shell, for example), you could always
parse the process list ("ps" output, or other methods) and check to
see if your parent's PID belongs to a web server process.
...Steve
--
Steve van der Burg
Technical Analyst, Information Services
London Health Sciences Centre
London, Ontario, Canada
Email: steve.vanderburg@lhsc.on.ca
------------------------------
Date: Wed, 04 Aug 1999 13:23:00 +0100
From: Richard H <rhrh@hotmail.com>
Subject: Re: Newbie question about hashes
Message-Id: <37A830A4.6303ADB4@hotmail.com>
Niek Slatius wrote:
>
> Hi people,
> I started of trying this code:
>
> foreach values %FORM{
> $FORM{$a} = lc $FORM{$a};
> }
>
> No good :'-(
>
> I've tried this code:
>
> foreach values %FORM ($value){
> $value = lc $value;
> }
>
> That didn't work either :'-(
>
> What a'm I missing here? Don't tell me I need to put the values of %FORM
> in an array first, then lowercase those values and then put 'em back in
> a hash again please (except of course if that's the only solution) ;-)
>
> Thanx in advance for any support.
> BTW if it is in the FAQ (but not in clear simple English) please
> redirect me if you would. My native language is not English you see ;-)
> so I sometimes have trouble figuring out what words mean (like
> 'iteration'... although I have a clue as to what it probably means).
>
> Thanx again,
>
> Niek Slatius
> nslatius@NO_SPAM.dds.nl (you know the drill)
> http://huizen.dds.nl/~nslatius
Try looking in perlfunc for each, exists, values and keys functions
This would do the job you're trying to do:
while (($key, $value) = each %hash) {
$hash{$key} = lc $value;
}
I'm sure there are better ways!,
Richard H
------------------------------
Date: Wed, 04 Aug 1999 13:54:30 GMT
From: Richard Lawrence <ralawrence@my-deja.com>
Subject: Perl counter muckup
Message-Id: <7o9gmh$cri$1@nnrp1.deja.com>
Hello!
I have written a small webpage counter (no big deal) in Perl and yet
every so often it resets itself (well, it reset itself today and had
been going for about 7 months before then). I've come to the not-so-
unreasonable conclusion that its my perl that is at fault. Could anyone
point me to what I've done wrong that makes this counter currently
unreliable please?
Thanks
Rich
---
#!/usr/bin/perl
# a simple counter by Rich
use strict;
use 5.004;
use Fcntl qw(:flock);
my $from = $ENV{'REMOTE_HOST'};
# realised that I have no idea how to just read one line from
# a file - this seems to work although I suspect its bad perl.
open (SITE, "counter.dat");
$_ = <SITE>; # urg?
chomp;
close SITE;
# split the details up
my @details = split(/ /);
# $details[0] = hits
# $details[1] = last site
# so people hitting reload a lot won't up the counter
$details[0]++ unless ($details[1] eq $from);
# write out new data - loop for lock
open (SITE, ">counter.dat") || die "can't!";
my $locked = 0;
while ($locked == 0) # could technically loop for ever.
{
if (flock(SITE, LOCK_EX))
{
$locked = 1;
}
}
printf SITE "$details[0] $from\n";
close SITE;
# display info
printf "Content-type: text/html\n\n";
printf("%d\n", $details[0]);
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 4 Aug 1999 13:22:53 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: revert gmtime()
Message-Id: <slrn7qgfpj.1uq.fl_aggie@thepentagon.com>
On Wed, 4 Aug 1999 06:36:00 -0400, James A Culp III <admin@futuristic.net>, in
<7o95ff$fc1$1@ffx2nh3.news.uu.net> wrote:
+ Lüder Sachse <sachse@aeb.de> wrote in message
+ news:37A8030C.82DFE115@aeb.de...
+ > Is there an easy way (or a function) to calculate the seconds since
+ > epoch out of a gmtime-formatted date string like 'Tue Aug 3 17:35:27
+ > 1999'?
Yes.
+ You might take a look at the Date::Calc module on CPAN. Very useful for
+ date manipulation.
I suppose one could do it this way, but why?
NAME
Time::Local - efficiently compute time from local and GMT
time
SYNOPSIS
$time = timelocal($sec,$min,$hours,$mday,$mon,$year);
$time = timegm($sec,$min,$hours,$mday,$mon,$year);
Part of the core perl.
James
------------------------------
Date: 4 Aug 1999 07:07:03 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Special delete
Message-Id: <37a83af7@cs.colorado.edu>
In comp.lang.perl.misc,
sangin@cam.org (Jean-Pierre Sangin) writes:
:Please could you tell me the command to delete in a directory all
:files created one week ago or more.
The same one they'd tell you in comp.unix.shell.
--tom
--
People usually get what's coming to them... unless it was mailed.
------------------------------
Date: Wed, 04 Aug 1999 15:33:18 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Jean-Pierre Sangin <sangin@cam.org>
Subject: Re: Special delete
Message-Id: <37A8411E.BDAF92AD@kawo2.rwth-aachen.de>
Hi Jean-Pierre,
Jean-Pierre Sangin wrote:
> Please could you tell me the command to delete in a directory all
> files created one week ago or more.
maybe something like (no guarantee):
opendir DIR, $DIR or die "can not read $DIR: $!\n"
@files = grep {$_ = "$DIR/$_" and # change to full path
-f and # plain file
-M > 7} readdir DIR; # over 7 days old
closedir DIR;
unlink @files;
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: 4 Aug 1999 12:11:06 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Strange STDOUT on script, any ideas?
Message-Id: <7o9akq$c9d$1@lublin.zrz.tu-berlin.de>
Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca> wrote in comp.lang.perl.misc:
>Hi,
>
>I've written a script to move files in a dir to a dir based on their
>filename. These files come in sets of twos: one image file, with a
>matching text file for metadata.
>
>I've used a foreach on all files to check the filename, search for the
>dir path, create it if it does not exist, then move the files.
>
>The files do reach their correct destination, and dirs are made (the
>script is functional), but STDOUT returns messages of "No such file or
^^^^^^
STDERR
>directory. It looks like it is looking for files that have been already
>moved.
Sure. Depending on what files the glob finds that's bound to happen.
>foreach $input (<*.txt>)
>{
> $north = $1 and $east = $2 if $input =~ /(N\d{2})d\d{2}m(W\d{3}).*/;
> if ( -d "/user/home/img/$east/$north")
> {
> system("mv $north*$east* /user/home/$east/$north/");
[more code]
You are calling the system command mv with a file glob. That can
move zero, one or many files to the target directory. Later you
may happen upon a file that's already been moved. You don't have
to, but no surprise if you do.
Anno
------------------------------
Date: Wed, 04 Aug 1999 13:35:29 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: thanks for nothing everybody - POINTERS ?
Message-Id: <7o9fo1$9a5$1@news.mch.sbs.de>
In article <rqgap5i4132ncq6@corp.supernews.com>, "Diane" <tech1@magicnet.net> wrote:
>Gee thanks for your help NOT!!
>
>All I wanted was a brief interpretation of some of the lines of code that
>were NOT related to HTML, and all you people could come up with are
>critiques of the code. I did not want or need that. Its NOT a cgi class,
>just touches on it and I just wanted to explain some of the code, but
>apparantly none of you are capable of doing that. I must say this is my
>first time being treated so badly and getting such useless info from a
>newsgroup. Most groups are most helpful and willing to share knowledge..
>guess you folks are not. Sorry I wasted my time and hoped for some help
>
In short :
(this is of course slightly exagerated (sp?) for didactical purposes)
"See, I had this wonderful shotgun I wanted to give to my three-year old
child, and I just wanted some pointers on how to load it before giving
it to him..."
What we basically recommended was to change the shotgun into a
toy waterpistol before you gave it to your child.
In the meantime, I've been trying to find a good source of introduction-
level code for you to use on the Web, but I seem to be out of luck :-(
Anyway, have a look at the Beginner's Guide to CGI Scripting with
Perl, at http://www.lies.com/begperl/. It does use CGI.pm (some-
times) and Taint (at the end).
The Unix part will probably not be relevant to you, so you can skip
that and get to the more "interesting" bits.
Or the CGI Programming 101, at http://www.cgi101.com/class/.
Again, stop after chapter 3, because it gets dirty again...
If any of the Perl hackers know of a better source for non-programmers,
with samples including the systematic use of CGI.pm or equivalent, and
the necessary -w, -T, use strict etc., please let us know :-)
HTH,
Michel.
------------------------------
Date: Wed, 4 Aug 1999 15:41:13 +1000
From: "Ron Savage" <ron_savage@non-hp-australia-om5.om.hp.com>
Subject: Re: Use of uninitialized value ....
Message-Id: <7o8k8u$75a$1@ocean.cup.hp.com>
Laura
You refer to lines 146 and 152. Which are they?
--
Cheers
Bus: rons@hpaco.aus.hp.com
Home: ron@savage.net.au
http://savage.net.au/
Laura Bello <lrb@aimnet.com> wrote in message
news:lrb-0208991847030001@oak-alg-gw4-55.ncal.verio.com...
> Hi folks,
>
> I'm new at perl and I'm really stumped with this one. The cgi script I
> wrote looks at a particular directory full of html formated memos. It
> creates a table with the file name, description, and modification date.
>
> The script appeared to work and the resulting html page looked totally
> fine. But then I discovered that if I viewed the page source or ran the
> cgi from the command line I was getting this error message:
>
> [Mon Aug 2 15:35:50 1999] memolist.cgi: Use of uninitialized value at
> ./memolist.cgi line 146.
>
> I would get it twice, once each for two files I know don't have a date in
> the actual document.
>
> Here is the subroutine in question, date_html. The script uses both the -w
> switch and "use strict" and the above is the only error message I get. Oh,
> and I'm running Perl5.004 on SunOS. I know this will look naive to you all
> but here goes:
>
> $mod = &date_html(@file) #subroutine invoked in this fashion
>
> #--------------------------------------------------------------------
> # DATE_HTML - extract date from html files
> #--------------------------------------------------------------------
> sub date_html {
> my (@f) = @_;
> my ($date, $tmp);
> ($tmp) = grep { /<TD.*>.*, \d{4}/i } @f;
> if ( defined $tmp ) {
> ($tmp) = ($tmp =~ m#<TD.*>\s*(.*?, \d{4})#i); # Extract just the
date
> ($date = $tmp) =~ s/<[^>]*>//gs; # Kill any other tags
> } else {
> $date = &mod_date("$memdir/$memo");
> }
> return $date;
> }
>
> #--------------------------------------------------------------------
> # MOD_DATE - plan B if date_html comes up with nothing
> #--------------------------------------------------------------------
> sub mod_date {
> my ($f) = @_;
> my $date = (stat($f))[9];
> $date = scalar localtime($date);
> my($mon, $mday, $year) = (split ' ', $date)[1, 2, 4];
> $date = "$mon $mday, $year";
> return $date;
> }
>
> After going thru the docs, faq, and books the only thing I unearthed was:
>
> Use of uninitialized value
>
> (W) An undefined value was used as if it were already defined. It was
> interpreted as a "" or a 0, but maybe it was a mistake. To suppress this
> warning assign an initial value to your variables.
>
> So I tried to be really explicit in evaluating the result of the grep:
>
> #--------------------------------------------------------------------
> # DATE_HTML - extract dates from html files
> #--------------------------------------------------------------------
> sub date_html {
> my (@f) = @_;
> my $stat = 0;
> my $date = "";
> my $tmp = "";
> $stat = eval{($tmp) = grep { /<TD.*>.*, \d{4}/i } @f};
> print "\n\n############ $stat #######################\n";
> if ( $stat == 1 ) {
> ($tmp) = ($tmp =~ m#<TD.*>\s*(.*?, \d{4})#i); # Extract just the
date
> ($date = $tmp) =~ s/<[^>]*>//gs; # Kill any other
tags
> } elsif ( $stat == 0 ) {
> $date = &mod_date("$memdir/$memo");
> }
> return $date;
> }
>
> Successful grep:
> ############ 1 #######################
> [good html follows]
>
> Unsuccessful grep:
> ############ 0 #######################
> [Mon Aug 2 16:32:25 1999] testit.cgi: Use of uninitialized value at
> ./testit.cgi line 152.
> [good html follows]
>
> Sorry for the length of this post but I wanted to be as clear as I could
> be. I suppose I could just turn off the -w switch since the script works
> but that doesn't make sense to me.
>
> Any help would be greatly appreciated.
>
> Thanks ... -laura
>
> --
> Laura Bello
> <mailto:lrb@aimnet.com>
------------------------------
Date: Wed, 04 Aug 1999 15:04:07 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: "Filip M. Gieszczykiewicz" <fmgst@pitt.edu>
Subject: Re: Useless error when {} unbalanced
Message-Id: <37A83A47.A80C1121@kawo2.rwth-aachen.de>
Hi Filip,
"Filip M. Gieszczykiewicz" wrote:
> URGH! The longer my scripts get, the more annoying the perl error for
> unbalanced {} is getting. Missing { is informative:
have you tried Vim 5.4 (Vi IMproved)? It has syntax-highlighting and more
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Wed, 04 Aug 1999 09:33:34 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Useless error when {} unbalanced
Message-Id: <brian-0408990934180001@rtp-cr45-dhcp-147.cisco.com>
In article <7o8om2$9g3$1@usenet01.srv.cis.pitt.edu>, fmgst+@pitt.edu
(Filip M. Gieszczykiewicz) wrote:
>URGH! The longer my scripts get, the more annoying the perl error for
>unbalanced {} is getting. Missing { is informative:
[snip error messages]
>I have thus two strategies:
>
>1) DATE all my changes and then search for latest date in src as
> area of most likely trouble
you mean, use source control? ;)
>2) vi's "%" matching of {}() for the brute-force cases...
> not too fun with >1500 lines....
there is also syntax highlighting and various other editor niceties
floating around.
>Oh gurus, what's the answer?
0) have a consistent indentation and coding style that makes it easy
to visually scan the code to see where the missing bracket is.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>
------------------------------
Date: Wed, 04 Aug 1999 15:14:45 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Matt <splinter@monmouth.com>
Subject: Re: Using CGI.pm to Retrieve Image
Message-Id: <37A83CC5.F365AE03@kawo2.rwth-aachen.de>
Hi Matt,
Matt wrote:
> use CGI;
> but now what? How do I save it to a specific directory as an image file?
run "perldoc CGI" and read about filefield
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Wed, 4 Aug 1999 07:13:01 -0400
From: Casey Tweten <crt@kiski.net>
Subject: Re: Web Startup Seeks Help, Programmer
Message-Id: <Pine.OSF.4.10.9908040711190.667-100000@home.kiski.net>
On 3 Aug 1999, Abigail wrote:
: Can I sue you for age discrimination?
I beleive the protected class for age begins at age 40, so if you are >=
40. Sue away!
[Web Startup Seeks Legal Help, Programmer]
Casey
------------------------------
Date: Wed, 04 Aug 1999 15:19:10 +0200
From: Alex Farber <alex@kawo2.rwth-aachen.de>
To: Dave <bisonman@optonline.net>
Subject: Re: Web Startup Seeks Help, Programmer
Message-Id: <37A83DCE.CE681D8E@kawo2.rwth-aachen.de>
Dave wrote:
> What's missing? An expert programmer (HTML, JAVA, CGI, SQL...)
> who is like us: young, driven, and willing to go the extra mile to make
sweatshop^^^^^^^^^^
> our dream into a reality.
Regards
Alex
--
Ich studiere Elektrotechnik (Technische Informatik) an der RWTH Aachen
und bin ein guter Perl-Programmierer (arbeite seit 4 Jahren als Intranet-
Entwickler). Kann auch C, Java, SQL, JavaScript und HTML, CGI und TCP/IP.
Ich suche eine gut bezahlte Diplomstelle in Koeln, Aachen oder Umgebung.
------------------------------
Date: Wed, 04 Aug 1999 23:26:10 +1000
From: Pat Heuvel <pheuvel@optusnet.com.au>
Subject: Re: Web Startup Seeks Help, Programmer
Message-Id: <37A83F72.DF09E5B3@optusnet.com.au>
Gday Abigail,
Abigail wrote:
>
> Dave (bisonman@optonline.net) wrote on MMCLXIV September MCMXCIII in
> <URL:news:37A79A6A.548FA0C6@optonline.net>:
...
> "" who is like us: young, driven, and willing to go the extra mile to make
> "" our dream into a reality.
>
> Can I sue you for age discrimination?
>
What if he was talking in geological terms?
> Abigail
> --
Pat
(Plenty of grey here, but I still wasn't around in the Cretaceous...)
--
+---------------------------------------------------------+
+ "Logic clearly dictates, that the strokes of the many +
+ outweigh the strokes of the two..." +
+ (Apologies to Mr Spock) +
+---------------------------------------------------------+
------------------------------
Date: Wed, 4 Aug 1999 15:36:47 +1000
From: "Ron Savage" <ron_savage@non-hp-australia-om5.om.hp.com>
Subject: Re: Whitespace
Message-Id: <7o8k0c$74b$1@ocean.cup.hp.com>
Count the whitespace characters. 0 is good. > 0 is bad. Tested code:
#!perl -w
use integer;
use strict;
my($string) = "A\t\n \r\fZ";
my($count) = $string =~ tr/ \f\n\r\t/ \f\n\r\t/;
print "Counted $count whitespace characters. \n";
--
Cheers
Bus: rons@hpaco.aus.hp.com
Home: ron@savage.net.au
http://savage.net.au/
Joan Richards <richj@home.com> wrote in message
news:37A5E9A8.D65F7138@home.com...
> At a prompt in my script, I don't want the user to be able to type in an
> input that contains more than one word. Now this word can be comprised
> of upper/lower case letters and number, but nothing else. So, foobar is
> valid, but foo bar is invalid. So is "foobar" is invalid.
>
> Now, the user can type in anything they want, however, I want to give
> them the finger if they input something bad.
>
> Thanks,
>
> -J
>
------------------------------
Date: Wed, 04 Aug 1999 09:28:40 -0400
From: Chris Goodwin <archer7@mindspring.com>
Subject: Why is it....
Message-Id: <37A84008.E00E9A72@mindspring.com>
why is it that I, who have only been hacking Perl for ~3 days, can read
through the documentation and the previous newsgroup postings (7000+ of them
on my server) and write up a 122-line program that does what I want it to do
(which is turn my text into my HTML -- not *entirely* finished yet, but the
rest is details -- I've gotten over my hurdles), all *without* having to ask
anyone for help, while other people around here, who apparently have been
hacking Perl for longer than I, have to come in and ask the same questions
over and over?
--
Making the world safe for anocracy! http://www.mindspring.com/~archer7
L. Neil Smith Supporter http://members.xoom.com/smith4prez
Sign up for E-gold: http://www.mindspring.com/~archer7/e-gold.html
------------------------------
Date: Wed, 04 Aug 1999 13:58:42 GMT
From: michel.dalle@usa.net (Michel Dalle)
Subject: Re: Why is it....
Message-Id: <7o9h3h$a50$1@news.mch.sbs.de>
In article <37A84008.E00E9A72@mindspring.com>, Chris Goodwin <archer7@mindspring.com> wrote:
>why is it that I, who have only been hacking Perl for ~3 days, can read
>through the documentation and the previous newsgroup postings (7000+ of them
>on my server) and write up a 122-line program that does what I want it to do
>(which is turn my text into my HTML -- not *entirely* finished yet, but the
>rest is details -- I've gotten over my hurdles), all *without* having to ask
>anyone for help, while other people around here, who apparently have been
>hacking Perl for longer than I, have to come in and ask the same questions
>over and over?
>
Must be that pizza delivery job you had in Oregon :-)
Oops, there goes my S/N ratio,
Michel.
------------------------------
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". 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 V9 Issue 362
*************************************