[11660] in Perl-Users-Digest
Perl-Users Digest, Issue: 5261 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 30 18:03:57 1999
Date: Tue, 30 Mar 99 15:01:41 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 30 Mar 1999 Volume: 8 Number: 5261
Today's topics:
one liner to remove nth occurrence of a character dboude@my-dejanews.com
Re: one liner to remove nth occurrence of a character (Tad McClellan)
One liner to remove the nth occurrence dboude@my-dejanews.com
Re: One liner to remove the nth occurrence (Greg Bacon)
Re: Perl DBI 'crypt' not available <gellyfish@gellyfish.com>
Re: Perl not running correctly (Tad McClellan)
Re: Perl question (Tad McClellan)
Re: Perl script goes zombie, help! mtaylor@cybernet.com
Problems writing to a file brackett@pobox.com
Re: Question: Odd If-Else problem. (Jack Applin)
Re: strange ERROR mssg <droby@copyright.com>
Syntax error in embedded foreach loops <grichard@uci.edu>
Re: Syntax error in embedded foreach loops <tbriles@austin.ibm.com>
Re: Syntax error in embedded foreach loops (Tad McClellan)
Re: use strict (Tad McClellan)
Re: What does this variable mean? (Tad McClellan)
Win32::Internet FTP question <adwats@spaceweb.com>
Winnipeg.pm meeting (Randy Kobes)
XML-Parser: dealing with predefined entities (Jed Parsons)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 30 Mar 1999 21:40:53 GMT
From: dboude@my-dejanews.com
Subject: one liner to remove nth occurrence of a character
Message-Id: <7drgd3$8md$1@nnrp1.dejanews.com>
Hi all. I need a little help with the appropriate line that will remove the
3rd occurrence of a double quote from each line of a file. I'm somewhat
familiar with Perl, being more successful at making Franken-scripts from
others input than making my own from scratch. If anyone could help me out
with this, I would appreciate it greatly.
Thanks.
Doug Boude :0)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 30 Mar 1999 11:38:47 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: one liner to remove nth occurrence of a character
Message-Id: <nmuqd7.9t.ln@magna.metronet.com>
dboude@my-dejanews.com wrote:
: Hi all. I need a little help with the appropriate line that will remove the
: 3rd occurrence of a double quote from each line of a file. I'm somewhat
: familiar with Perl, being more successful at making Franken-scripts from
: others input than making my own from scratch. If anyone could help me out
: with this, I would appreciate it greatly.
Please do not post the same question multiple times in
different threads.
s/([^"]*"[^"]*"[^"]*)"/$1/; # delete the third double quote char
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Mar 1999 21:36:14 GMT
From: dboude@my-dejanews.com
Subject: One liner to remove the nth occurrence
Message-Id: <7drg4d$8h7$1@nnrp1.dejanews.com>
If anyone is able, could you help me with the proper RE that will remove the
3rd occurrence of a double quote within a string? For some reason, my log
files are generated with an extra quote within each line, and it kills
AccessWatch. So, I need to strip it out. Currently using a VB utility I
wrote, but I think Perl would be a better way to go. I'm somewhat familiar
with it, but haven't done anything too extravagant besides modifying existing
scripts slightly. Please email me with any suggestions. Thank you very much.
Doug Boude :0)
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 30 Mar 1999 22:39:41 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: One liner to remove the nth occurrence
Message-Id: <7drjrd$8gk$2@info2.uah.edu>
In article <7drg4d$8h7$1@nnrp1.dejanews.com>,
dboude@my-dejanews.com writes:
: If anyone is able, could you help me with the proper RE that will
: remove the 3rd occurrence of a double quote within a string?
Well, I don't know about proper regular expression, but this works:
my $hit = 0;
$str =~ s/"/++$hit == 3 ? '' : '"'/ge;
Too bad there's no Prologish cut for /g. :-(
Greg
--
Today's agenda: Tug on Superman's cape, spit into wind, pull mask off Lone
Ranger, mess with Jim.
-- Ed Dravecky III
------------------------------
Date: 30 Mar 1999 21:38:43 -0000
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl DBI 'crypt' not available
Message-Id: <7drg93$fu$1@gellyfish.btinternet.com>
On Tue, 30 Mar 1999 13:10:46 -0600 Nelson Thompson wrote:
> In moving from perl 5.004 to Perl-DBI (based upon 5.004),
> the 'crypt' function no longer works.
> Attempting to use the function generates the error message"
>
> "The crypt() function is unimplemented due to excessive paranoia"
>
> Question 1: how can I re-install crypt() ??
>
> Question 2: why the paranoia; why was crypt() removed from Perl-DBI ??
>
I have never run into Perl-DBI but I guess it is a perl with the DBI
module statically linked in. Your only option to get crypt would be
to compile using a C library that has a crypt.
>From the perldiag manpage:
The crypt() function is unimplemented due to excessive
paranoia
(F) Configure couldn't find the crypt() function on
your machine, probably because your vendor didn't
supply it, probably because they think the U.S.
Government thinks it's a secret, or at least that they
will continue to pretend that it is. And if you quote
me on that, I will deny it.
/J\
--
Jonathan Stowe <jns@gellyfish.com>
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
------------------------------
Date: Tue, 30 Mar 1999 11:02:54 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl not running correctly
Message-Id: <ejsqd7.lo.ln@magna.metronet.com>
Joe Clark (jclark@asterion.com) wrote:
: Using SCO Unix server with Perl installed, when I call my Perl script from a
: browser, it simple brings up the Perl script source into my browser window
: without running the script.
You don't have a Perl problem.
You have a server configuration or CGI problem.
You have landed in the wrong newsgroup.
: Any ideas?
Ask in a newsgroup related to the problem that you are having:
comp.infosystems.www.authoring.cgi
comp.infosystems.www.servers.unix
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Mar 1999 10:53:30 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Perl question
Message-Id: <q1sqd7.lo.ln@magna.metronet.com>
Jack Schlotthauer (jacks@cybersource.com) wrote:
: When someone hits the enter key they send both a newline and
: a return.
... or just a return ...
... or just a newline.
It depends on what OS is being used.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Mar 1999 20:59:10 GMT
From: mtaylor@cybernet.com
Subject: Re: Perl script goes zombie, help!
Message-Id: <7drduo$6c4$1@nnrp1.dejanews.com>
After having Perl execute the command, do a "wait()", or "waitpid()"
on the PID of the spawned process. It will cause the perl program to
wait for the child process to terminate, and thereby getting around
the zombie state (a zombie is a process that is completed who's parent
didn't wait for them).
In article <7djrj2$220$1@gellyfish.btinternet.com>,
Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On Sat, 27 Mar 1999 20:59:43 +0100 Vanja Bertalan wrote:
> > What I'm trying to do is web based interface 4 my intranet users to be
> > able to dial-up the internet.
> > After all the testing which goes well I need to fire something like "ifup
> > ppp0" for example. The command executes but the program becomes zombie,
> > and occasionally kills apache...which is not good, right.
> > After firing "ifup..." I need to run additionall tests on ifconfig and ps
> > to figure out when is the connection established but that's out of
> > question because you can't talk to zombie :(
> > I tried with system, exec, backticks --- same result.
> > If you need additionall info, just name it, I'm out of ideas.
>
> Of course this has nothing to do with Perl as far as I can see but if
> you are using 'pppd' then this should run a program 'ip_up' after the
> network is established - mine is written in Perl and does one or two
> useful things - there will also be an 'ip_down' to help you clean up.
>
> /J\
> --
> Jonathan Stowe <jns@gellyfish.com>
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
> Hastings: <URL:http://www.newhoo.com/Regional/UK/England/East_Sussex/Hastings>
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 30 Mar 1999 21:17:50 GMT
From: brackett@pobox.com
Subject: Problems writing to a file
Message-Id: <7drf1l$7eo$1@nnrp1.dejanews.com>
Can someone tell me what I'm doing wrong with the following code? I'm reading
from one file, grabbing some data from the web according to the thing read,
and then writing the result to another file.
Should be straightforward, right? Well, it's not working -- and what's worse,
it works intermittently. FWIW, I'm running under Windows.
use LWP::Simple;
use URI::URL;
use strict -w;
open (DATA,">>newdata")
or die "Couldn't open floatdata for writing: $!\n";
open (INDICES,"data.txt")
or die "Couldn't open data.txt for reading: $!\n";
while (defined ($main=<INDICES>)) {
chomp ($main);
$first = substr($main,0,1);
my $url = url("http://www.foobar.com/$first/$main.html");
my $content = get($url);
$content =~ m/Stuff<\/td><td width="12%" align=right><tt>(.*?)<small>
(.*?)<\/small>/;
print DATA "$main,$1,$2\n";
}
close (INDICES);
close (DATA);
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 30 Mar 1999 22:20:06 GMT
From: neutron@fc.hp.com (Jack Applin)
Subject: Re: Question: Odd If-Else problem.
Message-Id: <7drimm$sg1$1@fcnews.fc.hp.com>
Ed (euston@mindspring.com) wrote:
> The problem I'm having is that the print immediately after the delete
> prints fine, but nothing else will print,
if (defined($class{$title})) {
delete($class{$title});
print qq|
<h3> $title deleted #3.
|;
if (!exists($class{$title})) {
print qq|
<h3> $title deleted.
|;
}
else {
print qq|
<h3> $title delete unsuccesful.
|;
}
print qq|
<h3> I just skipped the if - else.
|;
}
When I run it, it of course prints nothing, because $class{$title} is
not defined. If you want help, give us a COMPLETE PROGRAM that fails.
Simplify it as much as you can. I'll bet that you'll figure out the
problem during the simplification.
> The problem section is included below.
I'm not convinced of that. You're the one with the problem, you see,
so we can't trust your ability to figure out where the problem is.
-Jack Applin
neutron@fc.hp.com
http://www.geocities.com/HotSprings/6789/
------------------------------
Date: Tue, 30 Mar 1999 20:55:21 GMT
From: Don Roby <droby@copyright.com>
Subject: Re: strange ERROR mssg
Message-Id: <7drdnk$68h$1@nnrp1.dejanews.com>
In article <3700E063.786313FB@atmm.nl>,
Marc Bakker <mbakker@atmm.nl> wrote:
> Hi all
>
> I got this error message upon compiling (perl -c) my code:
>
> Illegal character \015 (carriage return) at get_top_ten.pl line 2.
> (Maybe you didn't strip carriage returns after a network transfer?)
Usually this means you didn't strip carriage returns after a network transfer.
>
> I see nothing unusual at line 2 - and yes, there is a CR.
That CR is something unusual.
>
> What does it mean?
>
You need to get rid of those carriage returns.
More help on interpreting error messages can be found in the perldiag
documentation, available on your local system if it's installed properly, and
at http://language.perl.com/newdocs/pod/perldiag.html as well.
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Tue, 30 Mar 1999 13:56:51 -0800
From: "Gabriel Richards" <grichard@uci.edu>
Subject: Syntax error in embedded foreach loops
Message-Id: <7drh5b$m5@news.service.uci.edu>
I'm new to Perl.
My code is generating the following syntax errors:
syntax error in file listings.cgi at line 32, next 2 tokens "$i @keywords"
syntax error in file listings.cgi at line 36, next 2 tokens "}"
syntax error in file listings.cgi at line 41, next 2 tokens "}"
syntax error in file listings.cgi at line 47, next token "}"
The following are the respective lines and some of the context:
sub getrecords {
#stuff
while (<DBASE>) {
($id,$keywordstring,$name,$sponsor,$award,$eligibility,$due,
$Contactn,$Contactp,$add1,$add2,$city,$state,$zip,$phone,$email,$web,$info)=
split("\t", $_);
@keywords = split (/ /, $keywordstring);
$counter = 0;
foreach $i @keywords { #line 32
foreach $j @request {
if ($j eq $i) { $counter += 1}
}
} #line 36
if ($counter = $#request + 1) {
#do stuff
} #line 41
}
} #line 47
------------------------------
Date: Tue, 30 Mar 1999 16:30:53 -0600
From: Tom Briles <tbriles@austin.ibm.com>
Subject: Re: Syntax error in embedded foreach loops
Message-Id: <3701509D.8E430E7C@austin.ibm.com>
Gabriel Richards wrote:
> I'm new to Perl.
>
> My code is generating the following syntax errors:
>
> syntax error in file listings.cgi at line 32, next 2 tokens "$i @keywords"
> syntax error in file listings.cgi at line 36, next 2 tokens "}"
> syntax error in file listings.cgi at line 41, next 2 tokens "}"
> syntax error in file listings.cgi at line 47, next token "}"
<snipped some>
> foreach $i @keywords { #line 32
> foreach $j @request {
<snipped some more>
Using the "-w" flag would have given additional clues. All of the gurus will
advise you to use it. So do I... :-)
Check out the syntax for the "foreach" command:
perldoc perlsyn
The POD (Perl On-line Documentation) is an invaluable resource. Always go
there first. To learn your way around it, start with:
perldoc perldoc
perldoc perltoc
- Tom
------------------------------
Date: Tue, 30 Mar 1999 11:40:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Syntax error in embedded foreach loops
Message-Id: <jpuqd7.9t.ln@magna.metronet.com>
Gabriel Richards (grichard@uci.edu) wrote:
: I'm new to Perl.
: My code is generating the following syntax errors:
: syntax error in file listings.cgi at line 32, next 2 tokens "$i @keywords"
: foreach $i @keywords { #line 32
foreach wants parenthesis around the LIST:
foreach $i (@keywords) {
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Mar 1999 11:18:45 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: use strict
Message-Id: <5htqd7.lo.ln@magna.metronet.com>
dpdq@my-dejanews.com wrote:
: The following code
: use strict;
: $a = 1;
: print "$a\n";
: works on my Ultra5 and Linux machines, both running perl5.
: As I understand, it should not work. Anybody know why?
$a and $b are the special "sorting" global variables.
Try chosing any variable name other than those.
: Email appreciated since I don't check newsgroup much.
Too bad. You might not see the answer then...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Mar 1999 11:13:21 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: What does this variable mean?
Message-Id: <17tqd7.lo.ln@magna.metronet.com>
solidice@my-dejanews.com wrote:
: Or can someone give me a link with a description of all
: the CGI script variables?
The Common Gateway Interface (CGI) is an _interface_, not
a programming language.
It has no variables.
A programming language that is often chosen for CGI applications
is Perl.
Perl lets you make up your own variable names.
Whoever wrote that code chose the name. It is not part of
any Standard or Specification.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 30 Mar 1999 16:43:11 -0500
From: "Andy Watts" <adwats@spaceweb.com>
Subject: Win32::Internet FTP question
Message-Id: <lGbM2.399$eJ.75931@news.shore.net>
I have a question, what would make the following code work? I'm trying to
upload to a NT server and nothing ever seems to be either read, or sent at
all.
------------------------------
use Win32::Internet();
$Bytes = 0;
$File = "c:\\temp\\map.txt"; # Drive path and file on local system
$Filename = "map.txt";
$Destination = "v:\\dr\\virtual_html\\incoming"; # Drive path on remote
system
$DestFile = "$Destination$Filename";
$INET = new Win32::Internet();
$result = $INET->FTP($FTP, "www.xxx.com", "userid", "pass");
$FTP->Ascii();
$FTP->Put($File, $DestFile);
$FTP->Close();
$INET->OpenURL($URL, "http://www.xxx.com/Incoming");
----------------------------------
Any thoughts or clues to this? Any help will be appreciated... as I am
fairly new to the use of this module.
Andy Watts
------------------------------
Date: 30 Mar 1999 22:16:21 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Winnipeg.pm meeting
Message-Id: <slrn7g2jt9.4lh.randy@theory.uwinnipeg.ca>
Hi,
The next meeting of the Winnipeg perl monger's group will
be Wednesday, March 31 at 8:30 PM in Applebee's in the Grant
Park Plaza. Hope to see you there.
--
Best regards,
Randy Kobes
Physics Department Phone: (204) 786-9399
University of Winnipeg Fax: (204) 774-4134
Winnipeg, Manitoba R3B 2E9 e-mail: randy@theory.uwinnipeg.ca
Canada http://theory.uwinnipeg.ca/
------------------------------
Date: 30 Mar 1999 22:41:14 GMT
From: jed@socrates.berkeley.edu (Jed Parsons)
Subject: XML-Parser: dealing with predefined entities
Message-Id: <7drjua$raf$1@agate.berkeley.edu>
Howdy-ho,
How does one deal with entities like &#amp; and &#quot; with the XML Parser
module?
If one were to define entities using <!ENTITY thingy "replacement">,
where would one put those definitions?
Many thanks,
Jed
--
Jed Parsons: ``Lingua balbus, hebes ingenio
Harpsichordist, Classicist, Homebrewer. Viris doctis sermonem facio.''
mailto:jed@socrates.berkeley.edu -- Archipoeta
http://www.OCF.Berkeley.EDU/~jparsons/
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 5261
**************************************