[7412] in Perl-Users-Digest
Perl-Users Digest, Issue: 1037 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 17 09:27:38 1997
Date: Wed, 17 Sep 97 06:01:01 -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 Wed, 17 Sep 1997 Volume: 8 Number: 1037
Today's topics:
Re: Beginner's question : Perl or Java ? <htchapma@oakland.edu>
Re: can I continuously read & empty logfile? <klausf@mucsun.sps.mot.com>
CGI-DOS/ Win & Foxpro database? (Stephen Wingreen)
Re: CGI-DOS/ Win & Foxpro database? <seay@absyss.fr>
Re: chatterbot in perl <chatmaster@spammnstate.net>
Client/Server over serial line... (Mark Nottingham)
Re: File Dates & Sizes (Eric Bohlman)
Flock me here flock me there. (kiet)
Re: method to calculate the time <hell@puls03.desy.de>
Multiple download <miran.sepic4@mss.tel.hr>
Net::FTP <mlb@netpath.net>
NEWBIE question <mgleibma@study.haifa.ac.il>
Newbie Question fischers@execpc.com
Re: NEWBIE question <seay@absyss.fr>
Re: NO SPACE (Bart Lateur)
Re: PERL 5 for Alpha OpenVMS <pvhp@forte.com>
Re: Perl equivalent to #ifdef in C? (robert)
Re: Perl equivalent to #ifdef in C? <seay@absyss.fr>
postmail and perlis <rene.sorger@onlinemedia.de>
Re: problem with regular expressions (Matti Kinnunen)
Question <agony@eden.com>
Re: Shortest Path Algorithm (Dirge )
Re: Submit Using Image <merlyn@stonehenge.com>
Re: Submit Using Image (Mike Heins)
Re: Submit Using Image <seay@absyss.fr>
Re: The CSV format stinks! (Daniel E. Macks)
Re: The CSV format stinks! <crn@bby.com.au>
Re: The CSV format stinks! (Bart Lateur)
Re: unshift function <jefpin@bergen.org>
Value within range? <craig@lucent.com>
Re: Value within range? (Tad McClellan)
Re: why exec finger doesnt work!!!?? <envaxvat@srrqvat.seraml.pbz>
Re: Win NT and PERL HELP!!!!!!! <rene.sorger@onlinemedia.de>
Yknow, the thing about perl is.... (Jason Hazzard)
Re: Yknow, the thing about perl is.... <merlyn@stonehenge.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 17 Sep 1997 12:35:04 GMT
From: "Harold Chapman" <htchapma@oakland.edu>
Subject: Re: Beginner's question : Perl or Java ?
Message-Id: <9B2D1AEA714CA0FE.BD02C007C7455A0F.FD608280EE1B8462@library-proxy.airnews.net>
Bart Lateur <bart.mediamind@tornado.be> wrote in article
<3416fa6a.2078526@news.tornado.be>...
> roy@unice.fr wrote:
>
<snip>
> I don't know if this is an important question. But you seem to be
> unaware of a very important distinction between Perl and Java:
>
> * Perl runs on the web server
> * Java runs on the client's computer
>
> If you want to prepare a html file for processing by a program in
> Scheme, and Scheme runs on the server, well, this rules Java out.
>
This is nuts! Java is a programming language. You can run your programs
anywhere you have a Java interpreter. You can write CGI programs in Java.
You could write a web server in Java.
The only important difference to me is that writing programs in Perl makes
me happy and writing programs in Java makes me wish I was programming in
Perl!
------------------------------
Date: Wed, 17 Sep 1997 13:53:31 +0200
From: Klaus Foerster <klausf@mucsun.sps.mot.com>
Subject: Re: can I continuously read & empty logfile?
Message-Id: <341FC4BB.5D62@mucsun.sps.mot.com>
John Stumbles wrote:
>
> Problem: I have a log file, written by a separate process (which I have to
> treat as unmodifiable) and I want to get the log records out of the file
> and into my perl script, and close up the file as I go. The log file is on
> a unix (SunOS 4.something, not Solaris) filesystem.
>
> At present I have a cron job calling a shell script which copies the
> logfile off to somewhere else and then truncates the logfile to 0. Of
> course between copying the contents of the file and zeroing it I sometimes
> lose some data. (I could modify it to rename the logfile and swap in an
> empty file but that's still non-atomic).
>
> 2: do a 'tail -f' equivalent in perl as per the FAQ to continuously get
> stuff out of the logfile, and (somehow!) truncate the file from the
> beginning as I go along. (In effect this would make it like a pipeline
> from the logging process to my perl script, except that my perl script
> could stop and the logfile would fill up like a buffer until my script
> started again.) I don't know whether you can change the physical starting
> point of a file on-the-fly as this would seem to require.
What do you think about replacing the log file with a named pipe.
Then the perl script could read from the named pipe. I assume, that this
perl
program would run the whole time, So it would be best to add the
invocation to your system-rc files.
The perl script could read the named pipe and generate and truncate the
logfile hoever you like.
The two disadvantages:
- the logfile(being a named pipe) could not be read directly,
because the real logfile would now have a different name.
- the perl program would always be active (occupy some memory and one
process
ID.
- It would of course work only, if the program generating the logfile
never
tries to read back it's own logfile. From my experiance almost all
log files
generated by programs, can be handled by a named pipe.
What do you think? If I didn't express myself clear enough, email me and
I can
send you a small example.
bye
Klaus
------------------------------
Date: 17 Sep 1997 11:13:40 GMT
From: wingreen@scfn.thpl.lib.fl.us (Stephen Wingreen)
Subject: CGI-DOS/ Win & Foxpro database?
Message-Id: <5voe14$gbr$1@news.usf.edu>
Does anybody out there have a script to search a database, specifically
FoxPro 2.5, using the CGI of Win-httpd? Any help will be appreciated.
Stephen Wingreen
Tampa-Hillsborough Public Library System
------------------------------
Date: Wed, 17 Sep 1997 14:39:02 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: CGI-DOS/ Win & Foxpro database?
Message-Id: <341FCF66.2D95AF19@absyss.fr>
Stephen Wingreen wrote:
>
> Does anybody out there have a script to search a database, specifically
> FoxPro 2.5, using the CGI of Win-httpd? Any help will be appreciated.
As I understand it, FoxPro is the same as CodeBase/xBase. There is a
module for reading xBase databases. You're on your own for writting. I
have heard that there is someone trying to make an xBase module that can
write files too, but I haven't seen any anouncements of a finished
product
- doug
------------------------------
Date: Wed, 17 Sep 1997 05:00:54 -0700
From: Chat Central <chatmaster@spammnstate.net>
To: Sanjay Varma <sanjay@rocketship.com>
Subject: Re: chatterbot in perl
Message-Id: <341FC676.5DF8@spammnstate.net>
[Posted and Mailed]
Chatterbot, or ChatterBox?..
~Tim...
((Remove "spamm" from email address to reply..))
Sanjay Varma wrote:
>
> Does anybody have a simple chatterbot program written in PERL,
> which I can use?
>
> Thanks
> Sanjay
>
> -------------------==== Posted via Deja News ====-----------------------
> http://www.dejanews.com/ Search, Read, Post to Usenet
--
Chat Central
In the top 5 most accessed sites on WebCrawler
since the first week up, and holding strong!!!
Receiving up to and over 10,000 visitors a day worldwide
Administrator - Chat Hub / Chat Central:
http://www.chathub.com - OR - http://chat.nstate.net
E-Mail Contact:
chatmaster@chathub.com, webmaster@chathub.com, sales@chathub.com,
info@chathub.com, admin@chathub.com, chatmaster@nstate.net
Webmaster Northstate Net:
http://www.nstate.net
E-Mail Contact:
webmaster@nstate.net
------------------------------
Date: 17 Sep 1997 08:20:19 GMT
From: mnot@mnot.cyber.com.au (Mark Nottingham)
Subject: Client/Server over serial line...
Message-Id: <874484380.370756@black-bean.cyber.com.au>
Hello all,
I'm in the middle of deploying a web solution where the customer is
ultra-paranoid about security. The design I'd like to go with is a web
server and a back-end server to process transactions. Between them would
be a serial line that transactions would be piped down as soon as they
were received; because the back-end box only has that connection, it's
considered 'off-line' to the credit card companies, and therefore 'safe'.
Unfortunately, serial connections are my achilles heel. Are there any good
tools for getting data over a serial connection reliably from perl? Is it
just a simple matter of open()ing a bi-directional pipe to the devices?
Thanks,
--
Mark Nottingham
Web Architecture, Design, Programming and Consulting
http://www.pobox.com/~mnot/
Melbourne, Australia
------------------------------
Date: Wed, 17 Sep 1997 09:06:53 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: File Dates & Sizes
Message-Id: <ebohlmanEGnAnH.MEI@netcom.com>
noneya@internet.com wrote:
: I am trying to print the file dates, file sizes and last
: modification date into an html file from a perl routine that is doing
: a foreach loop which opens a listing of files. I have tried
: stat($filename) in the loop but I can't get any output to the html
: file.
stat() doesn't print anything to STDOUT; it returns a 13-element list
containing information about the files. It's up to your program to print
some or all of it out.
------------------------------
Date: 17 Sep 1997 06:51:35 GMT
From: kiet@uclink2.berkeley.edu (kiet)
Subject: Flock me here flock me there.
Message-Id: <5vnuln$91d@agate.berkeley.edu>
Elo!
It seems the subroutine for flock() isn't implemented for the Activeware
version of Perl 5.0003.xxx . Does any1 know about this?
I need the flock() subroutine to carry some of the program under Win '95.
Any help is much appreciated!
ta ta,
kiet
------------------------------
Date: Wed, 17 Sep 1997 10:06:08 +0200
From: Otto Hell <hell@puls03.desy.de>
Subject: Re: method to calculate the time
Message-Id: <Pine.HPP.3.95.970917100045.18606A-100000@puls03.desy.de>
On Wed, 17 Sep 1997, Bremen Lee wrote:
> Date: Wed, 17 Sep 1997 01:27:21 +0800
> From: Bremen Lee <bremenlee@att.net.hk>
> Newsgroups: comp.lang.perl.misc
> Subject: method to calculate the time
>
> Hi,
>
> Is there any simple method to check a file is created today, not
> yesterday or other day??
>
> Please send me a mail if you know the answer.
>
>
> Cheers,
>
> Bremen
> bremenlee@attmail.com
>
>
Hi,
what is "today"? With me (Middle European Summer Time) it is now
Wednesday, September 17th, 10 o'clock. In California it must be around
midnight. Still farther west it will still be "yesterday", i.e. Tuesday.
Mit freundlichem Gruss / Greetings / Bien a vous Otto Hell
--
<Otto.Hell@desy.de> DESY - Abteilung ZDV
tel: 49 40 8998 2317 Notkestrasse 85
fax: 49 40 8994 2317 D 22603 Hamburg
------------------------------
Date: 17 Sep 1997 08:27:17 GMT
From: "Miran Sepic" <miran.sepic4@mss.tel.hr>
Subject: Multiple download
Message-Id: <01bcc343$d0511090$7a02a8c0@pc_miran>
I am trying to solve the following problem:
- make selection of few files (HTML)
- download them
Is it possible?
Thanks
Miran
------------------------------
Date: 17 Sep 1997 11:34:55 GMT
From: "Marvin Blackburn" <mlb@netpath.net>
Subject: Net::FTP
Message-Id: <01bcc35d$2a5c2cf0$090bf1a8@bh0880>
Is Net::FTP part of the perl 5.004 release? I can find no documentation
from perl doc and I see it referenced quite a bit here.
--
---
Marvin Blackburn
mlb@netpath.net
Burlington House MIS
Burlington Industries
------------------------------
Date: Wed, 17 Sep 1997 08:56:40 GMT
From: Michael Gleibman <mgleibma@study.haifa.ac.il>
Subject: NEWBIE question
Message-Id: <Pine.OSF.3.95-heb-2.07.970917114904.12928A-100000@study.haifa.ac.il>
Hello!
I am completely newbie in Perl. Any help willl be appreciated.
I am trying to write some script that will use telnet to connect to
VMS machine and send a couple of commands there (no hack:-).
When I do open (name, "| telnet host") and then print name "smth", it
doesn't passes anything to telnet session. Can anyone point me to a
mistake, please?
Thank you,
Michael Gleibman
------------------------------
Date: Wed, 17 Sep 1997 07:02:58 -0500
From: fischers@execpc.com
Subject: Newbie Question
Message-Id: <341FC6F2.73BBA334@execpc.com>
I am posting a form to a cgi perl script. I want to access a hidden
field in the form. How do I access the variable?
------------------------------
Date: Wed, 17 Sep 1997 14:36:50 +0200
From: Doug Seay <seay@absyss.fr>
To: mgleibma@study.haifa.ac.il
Subject: Re: NEWBIE question
Message-Id: <341FCEE2.4E44F942@absyss.fr>
[posted and mailed]
Michael Gleibman wrote:
>
> Hello!
> I am completely newbie in Perl. Any help willl be appreciated.
That is what we're here for.
> I am trying to write some script that will use telnet to connect to
> VMS machine and send a couple of commands there (no hack:-).
> When I do open (name, "| telnet host") and then print name "smth", it
> doesn't passes anything to telnet session. Can anyone point me to a
> mistake, please?
Have you looked into what buffering mode you're using? The easiest
thing would be
open(TELNET, "| telnet $host") || die "fork failed: $!";
select(TELNET);
$| = 1;
Because that'll put TELNET in autoflush mode. Open your copy of the
Camel and read about autoflush if you don't know what that means.
- doug
PS - Your open should be for 'NAME', not 'name' because of the perl
coding standards. I know you would do that when coding, I just like
pointing out the obvious.
------------------------------
Date: Wed, 17 Sep 1997 12:23:26 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: NO SPACE
Message-Id: <3420cb79.4717123@news.tornado.be>
Try something along these lines:
$\ ="\n"; #end of line
defined($_) and print;
HTH,
Bart.
------------------------------
Date: Tue, 16 Sep 1997 23:13:47 -0700
From: Peter Prymmer <pvhp@forte.com>
To: Daniel Mills <dmills@riag.com>
Subject: Re: PERL 5 for Alpha OpenVMS
Message-Id: <341F751B.7FA2@forte.com>
Daniel Mills wrote:
>
> Does anyone know where I can get a reliable port for this OS?
>
> -- TIA - Dan.
>
> =========================================================
> Dan Mills
> RIAG
> dmills@riag.com
The standard port on CPAN will work OK. To unpack it you
will need GUNZIP.EXE and VMSTAR_AXP.EXE. The former is buildable
from source obtainable from any GNU mirror. The latter is available
in binary form from DEC's ftp site in California (I've forgotten the
IP name just now) as well as in source code from MadGoat archives.
There is also a PERL5*.ZIP file from:
ftp://cor.newman.upenn.edu/perl5/
I have a web page that discusses the build (my page is a little out of
date with respect to version numbers and IP addresses, but it's at:
http://w4.lns.cornell.edu/~pvhp/perl/vms.html
You could try sending us a description of the trouble that you are
having to: vmsperl@cor.newman.upenn.edu
and we will try to answer questions.
Be prepared to answer questions
such as:
What compiler are you using (DECC answers via $ cc/version nl:)
What version of the OS are you running? ($ write sys$output
f$getsyi("VERSION"))
Are you using MMK or MMS - If so which ($ MMS/IDENT)
Peter Prymmer
------------------------------
Date: 17 Sep 1997 10:44:27 +0200
From: robert@ICK.il.fontys.nl (robert)
Subject: Re: Perl equivalent to #ifdef in C?
Message-Id: <5vo59b$an@bsd1.hqehv-internal.ilse.net>
lkasdorf@pressroom.com:
>What is an easy way to enable/disable blocks of code in perl. In C I
>would go...
>#define THIS_WAY TRUE
>#ifdef THIS_WAY
>// some c code done one way
>#else
>// the same code done another way
>#endif
>There must be an equivalent structure in Perl.
Sure:
--
#define THIS_WAY TRUE
#ifdef THIS_WAY
some perl code done one way
#else
some perl code done another way
#endif
--
:)
The trick is to use 'perl -P' to run the script, which will run the script
thru the C preprocessor (so you can use all C preprocessor commands in perl
scripts as well).
robert
------------------------------
Date: Wed, 17 Sep 1997 12:48:51 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Perl equivalent to #ifdef in C?
Message-Id: <341FB593.4C7848C@absyss.fr>
lynn kasdorf wrote:
>
> What is an easy way to enable/disable blocks of code in perl. In C I
> would go...
>
> #define THIS_WAY TRUE
>
> #ifdef THIS_WAY
> // some c code done one way
> #else
> // the same code done another way
> #endif
>
> There must be an equivalent structure in Perl.
Yes, there is an quivalent structure in Perl. It is "if". It would be
used like
if ( $this_way )
{ ; } # do something
else
{ ; } # do something else
It is almost identical to the mechanism found in C and is functionally
identical to what you had described.
Someone has already pointed out the -P (capital) option. I would like
to weigh in against it. I think it is ugly and a waste to launch a
separate process when it doesn't gain you anything over what is already
in Perl.
- doug
------------------------------
Date: Wed, 17 Sep 1997 09:15:09 +0200
From: Rene Sorger <rene.sorger@onlinemedia.de>
Subject: postmail and perlis
Message-Id: <341F837D.BF3ECA86@onlinemedia.de>
Hi,
I am using a perl script for feedback delivery on my websites. The
program Postmail is called by the script in this way :
open (MESSAGE," | postmail -t -H$smtpserver");
This works fine with perl32 3.07 and Netscape Enterprise Server. But
using the same script with MS IIS and perlIS doesn't work, postmail is
started, but does not end and so doesn't send the mail.
Did anybody have problems like this and knows what to do about it ?
Thanks,
Rene
--
---------------------------------------------------------------------
I Rene Sorger I I
I Online Media Riedlbauer GmbH I Ich hab' Hunger ! I
I Xlink PoP Krefeld I I
---------------------------------------------------------------------
------------------------------
Date: 17 Sep 1997 10:54:43 +0300
From: matti@universe.pc.helsinki.fi (Matti Kinnunen)
Subject: Re: problem with regular expressions
Message-Id: <lziuw0tlx8.fsf@universe.pc.helsinki.fi>
In article MSM Lab Supervisor <SUPERVISOR@msmlab.byu.edu> writes:
$line =~ s/!!!(.*)!!!/$data{\1}/g;
But my real question is this: how can I make a regular expression less
greedy? What happens is that with the line above, Perl wants to equate
!!!(.*)!!! with
***
$line =~ s/!!!(.*?)!!!/$data{$1}/g;
- matti -
--
* matti.kinnunen@helsinki.fi *
* http://universe.pc.helsinki.fi/~matti/contact.html *
* +358-(0)40-593 50 91 but try first +358-(0)9-191 23978 *
------------------------------
Date: Wed, 17 Sep 1997 07:09:42 -0500
From: Agony <agony@eden.com>
Subject: Question
Message-Id: <Pine.BSD/.3.91.970917070919.8427B-100000@matrix.eden.com>
Hi..I was wondering: I have a program that attempts to open up a
connection using telnet and open. From time to time, the host I'm
telnetting to either goes down or for some other reason the connection
doesn't get rejected, but just sits there without dropping. This causes
my program to hang. Because the connection itself was actually opened, it
just sits there, waiting for what would normally be a login prompt.
My question is this: Is there a way for me to monitor that in such a way
that, if there's no login prompt after, say, 5 seconds, it continues on?
Thanks a lot!
Ken
------------------------------
Date: 17 Sep 1997 09:27:33 GMT
From: mjw101@york.ac.uk (Dirge )
Subject: Re: Shortest Path Algorithm
Message-Id: <5vo7q5$r7b$1@netty.york.ac.uk>
Creeping stealthily through the corridors of comp.lang.perl.misc,
I overheard Steffen Beyer say:
: In article <5u2qkq$g5v$1@newbabylon.rs.itd.umich.edu>,
: Matthew Scott Britt <msbritt@ren.us.itd.umich.edu> wrote:
: > Does anyone know of a shortest path algorithm written in perl?
: > I searched CPAN with no luck...
: > The algoithm would depend on whether you want depth-first or
: > breadth-first searching done, I would have thought..
: I'm not sure about what you want exactly.
: But depending on wether you want the shortest path in a graph for
: just TWO particular nodes or between ALL nodes, you should implement
: Dijkstra's algorithm for shortest paths or use the "Graph::Kruskal"
: module (written in Perl, available from
: http://www.engelschall.com/u/sb/download/), respectively.
Um. Graph::Kruskal implements a minimum spanning tree algorithm, which is
*not* the same as the Shotest Path.
Eg: Three nodes A, B, C connected in a triangle. AB has weight 3, AC
weight 3 and BC weight 1. Kruskal's would say that the MST is AB,BC (or
AC,BC, it doesn't matter) and so you would think that the sortest bath to
C from A is A-B-C (weight 4) whilst the true Shortest path is just AC
(weight 3).
My bet: Code up Dijekstra's yourslef... its not hard at all in perl (2
weeks to write in Ada came down to 1 day in perl)
--
/\ Michael /\
< > Only cat lovers know the joy of a fur-covered < >
\/ musical hot-water bottle that never goes cold. \/
------------------------------
Date: 17 Sep 1997 05:03:59 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: mheins@prairienet.org (Mike Heins)
Subject: Re: Submit Using Image
Message-Id: <8cg1r4qh8w.fsf@gadget.cscaper.com>
>>>>> "Mike" == Mike Heins <mheins@prairienet.org> writes:
Mike> @map = `cat whatever.map`;
Oooh. A second "useless use of cat" in a week of clpm!
use IO::File;
@map = IO::File->new("whatever.map")->getlines;
Thou Shalt Not Needlessly Fork. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 349 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 17 Sep 1997 12:30:18 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Submit Using Image
Message-Id: <5voigq$na6$1@vixen.cso.uiuc.edu>
Randal Schwartz (merlyn@stonehenge.com) wrote:
:
: Mike> @map = `cat whatever.map`;
:
: Oooh. A second "useless use of cat" in a week of clpm!
:
: use IO::File;
: @map = IO::File->new("whatever.map")->getlines;
:
: Thou Shalt Not Needlessly Fork. :-)
:
Randal, do you have a kibo going or what? 8-)
The docs for CGI::Imagemap are circa 5.001m, when quick and dirty
and portable wasn't so easy.
--
Regards,
Mike Heins
This post reflects the
opinion of my employer.
------------------------------
Date: Wed, 17 Sep 1997 14:41:32 +0200
From: Doug Seay <seay@absyss.fr>
Subject: Re: Submit Using Image
Message-Id: <341FCFFC.78FC5941@absyss.fr>
Randal Schwartz wrote:
>
> >>>>> "Mike" == Mike Heins <mheins@prairienet.org> writes:
>
> Mike> @map = `cat whatever.map`;
>
> Oooh. A second "useless use of cat" in a week of clpm!
If people had to pay you a nickel ($0.05) for each useless 'cat' you
found, you'd be several dollars closer to paying off your legal fees.
- doug
------------------------------
Date: 17 Sep 1997 06:07:29 GMT
From: dmacks@sas.upenn.edu (Daniel E. Macks)
Subject: Re: The CSV format stinks!
Message-Id: <5vns31$tlt$1@netnews.upenn.edu>
Daniel Freeman (daniel@aksi.net) said:
: We can even have quotes inside our quotes, oddly, like so:
:
: "MY 3.5" DISK","MY 5" INCH FLOPPY","MY 10" RECORD"
[...]
: Granted, there are ways to fix the CSV format. To borrow a trick from
: some versions of Pascal I've seen, you can make "" represent " within
: fields, similar to the way Unix and Perl make \\ represent \ in certain
: contexts.
:
: Is this situation be as bleak as it appears? Has anybody else had
: problems with CSVs like this? Is Bill Gates to blame for this?
The situation is much bleaker than you think: The solution comes from
Gates 'n' Co. Excel's CSV format uses "" to represent a " in a field.
One option [1][2] would be
$line = <CSV_FILE>;
chomp $line;
$line =~ s/""/\0/g;
@fields = &usual_CSV_parse_function;
map s/\0/"/g, @fields;
[1] Ugly, multi-pass, first that came to mind. Obv, TMTOWTDI, and
"perl's the power to write crappy code" (can't recall who said
it...check DejaNews).
[2] Assumes \0 isn't used in your data file...if it is, use anything
(\n perhaps?) you know will never be in the real data.
dan
--
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks
------------------------------
Date: 17 Sep 1997 12:15:15 +1000
From: Clive Newall <crn@bby.com.au>
Subject: Re: The CSV format stinks!
Message-Id: <v54t7kptxo.fsf@nellie.bby.com.au>
In article <5vkofi$dpr$1@wn.aksi.net>,
daniel@aksi.net (Daniel Freeman) writes:
We can even have quotes inside our quotes, oddly, like so:
"MY 3.5" DISK","MY 5" INCH FLOPPY","MY 10" RECORD"
Now the parser for this was a real pain in the butt to write. You can't
simply use "split" because you don't want to split on commas which are
inside quotes. Then my fairy godmother came and said, "Daniel... read
the Perl FAQ!" Jolly good idea, somebody else had already wracked their
brains and came up with much prettier code than mine. Although I still
use mine!
But oddly, neither my code nor the code I downloaded worked on the data
file I was tackling. The line that it bombed on looked like so:
"WINDOWS CD 3.5",MACINTOSH CD ONLY","FIELD TWO","FIELD THREE"
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ ^^^^^^^^^^^
first field 2nd field 3rd field
I'm curious. What *exactly* produced this _broken_ csv file?
Excel appears to, by default, use "" for internal quotes.
The program that produced your data is broken.
(My guess: It isn't a speadsheet at all, but some data extraction from
a database, written by a programmer who did not allow for the
delimiters to appear within fields. S/he should be re-educated. Or shot.)
Is this situation be as bleak as it appears? Has anybody else had
problems with CSVs like this? Is Bill Gates to blame for this?
They work quite well, providing the programmer producing them
thinks, just a little.
Daniel Freeman
*----------------------------------------------------------------------------*
20/20 Technologies: A Clear Vision of Internet Marketing
6980 NW 29th Way, Ft. Lauderdale, FL 33309 * (954) 984-8898 (M-F, 9a-5p EST)
E-Mail: ttt@2020tech.com WWW: http://www.2020tech.com/
*----------------------------------------------------------------------------*
--
Clive Newall <crn@bby.com.au> / Burdett Buckeridge & Young Ltd Melb Australia
"I think Casper is the ghost of Richie Rich. I wonder how Richie died?"
"Perhaps he realized how hollow the pursuit of money is and took his own life"
--Bart and Lisa Simpson
------------------------------
Date: Wed, 17 Sep 1997 12:22:03 GMT
From: bart.mediamind@tornado.be (Bart Lateur)
Subject: Re: The CSV format stinks!
Message-Id: <341fc918.4107566@news.tornado.be>
daniel@aksi.net (Daniel Freeman) wrote:
> Subject: The CSV format stinks!
I don't know where you got your CSV file from, but it most probably was
NOT automatically generated by Excel. Excel behaves a little better.
>Some implementations I have seen will quote every field,
>other's don't. Moreover, you can have commas inside your fields, even
>though the comma is the separator.
The quotes are around the field just BECAUSE of the comma's inside the
fields. In general, numeric fields are not inside quotes, but text
fields are. If there aren't any comma's between the fields, the quotes
might be dropped.
> "WINDOWS CD 3.5",MACINTOSH CD ONLY","FIELD TWO","FIELD THREE"
Nonsense. Quotes inside fields should be DOUBLED!
I've tested it, and a field like
3.5" floppy
is saved as
"3.5"" floppy"
As I said, I'm pretty sure your file doesn't originate from Excel, but
is generated by (a program written by) someone who is unaware of these
finer details.
HTH,
Bart.
------------------------------
Date: Wed, 17 Sep 1997 08:00:45 -0400
From: TechMaster Pinyan <jefpin@bergen.org>
To: Rick B Teh <boonteh@acsu.buffalo.edu>
Subject: Re: unshift function
Message-Id: <Pine.SGI.3.95.970917075637.5563A-100000@vangogh.bergen.org>
(more useful advice)
>Can someone please show me an example of using the unshift function?
>I have just lost my camel book. ANy help will be appreciated.
>Thanks.
useful array functions are: shift, unshift, push, pop, splice.
unshift ARRAY, LIST
let's say your array is @array, and it contains:
AA, AAA, B, BB, BBB, C, CC, CCC
if you were to do:
unshift @array, "A";
you'd get:
A, AA, AAA, B, BB, BBB, C, CC, CCC
and if @letters contains:
a, aa, aaa
and you do:
unshift @array, @letters;
you'd get:
a, aa, aaa, A, AA, AAA, B, BB, BBB, C, CC, CCC
helpful? I hope so!
----------------
| "To be a rock, and not to roll."
| - Led Zeppelin
----------------
Jeff Pinyan | http://users.bergen.org/~jefpin | jefpin@bergen.org
webXS - the new eZine for WebProgrammers! TechMaster@bergen.org
Visit us @ http://users.bergen.org/~jefpin/webXS
** I can be found on #perl on irc.ais.net as jpinyan **
- geek code -
GCS/IT d- s>+: a--- C+>++ UAIS+>$ P+++$>++++ L E--->---- W++$
N++ !o K--? w>+ !O M>- V-- PS PE+ !Y !PGP t+ !5 X+ R tv+ b>+
DI+++ D+>++ G>++ e- h- r y?
------------------------------
Date: Tue, 16 Sep 1997 11:47:50 -0500
From: "Craig M. Votava" <craig@lucent.com>
Subject: Value within range?
Message-Id: <341EB836.6963@lucent.com>
Folks-
I trying to understand the best way to check if a value is within a
given range. The perl program below show's how my inputs look, and my
first crack at solving the problem. Is this the best way, or is there
a better one?
All help is appreciated!
Thanks
-Craig
---------------------------------------------------------------------
#!perl -w
my $range = "1..20";
my $number = 35;
if($number =~ /[$range]/) {print "yes\n"} else {print "no\n"};
----------------------------------------------------------------------
()_() Craig Votava
(_) Lucent Technologies
craig@lucent.com
------------------------------
Date: Wed, 17 Sep 1997 07:08:37 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Value within range?
Message-Id: <58hov5.1ss.ln@localhost>
Craig M. Votava (craig@lucent.com) wrote:
: Folks-
: I trying to understand the best way to check if a value is within a
: given range. The perl program below show's how my inputs look, and my
: first crack at solving the problem. Is this the best way, or is there
: a better one?
It is not the best way.
$number = 0;
$number = 21;
$number = 222;
$number = '.';
All print 'yes' ;-)
Pattern matches operate on *strings*. If you want to operate on
numbers, pattern matches are not the way to go.
I submit that this way is "better", primarily because it will
at least work ;-)
if ( $number >= 1 && $number <= 20 )
{print "yes\n"}
else
{print "no\n"};
: All help is appreciated!
: Thanks
: ---------------------------------------------------------------------
: #!perl -w
: my $range = "1..20";
: my $number = 35;
: if($number =~ /[$range]/) {print "yes\n"} else {print "no\n"};
: ----------------------------------------------------------------------
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Sep 1997 07:27:24 GMT
From: Dennis Moore <envaxvat@srrqvat.seraml.pbz>
Subject: Re: why exec finger doesnt work!!!??
Message-Id: <5vo0os$jm9$1@iapetus.comco.com>
Nadeem Rana <nrana@aludra.usc.edu> wrote:
: I have some user Ids in a file temp. I am writing a simple perl script but
: it doesnt work.
: Heres the script
: #!/usr/bin/perl
: while($_ = <ARGV>){
: chop($_);
: exec 'finger', $_;
: }
: but it runs finger ONLY on the first user id in temp. Could you please
: help me why is it doing so?
: My temp sile is something like this...
i'm sure by now you've realized what exec does. you might want to try my
Net::Finger module at:
http://feeding.frenzy.com/~rainking/finger.html
--
pity this busy monster, manunkind, | Dennis Moore | Sarah
not. Progress is a comfortable disease. | | McLachlan
-e.e. cummings: One Times One | archon on the irc | "Black"
If I cried me a river of all my confessions would I drown in my shallow regret?
------------------------------
Date: Wed, 17 Sep 1997 09:35:17 +0200
From: Rene Sorger <rene.sorger@onlinemedia.de>
To: Orderpbs <orderpbs@aol.com>
Subject: Re: Win NT and PERL HELP!!!!!!!
Message-Id: <341F8835.BFBDCE58@onlinemedia.de>
Orderpbs wrote:
>
> we are running IIS2.0 and NT and need to run Perl to be able to use
> Formail and other cgi/perl scripts with web pages.
>
> Getting a NOT SUPPORTED error when the html page executes the script over
> the web.
Go to http://www.activestate.com and get Perl for Win32 and Perl for
ISAPI, the last one is needed for your IIS2.0. There is also an FAQ
where the installation is described.
Regards,
Rene
--
---------------------------------------------------------------------
I Rene Sorger I I
I Online Media Riedlbauer GmbH I Ich hab' Hunger ! I
I Xlink PoP Krefeld I I
---------------------------------------------------------------------
------------------------------
Date: Wed, 17 Sep 1997 08:00:14 GMT
From: hazzard@usa.net (Jason Hazzard)
Subject: Yknow, the thing about perl is....
Message-Id: <5vo2o1$rrv$1@brie.direct.ca>
Perl Rules!
But, geez the thing about perl is, I can write a script, that is say, about
200 lines long (I am doing one right now). Then, when I actually utilize the
real power of this language I can boil it down to about 50 lines!
Hehehehe!
Tad, Mr. Phoenix, and Mr.Christiansen, (and many others) thanks for all your
help in this group.... With your help those scripts may just be 25 liners yet!
Jay
------------------------------
Date: 17 Sep 1997 05:15:23 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: hazzard@usa.net (Jason Hazzard)
Subject: Re: Yknow, the thing about perl is....
Message-Id: <8cbu1sqgpw.fsf@gadget.cscaper.com>
>>>>> "Jason" == Jason Hazzard <hazzard@usa.net> writes:
Jason> Perl Rules!
I think the Perl rules are found on the manpages, if you need them. :-)
Jason> But, geez the thing about perl is, I can write a script, that
Jason> is say, about 200 lines long (I am doing one right now). Then,
Jason> when I actually utilize the real power of this language I can
Jason> boil it down to about 50 lines!
Or show it to me, and I can probably get it down to 10 lines firing off
three fewer processes. :-)
print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 349 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@ora.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 1037
**************************************