[13400] in Perl-Users-Digest
Perl-Users Digest, Issue: 811 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 15 20:17:22 1999
Date: Wed, 15 Sep 1999 17:10:16 -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, 15 Sep 1999 Volume: 9 Number: 811
Today's topics:
Re: Parsing Tab Delimited File <tchrist@mox.perl.com>
Re: Parsing Tab Delimited File (Abigail)
Re: Parsing Tab Delimited File (Martien Verbruggen)
Re: Parsing Tab Delimited File (Kragen Sitaker)
Re: passing "=" as an argument to CGI (Larry Rosler)
Re: passing in multiple file names (Martien Verbruggen)
Re: passing in multiple file names <makkulka@cisco.com>
Re: Perl / C Memory (Martien Verbruggen)
Re: Perl Apache Win95 (Martien Verbruggen)
Perl, Win32, GetPrivateProfileString sub/module ? (A.Warnier)
Re: Please help a newbie! - sorry for the mistake! (Larry Rosler)
Text Parsing - How to Multi-Line? <scott@royallepage.com>
Two dimensional array <shadowsystems@ibm.net>
Re: Two dimensional array <srooij@wins.uva.nl>
Re: Two dimensional array (Kragen Sitaker)
Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Sep 1999 16:39:59 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Parsing Tab Delimited File
Message-Id: <37e0203f@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
:print unpack('H*' => "a\tb\tc\n"), " $^O\n";
That's not what I meant. When people say "comma-separated",
what about commas in the fields?
Bach,Mozart,Schubert
is three fields, but what about adding CSN and Yes?
Bach,Mozart,Schubert,Crosby, Stills, and Nash,Yes
won't work. So you may end up with something like this:
Bach,Mozart,Schubert,'Crosby, Stills, and Nash',Yes
in which case you have to strip the quotes, but then you'd
lose embedded quoted, or have to escape them, like
Othello,Wayne's World,Mork and Midy
would need to be
Othello,Wayne\'s World,Mork and Midy
in Unix parlance. Which leads to a solution like:
Bach,Mozart,Schubert,Crosby\, Stills\, and Nash,Yes
or
Bach,Mozart,Schubert,Crosby\054 Stills\054 and Nash,Yes
which is still reasonably easy to parse. But I am told that
certain non-Unix-thinking programs generate warped things
Bill, 'Peter''s Place, Mary and Ned', Fred
which are rather un-split-friendly.
I have never seen this kind of noise, but even
Bach,Mozart,Schubert,'Crosby, Stills, and Nash',Yes
is enough to screw up a split. I vote for:
Bach,Mozart,Schubert,Crosby\054 Stills\054 and Nash,Yes
:-)
--
This is Unix; if you can't get the sources, it isn't freeware.
--Peter Salus
An Intelligent terminal is not a smart-ass terminal; it is one you can educate.
--Rob Pike
------------------------------
Date: 15 Sep 1999 18:41:36 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Parsing Tab Delimited File
Message-Id: <slrn7u0bqd.i4j.abigail@alexandra.delanet.com>
Tom Christiansen (tchrist@mox.perl.com) wrote on MMCCVI September
MCMXCIII in <URL:news:37e0203f@cs.colorado.edu>:
""
"" But I am told that
"" certain non-Unix-thinking programs generate warped things
""
"" Bill, 'Peter''s Place, Mary and Ned', Fred
""
"" which are rather un-split-friendly.
I fail to see what "split" has to do with being Unix-thinking or
non-Unix thinking.
Could you cite some references please?
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'
-----------== 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, 15 Sep 1999 23:44:15 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Parsing Tab Delimited File
Message-Id: <jbWD3.58$E%1.3497@nsw.nnrp.telstra.net>
In article <37e0203f@cs.colorado.edu>,
Tom Christiansen <tchrist@mox.perl.com> writes:
> [courtesy cc of this posting mailed to cited author]
>
> In comp.lang.perl.misc, lr@hpl.hp.com (Larry Rosler) writes:
>:print unpack('H*' => "a\tb\tc\n"), " $^O\n";
>
> That's not what I meant. When people say "comma-separated",
> what about commas in the fields?
[snip examples]
Sure, that's a problem, but it's not pltoform dependent. It's
programmer dependent. And sure, many Microsoft products screw this up.
But I would not in this case blame Microsoft for this, however much I
would like to :)
I've seen bad code trying to deal with xx-separated text files in bad
ways, spitting out horrible formats. And that code did not originate
at Microsoft, or had anything to do with any of their platforms. MS is
to blame for a lot, but here they at least share the blame with many
others.
Martien
--
Martien Verbruggen |
Interactive Media Division | That's funny, that plane's dustin'
Commercial Dynamics Pty. Ltd. | crops where there ain't no crops.
NSW, Australia |
------------------------------
Date: Wed, 15 Sep 1999 23:59:30 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Parsing Tab Delimited File
Message-Id: <CpWD3.13678$N77.991466@typ11.nn.bcandid.com>
In article <7rp003$oe$1@nnrp1.deja.com>,
stampede <hardpack@my-deja.com> wrote:
>foreach (<FILE>) {
This reads the entire file in before starting to process it.
> my $line = chomp($_);
This assigns '1' to $line.
> my @columns = split(/\t+/, $line);
> &process_columns_here(@columns);
>}
A broken answer is worse than no answer at all. And this fellow had
already gotten several answers before you posted. Please:
- if you write something that you aren't *sure* works, TEST IT before you
post it.
- if you do something weird, like the foreach above, explain why.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 15 Sep 1999 15:09:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: passing "=" as an argument to CGI
Message-Id: <MPG.1249b8eeb9cab375989f78@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <7rp43h$11f$1@gellyfish.btinternet.com> on 15 Sep 1999
21:46:25 -0000, Jonathan Stowe <gellyfish@gellyfish.com> says...
> On Wed, 15 Sep 1999 20:30:19 GMT stampede wrote:
> > is there a way to pass an "=" as an argument to CGI?
> >
> > e.g.,
> >
> > http://www.foo.org/perl.cgi?url=http://www.foo.com/perl.cgi?x=y
That second '?' should be an '&'.
But it's not clear why one wants to duplicate in 'url' a value that can
be accessed by CGI::script_name() or $ENV{SCRIPT_NAME}.
> > so that foo.com/perl.cgi processes the value "y" as param('x')?
>
> I'm not sure what you mean ...
>
> If you mean that you want to post that second URL as a parameter to
> the first CGI program then you will want to encode it like:
>
> $string = 'http://www.foo.com/perl.cgi?x=y';
>
> $string =~ s/([^A-Za-z0-9])/sprintf("%%%02X",ord($1))/eg;
>
> which is probably overkill (in the characters it encodes ) but wont hurt.
Yes, it will hurt. It is destructive. The parser will see the escaped
'?' (which should be '&' as stated above) and '=' as part of the data,
rather than as separators. They must be there literally.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 15 Sep 1999 23:01:40 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: passing in multiple file names
Message-Id: <ozVD3.37$E%1.3096@nsw.nnrp.telstra.net>
In article <37E017CB.668FF359@governet.net>,
Darren Brock <brock@governet.net> writes:
> This is a multi-part message in MIME format.
Please don't do this. Usenet is a plain text medium. Get rid of the
vcard stuff.
> My problem is getting the script to take multiple filenames and then
> loop over the parser with each. How can I do that?
foreach my $file (@ARGV)
{
# do something with file.
}
Also have a look at
# perldoc perlrun
(some of the flags might be what you are really looking for)
# perldoc perlvar
Martien
PS. Be aware that some shells have a limit on the number of characters
and/or arguments that they can pass on to programs.
--
Martien Verbruggen |
Interactive Media Division | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd. | make a better idiot.
NSW, Australia |
------------------------------
Date: Wed, 15 Sep 1999 16:22:07 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: passing in multiple file names
Message-Id: <37E02A1F.5EC1124@cisco.com>
[ Darren Brock wrote:
> My problem is getting the script to take multiple filenames and then
> loop over the parser with each. How can I do that?
Try listing these filenames under token __DATA__ and then
read each of these using <DATA>
while ($name = <DATA>)
{
# all pseudo code.
open file $name ;
invoke parse routine on this file
store results and continue ;
}
------------------------------
Date: Wed, 15 Sep 1999 22:53:52 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl / C Memory
Message-Id: <4sVD3.33$E%1.3096@nsw.nnrp.telstra.net>
In article <7rp33d$v8$1@gellyfish.btinternet.com>,
Jonathan Stowe <gellyfish@gellyfish.com> writes:
> On Tue, 14 Sep 1999 23:56:49 GMT Martien Verbruggen wrote:
>> That's not entirely true. Flavours of Unix that do anonymous mmaps that
>> I know of:
[snip list]
>> None of the SVR4 systems I know has anonymous mmaps.
> Linux does too.
Yes, yes, I know. I just figured that was implicit from the thread
going before :). It's only recent though.
Martien
--
Martien Verbruggen |
Interactive Media Division | This matter is best disposed of from a
Commercial Dynamics Pty. Ltd. | great height, over water.
NSW, Australia |
------------------------------
Date: Wed, 15 Sep 1999 23:18:56 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Apache Win95
Message-Id: <APVD3.43$E%1.3497@nsw.nnrp.telstra.net>
In article <37DF647D.D7FD24E1@triniti.troitsk.ru>,
tokaev <tokaev@triniti.troitsk.ru> writes:
> I need perl for win98 under Apache.
I didn't know that Windows 98 ran under Apache.
Well.. I guess it can only be an improvement (of Windows that is)
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | Can't say that it is, 'cause it ain't.
NSW, Australia |
------------------------------
Date: 15 Sep 1999 22:36:43 GMT
From: aw_eis@compuserve.com (A.Warnier)
Subject: Perl, Win32, GetPrivateProfileString sub/module ?
Message-Id: <7rp71r$i4k$1@ssauraab-i-1.production.compuserve.com>
Although it would probably be a breeze for any of the gurus that post in this
group, it wouldn't for me, and I am being lazy (which I read somewhere is a
quality of Perl programmers).
So, does anyone know of an existing module or sub that emulates the Windows
GetPrivateProfileString routine (parse an INI file) ?
Thank you in advance.
------------------------------
Date: Wed, 15 Sep 1999 15:30:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Please help a newbie! - sorry for the mistake!
Message-Id: <MPG.1249bdef466f2fe6989f79@nntp.hpl.hp.com>
In article <7rp49h$3qj$1@nnrp1.deja.com> on Wed, 15 Sep 1999 21:49:42
GMT, makau@my-deja.com <makau@my-deja.com> says...
> Sorry but I was so much excited that I commited a few mistakes in my
> code.
>
> Here's is a much cleaner code :
But still worth improvement. You certainly didn't test it at all before
posting it.
> -------------------------------------------------------------
> #!/usr/local/perl -w
>
> use strict;
Excellent start!
> my $data;
Why do you accumulate the output strings here instead of just printing
them out a line at a time?
> open (INPUT,"./input.txt") or die $!;
> open (OUTPUT,">./output.txt") or die $!;
Good, but it might be courteous to include the filename in the
diagnostic.
> while (<INPUT>) {
> m!^(.{180})(\d{2})(\d{2})(\d{2})(.*)!;
What happens if the data are faulty and this match fails?
> $data .= "$1$2/$3/$4$5";
Where, oh, where, has my little newline gone?
s!(.{182})(..)!$1/$2/!;
print;
But I still like substr() better.
...
> In article <7rokdr$ndp$1@nnrp1.deja.com>,
> sg95m476@dunx1.ocs.drexel.edu wrote:
WHY, oh why, do you quote the whole article, *after* your response to
it?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Wed, 15 Sep 1999 23:11:24 GMT
From: Scott Davis <scott@royallepage.com>
Subject: Text Parsing - How to Multi-Line?
Message-Id: <37E027CC.46AAB27D@royallepage.com>
Newbie here. I'm attempting to parse a multi-line input to a single
line output. Is this possible? Any quick tips would be appreciated.
Here's a sample:
Line 1 text
I want something in this line, fixed characters here, variable here
Line 3 text
Line 4 text
I want something in this line, variable text here, fixed characters here
Line 6 text
Line 7 test
My code is:
> open OUTFILE, '>results2';
>
> while (<>)
> {
> print OUTFILE if /16th char is \(3\)(\n|\r|\f)IP Address is/;
> }
What I'm trying to do is find line 1 text ending with specific "char is
(3)" and line 2 text starting with "IP Address". If I can find that,
I'll be happy as a clam. All other text is to be ignored.
If you can, please reply via email also.
My Sincere Thanks!,
Scott.
------------------------------
Date: Wed, 15 Sep 1999 17:04:47 -0400
From: "Scott D. Wells" <shadowsystems@ibm.net>
Subject: Two dimensional array
Message-Id: <37E009EF.BF28CA69@ibm.net>
Does PERL have any kind of implimentation of two dimensional arrays?
IE... like arrays in BASIC $junk(x,y).
Scott
------------------------------
Date: Thu, 16 Sep 1999 00:47:21 +0200
From: Steven de Rooij <srooij@wins.uva.nl>
Subject: Re: Two dimensional array
Message-Id: <37E021F9.26AE8B82@wins.uva.nl>
Scott D. Wells wrote:
>
> Does PERL have any kind of implimentation of two dimensional arrays?
> IE... like arrays in BASIC $junk(x,y).
>
> Scott
You create an array and store array references in it.
It works pretty good.
See perldoc or manpage under perllol and perlref.
Steven
------------------------------
Date: Thu, 16 Sep 1999 00:02:52 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Two dimensional array
Message-Id: <MsWD3.13683$N77.991935@typ11.nn.bcandid.com>
In article <37E021F9.26AE8B82@wins.uva.nl>,
Steven de Rooij <srooij@wins.uva.nl> wrote:
>Scott D. Wells wrote:
>> Does PERL have any kind of implimentation of two dimensional arrays?
>> IE... like arrays in BASIC $junk(x,y).
>
>You create an array and store array references in it.
>It works pretty good.
>See perldoc or manpage under perllol and perlref.
my @x;
$x[1][2] = 'boo';
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Sep 14 1999
55 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 811
*************************************