[12373] in Perl-Users-Digest
Perl-Users Digest, Issue: 5973 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 12 18:07:18 1999
Date: Sat, 12 Jun 99 15:00:19 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 12 Jun 1999 Volume: 8 Number: 5973
Today's topics:
"interactive" Net::FTP? <kin@symmetrycomm.com>
Re: "interactive" Net::FTP? <gellyfish@gellyfish.com>
Re: clear memory <cassell@mail.cor.epa.gov>
Re: cookie-monster.pl, a cookie scrambler. (Ronald J Kimball)
Re: DBD::CSV <cassell@mail.cor.epa.gov>
Re: delete line ending with ) (Ronald J Kimball)
Re: disalowing words (Ilya Zakharevich)
Re: disalowing words <cassell@mail.cor.epa.gov>
FAQ? (was Re: accessing a single char in a string) <uri@sysarch.com>
Re: File Uploading via html form (Marcel Grunauer)
Re: good newbie advice (was Re: Silly old me) (Abigail)
Re: HELP: Perl on Windows Platform??? <cassell@mail.cor.epa.gov>
Re: I <dpodbori@email.msn.com>
Re: importing comma-delimited data into perl? <jeff@vpservices.com>
Re: Interpolation Question (Ronald J Kimball)
Re: Log file <hellraiser@linuxfreak.com>
Re: Perl Script - HELP! <cassell@mail.cor.epa.gov>
Re: Please Help!! <cassell@mail.cor.epa.gov>
Re: Prevent loading from Cache? <xpalo03@vse.cz>
Re: Printing <cassell@mail.cor.epa.gov>
Re: Printing <gellyfish@gellyfish.com>
Re: problem with no text outputting from Perl CGI scrip <cassell@mail.cor.epa.gov>
Re: Require "No NT commands" on UNIX (Owen O'Byrne)
sorting (Jimtaylor5)
Re: Stat mtime <aef@pangea.ca>
Re: Stat mtime <aef@pangea.ca>
Re: Stat mtime <gellyfish@gellyfish.com>
Re: Stat mtime (Dan Zetterstrom)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 12 Jun 1999 17:29:55 -0000
From: Kin Cho <kin@symmetrycomm.com>
Subject: "interactive" Net::FTP?
Message-Id: <19990612172955.16746.qmail@nym.alias.net>
Hi,
I'd like to use Net::FTP to login to a server,
then return control to the user to interact
with the remote server as if using a regular FTP client.
Can this be done, or are there other modules that can do this?
TIA,
-kin
------------------------------
Date: 12 Jun 1999 18:52:35 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: "interactive" Net::FTP?
Message-Id: <7jua9j$3f6$1@gellyfish.btinternet.com>
On 12 Jun 1999 17:29:55 -0000 Kin Cho wrote:
> Hi,
>
> I'd like to use Net::FTP to login to a server,
> then return control to the user to interact
> with the remote server as if using a regular FTP client.
>
> Can this be done, or are there other modules that can do this?
>
Of course you dont need another module, but you do need to write the
code that will prompt the user and apply that input to the methods
that the module provides. As far as I can tell every command that one
might want of an ftp client is provided.
OK we do recommend people to use the modules a lot, but these are only
there for purposes of code reuse - in nearly all cases they wont do
everything for you.
If you have any problem implementing your client software please feel
free to post back the shortest piece of code that is giving you trouble.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 12 Jun 1999 12:46:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: clear memory
Message-Id: <3762B92E.F7C79030@mail.cor.epa.gov>
IzB. wrote:
>
> hi,
> is there a function that free the memory associated with an object or
> another vaiable ?
>
> @array[obj1,obj2,obj3]
>
> if I want to clear my 'obj2', what could I do if I want to be certain
> that all the memory used by 'obj2' is free again ?
If you want to know about freeing memory up, you'll want to
read what the FAQ says. Type 'perldoc -q free' to see the
relevant piece.
But the bottom line is: you can't get there from here. Most
OSes do not reclaim free()d memory from processes the way you
want until after the process ends.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sat, 12 Jun 1999 17:03:06 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: cookie-monster.pl, a cookie scrambler.
Message-Id: <1dtabkn.447bld36ujuyN@p84.tc1.metro.ma.tiac.com>
Eric Bohlman <ebohlman@netcom.com> wrote:
> Ronald J Kimball (rjk@linguist.dartmouth.edu) wrote:
> :
> : @poschars_hex=("a" .. "f","0" .. "9");
> : @poschars_b64=("0" .. "9", "=", "/", "a" .. "z", "A" .. "Z");
>
> : Thanks for catching that!
>
> Let's count in hex: a, b, c, d, e, f, 0, 1...oops.
Since these arrays are used for random elements, not for counting, the
order does not matter.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sat, 12 Jun 1999 12:55:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: DBD::CSV
Message-Id: <3762BB20.64D13B58@mail.cor.epa.gov>
Kevin Howe wrote:
>
> How reliable/bug free is DBD::CSV? Is it safe to use in large projects?
I haven't had any problems with it. But I haven't tried it in
a large project. You need to read the documentation so you
use it properly. There is a known bug, which is really an OS
issue. It uses flock() internally, and when flock() isn't
implemented in the OS you don't get locking. A bad thing in
a 'large project', a trivial issue when I was tinkering with it.
But more importantly, why would you even think about using
a CSV file for a database in a large project? That's just
asking for trouble later, and scalability problems. Use a
real RDBMS. There are free ones which Perl is quite happy
to use. MySQL, SDBM, GDBM, Berkeley DB, ...
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sat, 12 Jun 1999 17:03:08 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: delete line ending with )
Message-Id: <1dtabs2.uj5pgh1m5lagwN@p84.tc1.metro.ma.tiac.com>
<jimbob4334@my-deja.com> wrote:
> How do I delect every line ending with ).
You mean like this?
perl -ni -e 'print unless /\)$/' filename
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 12 Jun 1999 19:12:51 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: disalowing words
Message-Id: <7jubfj$od7$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Larry Rosler
<lr@hpl.hp.com>],
who wrote in article <MPG.11cc1988b278fae3989bd1@nntp.hpl.hp.com>:
> <SNIP> of method described in that FAQ as 'extremely inefficient'. The
> following is efficient.
[Using split and hash lookup].
I do not believe you. Not that I trust the FAQ a tiny bit, but your
method should be *much* slower than matching 7 RExen.
Hope this helps,
Ilya
------------------------------
Date: Sat, 12 Jun 1999 12:40:56 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Twarren10 <twarren10@aol.com>
Subject: Re: disalowing words
Message-Id: <3762B7C8.6473DDA7@mail.cor.epa.gov>
[courtesy cc to poster]
Twarren10 wrote:
> >
> >if ($message =~ /any|naughty|word/) {
> > tell($mom);
> >}
> >
> >Lee
> >
> That was BEAUTIFUL, thank you my friend!
Lovely. Except that it has a couple problems of which you
should be aware. The first is that it is not very scalable.
See the other posts in this thread for more scalable solutions
[for when your list of 9 bad words gets bumped up to 90].
The second is that it only looks for the inclusion of the
selected letters in the line, and doesn't check to see if
they occur by accident in the middle of a nice word. For
example, consider the perfectly nice words:
seersucker suit
honeysuckle vines
delicious suckling pig
Nor does it get an all-caps curse.
So you might want to change the above code to:
if ($message =~ /\b(?:any|naughty|word)\b/i ) {
tell($mom)
}
or, in a recent Perl,
tell($mom) if ($message =~ /\b(?:any|naughty|word)\b/i );
Still, none of these will catch this: "You @sshole!" So
you might need to think more about what you want to flag.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Jun 1999 16:23:50 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: FAQ? (was Re: accessing a single char in a string)
Message-Id: <x7674ti2w9.fsf_-_@home.sysarch.com>
>>>>> "JS" == Jonathan Stowe <gellyfish@gellyfish.com> writes:
JS> On Sat, 12 Jun 1999 11:53:24 +0200 Maan Bsat wrote:
>>
>> In C, to access a single character in a string you just use the index in
>> the array. How can you do this in perl ? Thanks a lot.
JS> You will need to use the substr() function:
JS> perldoc -f substr
this is the 2nd or 3rd query about this in the last few days. did
someone give out a homework assignment or what? they all have asked a
similar question and use C strings for comparison. is this in the faq and
if not, should it be? a grep on single and char found nothing relevent.
in alt.perl someone kept asking why the $array[$i] syntax wouldn't work
or be made to work for this instead of substr.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
uri@sysarch.com --------------------------- Perl, Internet, UNIX Consulting
Have Perl, Will Travel ----------------------------- http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Sat, 12 Jun 1999 17:07:00 GMT
From: marcel.grunauer@lovely.net (Marcel Grunauer)
Subject: Re: File Uploading via html form
Message-Id: <376879d0.10115365@enews.newsguy.com>
On Sat, 12 Jun 1999 10:24:01 GMT, marcel.grunauer@lovely.net (Marcel
Grunauer) wrote:
>Specifically on p.152 of that book, the author gives an example of how
>to determine the file name and length of what the user tried to
>upload. So before saving the file somewhere on your server you could
>check the file's extension.
>
>I could type in the program, but I'd have to test it first to make
>sure there aren't any typos, and I'm not sure if it's ok to take a
>program 1:1 from a book.
Actually, I've had a look at the docs for CGI.pm and found that the
scenario is mentioned right there:
When a file is uploaded the browser usually sends along some
information along with it in the format of headers. The
information usually includes the MIME content type. Future
browsers may send other information as well (such as
modification date and size). To retrieve this information,
call uploadInfo(). It returns a reference to an associative
array containing all the document headers.
$filename = $query->param('uploaded_file');
$type = $query->uploadInfo($filename)->{'Content-Type'};
unless ($type eq 'text/html') {
die "HTML FILES ONLY!";
}
HTH
Marcel
------------------------------
Date: 12 Jun 1999 12:06:39 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: good newbie advice (was Re: Silly old me)
Message-Id: <slrn7m55de.4e6.abigail@alexandra.delanet.com>
Uri Guttman (uri@sysarch.com) wrote on MMCXI September MCMXCIII in
<URL:news:x7ogimhx6e.fsf@home.sysarch.com>:
`` >>>>> "A" == Abigail <abigail@delanet.com> writes:
``
`` looks like you jumped jobs judging from the domain.
Wrong conclusion.
Abigail
--
perl5.004 -wMMath::BigInt -e'$^V=Math::BigInt->new(qq]$^F$^W783$[$%9889$^F47]
.qq]$|88768$^W596577669$%$^W5$^F3364$[$^W$^F$|838747$[8889739$%$|$^F673$%$^W]
.qq]98$^F76777$=56]);$^U=substr($]=>$|=>5)*(q.25..($^W=@^V))=>do{print+chr$^V
%$^U;$^V/=$^U}while$^V!=$^W'
-----------== 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: Sat, 12 Jun 1999 11:28:28 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: HELP: Perl on Windows Platform???
Message-Id: <3762A6CC.1DE26B9F@mail.cor.epa.gov>
Marcel Grunauer wrote:
> [snip]
>
> First of all, I think you should phrase this "to run a Perl script",
> or rather "Perl program". CGI is a protocol, it can't do anything by
> itself.
I like 'Perl program'. But.. chacun a son gout. Note what the
FAQ says on this subject.
> You should use the same line as in Unix. To use Perl programs for CGI
> under, say, IIS or Personal Web Server, you'll probably give them the
> extension .pl and create an association on your server to run the Perl
> interpreter when something with that extension is requested. But
Actually, this is server-dependent. Some servers don't care
what's on the shebang line. Some require the exact path to
the Perl executable, or else kablooie. The poster will just have
to do some reading in the docs for the relevant server(s).
Jeff Zucker already answered this part (correctly).
> although the server then already knows to use Perl, you should still
> use the shebang line, because (someone correct me if I'm wrong here)
> Perl still looks for switches on the shebang (like -w or -T).
You're correct here. We should always encourage posters to
use -w after the 'perl' part on the shebang line; and to use -wT
if it's a CGI program. And new users should be encouraged
to not only 'use strict' but also 'use diagnostics' so they
get more explanation on their errors. Aren't I a pain? :-)
> To make your scripts a little bit more portable between Win9x/NT and
> Unix, you could place make C:\usr your Perl directory, so that the
> interpreter itself resides in C:\usr\bin, then you can keep the
> #!/usr/bin/perl you see in many scripts.
A good suggestion, if one has control over the installation.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sat, 12 Jun 1999 15:43:39 -0400
From: "Dmitry P." <dpodbori@email.msn.com>
Subject: Re: I
Message-Id: <#ddz3sQt#GA.252@cpmsnbbsa05>
The statement
$#Array = 3000;
means that the array size is set to exactly 3001 entries, discarding all the
entries with indexes 3000 and up that could have existed and setting entries
Walter <walter@tscinternet.com> wrote in message
news:37627f45@news1.us.ibm.net...
> I ran across a reference to arrays that state...
>
> Initialize your array before adding items to increase efficiency.
>
> i.e.: $#priceList = 3000;
>
> What do you guys think?
>
> If I know the size of my array, does this help?
>
> Thanks
>
> Walter
>
>
>
>
>
------------------------------
Date: 12 Jun 1999 19:44:03 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: importing comma-delimited data into perl?
Message-Id: <3762B7F2.C0C635F@vpservices.com>
Kate Roberts wrote:
>
> I have a file containing comma-delimited data (exported from EXCEL),
>
> [code using arrays snipped]
While you can certainly do what you want using arrays in a fashion
similar to your code, you may also want to look at DBI and the DBD::CSV
module. Those will handle all CSV (comma separated values, also called
comma-delimited data) files including things like embedded quotes and
let you flexibly pull out any fields or records you want using simple
SQL commands.
One caveat that applies to both to the DBI way of doing it and to the
array method you used: check the files Excel exports, it doesn't always
produce very clean comma-separated files.
--
Jeff
------------------------------
Date: Sat, 12 Jun 1999 17:03:12 -0400
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Interpolation Question
Message-Id: <1dtaof4.1iric361skgb41N@p84.tc1.metro.ma.tiac.com>
Aidan Humphreys <ahumphr@c-s-k.de> wrote:
> Jonathan Feinberg schrieb in Nachricht ...
> >If I understand you correctly, then what you're asking is a FAQ,
> >perlfaq4, "How can I expand variables in text strings?"
>
> Except that I was explicitly looking for a solution not using the s///
> function, rather using the eval function.
>
> How would I do this with eval ?
Maybe something like this:
$evaled = eval qq{"$string"};
But using s/// would be safer.
--
_ / ' _ / - aka -
( /)//)//)(//)/( Ronald J Kimball rjk@linguist.dartmouth.edu
/ http://www.tiac.net/users/chipmunk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Sat, 12 Jun 1999 14:26:59 -0400
From: hellraiser <hellraiser@linuxfreak.com>
Subject: Re: Log file
Message-Id: <3762A673.E9CC9B6D@linuxfreak.com>
try giving perl the -w parameter
--
hellraiser ( @linuxfreak.com || @nac.net )
awk 'BEGIN { printf "Just another %s hacker\n", ARGV[0] }'
------------------------------
Date: Sat, 12 Jun 1999 11:04:17 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Perl Script - HELP!
Message-Id: <3762A121.AD9AEAC5@mail.cor.epa.gov>
[courtesy cc sent to poster]
Larry Rosler wrote:
>
> [snip]
> Merging your attempt at garnering the names from the logfile with TomP's
> code for processing them:
>
> {
> my %count;
> while (<>) {
> $count{$1}++ if /IDENTIFIED '([^']+)'/;
or to change this line so that you pick up the single quotes when
present, as you requested:
$count{$1}++ if /IDENTIFIED (\S+)/;
> }
> for (sort keys %count) {
> print "$_ was here $count{$_} times.<br>\n";
> }
> }
It's hard to improve on TomP or LarryR's code. Read it over
carefully. There are lots of good techniques and style tips
in there.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sat, 12 Jun 1999 12:04:01 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Please Help!!
Message-Id: <3762AF21.37BCD519@mail.cor.epa.gov>
Bart Lateur wrote:
>
> coneliberation@my-deja.com wrote:
>
> >The cone liberation society needs your help. We are an international
> >organisation dedicated to liberating traffic cones, an we're updating
> >our webpages.
>
> Completely off-topic, but... why would you want to free traffic cones?
> It seems to me like they are perfectly happy where they are.
How can they be happy, stuck out in streets to be run over by
joyriding teenagers, or packed together on top of one another
in some DOT version of a slaveship? :-)
> Is this some Monty-Python-esque fun organization?
Yes. At least, I hope to G_d that it is...
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Sat, 12 Jun 1999 21:54:18 +0200
From: Ondrej Palkovsky <xpalo03@vse.cz>
Subject: Re: Prevent loading from Cache?
Message-Id: <3762BAEA.C5F10215@vse.cz>
Hans Bolte wrote:
>
> Hello,
>
> can I prevent, that the browser loads the output from a cgi-script from
> his cache?
>
I'm currently using:
print
header(-type=>'text/html',-'Cache-Control'=>'no-cache',-Pragma=>"no-cache");
Works with all browsers...
Bye
Ondrej Palkovsky
xpalo03@vse.cz
--
I have never understood the female capacity to avoid a direct answer to
any question.
-- Spock, "This Side of Paradise", stardate 3417.3
------------------------------
Date: Sat, 12 Jun 1999 13:00:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Printing
Message-Id: <3762BC4B.8AFAED3B@mail.cor.epa.gov>
Bjvrn Teegen wrote:
>
> > I'm new to Perl programming and cannot find the command(s) I need to
> > send data to the printer. I've been through three manuals and looked
> > online to no avail.
>
> One possibility is to write directly to the printer device:
>
> # UNIX
> open(PRINTER, '/dev/lp1');
> print PRINTER "Hello, world!\n";
> close(PRINTER);
>
> # DOS
> open(PRINTER, 'LPT1:'); # I am not sure if this works under DOS
> print PRINTER "Hello, world!\n";
> close(PRINTER);
Yes, this does work under DOS. If the printer is local, or
your LPT1 has been co-opted to serve as a feed to a network
printer. But I wouldn't count on it in the general case.
Also, most printers I've grappled with since I stopped using
dot-matrix printers will need a formfeed (the \f ) sent after
that \n or else the output will sit in the printer awaiting
the completion of the page. An annoying feature.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Jun 1999 20:46:18 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Printing
Message-Id: <7juguq$49e$1@gellyfish.btinternet.com>
On Sat, 12 Jun 1999 15:44:10 GMT rsanders@ac.net wrote:
> I'm new to Perl programming and cannot find the command(s) I need to
> send data to the printer. I've been through three manuals and looked
> online to no avail.
Hey thats a trick question 'cause there arent no such commands ... you've
been spoilt by VB or somesuch ...
On Unix you will probably want to open a pipe to the command that does
print spooling on your system :
open(PRINTER,"| /usr/bin/lpr ") || die "Cant fork lpr - $!\n";
print PRINTER "Blah blash ...";
<etc ...>
On MS platforms you will probably have to open the LPT1: directly and
so forth - if you have network printers then you can address them as:
\\server\printer
If you want fancy output then you will have to look at outputting the
correct things to your printer to make them do that - Perl doesnt do
that for you.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 12 Jun 1999 11:49:15 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: problem with no text outputting from Perl CGI script (long, enclosure)
Message-Id: <3762ABAB.D1C0865B@mail.cor.epa.gov>
Nicholas Marchalleck wrote:
> [snip of poster's question]
>
> No output at all? No errors? Not even the html from the template file? Did you
> try running from the command line? You won't have the form input, but you can
> still get an idea of what's wrong...hopefully.
Good idea. With CGI.pm (which is already used in the program)
and a small [local] webserver, the poster can get browser output
*and* a look at the server logs to see any errors that were
re-directed to STDERR. Or CGI::Carp can take care of that for
you.
> The file name in the last open should be quoted, and you really should do:
> open(<TEMPLATE>, "cars.html") or die "can't open cars.html: $!\n";
Here's the reason I wrote. No. This is wrong. TEMPLATE is
a filehandle, which open() is expecting. <TEMPLATE> is the
'angle' operator working on TEMPLATE. They are *not* the same.
The poster's code has a bareword, but using -w would have caught
that. And there is no reason to put "" around something which
has no need for double-quote interpolation. Single quotes will
do for the filename [although you are correct to have double
quotes around the expr after die()].
> You would also need to print a header. So before you print $buffer, do
> print header;
> This prints "Content-Type: text/html\n\n". Without this your html won't be
> displayed in the browser, or cause browser to display error.
>
> It's not easy to debug a Perl-CGI script. What I usually do is use print
> statements at strategic points in the script to locate the problem area(s).
> Also try perl -c scriptname from command line to do syntax check.
Don't forget:
-w
-T
use strict;
use diagnostics; # good for beginners - explains those errors
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Jun 1999 20:11:28 +0100
From: owenob@maths.tcd.ie (Owen O'Byrne)
Subject: Re: Require "No NT commands" on UNIX
Message-Id: <7jubd0$ass@boole.maths.tcd.ie>
lr@hpl.hp.com (Larry Rosler) writes:
>In article <929059463.22446@www2.remarq.com> on Thu, 10 Jun 1999
>16:04:21 -0800, Ashish Kadakia <anonymous@web.remarq.com> says...
>> Currently I cannot run web server on that UNIX machine,
>> also the perticular command that I am looking for
>> is "gunzip". In future, I may look for some other commands.
>> language.perl.com/ppt doesn't have gunzip.
>Download an evaluation version of WinZip from
><URL:http://www.winzip.com> .
Hi all, I tried this but the evaluation version of WinZip
requires the user to click "I Agree" whenever you use
it (including from the command-line) so it's no good
for CGI.
Try PKZip?
I ended up leaving it out altogether.
Owen
------------------------------
Date: 12 Jun 1999 18:16:35 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: sorting
Message-Id: <19990612141635.01261.00000970@ng-fb1.aol.com>
I have a file which holds a list of two fields (name and how many sales) and I
would like to sort the list with the highest sales on top. For example the list
is like this:
Bob jones|9
Jim jones|2
David jones|10
Sally jones|1
Bill Bates|3
etc. I want to sort it so david is on top and the next highest sales (bob
jones) next, etc., etc., to the end of list.
I read the file in, but how do I sort it and then save it. can anyone help me
out with this? Please. How would I sort the names and numbers so they list
correctly.
------------------------------
Date: Sat, 12 Jun 1999 12:05:54 -0500
From: "AEF" <aef@pangea.ca>
Subject: Re: Stat mtime
Message-Id: <7ju40k$96f$1@pumpkin.pangea.ca>
More information for reference...
opendir(DIR, "$base_dir") || die "Can't open $base_dir\n";
while($file = readdir(DIR)) {
$mtime = (stat($file))[9];
printf "file %s updated at %s\n", $file, scalar localtime($mtime);
}
_OUTPUT_
file . updated at Mon Mar 1 10:27:21 1999
file .. updated at Fri Jun 11 20:01:13 1999
file 21.ip updated at Wed Dec 31 18:00:00 1969
file 23.ip updated at Wed Dec 31 18:00:00 1969
file 22.ip updated at Wed Dec 31 18:00:00 1969
file 21.vote.old updated at Wed Dec 31 18:00:00 1969
file 22.vote.old updated at Wed Dec 31 18:00:00 1969
file 27.ip updated at Wed Dec 31 18:00:00 1969
file 24.ip updated at Wed Dec 31 18:00:00 1969
file 15.ip updated at Wed Dec 31 18:00:00 1969
file 15.vote.old updated at Wed Dec 31 18:00:00 1969
file 16.ip updated at Wed Dec 31 18:00:00 1969
file 16.vote.old updated at Wed Dec 31 18:00:00 1969
file 17.ip updated at Wed Dec 31 18:00:00 1969
file 17.vote.old updated at Wed Dec 31 18:00:00 1969
------------------------------
Date: Sat, 12 Jun 1999 12:21:13 -0500
From: "AEF" <aef@pangea.ca>
Subject: Re: Stat mtime
Message-Id: <7ju4tc$9ge$1@pumpkin.pangea.ca>
Missed something else, what is this telling me?
while($file = readdir(DIR)) {
use File::stat;
use Time::localtime;
$string = ctime(stat($file)->mtime);
print "file $file updated at $string\n";
}
_OUTPUT_
file . updated at Mon Mar 1 10:27:21 1999
file .. updated at Fri Jun 11 20:01:13 1999
Can't call method "mtime" on an undefined value at ./test2.cgi line 108.
------------------------------
Date: 12 Jun 1999 18:14:48 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Stat mtime
Message-Id: <7ju82o$3e7$1@gellyfish.btinternet.com>
On Sat, 12 Jun 1999 12:05:54 -0500 AEF wrote:
> More information for reference...
>
> opendir(DIR, "$base_dir") || die "Can't open $base_dir\n";
>
> while($file = readdir(DIR)) {
> $mtime = (stat($file))[9];
> printf "file %s updated at %s\n", $file, scalar localtime($mtime);
>
> }
>
I dont see here where you are prepending $base_dir to your file before
you stat() it ...
$mtime = (stat("$base_dir/$file))[9];
Indeed you might not want to be doing that without testing whether the
stat worked at all - it would have been failing unless you were testing
the current directory '.' .
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Sat, 12 Jun 1999 21:41:09 GMT
From: methabol@hem.passagen.se (Dan Zetterstrom)
Subject: Re: Stat mtime
Message-Id: <3763d27a.9561058@news.algonet.se>
On Sat, 12 Jun 1999 12:05:54 -0500, "AEF" <aef@pangea.ca> wrote:
>More information for reference...
>
>opendir(DIR, "$base_dir") || die "Can't open $base_dir\n";
>
You read files from $base_dir...
> while($file = readdir(DIR)) {
> $mtime = (stat($file))[9];
... but check the date on $file in the _current_ dir. Try:
$mtime = (stat("$base_dir/$file"))[9];
> printf "file %s updated at %s\n", $file, scalar localtime($mtime);
>
>}
>
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5973
**************************************