[23706] in Perl-Users-Digest
Perl-Users Digest, Issue: 5912 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 8 18:05:39 2003
Date: Mon, 8 Dec 2003 15:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 8 Dec 2003 Volume: 10 Number: 5912
Today's topics:
adobe multiline substitution <justplain5fm@email.com>
Re: Am I right on Mod_Perl? (Tad McClellan)
Re: Am I right on Mod_Perl? <uri@stemsystems.com>
Re: Do we just use different file handles when we want <jwillmore@remove.adelphia.net>
Re: editing challenge: Perl vs. cfengine <perl@my-header.org>
Re: How to open a file from the end and read the last 1 <jwillmore@remove.adelphia.net>
Re: How to write to drive A:\ from CGI Perl (Tad McClellan)
Re: HTML::Lint vs. XML <jwillmore@remove.adelphia.net>
Perl hash question (Jeff Vacha)
Re: Perl hash question <xx087@freenet.carleton.ca>
Re: Perl2EXE vs. PAR vs. perlcc <michael.p.broida@fake.domain>
Re: Perl2EXE vs. PAR vs. perlcc <kalinaubears@iinet.net.au>
PPM via proxy server <Allen.Windhorn@LSUSA.com>
Re: PPM via proxy server <asu1@c-o-r-n-e-l-l.edu>
Re: Ranging to 'z' (Malcolm Dew-Jones)
Re: Ranging to 'z' (John M. Gamble)
Re: Reading slective columns from *.csv file <asu1@c-o-r-n-e-l-l.edu>
Re: Reading slective columns from *.csv file <jwillmore@remove.adelphia.net>
Re: Reading slective columns from *.csv file <REMOVEsdnCAPS@comcast.net>
Re: Why can't I parse google search results? <pkent77tea@yahoo.com.tea>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 8 Dec 2003 15:28:21 -0500
From: "Justin" <justplain5fm@email.com>
Subject: adobe multiline substitution
Message-Id: <br2ms4$86i$1@news3.bu.edu>
Hi,
First off, I must apologise for cross posting.
I am having difficulty creating a pdf document using perl cgi to do
substitution for multiline pdf form fields. I created a pdf template/file
with substitution variables. The file is then read and variables substituted
using pattern matching. When I view the pdf multiline form field using
acrobat, the field seems to be truncated. Upon view the properties of the
multiline text field, I can see all the data in the field, but it still
doesn't view correctly. I then view the properties, and just change/add a
space using acrobat, the data then displays over multi lines.
Does anyone have any ideas as to what I might be doing wrong.
Many thanks ,
------------------------------
Date: Mon, 8 Dec 2003 14:09:46 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Am I right on Mod_Perl?
Message-Id: <slrnbt9mka.q4f.tadmc@magna.augustmail.com>
David K. Wall <usenet@dwall.fastmail.fm> wrote:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> Randal L. Schwartz <merlyn@stonehenge.com> wrote in
>> comp.lang.perl.misc:
>>> >>>>> "Picker" == Picker Leon <Temp@NoSuchDomain.Info> writes:
>>>
>>> Picker> Please correct me if I am wrong.
>>>
>>> Asking for that is implied. :) You're in CLPM, remember? :)
>>
>> s/CLPM/Usenet/
>
> "the best way to get accurate information on Usenet is to post
> something wrong and wait for corrections"
Pigs can fly!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 08 Dec 2003 20:23:14 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Am I right on Mod_Perl?
Message-Id: <x7y8tnkqj1.fsf@mail.sysarch.com>
>>>>> "TM" == Tad McClellan <tadmc@augustmail.com> writes:
TM> David K. Wall <usenet@dwall.fastmail.fm> wrote:
>> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>>> Randal L. Schwartz <merlyn@stonehenge.com> wrote in
>>> comp.lang.perl.misc:
>>>> >>>>> "Picker" == Picker Leon <Temp@NoSuchDomain.Info> writes:
>>>>
Picker> Please correct me if I am wrong.
>>>>
>>>> Asking for that is implied. :) You're in CLPM, remember? :)
>>>
>>> s/CLPM/Usenet/
>>
>> "the best way to get accurate information on Usenet is to post
>> something wrong and wait for corrections"
TM> Pigs can fly!
1. i saw a flying pig at a pink floyd concert in '77 at madison sq
garden. it was the 'animals' tour.
2. we buy bread from a bakery called 'when pigs fly'. they are in maine
and sell in stores all over new england.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 08 Dec 2003 19:14:04 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Do we just use different file handles when we want to have multiple files open at the same time...?
Message-Id: <20031208141404.74cea94d.jwillmore@remove.adelphia.net>
On Mon, 8 Dec 2003 00:21:09 -0500
"Matt Garrish" <matthew.garrish@sympatico.ca> wrote:
> I'd also drop the useless quotes:
>
> open(FILEA, $stopfil) or die "Open failed for $stopfil: $!\n";
> open(FILEB, $startfil) or die "Open failed for $starfil: $!\n";
True. See what I get fro re-typing code :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
%DCL-MEM-BAD, bad memory VMS-F-PDGERS, pudding between the ears
------------------------------
Date: Mon, 08 Dec 2003 21:33:33 +0100
From: Matija Papec <perl@my-header.org>
Subject: Re: editing challenge: Perl vs. cfengine
Message-Id: <9pn9tvs37ub70o7rn8e49bb7b504tbftr8@4ax.com>
X-Ftn-To: Ted Zlatanov
Ted Zlatanov <tzz@lifelogs.com> wrote:
>The actual sequence of commands is pretty obvious - the outer
>BeginGroup/EndGroup is an if() statement, and
>LocateLineMatching/IncrementPointer move the editing cursor; -3 means
>to move 3 lines back in the file.
>
>My own attempt used an array-file tie and was definitely not
>as elegant.
IMHO, you don't have much choice; you'll need some module with nice
interface to stay elegant.
--
Matija
------------------------------
Date: Mon, 08 Dec 2003 19:38:49 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: How to open a file from the end and read the last 100 lines
Message-Id: <20031208143848.220f046e.jwillmore@remove.adelphia.net>
On Mon, 08 Dec 2003 00:02:39 GMT
"Mihai N." <nmihai_year_2000@yahoo.com> wrote:
> "I" was not told. I am not the original poster.
Sorry. Didn't mean to offend.
> There is no problem using it. I am pretty sure it does it's work
> pretty well. And I was not talking about this special case.
>
> If you need the script to work without installing other 20 modules
> from CPAN, this will do.
I disagree. I also think that your statement about "20 modules" is a
bit extreme. If I were to read into this, I'd say you're using a
dialup connection and are frustrated about the fact that you have a
hard time maintaining Perl and all the modules. I could be wrong.
I have seen some modules that have quite a few dependencies. Most of
them (the dependencies) were core Perl modules. When the core Perl
modules go out of date, it's time to upgrade Perl. It's like that
*everywhere*. When you see apps failing to install on a Linux system
- and they fail because of an outdated kernel version, it's time to
upgrade the kernel - and *all* the applications that are dependent
upon the kernel (like iptables). Granted, this example is Linux, but
it illustrates the fact that it's not just Perl, it's a lot of other
software/hardware/etc out there.
>
> I was talking about the principle of checking CPAN for trivial
> problems. Don't get me wrong, this may not be a trivial problem if
> you have to run this script on GB or TB of data, several times a
> minute/second. But if you run it once a day/week on some MB, should
> be ok.
No - read on ...
> The main think is productivity and what I am advocating is
> "balance." Sometimes is faster/better your own, sometimes some CPAN
> module. Decide when to go for one or the other is the difficult
> part.
Again, I disagree. Why spend the extra time to find out that someone
else has already figured out what you need to do - and has *tested*
it. Sounds like you speak out of frustration and not anything
practical.
Let's look at something that's been posted *many* times here - the
famous "I can't use sendmail to send email in my script" example.
This issue would be moot if the person would just use one of the
*many* email modules available. Now you don't have to worry about
*what* the system you're using uses to send email. In fact, you could
use a system without *any* email server. Our NTP server at work uses
... a Perl script ... to send email. No email services are on the
system at all. It uses a module to do this.
I suppose you *could* code using sockets and a whole lot of other
basic idioms of code to accomplish this. But you could *never* be
quite sure you have tested the code enough. Or that it would work
after, say, a system upgrade. With modules, this issue is reduced,
even eliminated, because the maintainers would take the time to apply
the appropriate fixes to the code. You just upgrade and, in most
cases, problem solved *before* you even know there's a problem :-)
But, if you feel the need to "roll your own", then you're entitled to
do so :-)
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
"Nuclear war would really set back cable." -- Ted Turner
------------------------------
Date: Mon, 8 Dec 2003 14:13:04 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to write to drive A:\ from CGI Perl
Message-Id: <slrnbt9mqg.q4f.tadmc@magna.augustmail.com>
Cle <canle@lecan.com> wrote:
> Paul Haffman, author of Netscape 4 and Perl for Dummies, page 175:
> open(IN, "D:\ORDERS\DATA\JAN97.DAT");
If you read a Bad Book you will see Bad Code.
There are lots of bad "Perl books" out there, be discriminating.
You should always, yes *always, and double-especially if you
are teaching, check the return value from open().
Your book has lead you astray.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 08 Dec 2003 19:46:13 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: HTML::Lint vs. XML
Message-Id: <20031208144613.2c4b91ab.jwillmore@remove.adelphia.net>
On 7 Dec 2003 19:40:18 -0500
jester@panix.com (Jesse Sheidlower) wrote:
>
> I've just started doing some real testing on my scripts,
> and I've run into a problem already. I am trying to test
> a generated Web page using WWW::Mechanize and Test::HTML::Lint,
> following some posted suggestions from Andy Lester. But I'm
> getting an error that doesn't seem to be described in the
> Lint docs.
>
> I generate my page using standard CGI.pm functions (via
> Template Toolkit), starting with CGI::header and
> CGI::start_html, which generates text beginning:
>
> ---
> <?xml version="1.0" encoding="iso-8859-1"?>
> <!DOCTYPE html
> PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US"
> xml:lang="en-US"><head>...
Deep in the reaches of the CGI documentation, there in mention of how
to make the output a particular version of HTML. I think it goes
something like ...
use CGI qw(:html4);
or something to that effect. This *may* let Lint verify the HTML in a
version it understands.
Check the documentation to verify. Salt to taste :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Barometer, n.: An ingenious instrument which indicates what kind
of weather we are having. -- Ambrose Bierce, "The Devil's
<Dictionary"
------------------------------
Date: 8 Dec 2003 12:22:14 -0800
From: jeff.vacha@bmg.com (Jeff Vacha)
Subject: Perl hash question
Message-Id: <4deafd6d.0312081222.19182e8b@posting.google.com>
Hello All,
I am new to Perl and am really struggling to understand why the below
does not print an email address as I believe it should. When the
whole hash is displayed, the email address appears. However, when I
try to "look it up" in the hash, it doesn't appear. Any ideas what I
am doing wrong.
Thanks!
Jeff Vacha
jeff.vacha@bmg.com
# This is SybPerl code. If you don't no Sybperl, I think you can
still understand the question without understanding this part...
$dbh->ct_execute("select parm_name, parm_value from behavior_parms
where key=$key");
while($dbh->ct_results($restype) == SUCCEED) {
next unless $dbh->ct_fetchable($restype);
while (%dat = $dbh->ct_fetch()) {
$parms{$dat[0]} = $dat[1];
}
}
while(($TheKey, $TheVal) = each(%parms))
{print "$TheKey is the only key for $TheVal\n"}
$email_address = $parms{'email address'};
print "\nEmail: $email_address\n";
<<OUTPUT EXAMPLE:
email address is the only key for jeff.vacha@bmg.com
zip result is the only key for y
input table is the only key for map_cd
output file name is the only key for file_to_email.txt
Email:
>>
Note.. the while loops works but the print of just the email address
doesn't.
------------------------------
Date: 8 Dec 2003 21:09:54 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: Perl hash question
Message-Id: <slrnbt9q6l.srm.xx087@smeagol.ncf.ca>
Jeff Vacha <jeff.vacha@bmg.com> wrote:
> When the whole hash is displayed, the email address appears.
> However, when I try to "look it up" in the hash, it doesn't appear.
[...]
> while(($TheKey, $TheVal) = each(%parms))
> {print "$TheKey is the only key for $TheVal\n"}
>
> $email_address = $parms{'email address'};
> print "\nEmail: $email_address\n";
>
>
> <<OUTPUT EXAMPLE:
>
> email address is the only key for jeff.vacha@bmg.com
> zip result is the only key for y
> input table is the only key for map_cd
> output file name is the only key for file_to_email.txt
>
> Email:
>
Note your output: "email address is the..."
Do you see that there are 2 spaces after address?
Your hash does not contain the key 'email address', but it does contain
the key 'email address '.
You should get into the habit of
use strict;
use warnings;
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Mon, 8 Dec 2003 20:20:40 GMT
From: MPBroida <michael.p.broida@fake.domain>
Subject: Re: Perl2EXE vs. PAR vs. perlcc
Message-Id: <3FD4DD18.CDAF76E7@fake.domain>
Sisyphus wrote:
>
> Ralph K wrote:
> > Before committing the time and effort to try one of these methods of
> > producing compiled perl programs, I'd welcome the observations,
> > experiences and warnings from those who have gone before.
> >
>
> Forget perlcc.
>
> Try PAR first. It doesn't yet handle all situations on all operating
> systems. If it doesn't do the job you need, report the bug to the PAR
> mailing list (see http://lists.perl.org ) and try perl2exe (or Active
> State's perlapp from their PDK).
Can you give a pointer/URL to a PAR site?
Thanks!
Mike
------------------------------
Date: Tue, 09 Dec 2003 08:50:47 +1100
From: Sisyphus <kalinaubears@iinet.net.au>
Subject: Re: Perl2EXE vs. PAR vs. perlcc
Message-Id: <3fd4f304$0$1754$5a62ac22@freenews.iinet.net.au>
MPBroida wrote:
> Sisyphus wrote:
>
>>Ralph K wrote:
>>
>>>Before committing the time and effort to try one of these methods of
>>>producing compiled perl programs, I'd welcome the observations,
>>>experiences and warnings from those who have gone before.
>>>
>>
>>Forget perlcc.
>>
>>Try PAR first. It doesn't yet handle all situations on all operating
>>systems. If it doesn't do the job you need, report the bug to the PAR
>>mailing list (see http://lists.perl.org ) and try perl2exe (or Active
>>State's perlapp from their PDK).
>
>
> Can you give a pointer/URL to a PAR site?
>
> Thanks!
> Mike
Not sure that there is a par-designated site. You might find something
at http://par.perl.org . (Well ... of course that *is* a
"par-designated" site, but I don't know how useful that will be to you.
Check it out.)
Afaict you've got the module's documentation and the mailing list I
referred to above and that's about it. The release of new versions is
announced on the mailing list, and of course there's the usual bug
reports (not many these days) and the occasional piece of general
discussion. It's not a high volume list, but it is closely scrutinised
by the module's author - so quality help is always at hand :-)
Cheers,
Rob
--
To reply by email u have to take out the u in kalinaubears.
------------------------------
Date: Mon, 08 Dec 2003 20:16:11 GMT
From: Allen Windhorn <Allen.Windhorn@LSUSA.com>
Subject: PPM via proxy server
Message-Id: <u4qwb3w0o.fsf@LSUSA.com>
PPM doesn't work on my office machine, apparently because it can't get
through our firewall. HTTP and FTP are normally no problem here. Is
there a setting I need to make?
(Error message follows)
C:\perl>ppm install PAR
Error: No valid repositories: Error: 407 Proxy authentication required
Error: 407 Proxy authentication required
Thanks,
Allen
--
Allen Windhorn (507) 345-2782 FAX (507) 345-2805
Kato Engineering (Though I do not speak for Kato)
P.O. Box 8447, N. Mankato, MN 56002
Allen.Windhorn@LSUSA.com
------------------------------
Date: 8 Dec 2003 21:29:05 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: PPM via proxy server
Message-Id: <Xns944BA7B267A7Easu1cornelledu@132.236.56.8>
Allen Windhorn <Allen.Windhorn@LSUSA.com> wrote in
news:u4qwb3w0o.fsf@LSUSA.com:
> PPM doesn't work on my office machine, apparently because it can't get
> through our firewall. HTTP and FTP are normally no problem here. Is
> there a setting I need to make?
>
> (Error message follows)
>
> C:\perl>ppm install PAR
> Error: No valid repositories: Error: 407 Proxy authentication required
> Error: 407 Proxy authentication required
Did you check the ActivePerl FAQ? Is there a problem with the explanation
provided there?
http://aspn.activestate.com/ASPN/docs/ActivePerl/faq/ActivePerl-
faq2.html#running_ppm
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 8 Dec 2003 11:10:56 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Ranging to 'z'
Message-Id: <3fd4ccc0@news.victoria.tc.ca>
John M. Gamble (jgamble@ripco.com) wrote:
: I was reviewing my code, and came across a bit that made me say, "wait,
: that can't work." Followed immediately by "why does that work?"
: Here is the code reduced to it's essence:
: my $inputs = 8;
: my @alphabase = ('a'..chr($inputs));
: The *intent* was to create a simple translation array (more complex
: arrays are possible in this application, which is why i was going
: through the bother of an array with this one). Now, according to my
: naive reading of this code, this shouldn't produce anything useful at all.
: But if you add the line
: print @alphabase, "\n";
: you get "abcdefghijklmnopqrstuvwxyz", which accidentally saved me.
: Thing is, i don't think i deserved to be saved. Not because i am not
: worthy (heh), but because this could be an error waiting to happen.
: What if i wanted the length of the translation array later on, and i
: used C<scalar @alphabase> instead of $inputs? Complications ensue.
: The "Give 'em up to Z" feature can be seen in the even simpler one-
: liner:
: perl -le "print 'h'..'a'"
: which prints out h through z. It's too consistent not be deliberate,
: but what on Earth was it supposed to solve that someone thought it
: was DWIM? Should this feature persist?
perldoc perlop
The range operator (in list context) makes use of the magical
auto-increment algorithm if the operands are strings.
...
...If the final value specified is not
in the sequence that the magical increment would produce, the
sequence goes until the next value would be longer than the final
value specified.
I.e. When using strings, I guess this means the "range" can be magically
based on the length of the string, (magically here meaning "not all the
time", and coincidently also not what you anticipated some of the time).
In this case I guess the auto-increment ran out of values before it found
one that was longer, and so the last available auto-increment value (z)
became the last value.
------------------------------
Date: Mon, 8 Dec 2003 21:20:02 +0000 (UTC)
From: jgamble@ripco.com (John M. Gamble)
Subject: Re: Ranging to 'z'
Message-Id: <br2pu2$o7v$4@e250.ripco.com>
In article <3fd4ccc0@news.victoria.tc.ca>,
Malcolm Dew-Jones <yf110@vtn1.victoria.tc.ca> wrote:
>John M. Gamble (jgamble@ripco.com) wrote:
>: I was reviewing my code, and came across a bit that made me say, "wait,
>: that can't work." Followed immediately by "why does that work?"
>
>: Here is the code reduced to it's essence:
>: my $inputs = 8;
>: my @alphabase = ('a'..chr($inputs));
>
>: The *intent* was to create a simple translation array (more complex
>: arrays are possible in this application, which is why i was going
>: through the bother of an array with this one). Now, according to my
>: naive reading of this code, this shouldn't produce anything useful at all.
>: But if you add the line
>: print @alphabase, "\n";
>: you get "abcdefghijklmnopqrstuvwxyz", which accidentally saved me.
>
>: Thing is, i don't think i deserved to be saved. Not because i am not
>: worthy (heh), but because this could be an error waiting to happen.
>: What if i wanted the length of the translation array later on, and i
>: used C<scalar @alphabase> instead of $inputs? Complications ensue.
>
>: The "Give 'em up to Z" feature can be seen in the even simpler one-
>: liner:
>: perl -le "print 'h'..'a'"
>
>: which prints out h through z. It's too consistent not be deliberate,
>: but what on Earth was it supposed to solve that someone thought it
>: was DWIM? Should this feature persist?
>
>perldoc perlop
>
> The range operator (in list context) makes use of the magical
> auto-increment algorithm if the operands are strings.
> ...
> ...If the final value specified is not
> in the sequence that the magical increment would produce, the
> sequence goes until the next value would be longer than the final
> value specified.
"... until the next value would be longer than the final
value specified."
It took me a while to parse that sentence. Fortunately, your next
paragraph helped a lot.
>
>I.e. When using strings, I guess this means the "range" can be magically
>based on the length of the string, (magically here meaning "not all the
>time", and coincidently also not what you anticipated some of the time).
>
Gotcha. "Longer," not "Larger." String length, not value size.
>In this case I guess the auto-increment ran out of values before it found
>one that was longer, and so the last available auto-increment value (z)
>became the last value.
>
Yeah, that's still a little strange to me. I think i would have
preferred an outright error message.
Thank you very much.
--
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
------------------------------
Date: 8 Dec 2003 19:15:27 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Reading slective columns from *.csv file
Message-Id: <Xns944B910ACF0C8asu1cornelledu@132.236.56.8>
survesh2000@yahoo.com (Nithin) wrote in
news:55b7ea65.0312081059.1f8b6a2@posting.google.com:
> Hi,
> I have a *.csv file that looks like this. I need to ignore Rows 1-5
> and start reading from Row 6. From Row 6 I need only Column1, Column
> 3, Column4 and so on....(has about 35 values in each row).
So, skip the first 5 lines.
> RED - Letters in Red auto-populate columns from left to right.
> Color Code - Yellow Field name boxes in yellow are fields required
> Color Code - Gray Field name boxes in gray are fields are optional
> Color Code - Green Field name boxes in green are optional fields
> Color Code - Orange Field name boxes in orange indicate d - refer etc
> 44383 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
> 44384 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
> 44385 Ontario Dork Canal 288 1398 Malheur Ave
> TAC31NT
Is this your data file? It is not in CSV format.
> My code looks like this
>
> open FILE, "input.csv";
Always check if open succeeded.
open FILE, '<', 'input.csv' or die "Cannot open input: $!\n";
> while (<FILE>) {
> chomp;
> my ($col1, $col2, $col3, $col4, $col6) = split (/\,/);
> }
So, basically, you haven't done anything and you'd like someone else to
do all the work for you. I would have thought it went without saying that
so should at least show some code that tries to accomplish your goal of
skipping the first few lines. Very annoying.
> my ($col1, $col2, $col3, $col4, $col6) = split (/\,/);
Have you looked at Text::CSV? It would help you avoid all sorts of
troubles that would be cause by this kind of code.
Untested:
use strict;
use warnings;
open FILE, '<', 'input.csv' or die "Cannot open input: $!\n";
for (1..5) {
unless(defined <FILE>) {
die "Error skipping header: $!\n";
}
}
use Text::CSV;
my $csv = Text::CSV->new();
while(<FILE>) {
if($csv->parse($_)) {
for ( $csv->fields() ) {
print;
}
print "\n";
}
}
__END__
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: Mon, 08 Dec 2003 19:53:34 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Reading slective columns from *.csv file
Message-Id: <20031208145334.4f14ab9a.jwillmore@remove.adelphia.net>
On 8 Dec 2003 10:59:20 -0800
survesh2000@yahoo.com (Nithin) wrote:
> Hi,
> I have a *.csv file that looks like this. I need to ignore Rows 1-5
> and start reading from Row 6. From Row 6 I need only Column1, Column
> 3, Column4 and so on....(has about 35 values in each row).
>
>
> RED - Letters in Red auto-populate columns from left to right.
> Color Code - Yellow Field name boxes in yellow are fields required
> Color Code - Gray Field name boxes in gray are fields are optional
> Color Code - Green Field name boxes in green are optional fields
> Color Code - Orange Field name boxes in orange indicate d - refer
> etc 44383 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
> 44384 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
> 44385 Ontario Dork Canal 288 1398 Malheur Ave TAC31NT
>
>
> Previously, I used to copy manually the values I wanted to the
> input.csv file. But, now I want to read directly from the source
> file and avoid the extra step.
>
> My code looks like this
>
> open FILE, "input.csv";
open FILE, 'input.csv' or die "Can't open input.csv file: $!\n;
> while (<FILE>) {
next if $. <= 5;
> chomp;
> my ($col1, $col2, $col3, $col4, $col6) = split (/\,/);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Are you *sure* you want to split on ','? I didn't see a comma in the
data provided.
> }
There are other ways. But this is what I came up with in about 30
seconds (untested) :-)
HTH
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Bennett's Laws of Horticulture: (1) Houses are for people to
live in. (2) Gardens are for plants to live in. (3) There is
no such thing as a houseplant.
------------------------------
Date: Mon, 08 Dec 2003 17:03:38 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Reading slective columns from *.csv file
Message-Id: <Xns944BB800DB762sdn.comcast@216.196.97.136>
survesh2000@yahoo.com (Nithin) wrote in
news:55b7ea65.0312081059.1f8b6a2@posting.google.com:
> Hi,
> I have a *.csv file that looks like this. I need to ignore Rows 1-5
> and start reading from Row 6. From Row 6 I need only Column1, Column
> 3, Column4 and so on....(has about 35 values in each row).
...
> Previously, I used to copy manually the values I wanted to the
> input.csv file. But, now I want to read directly from the source file
> and avoid the extra step.
>
> My code looks like this
>
> open FILE, "input.csv";
>
> while (<FILE>) {
> chomp;
> my ($col1, $col2, $col3, $col4, $col6) = split (/\,/);
> }
Did you have a question in there? :-)
--
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
------------------------------
Date: Mon, 08 Dec 2003 20:59:48 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Why can't I parse google search results?
Message-Id: <pkent77tea-D5BFFC.20594708122003@ptb-nnrpp01.plus.net>
In article <51c3a5d3.0312070801.5093c8cf@posting.google.com>,
utsuxs@hotmail.com (bob) wrote:
> I'm trying to extract data from the results page of search engines
> with these two
> modules use LWP::Simple and HTML::Parse, and the get command.
>
> I can extract from yahoo and altavista but google is not cooperating.
Google has an API that is designed for machines to use and can happily
be used from Perl:
http://w.google.com/apis/
Remember to read and comply with the terms of service, etc :-)
> I get this error message
>
> Can't fetch HTML from http://www.google.com/search?q=smeghead at
> parsing.pl line 13.
I would bet, but I don't know for sure, that Google rejects queries that
come in with certain Useragent headers and LWP::UserAgent has a default
string.
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 5912
***************************************