[16606] in Perl-Users-Digest
Perl-Users Digest, Issue: 4018 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Aug 15 03:05:36 2000
Date: Tue, 15 Aug 2000 00:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966323113-v9-i4018@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 15 Aug 2000 Volume: 9 Number: 4018
Today's topics:
Re: [Perl] invalud method (brian d foy)
Re: [Perl] offline mode (brian d foy)
Re: [Perl] offline mode <katz@underlevel.net>
Re: Array Printing <lr@hpl.hp.com>
Re: Ascii highlight code? (Philip 'Yes, that's my address' Newton)
Re: Convert URLs to links (Keith Calvert Ivey)
Get ip from visitor rune@clamon.dk
Re: Help a little needed from regex expert please <katz@underlevel.net>
Multiline regexp search and replace? henrik7205@hotmail.com
Re: Negativity in Newsgroup <joehecht@code4sale.com>
Re: Perfect Place to find Perl Jobs (Gwyn Judd)
Re: Perfect Place to find Perl Jobs <juex@my-deja.com>
Re: Perl code for a newbie!! (Keith Calvert Ivey)
Re: RegExp or something like that.. <godzilla@stomp.stomp.tokyo>
Re: RegExp or something like that.. <uri@sysarch.com>
Re: RegExp Puzzle <godzilla@stomp.stomp.tokyo>
Re: RegExp Puzzle <uri@sysarch.com>
Re: RegExp Puzzle <lr@hpl.hp.com>
Re: RegExp Puzzle jamesk5674@my-deja.com
Re: RegExp Puzzle jamesk5674@my-deja.com
Re: RegExp Puzzle <godzilla@stomp.stomp.tokyo>
regular expression help <jheffinger@ipivot.com>
Re: Socket hang, any ideas??? (Steve Leibel)
Re: Substituting newlines for HTML equivalent (Keith Calvert Ivey)
Re: tag parsing. johnvert@my-deja.com
Re: Updating flat text file problem (Keith Calvert Ivey)
Re: XML::DOM question (Eric Bohlman)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 15 Aug 2000 00:14:49 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: [Perl] invalud method
Message-Id: <brian-ya02408000R1508000014490001@news.panix.com>
In article <8na9q6$bc$1@nnrp1.deja.com>, bolero92@my-deja.com posted:
> I am writing a CGI Perl script for users to change their e-mail
> forwarding settings
> the script will change /etc/mail/aliases and run /usr/bin/newaliases
> this script is setuid to root
that's a really bad idea. see the security documents referenced
in the CGI Meta FAQ.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Tue, 15 Aug 2000 00:09:12 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: [Perl] offline mode
Message-Id: <brian-ya02408000R1508000009120001@news.panix.com>
In article <8na6ao$tse$1@nnrp1.deja.com>, bolero92@my-deja.com posted:
> I'm writing CGI Perl script
> I found that Apache error logs generate the following error message
> while running this script:
>
> (offline mode: enter name=value pairs on standard input)
see the CGI.pm documentation section that deals with offline
testing.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: 15 Aug 2000 01:20:26 -0400
From: Jordan Katz <katz@underlevel.net>
Subject: Re: [Perl] offline mode
Message-Id: <m3r97r3xt1.fsf@underlevel.underlevel.net>
bolero92@my-deja.com writes:
> I'm writing CGI Perl script
> I found that Apache error logs generate the following error message
> while running this script:
>
> (offline mode: enter name=value pairs on standard input)
>
> What does this line mean?
When running a CGI script that expects parameters (such as from a
form) from the command line, Perl prompts you to manually enter your
name=pair values as opposed to getting them from the browser.
--
Jordan Katz <katz@underlevel.net>
------------------------------
Date: Mon, 14 Aug 2000 21:31:56 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Array Printing
Message-Id: <MPG.14026795b4b5d36598ac7b@nntp.hpl.hp.com>
In article <x7r97rxk0p.fsf@home.sysarch.com>, uri@sysarch.com says...
> >>>>> "LS" == Logan Shaw <logan@cs.utexas.edu> writes:
>
> >>> print map ("$_\n", @block);
> >>>
> >> or even to shave a couple of pecks:
> >>
> >> print "$_\n" for @block;
>
> LS> Yes, but if @block contains n elements, the for loop version
> LS> version will make n system calls (to write). The map() version
> LS> will make only one system call. If @block is relatively small (a
> LS> few hundred kilobytes or less), this will most likely be more
> LS> efficient, especially if the output is going to hard disk.
>
> never say that something in perl is more efficient without
> benchmarking. you will get bitten otherwise. even though the second line
> makes many calls to print it doesn't have to allocate the data for the
> map list. so it is very dependent on the data in @block, both the number
> of elements and the size of each one.
Also, the many calls to print do *not* translate to many system calls to
write, because of buffering in the stdio library.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Aug 2000 05:08:25 GMT
From: nospam.newton@gmx.li (Philip 'Yes, that's my address' Newton)
Subject: Re: Ascii highlight code?
Message-Id: <3998c7de.752617864@news.nikoma.de>
On Mon, 14 Aug 2000 11:58:15 -0700, Larry Rosler <lr@hpl.hp.com> wrote:
> In article <8n9c8c$2ud$1@provolone.cs.utexas.edu> on 14 Aug 2000
> 13:02:52 -0500, Logan Shaw <logan@cs.utexas.edu> says...
>
> > s/\b.//g;
>
> Snurked by Perl! (It is so easy to fall into these little traps! I'm
> very familiar with this one, having posted something like it myself.)
>
> Look in perlre to see what \b means in a regex (but nowhere else).
>
> Use \cH instead (or \010 as the original poster did).
Or [\b]. In a character class, it means "backspace" again.
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Tue, 15 Aug 2000 04:35:40 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Convert URLs to links
Message-Id: <3998c733.1053033@news.newsguy.com>
decklin+usenet@red-bean.com (Decklin Foster) wrote:
>Keith Calvert Ivey <kcivey@cpcug.org> writes:
>
>> And it won't do what people want with things like
>>
>> http://www.w3.org/Addressing/#time
>
>Just curious, what do we 'want' to do with that one?
Well, I'd want to include the fragment identifier (the "#time")
in the value of HREF, so that following the link would put me at
the right place on the page. But since the fragment identifier
isn't really part of the URL, it's not recognized by Abigail's
regex, so the link stops before the #.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Tue, 15 Aug 2000 06:26:24 GMT
From: rune@clamon.dk
Subject: Get ip from visitor
Message-Id: <8nanqf$9i1$1@nnrp1.deja.com>
Hi,
I want to get the ip-adress from the visitor on my homepage that
executes my perl cgi-script. How is this possible?
Regards,
Rune Christensen - DK
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 15 Aug 2000 01:27:34 -0400
From: Jordan Katz <katz@underlevel.net>
Subject: Re: Help a little needed from regex expert please
Message-Id: <m3k8dj3xh5.fsf@underlevel.underlevel.net>
"Robert Chalmers" <robert@chalmers.com.au> writes:
> Hi,
> I have a string like this.
>
> No match for "CCSCHINO.COM".
>
>
> Exactly like this, even with the full-stop (period) at the end, and the ""
> quote marks.
>
> What I need to do is extract ONLY the word between the "", ie, in this
> case - CCSCHINO.COM
>
> Nothing I try returns that. Everything else.... !!! but not that.
>
> Does anyone have any clues please.
> Thanks very much for any help
Try:
my $str = "\"CCSCHINO.COM\".";
my $result;
if ($str =~ /"(.*)"/) {
$result = $1;
}
print $result;
--
Jordan Katz <katz@underlevel.net>
------------------------------
Date: Tue, 15 Aug 2000 06:30:14 GMT
From: henrik7205@hotmail.com
Subject: Multiline regexp search and replace?
Message-Id: <8nao1n$9r5$1@nnrp1.deja.com>
Hi,
I am trying to make a search and replace in a multiline string but I
can't get it to work.
I have a textbox where the user can enter a description for a file.
This description is then stored in a text file with a single record per
line. But in order to store the record on one line I need to replace
the \n with <br>'s.
I tried s/\n/<br>/gs but it didn't work.
Thanks
Henrik
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 15 Aug 2000 04:00:35 GMT
From: "Joe C. Hecht" <joehecht@code4sale.com>
Subject: Re: Negativity in Newsgroup
Message-Id: <Cf3m5.3341$TM6.319482@dfiatx1-snr1.gtei.net>
> > [Godzilla! tempts me out of lurk mode]
>
> I am less tempting when nude, which is almost
> always, least at home. However I have no tanlines
> which seems attractive to some.
[sigh] I could not see them anyway, as I work
all night in the Florida moonlight, either on the
boat, the dock, or the hottub. I like the hottub
cause it has a fast eithernet connection.
> > I am unsure. Having miserbly failed english and
> > spelling, I find it difficult to speak properly at all
> > though a keyboard.
>
> Develop an exceptionally talented tongue. You
> will experience better luck with this method
> and, perhaps better luck as a lover.
Wife (versions 1.0 though 3.0) and Girlfriend (versions
2.0 through 27.3) think I have that down ok...
> > I see no reason to be offended, although, I
> > must admit, I am swooned by your use of
> > the English language.
>
> I know nothing about use of English. I am quite
> talented at copy and paste from books of cute
> quips and quotes.
Gotcha! Cliff Notes???
> > Is that Miss. Godzilla!, Mrs. Godzilla!, Ms. Godzilla!,
> > or is there another, more approprate title I should use?
>
> You may refer to me as God for short.
Well, you may be devine, but I cant do that one,
at least until you turn the hottub water into a good
Cab or Merlot ;)
> > I must admit, you are far too kind...
>
> I am capable of being less kind, if this
> would please you.
No, just be yourself and I will be quite pleased :)
> Godzilla!
> Join comp.lang.perl.misc campaign of hatred!
> Learn to send secretive very hateful email!
> Learn vulgarity, bigotry, hatred and crime!
> Enjoy your USENET experience with vile hatred!
> For further information, contact Perl Mongers!
I am sending a telegram right now...
Joe
------------------------------
Date: Tue, 15 Aug 2000 04:20:40 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: Perfect Place to find Perl Jobs
Message-Id: <slrn8phh8m.6kr.tjla@thislove.dyndns.org>
I was shocked! How could sammytalin <sammytalinNOsaSPAM@usa.com.invalid>
say such a terrible thing:
>Don't listen to this guy...
No offense but I'll listen to whoever I want.
>this newsgroup is all about Perl in general.
No it isn't. This newsgroup is specifically about Perl programming
related topics.
>This is useful information.
No, a post about how to create a Duke Nukem clone in Perl would be
useful information. A post on how to rewrite Windows NT in Perl would
be useful information. This is like the "Easy Listening Music" of useful
information (ie. it sounds like music to someone who had read about
music in a book and said "oooh that sounds niiiiiiiiice").
>This guy is probably bitter cuz he can't find a job!
Actually he's bitter because he can't find those Brittany jpeg's.
>LOSER...
Don't you mean YHL? Trolls these days, I don't know. In my day they had
a little imagination and wit to colour their discourse but now it's all
hot grits and yada yada
*plonk*
--
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Do not argue with the forces of nature for you are small insignificant
and biodegradable. (contributed by David Allen)
------------------------------
Date: Mon, 14 Aug 2000 21:32:45 -0700
From: "Jürgen Exner" <juex@my-deja.com>
Subject: Re: Perfect Place to find Perl Jobs
Message-Id: <3998c7ee@news.microsoft.com>
"Logan Shaw" <logan@cs.utexas.edu> wrote in message
news:8naae9$4oo$1@provolone.cs.utexas.edu...
> O.K., silly question here, but does anyone have a copy of the charter?
[...]
>
> Anyway, my point would be that if the charter says "no job listings"
> then that would help settle the debate.
Actually you don't have to, it's just the other way round.
Commercial postings, spamming, and job postings are not welcome in any NG
unless the charta of this NG explicitely allows them.
In so far it is PerlPrincess' duty to prove, that his postings are ok.
jue
------------------------------
Date: Tue, 15 Aug 2000 04:43:20 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Perl code for a newbie!!
Message-Id: <3999c900.1514188@news.newsguy.com>
"Craig Pugsley" <craig.pugsley@mimesweeper.com> wrote:
>There are several sub-threads under my initial main question. At one point,
>it digresses into this totally different comment altogether! I admit, it is
>getting slightly confusing! Persist.
It's hard to have a discussion with someone who refuses to
follow the conventions of Usenet discussions. Note that other
people in the thread quote only the relevant parts of the
messages they're responding to and put their responses *after*
the quoted material. If you decide to do something different,
even after being advised of the problem, you have no one but
yourself to blame if you find things confusing -- or if you end
up being killfiled and ignored by the people you're trying to
get a response from.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Mon, 14 Aug 2000 22:42:28 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: RegExp or something like that..
Message-Id: <3998D844.292DC5FD@stomp.stomp.tokyo>
SuperNews should be named SuckerNews.
Sorry again, no references. This is pulled from another
news server from which I should not post, although a legit
subscriber, because of Stowe's.. hmm.. whatever.. suppose
it is best described as self-appointed constable of this
Mule Manure Mountain. He hardly ever gets it right though.
Uri Guttman whined:
> Godzilla! eloquently wrote:
> > foreach $element (@Array)
> > {
> > if ($element =~ tr/"// == 6)
> > { $element = "$element\"\","; }
> amazing, but she answered the same way i did with tr. but as always she
> has crappy code by not using .= and single quotes. typical
> moronzilla. never learns anything.
> and as always she still thinks the world is all cgi.
Well gosh, Mr. Buttman, did I accidently step on your fragile
male ego by posting a well written, very informative and high
quality article contrasting yours? Embarrassed little boy?
Next time I will base my code on commas so as not to cause
you to mess your diapers then pitch a Hissy Fit.
Godzilla!
--
Like a barracuda, I will bite you and rock you.
http://la.znet.com/~callgirl5/baracuda.mid
------------------------------
Date: Tue, 15 Aug 2000 06:18:07 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: RegExp or something like that..
Message-Id: <x7hf8nxd28.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> Well gosh, Mr. Buttman, did I accidently step on your fragile
G> male ego by posting a well written, very informative and high
G> quality article contrasting yours? Embarrassed little boy?
G> Next time I will base my code on commas so as not to cause
G> you to mess your diapers then pitch a Hissy Fit.
i am just curious as to what brain damage causes you to be able to
marginally function and not be able to comprehend logical
statements. you translate disagreement with assault and correction as
rape. your comments are childishly repetative with plenty of potty stuff
which shows off your phd in english. and you still don't know how to
learn new perl stuff at a rate higher than 1 op perl month. at that rate
you might become a competent perl hacker in another hundred years.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 14 Aug 2000 21:19:32 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: RegExp Puzzle
Message-Id: <3998C4D4.1C9C4136@stomp.stomp.tokyo>
(no references, pulled from a different news server)
(Jonathan Stowe will complain if I post from there)
jamesk wrote:
> My problem lies in the fact that I have a text file
> formatted as the following:
> "field1","field2","field3",
> "field1","field2","field3","",
> "field1","field2","field3",
> "field1","field2","field3","field4",
> The file will contain at least 3 fields and may or may not
> contain a 4th field.
> What I need is for all rows to have 4 fields after the solution is
> applied. If the 4th field is not there, I need to append -- "", -- to
> the record.
(snipped)
Why are you using slower, klunky and possibly error prone
regex / substitution for such a simple task? I am curious
why you want a comma after your fourth and final data field.
Doesn't seem prudent if you are planning a comma split later.
Do not respond with changed parameters and,
"This does not work."
Godzilla!
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$input = '"field1","field2","field3",
"field1","field2","field3","",
"field1","field2","field3",
"field1","field2","field3","field4",';
print "Input:\n $input\n\n";
@Array = split (/\n/, $input);
print "Output:\n";
foreach $element (@Array)
{
if ($element =~ tr/"// == 6)
{ $element = "$element\"\","; }
print " $element\n";
}
exit;
PRINTED RESULTS:
________________
Input:
"field1","field2","field3",
"field1","field2","field3","",
"field1","field2","field3",
"field1","field2","field3","field4",
Output:
"field1","field2","field3","",
"field1","field2","field3","",
"field1","field2","field3","",
"field1","field2","field3","field4",
------------------------------
Date: Tue, 15 Aug 2000 04:47:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: RegExp Puzzle
Message-Id: <x7lmxzxh8r.fsf@home.sysarch.com>
>>>>> "G" == Godzilla! <godzilla@stomp.stomp.tokyo> writes:
G> foreach $element (@Array)
G> {
G> if ($element =~ tr/"// == 6)
G> { $element = "$element\"\","; }
amazing, but she answered the same way i did with tr. but as always she
has crappy code by not using .= and single quotes. typical
moronzilla. never learns anything.
and as always she still thinks the world is all cgi.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 14 Aug 2000 21:47:41 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: RegExp Puzzle
Message-Id: <MPG.14026b42b3635d8698ac7c@nntp.hpl.hp.com>
In article <8nac6a$20a$1@nnrp1.deja.com>, jamesk5674@my-deja.com says...
> Greetings, my fellow Geeks (rulers of the modern world),
> Thank you for using usenet and for your time.
>
> My problem lies in the fact that I have a text file formatted as the
> following:
>
> "field1","field2","field3",
> "field1","field2","field3","",
> "field1","field2","field3",
> "field1","field2","field3","field4",
>
> The file will contain at least 3 fields and may or may not contain a
> 4th field.
>
> What I need is for all rows to have 4 fields after the solution is
> applied. If the 4th field is not there, I need to append -- "", -- to
> the record.
>
> I am exploring the following methods and they seem close.
>
> my $result =~ s/("[^\"]+",){3}$/$1\"\",/g;
That isn't correct, because it doesn't capture the entire string.
my $result =~ s/(("[^\"]+",){3})$/$1"",/g;
or, slighly better,
my $result =~ s/((?:"[^\"]+",){3})$/$1"",/g;
> my $result =~ s/("[^\"]+",)("[^\"]+",)("[^\"]+",)$/$1$2$3\"\",/g;
That is the same thing, just wordier.
But I would have published Uri Guttman's "count the quotes" solution if
he hadn't. :-)
Do some benchmarks to decide the Bst Way to Do It.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 15 Aug 2000 04:49:24 GMT
From: jamesk5674@my-deja.com
Subject: Re: RegExp Puzzle
Message-Id: <8nai4j$5uv$1@nnrp1.deja.com>
I can be pretty stubborn when I want to figure out a problem like this.
This will save me time tommorow at work and I thank you.
In article <3998C4D4.1C9C4136@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
>
> (no references, pulled from a different news server)
> (Jonathan Stowe will complain if I post from there)
>
> jamesk wrote:
>
> > My problem lies in the fact that I have a text file
> > formatted as the following:
>
> > "field1","field2","field3",
> > "field1","field2","field3","",
> > "field1","field2","field3",
> > "field1","field2","field3","field4",
>
> > The file will contain at least 3 fields and may or may not
> > contain a 4th field.
>
> > What I need is for all rows to have 4 fields after the solution is
> > applied. If the 4th field is not there, I need to append -- "", --
to
> > the record.
>
> (snipped)
>
> Why are you using slower, klunky and possibly error prone
> regex / substitution for such a simple task? I am curious
> why you want a comma after your fourth and final data field.
> Doesn't seem prudent if you are planning a comma split later.
>
> Do not respond with changed parameters and,
> "This does not work."
>
> Godzilla!
>
> TEST SCRIPT:
> ____________
>
> #!/usr/local/bin/perl
>
> print "Content-Type: text/plain\n\n";
>
> $input = '"field1","field2","field3",
> "field1","field2","field3","",
> "field1","field2","field3",
> "field1","field2","field3","field4",';
>
> print "Input:\n $input\n\n";
>
> @Array = split (/\n/, $input);
>
> print "Output:\n";
>
> foreach $element (@Array)
> {
> if ($element =~ tr/"// == 6)
> { $element = "$element\"\","; }
> print " $element\n";
> }
>
> exit;
>
> PRINTED RESULTS:
> ________________
>
> Input:
> "field1","field2","field3",
> "field1","field2","field3","",
> "field1","field2","field3",
> "field1","field2","field3","field4",
>
> Output:
> "field1","field2","field3","",
> "field1","field2","field3","",
> "field1","field2","field3","",
> "field1","field2","field3","field4",
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 15 Aug 2000 04:51:12 GMT
From: jamesk5674@my-deja.com
Subject: Re: RegExp Puzzle
Message-Id: <8nai7v$60p$1@nnrp1.deja.com>
The most elegant reply yet.
Thanks Uri.
In article <x7og2vxjo8.fsf@home.sysarch.com>,
Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "j" == jamesk5674 <jamesk5674@my-deja.com> writes:
>
> j> "field1","field2","field3",
> j> "field1","field2","field3","",
> j> "field1","field2","field3",
> j> "field1","field2","field3","field4",
>
> j> The file will contain at least 3 fields and may or may not
contain a
> j> 4th field.
>
> j> What I need is for all rows to have 4 fields after the solution
is
> j> applied. If the 4th field is not there, I need to append --
"", -- to
> j> the record.
>
> if you don't have internal quotes, then this will do:
>
> $line .= '"",' if $line =~ tr/"// == 6 ;
>
> uri
>
> --
> Uri Guttman --------- uri@sysarch.com ----------
http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX
Consulting
> The Perl Books Page ----------- http://www.sysarch.com/cgi-
bin/perl_books
> The Best Search Engine on the Net ----------
http://www.northernlight.com
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 14 Aug 2000 23:09:38 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: RegExp Puzzle
Message-Id: <3998DEA2.1BA069D0@stomp.stomp.tokyo>
Oh look, Supernews is running backwards in time now...
jamesk5674 wrote:
> I can be pretty stubborn when I want to figure out a problem
> like this. This will save me time tommorow at work and I thank you.
> Godzilla! lectured:
umm.. hmm.. snipped
You have no conception of stubborn until you encounter
a barefoot, scrawny, hungry, penniless Oklahoma farm
girl turned fat, dumb and sassy English teacher.
I have more gitty up and gumption than all of you
boys here, combined, and, still quite capable of
breaking and training a green stubborn Missouri Mule
to a step-in harness plow. Gee! Haw! Gitty up you
stupid smelly mule.
Mr. Rosler posted some halfway decent regex solutions
for you, although slower than my method. Why figure
when it's done figured?
Godzilla!
------------------------------
Date: Mon, 14 Aug 2000 22:33:05 -0700
From: "Jesse Heffinger" <jheffinger@ipivot.com>
Subject: regular expression help
Message-Id: <sphl5taokn970@corp.supernews.com>
I have a string I would like to parse into substrings using the whitespace
as the delimiter as long as the whitespace is not within double quotes.
ie.
$line = "a = \" two \" and b=\" three \"";
@tokens = split /regexpr/, $line;
desire output:
@tokens->[0]: a
@tokens->[1]: =
@tokens->[2]: " two "
@tokens->[3]: and
@tokens->[4]: b=" three "
I'm having a hard time coming up with an expression to ignore the
whitespaces inside the quotations. Any suggestions?
-Jesse
------------------------------
Date: Mon, 14 Aug 2000 22:01:01 -0700
From: stevel@bluetuna.com (Steve Leibel)
Subject: Re: Socket hang, any ideas???
Message-Id: <stevel-1408002201010001@192.168.100.2>
In article <8n9u02$nvr$1@nnrp1.deja.com>, krpotter@co.douglas.or.us wrote:
> $sockaddr = 'S n a4 x8';
> $AF_INET = 2;
> $SOCK_STREAM = 1;
> $proto = 6;
>
Just an idle thought. Are those the right constants for NT?
------------------------------
Date: Tue, 15 Aug 2000 04:59:44 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Substituting newlines for HTML equivalent
Message-Id: <399acdb8.2722079@news.newsguy.com>
Larry Rosler <lr@hpl.hp.com> wrote:
>Keith Calvert Ivey <kcivey@cpcug.org> says...
>> $field =~ s/\n\n/<P>/g;
>> $field =~ s/\n/<BR>/g;
>
>Though the specification is inadequate, perhaps three or more newlines
>should be replaced by just <P>, not by a sequence of <P><BR> or <P><P>,
>etc.
Probably so.
>Also, for the sake of a human using a browser to look at the HTML
>source, I would leave a newline in place.
Normally I'd agree, but the original poster did say "the form
puts the info in a pipe-delimited text file, which I later split
on pipes and newlines", so I thought it better not to leave
newlines in the data.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: Tue, 15 Aug 2000 05:45:08 GMT
From: johnvert@my-deja.com
Subject: Re: tag parsing.
Message-Id: <8nald4$825$1@nnrp1.deja.com>
Could you please clarify what you mean by ``consistently changing your
parameters with each response provided''? I have no idea what you
mean. The only mistake I've made in this thread was posting the post
more than once, which happened accidently. If I did anything else wrong
I'd like to know. But please, before throwing accusations around, at
least tell me what it is that you mean.
thanks,
-- john
In article <39984F11.95A39D3@stomp.stomp.tokyo>,
"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote:
> johnvert@my-deja.com wrote:
>
> > Thank you for your unpolite but useful response.
>
> You mistake rudeness for a matter-of-fact
> attitude on my part. I afforded you help,
> for free, and my help is afforded under
> rules set by me, being free help which
> uses up a portion of my Life's remaining
> time. My time is precious. I just gave
> some of my Life to you.
>
> You have a well earned reputation for
> consistently changing your parameters
> with each response provided. This annoys
> me. Deal with it.
>
> This is no Beggar's Banquet.
>
> Godzilla!
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 15 Aug 2000 05:30:58 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Updating flat text file problem
Message-Id: <399cd45a.4420384@news.newsguy.com>
musicfan <musicfan@punitiveart.com> wrote:
>The error I get in the debugger is:
>
>invalid type in pack: '1' at line 22
Presumably that's referring to this line:
>$buffer = pack($username, $password, $clickthrough);
$username is an unusual name for a pack template.
Perhaps you're missing something?
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
------------------------------
Date: 15 Aug 2000 05:24:52 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: XML::DOM question
Message-Id: <8nak74$g6$1@slb6.atl.mindspring.net>
F. Geeb (no_spam_frage@post1.tele.dk) wrote:
: What would be the fastest way to navigate through a xml-document to a
: node with an attribute which is unique in this document (id-number eg:
: ... <text id="21"> ...)?
If you need to use standard DOM nodes, use XML::XQL. If you can stand to
work with a simpler tree-structured representation of your document, use
XML::XPath, which will probably be faster.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4018
**************************************