[16398] in Perl-Users-Digest
Perl-Users Digest, Issue: 3810 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 26 14:10:33 2000
Date: Wed, 26 Jul 2000 11:10:22 -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: <964635022-v9-i3810@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 26 Jul 2000 Volume: 9 Number: 3810
Today's topics:
Making and extracting from XML-like string <Sasa.Danicic@eurodyn.com>
Re: Making and extracting from XML-like string (Mark W. Schumann)
Re: NetBIOS/nbname ??? (John Stanley)
Re: No Data from Database (Mark W. Schumann)
Re: or die not working <bart.lateur@skynet.be>
output of "system" <stefanp@mediaaktiv.de>
Re: output of "system" <aqumsieh@hyperchip.com>
Re: output of "system" (matt venn)
Re: output of "system" (Steve Leibel)
Re: Outputing CSV?? nobull@mail.com
parsing a string that is a directory path. <joeschmoe@aol.com>
PATCH: AI::NeuralNet::BackProp v0.42 <jdb@wcoil.com>
pattern match <webmaster@ej-sunglasses.com>
Re: pattern match (Mark W. Schumann)
Re: pattern match <jimmy.lantz@ostas.lu.se>
Re: Perhaps a dumb question... <beanNObeSPAM@agentkhaki.com.invalid>
Re: perl reg. ex. problem (matt venn)
Re: Perl Scripts served by NT IIS4 / ActivePerl 5.6 cau <gregory_griffiths@cargill.com>
Re: Perl sequivallent for tidy (HTML fixup program)? (Frans la Cour)
Re: perl v. tcl <ivler@basecamp1.netquest.net>
perplexing problem - bug in perl?, looking for suggesti <mckim@bandersnatch.lerc.nasa.gov>
Re: perplexing problem - bug in perl?, looking for sugg nobull@mail.com
Re: perplexing problem - bug in perl?, looking for sugg (Mark W. Schumann)
Re: perplexing problem - bug in perl?, looking for sugg (Neil Kandalgaonkar)
Re: pos() bug? nobull@mail.com
reg exp is driving me crazy <pjakobs@wt.net>
Re: reg exp is driving me crazy <aqumsieh@hyperchip.com>
Search Question ?? <lenny123@redhotant.com>
Re: Search Question ?? (Mark W. Schumann)
SQL USE Keyword in DBI <etienno@my-deja.com>
Re: SQL USE Keyword in DBI (NP)
SSI <kc7gza@yahoo.com>
Re: Suggestion for syntax change <keithmur@mindspring.com>
Re: Suggestion for syntax change <lr@hpl.hp.com>
Re: This is driving me crazy!! (Mark Badolato)
Re: Warnings and undefs <mjcarman@home.com>
Re: Was Why won't "use strict;" work? (BUCK NAKED1)
Re: When to use for and foreach? <stevenjm@telisphere.com>
Re: When to use for and foreach? (Craig Berry)
Re: Why use anonymous? (Nobody)
Re: Why won't "use strict;" work? (BUCK NAKED1)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 26 Jul 2000 18:37:28 +0300
From: Sasa Danicic <Sasa.Danicic@eurodyn.com>
Subject: Making and extracting from XML-like string
Message-Id: <397F05B8.49DF4BE5@eurodyn.com>
Hi,
I 've have to use an output made by some database query and to create a
XML-like string:
<PERSON>
<JOE>field_1</JOE>
<MARY>field_2</MARY>
...
<STEVE>field_n</STEVE>
</PERSON>
<EDUCATION>
<STUDENT>student_name</STUDENT>
<PROFESSOR>professor_name</PROFESOR>
....
<SCHOOL>school_name</SCHOOL>
</EDUCATION>
On the other way, I've need to extract field_1, field_2,...,
student_name, professor_name, school_name from already crated XML-like
string.
Have you got some idea about this?
It is important that all these XML stuffs are STRINGS.
------------------------------
Date: 26 Jul 2000 13:05:25 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Making and extracting from XML-like string
Message-Id: <8ln5ol$1bu@junior.apk.net>
In article <397F05B8.49DF4BE5@eurodyn.com>,
Sasa Danicic <Sasa.Danicic@eurodyn.com> wrote:
>I 've have to use an output made by some database query and to create a
>XML-like string:
>
><PERSON>
><JOE>field_1</JOE>
><MARY>field_2</MARY>
>...
><STEVE>field_n</STEVE>
></PERSON>
><EDUCATION>
><STUDENT>student_name</STUDENT>
><PROFESSOR>professor_name</PROFESOR>
>....
><SCHOOL>school_name</SCHOOL>
></EDUCATION>
>
>On the other way, I've need to extract field_1, field_2,...,
>student_name, professor_name, school_name from already crated XML-like
>string.
I would start by downloading and reading the documentation for
Bundle::XML from CPAN.
>Have you got some idea about this?
Well, what have you tried, and what part of it doesn't work yet?
>It is important that all these XML stuffs are STRINGS.
Yes, that's part of the idea of XML.
If you have a question about Perl, or how to do something specific with
Perl and XML, I'm sure several people here would be happy to help you.
------------------------------
Date: 26 Jul 2000 17:22:21 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: NetBIOS/nbname ???
Message-Id: <8ln6od$56s$1@news.NERO.NET>
In article <397EC7F5.2A6B11E3@patriot.net>, H C <carvdawg@patriot.net> wrote:
>What do you mean, "there is no Windows thing to ask for it"?
Very simple. The system whose name he is asking for has no Windows thing
to ask. The system whose name he is asking for is not in any Windows
thing, since it does not run Windows.
------------------------------
Date: 26 Jul 2000 12:58:09 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: No Data from Database
Message-Id: <8ln5b1$rr1@junior.apk.net>
In article <8llaog$hs1$1@pinto.cobaltgroup.com>,
Mark Watters <mwatters@cobaltgroup.com> wrote:
>My cgi (is supposed to)first query a db, then display on a webpage:
>
>&queryDb;
>&displayResults;
>
>sub queryDb {
> #stores info in scalar or array
>}
>sub displayResults {
> #takes info, puts in appropriate columns puts on page
>}
>
>The problem is this, when I run from the command line 'perl myprogram.cgi"
>the output is the correct html, but when I access it from the web page the
>db info doesn't show up. Anyone?
Yes. Start with the "Idiot's Guide to Solving Perl CGI Problems." No,
really, it helps a lot and isn't insulting in tone.
It's easy to find. Go to any decent search engine and query for "IDIOT
PERL CGI". Run through the suggestions there and let us know if those
help. And if you're still stuck, you'll probably at least have a really
specific question when you come back.
Good luck.
------------------------------
Date: Wed, 26 Jul 2000 16:43:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: or die not working
Message-Id: <cp4unssg8v3mt5sqqjo05aidaee2cvj089@4ax.com>
The WebDragon wrote:
> | near the top of your program. If that doesn't work, try adding
> |
> | BEGIN { open STDERR, ">&STDOUT" }
> |
> | instead. This will redirect the error stream to go to the browser.
>
>but this has me somewhat confused.. is there a spot in the
>perlfaq/perldocs that deals with redirecting output ?
Look at the implementation of CGI::Carp, and you'll see this trick being
used. Search for "sub carpout", starting at line 292 in the version I
currently am using.
The perlfunc entry for open() includes:
You may also, in the Bourne shell tradition, specify an EXPR
beginning with `'>&'', in which case the rest of the string is
interpreted as the name of a filehandle (or file descriptor, if
numeric) to be duped and opened. You may use `&' after `>',
`>>', `<', `+>', `+>>', and `+<'. The mode you specify should
match the mode of the original filehandle.
--
Bart.
------------------------------
Date: Wed, 26 Jul 2000 18:54:40 +0200
From: Stefan <stefanp@mediaaktiv.de>
Subject: output of "system"
Message-Id: <397F17D0.98972F12@mediaaktiv.de>
How can I access the output of a "system" statement in a perl programm:
for example
#!/usr/bin/perl
system("echo hi");
i want to show this output "hi" on the webpage ...
------------------------------
Date: Wed, 26 Jul 2000 17:06:02 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: output of "system"
Message-Id: <7ahf9chldv.fsf@merlin.hyperchip.com>
Stefan <stefanp@mediaaktiv.de> writes:
> How can I access the output of a "system" statement in a perl
> programm:
By reading the FAQs. In perlfaq8:
Why can't I get the output of a command with system()?
--Ala
------------------------------
Date: Wed, 26 Jul 2000 17:27:11 GMT
From: matt@NOSPAMraas.screaming.net (matt venn)
Subject: Re: output of "system"
Message-Id: <397f1f4c.29974250@news.ntlworld.com>
if you want to write to webpages, read up on the CGI modules
matt
------------------------------
Date: Wed, 26 Jul 2000 10:41:26 -0700
From: stevel@bluetuna.com (Steve Leibel)
Subject: Re: output of "system"
Message-Id: <stevel-2607001041570001@192.168.100.2>
In article <397F17D0.98972F12@mediaaktiv.de>, Stefan
<stefanp@mediaaktiv.de> wrote:
> How can I access the output of a "system" statement in a perl programm:
> for example
>
>
>
> #!/usr/bin/perl
>
> system("echo hi");
>
>
You can't do that with system(), but you can use backticks, like this:
$response = `echo hi';
If you expect a lot of output and you want to do line-by-line processing,
you can also pipe the output back to your program using open(), for
example:
use FileHandle;
my $fh = new FileHandle;
open($fh, "ls -al |")
|| die "can't open";
while (<$fh>) {
print;
}
Steve L
------------------------------
Date: 26 Jul 2000 17:50:32 +0100
From: nobull@mail.com
To: rand_mcneely@yahoo.com
Subject: Re: Outputing CSV??
Message-Id: <u9snswj0o7.fsf@wcl-l.bham.ac.uk>
"Rand" <rand_mcneely@yahoo.com> writes:
> Subject: Re: Outputing CSV??
This has nothing to do with what you are actually asking.
Please put at least as much thought into asking your questions as you
are expecting people to put into answering them. Not everyone is too
lazy to do a Usenet search before they post a question, and these
people will be impeded if you don't make the effort to give a helpful
subject line.
The question you are actually asking is: "How can a script on a web
server suggest a default save-as filename to a web client?"
This question really has very little to do with Perl, however it has
been discussed here at length many times. There are a lot of very bad
answers given and a lot of name calling.
Rather than re-igniting the same old flame-war please re-visit these
disussions in the privacy of your own web browser.
BTW: The "right" answer is to use the "filename" attribute in the
"Content-disposition" HTTP header. However HTTP clients are not
obliged to to take note of this and at least one popular browser
does not.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 26 Jul 2000 10:39:11 -0700
From: Joe Schmoe <joeschmoe@aol.com>
Subject: parsing a string that is a directory path.
Message-Id: <fk6unsgt9fe1mb7soe62ro0k5opnqgef28@4ax.com>
I have a CGI scripts that is suppose to list the content of a
directory on the local computer. That's easy, it's something even I
can do.
But I also have to create a "up" button to get the web page to display
the contents of the directory one step above. For example, if the CGI
is displaying the contents of
"/home/john/notes/class1"
It also needs to display a link capable of go showing
"/home/john/notes"
I'm looking for a way to take the string
"/home/john/notes/class1"
and be able to change it to
"/home/johm/notes/class1"
So it looks for the last slash "/" and remove it and everything after
it. I think regexp may be the way to go, but I don't know how to go
about it.
Or maybe there are better methods, any help is greatly appreciated.
------------------------------
Date: 26 Jul 2000 17:21:08 GMT
From: "Josiah Bryan" <jdb@wcoil.com>
Subject: PATCH: AI::NeuralNet::BackProp v0.42
Message-Id: <8ln6m4$7hn$0@206.230.71.51>
Greets,
Version 0.42, the patch for the first public release which was version 0.40.
It includes several updates and fixes, including more 'intelligent'
learning, smaller memory size, actual loading and saving of network,
internal support for strings as network
maps and targets, and integrated support for direct loading of PCX-format
bitmap files (pure-perl loading).
I finally finished patching up version 0.40 and released it at v0.42. It is
in the
CPAN under:
$CPAN/authors/id/J/JB/JBRYAN/AI-NeuralNet-BackProp-0.42.zip
or downloadable right now from my website:
http://www.josiah.countystart.com/modules/AI/cgi-bin/rec.pl
Do checkout all the new examples...11 of them to be exact. Let me know what
you think of the changes, as well as the string and pcx support ideas.
--
Josiah Bryan
VP of Product Development
TDCJ, Inc.
"Anything is possible."
vp@tdcj.com
http://www.josiah.countystart.com/
Tel: 937.316.6256
------------------------------
Date: Wed, 26 Jul 2000 11:24:13 -0500
From: "Jim" <webmaster@ej-sunglasses.com>
Subject: pattern match
Message-Id: <397f111e$0$8317$7f8943f3@newsreader.visi.com>
I have info in a file set as so,
someinof | moreinfo | evenmore | more |
I want to assign each variable a name ( $a= someinfo, $b= moreinfo ect..)
So I need to read the file until the pipe ( | ) is found, name it, continue
reading until the next pipe is found- name that something else ect...
I know there has to be an easy way to do this using pattern matching, but I
am new to Perl and cant figure out how to do it. Thanks for any help
Jim
------------------------------
Date: 26 Jul 2000 13:02:55 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: pattern match
Message-Id: <8ln5jv$f0@junior.apk.net>
In article <397f111e$0$8317$7f8943f3@newsreader.visi.com>,
Jim <webmaster@ej-sunglasses.com> wrote:
>I have info in a file set as so,
>
> someinof | moreinfo | evenmore | more |
>
>I want to assign each variable a name ( $a= someinfo, $b= moreinfo ect..)
>So I need to read the file until the pipe ( | ) is found, name it, continue
>reading until the next pipe is found- name that something else ect...
>I know there has to be an easy way to do this using pattern matching, but I
>am new to Perl and cant figure out how to do it. Thanks for any help
$ perldoc -f split
------------------------------
Date: Wed, 26 Jul 2000 19:54:06 +0200
From: Jimmy Lantz <jimmy.lantz@ostas.lu.se>
Subject: Re: pattern match
Message-Id: <397F25BE.11481918@ostas.lu.se>
Even better, pattern memory.
you should look up on Regular expressions and pattern memory, by
using ().
more info at
www.codebits.com/p5be/ch10.cfm
good luck
Jimmy.
"Mark W. Schumann" wrote:
>
> In article <397f111e$0$8317$7f8943f3@newsreader.visi.com>,
> Jim <webmaster@ej-sunglasses.com> wrote:
> >I have info in a file set as so,
> >
> > someinof | moreinfo | evenmore | more |
> >
> >I want to assign each variable a name ( $a= someinfo, $b= moreinfo ect..)
> >So I need to read the file until the pipe ( | ) is found, name it, continue
> >reading until the next pipe is found- name that something else ect...
> >I know there has to be an easy way to do this using pattern matching, but I
> >am new to Perl and cant figure out how to do it. Thanks for any help
>
> $ perldoc -f split
------------------------------
Date: Wed, 26 Jul 2000 08:08:50 -0700
From: bean <beanNObeSPAM@agentkhaki.com.invalid>
Subject: Re: Perhaps a dumb question...
Message-Id: <00ee4bd4.c7ba1c66@usw-ex0101-005.remarq.com>
*groan*
I knew it was going to be something simple and quite stupid on
my part. Thanks for the help.
Oh, one more thing. I'm pretty much new to this whole Usenet
thing (I've been using RemarQ.com to post to this group for
about a month now) and I decided that I wanted to use software
rather than RemarQ. So I downloaded Gravity. Here's my question:
whenever I retrieve headers, it only gets headers for postings
that are two or more days old... is that because of the news
server I'm using, and if so, does anyone know of a free news
server I can use that will update much more often than that?
Thanks.
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Wed, 26 Jul 2000 17:25:37 GMT
From: matt@NOSPAMraas.screaming.net (matt venn)
Subject: Re: perl reg. ex. problem
Message-Id: <397f1e9f.29801241@news.ntlworld.com>
if you are just removing the last line of a file, then maybe perl isnt
the best solution.
using sed would solve any memory problems too.
laters
matt
------------------------------
Date: Wed, 26 Jul 2000 15:56:03 +0100
From: "Greg Griffiths" <gregory_griffiths@cargill.com>
Subject: Re: Perl Scripts served by NT IIS4 / ActivePerl 5.6 cause Netscape to display "File - Save As" Dialog rather than viewing Perl output
Message-Id: <8lmu66$44p$1@mercury.cargill.com>
you need to tie the .pl extentsion into IIS so that it treats it as an
application code and not as a file to download, this is the problem, also
your ENCTYPE attribute is not required in all servers as this is the default
transaction type.
john wooding <john@wwit.freeserve.co.uk> wrote in message
news:8lmf5j$iok$1@newsg3.svr.pol.co.uk...
> This is a problem of interaction between NT IIS 4 and Netscape 4.5 or
4.7
> :
>
> When the following form header is included and the form submitted Netscape
> inquires how
> mlogin2.pl should be saved. This does not happen when IIS4 is serving to
IE4
> or 5 and does not
> happen when other servers are serving to Netscape 4.5/4.7 (these are the
> only two versions we currently have
> tried).
>
> <form name="g" action="/cgi-bin/mlogin2.pl" method="GET"
> ENCTYPE="application/x-www-form-urlencoded">
>
> This problem occurs with all script references. When NT is setup to
> recognise .cgi is to be processed by Perl
> then this also happens with .cgi references.
>
>
> Any suggestions?
>
>
>
>
------------------------------
Date: 26 Jul 2000 17:53:05 GMT
From: flc@metier.dk (Frans la Cour)
Subject: Re: Perl sequivallent for tidy (HTML fixup program)?
Message-Id: <8F7DCFFD8flcmetierdk@212.242.40.196>
posting.account@lynxview.com (William Herrera) wrote in
<397da662.460115870@news.rmi.net>:
>Hi, I am currently looking at running some program HTML output (from a
>text or MS word to HTML translator) through tidy via system() in a perl
>program. Is there a native perl equivalent to the tidy program for
>cleaning up HTML?
http://www.fourmilab.ch/webtools/demoroniser/
was made with that purpose
by
John Walker
http://www.fourmilab.ch/
It might be just what you are looking for.
Rgds
Frans
------------------------------
Date: Wed, 26 Jul 2000 15:50:04 GMT
From: "J.M. Ivler" <ivler@basecamp1.netquest.net>
Subject: Re: perl v. tcl
Message-Id: <MMDf5.17739$G7.619327@news-west.usenetserver.com>
In comp.lang.tcl Peter Tutko <pmtutko@worldnet.att.net> wrote:
> I think that many web hosting services are unaware that Tcl is probably
> already installed on their systems, and they remain ignorant of how to deal
> with it. Ultimately, if Verio will not upgrade, I will have to de-tune my
> scripts or consider re-writing in Perl or even find another web hosting
> service.
If the ISP won't support Tcl, change ISPs. For $450/mo you can lease a
sparc 20 with Tcl on it and apache with mod-tcl (if you want that, or you
can just go with AOLServer -- it's your box!). Now the ISP may not be as
big a verio (in the case above it isn't), but there are many ISPs that
want your business and are willing to work with you rather than fighting
you. :-)
------------------------------
Date: 26 Jul 2000 11:15:09 -0400
From: Jim McKim <mckim@bandersnatch.lerc.nasa.gov>
Subject: perplexing problem - bug in perl?, looking for suggestions
Message-Id: <y7gbszk6hz6.fsf@bandersnatch.lerc.nasa.gov>
While incrementally developing a script, I started getting the
diagnostic:
syntax error at ./monitor.pl line 235, at EOF
Execution of ./monitor.pl aborted due to compilation errors.
Missing right curly or square bracket at ./monitor.pl line 235, at end of line
I've seen this message many times, since I'm sometimes forgetful about
closing parenthesis. First step was to go back and inspect the newly
added section of code. Couldn't see any problems - it was a simple
short (three line) modification.
Next step: comment out the new code (hatchmark each line) and
rerun. Here's where it gets strange. The diagnostic did not go away as
expected. In other words, perl's behavior is (in this case) being
affected by comment lines.
Next step: revert, remove the new lines of code. Diagnostic goes away.
This is perplexing. Perl's interpretation of a script shouldn't be
affected by comment lines.
A couple additional points - the error line given in the diagnostic is
itself in the middle of a block of comments, which doesn't make
a lot of sense. The line number given (235) is not at EOF either,
there are about eight more lines in the file.
Also perhaps worth mentioning - the problematic script is a fragment
of code dynamically loaded in (via require). The problematic script
itself loads additional fragments as it runs. The overall script
dynamically loads much during its operation.
Removing some number of the comment lines makes the diagnostic go
away, doesn't seem to matter which lines, though. Guessing: possibly
some internal perl interpreter table is silently overflowing during
execution of this script. Reducing the size of the script avoids the
problem (doesn't help me, though).
I'm looking for suggestions for a fix or workaround if anyone else has
run into a like problem - tweaking perl's internals if necessary. Any
input is welcome.
--
Jim McKim
NASA Glenn Research Center
------------------------------
Date: 26 Jul 2000 17:53:14 +0100
From: nobull@mail.com
Subject: Re: perplexing problem - bug in perl?, looking for suggestions
Message-Id: <u9k8e8j0jp.fsf@wcl-l.bham.ac.uk>
Jim McKim <mckim@bandersnatch.lerc.nasa.gov> writes:
> While incrementally developing a script, I started getting the
> diagnostic:
>
> syntax error at ./monitor.pl line 235, at EOF
> Execution of ./monitor.pl aborted due to compilation errors.
> Missing right curly or square bracket at ./monitor.pl line 235, at end of line
>
> This is perplexing. Perl's interpretation of a script shouldn't be
> affected by comment lines.
OK we can't see the code so we're stuck with guessing.
A line that starts with a hash is not a comment if it's inside a
quoting construct. If it's inside an interpolating quoting construct
then it can cause syntax errors.
print <<END
# This is not a comment
# This is not only not a comment but a ${ syntax error! }
END
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: 26 Jul 2000 13:09:40 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: perplexing problem - bug in perl?, looking for suggestions
Message-Id: <8ln60k$31n@junior.apk.net>
In article <y7gbszk6hz6.fsf@bandersnatch.lerc.nasa.gov>,
Jim McKim <mckim@bandersnatch.lerc.nasa.gov> wrote:
>Next step: comment out the new code (hatchmark each line) and
>rerun. Here's where it gets strange. The diagnostic did not go away as
>expected. In other words, perl's behavior is (in this case) being
>affected by comment lines.
Highly unlikely.
>Next step: revert, remove the new lines of code. Diagnostic goes away.
>
>This is perplexing. Perl's interpretation of a script shouldn't be
>affected by comment lines.
You're right. It shouldn't. More likely you are not running the
script you think you are running.
Perchance is this a CGI script? I wonder whether the server is
caching the script itself (not its output), so your changes might
not be visible to browsers right away. Just a thought.
>A couple additional points - the error line given in the diagnostic is
>itself in the middle of a block of comments, which doesn't make
>a lot of sense. The line number given (235) is not at EOF either,
>there are about eight more lines in the file.
See, that's really ringing alarm bells. Are you REALLY REALLY SURE
you are running the same script that you are modifying?
>I'm looking for suggestions for a fix or workaround if anyone else has
>run into a like problem - tweaking perl's internals if necessary. Any
>input is welcome.
Eh. If you have to go that far to fix the kind of behavior you're
talking about, Perl sucks too badly to be useful for you. Since I
know Perl isn't that badly implemented, I doubt that an internals
hack is what you need.
If my hint to check up on your assumptions solves your problem, great.
If not, please come back with more specifics including:
* operating system environment
* is this a CGI thing?
* Perl version, and perl version
------------------------------
Date: Wed, 26 Jul 2000 17:09:51 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: perplexing problem - bug in perl?, looking for suggestions
Message-Id: <8ln5k3$fc5$1@localhost.localdomain>
In article <y7gbszk6hz6.fsf@bandersnatch.lerc.nasa.gov>,
Jim McKim <mckim@bandersnatch.lerc.nasa.gov> wrote:
>While incrementally developing a script, I started getting the
>diagnostic:
>
> syntax error at ./monitor.pl line 235, at EOF
> Execution of ./monitor.pl aborted due to compilation errors.
> Missing right curly or square bracket at ./monitor.pl line 235, at end of line
>
>Removing some number of the comment lines makes the diagnostic go
>away, doesn't seem to matter which lines, though.
This is pretty odd-sounding. Is there any way you can post this code
for us to have a look? It sounds like it's part of some gigantic
system, but can you isolate the part that does this?
>Guessing: possibly
>some internal perl interpreter table is silently overflowing during
>execution of this script. Reducing the size of the script avoids the
>problem (doesn't help me, though).
I'm inclined to believe it's some weird parsing thing, rather than
an overflow in perl, but if you can post the code here or on a web page
the world can have a crack at solving the problem.
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: 26 Jul 2000 17:50:47 +0100
From: nobull@mail.com
Subject: Re: pos() bug?
Message-Id: <u9puo0j0ns.fsf@wcl-l.bham.ac.uk>
"The Binskter" <jarjar@starwars.com> writes:
> I have written a small piece of code to extract some info from a .html page.
> The information comes from a comment
> <!-- and --> within the page. If I write out the code in the main procedure
> I get the correct information, if I use it in a sub, then I get nothing.
> pos returns nothing. The code is supposed to return each position that the
> comment starts...
Sounds very like a thread within the last week describing a bug in
5.4 that was fixed in 5.5. What version are you using?
> Here is the code:
Please always make the effort top and tail your code that we can run
for ourselves to reproduce the bug without each having to do what you
could not be bothered to do. This also means that you can run the
actual code you post to be sure that it does in fact run and does in
fact illustrate the behaviour in question (you'd be supprised how
often people get it wrong).
#!/usr/bin/perl -w
use strict; # Always do this in examples
my $strSearch = "foo <!-- foo <!-- foo"; # Set input
my @strStart;
$strSearch =~ m/<!--/g;
while (pos($strSearch))
{
push (@strStart,pos($strSearch));
$strSearch =~ m//;
}
print "@strStart\n"; # Print output
__END__ # Make end of example explict
Works fine on 5.00503.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Wed, 26 Jul 2000 12:17:54 -0500
From: Paula Jakobs <pjakobs@wt.net>
Subject: reg exp is driving me crazy
Message-Id: <397F1D42.5FF43606@wt.net>
I have a file with a line like this:
EXCLUDE: 215001, 1194001, 1194002
I'm trying to put all of the numbers into a list. I don't know in
advance how many numbers there will be. I am trying to solve that by
doing this:
open(ITEMS, "$itemlist");
while(<ITEMS>){
if(/^EXCLUDE|INCLUDE: (.*)/){
print "test: $1";
@items=split(',', $1);
}
}
close ITEMS;
But it's not working. I've tested what's in $1 with a print statement
and $1 is empty. It only prints "test: " I at least know that it is
finding the right line because that part wouldn't have printed either,
but why is $1 empty? I've tried other things like: /^EXCLUDE|INCLUDE:
(\d+)/ just to see if I can get anything to appear in $1 but it always
comes up empty.
I'm going crazy trying to figure it out.
Paula
------------------------------
Date: Wed, 26 Jul 2000 17:26:26 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: reg exp is driving me crazy
Message-Id: <7aem4ghkfw.fsf@merlin.hyperchip.com>
Paula Jakobs <pjakobs@wt.net> writes:
> I have a file with a line like this:
> EXCLUDE: 215001, 1194001, 1194002
>
> I'm trying to put all of the numbers into a list. I don't know in
> advance how many numbers there will be. I am trying to solve that by
> doing this:
>
> open(ITEMS, "$itemlist");
> while(<ITEMS>){
> if(/^EXCLUDE|INCLUDE: (.*)/){
You are having precedence problems here. Change that to:
if (/^(?:EXCLUDE|INCLUDE): (.*)/) {
> print "test: $1";
> @items=split(',', $1);
Perhaps you also want to push everything on @items:
push @items => split /,/, $1;
> }
> }
> close ITEMS;
--Ala
------------------------------
Date: Wed, 26 Jul 2000 16:11:31 -0700
From: "Paul Moseley" <lenny123@redhotant.com>
Subject: Search Question ??
Message-Id: <397f0008$1@news.jakinternet.co.uk>
I have a search engine at www.marketchat.co.uk its a financial site that
searches for stockmarket websites in the uk and us. Im not an expert
on CGI/Perl prgramming and got the program from a website. It works
well, Would it be very hard to change the script to include on Add your
URL to have a radio button with US Site / UK Site and then on the search
display a Flag for the right country, or is this to hard to do , just a
thought
Paul
p.moseley@btinternet.com
------------------------------
Date: 26 Jul 2000 13:02:24 -0400
From: catfood@apk.net (Mark W. Schumann)
Subject: Re: Search Question ??
Message-Id: <8ln5j0$5f@junior.apk.net>
In article <397f0008$1@news.jakinternet.co.uk>,
Paul Moseley <lenny123@redhotant.com> wrote:
>I have a search engine at www.marketchat.co.uk its a financial site that
>searches for stockmarket websites in the uk and us. Im not an expert
>on CGI/Perl prgramming and got the program from a website. It works
>well, Would it be very hard to change the script to include on Add your
>URL to have a radio button with US Site / UK Site and then on the search
>display a Flag for the right country, or is this to hard to do , just a
>thought
Oh, no, that wouldn't be hard at all.
What was your Perl question?
------------------------------
Date: Wed, 26 Jul 2000 16:40:14 GMT
From: Etienne Laverdiere <etienno@my-deja.com>
Subject: SQL USE Keyword in DBI
Message-Id: <8ln49d$qig$1@nnrp1.deja.com>
Does anyone knows ho to translate a USE "databaseName" SQL statement in
DBI?
Thanks
Etienne Laverdiere
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 26 Jul 2000 17:00:56 GMT
From: nvp@spamnothanks.speakeasy.org (NP)
Subject: Re: SQL USE Keyword in DBI
Message-Id: <cPEf5.378456$MB.5972192@news6.giganews.com>
Wed, 26 Jul 2000 16:40:14 GMT, Etienne Laverdiere <etienno@my-deja.com> wrote:
: Does anyone knows ho to translate a USE "databaseName" SQL statement in
: DBI?
Unless I'm misunderstading your query -- the answer is to install the
appropriate DBD module (is this MS-SQL?). After you've installed the
DBD module, read the docs; this will tell you how to connect to the
database. And no, I don't think that you'll have to do use a 'USE
databaseName' statement at all.
--
Nate II
------------------------------
Date: Wed, 26 Jul 2000 08:33:33 -0600
From: Aaron Andersen <kc7gza@yahoo.com>
Subject: SSI
Message-Id: <397EF6BC.BA0AFECA@domain.com>
I'm sure this question has been asked hundreds of times, but I can't
seem to find the answer so I will ask it again.
On my web site my pages use SSIs to pull in some information. However,
my search cgi generates its own output, so even if I put SSIs in that
output they are never processed.
I need to figure out how to put the equivlent of a #include SSI and a
#exec SSI in a perl script. If I could have the file from the #include
and the output from the #exec end up two variables (e.g., $include and
$exec) that would be perfect.
Any ideas?
Aaron
------------------------------
Date: Wed, 26 Jul 2000 11:24:39 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Suggestion for syntax change
Message-Id: <397F10C7.8BE8C5B@mindspring.com>
jason wrote:
>
[cut]
> but Bart's argument about the fact that before any evaluation of '..' is
> done in list index any negative arguments are just converted to relative
> indices from the end of the list is compelling
>
> the main part of the behaviour that I want consistent is that '..'
> counts down when the first argument is larger than the second (and both
> are positive) .. so that things like
>
> (localtime)[2..1]
>
> can be done .. as long as the special treatment is only for negative
> indices then I think it would work ok .. AND .. I think it's more
> consitent than what I originally proposed .. here's why...
>
> essentially we're just debating about evaluation order .. -1 always
> means the index of the last element .. so if [2..-1] equates to [2,1,0,-
> 1] then it means that the '..' is done first and THEN the '-1' is given
> it's special meaning
>
> the other (and I'm now thinking MORE consitent behaviour) is for '-1' to
> be interpreted first and THEN the '..' is evaluated so you get [2..-1]
> equating to [2..4] for a 5 element list .. then the '..' is done and you
> get [2,3,4]
>
> I see that as very useful .. AND (thanks to Bart's explanation) more
> consistent
I absolutely agree: the '-1' should be evaluated first, and I'm glad
Bart's shown you the light.
Now, what should be the interpretation of:
[2..-2]
in the case of a 3-element list? That comes out to [2..1], so should we
yield a two-element list ([2] and [1]), or the empty list? You would
probably say the former. I'm still not sure I like that: see below.
>
> of course - out of a list index context '-1' has no special meaning ..
> so
>
> for(2..-1)
>
> would equate to
>
> for(2,1,0,-1)
>
This is one thing that troubles me, and what I was getting at with all
my verbiage in my last post. It's a change from current behavior.
But what bugs me the most, and that I can imagine biting someone, is
this kind of behavior, back in the list case:
Imagine that you were trying to take successively smaller slices from a
list (not such an unrealistic thing to do), starting at a certain point,
going to the end of the list, then end-1, etc., terminating when you
reach a certain end point. This would seem a pretty good approach:
my $start = 2;
my $last_end = &some_calculation;
for ($end = -1; $end >= $last_end; $end--) {
@myslice = @mylist[$start..$end];
}
Now, for $end >= 2 things are fine. But imagine that $last_end turns
out to be 0. As soon as $end < 2, by my interpretation @myslice starts
turning into the empty list. By yours, we get slices with elements
[2,1] and [2,1,0].
I *think* my interpretion would be the desired behavior in most cases,
but would like to hear from others.
This sort of thing is probably why Pascal has 'to' and 'downto' keywords
for use in loops.
It's also interesting that by changing this syntax I could have
simplified my 'for' loop above.
By your interpretation:
for ($end..$last_end)
would count down nicely.
But if $last_end had happened to come out *larger* than $end, we'd be
counting up, which is probably (*I* think) not what we'd want in this
case, though it would be current behavior.
I would suggest that something like:
for ($end.-.$last_end)
would be better, to explicitly specify descent. Maybe we need three
operators:
'..' (jason-style wraparound)
'.+.' (current '..' behavior: ascent only)
'.-.' (descent only)
The more I look at it, the more I like it. I *do* think it's good.
(Anyone catch the song-lyric reference?)
But since '..' for wraparound would change the current behavior of for
loops, maybe some of these would be better:
'...' or '.?.' or ' to ' (jason-style wraparound)
'..' or '.+.' or ' upto ' (current '..' behavior: ascent only)
'.-.' or ' downto ' (descent only)
Wouldn't:
for ($last downto $first) { }
be a sweet thing to be able to do? :-)
------------------------------
Date: Wed, 26 Jul 2000 09:57:02 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Suggestion for syntax change
Message-Id: <MPG.13e8b83d7eee659398abeb@nntp.hpl.hp.com>
In article <397F10C7.8BE8C5B@mindspring.com> on Wed, 26 Jul 2000
11:24:39 -0500, Keith G. Murphy <keithmur@mindspring.com> says...
...
> Wouldn't:
>
> for ($last downto $first) { }
>
> be a sweet thing to be able to do? :-)
This thread has been going on for a long time, and I have been away for
much of it and haven't caught up. So please forgive my presumption in
wondering whether the following has been considered adequately:
for (reverse $first .. $last) { }
At the cost of one more (efficient) operation, doesn't this accomplish
all that the proposed new syntax is inted to provide?
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 26 Jul 2000 17:40:31 GMT
From: mbadolato@cybernox.com (Mark Badolato)
Subject: Re: This is driving me crazy!!
Message-Id: <8F7D63F75mbadolatocybernoxcom@206.165.3.70>
ivolla@my-deja.com wrote in <8lm4mt$3cs$1@nnrp1.deja.com>:
>I am VERY new to Perl and so far am up to speed
>except one thing. When I try to execute a script
>it shows up for about 1/2 a second then it
>disappears.
Running from command line is one way to solve that "problem".
--mark
------------------------------
Date: Wed, 26 Jul 2000 10:58:04 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Warnings and undefs
Message-Id: <397F0A8C.387C86BE@home.com>
"Dr. Peter Dintelmann" wrote:
>
> warnings can be swichted on/off using $^W.
> Thus try
>
> {
> $^W = 0; # disable warnings in this code block
> <... your code>
> }
>
No, that disables *all* warnings! You must localize the change to the
block:
{
local $^W = 0;
# code that squawks here
}
-mjc
------------------------------
Date: Wed, 26 Jul 2000 11:47:57 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Was Why won't "use strict;" work?
Message-Id: <22696-397F163D-18@storefull-248.iap.bryant.webtv.net>
I sent a lengthy post from my whataman@home.com addy with 5 questions,
and I don't see the post. Did I do the unthinkable, and accidentally
email it to one of you? Hard to tell, my isp @home really has problems
with their mail servers being out alot.
Regards,
Dennis
------------------------------
Date: Wed, 26 Jul 2000 17:22:26 GMT
From: Steven May <stevenjm@telisphere.com>
Subject: Re: When to use for and foreach?
Message-Id: <397F1E17.1B7A7148@telisphere.com>
Bernard El-Hagin wrote:
>
> On Wed, 26 Jul 2000 05:39:43 GMT, Steven May <stevenjm@telisphere.com>
> wrote:
> >Abigail wrote:
> >>
> >> Reini Urban (rurban@sbox.tu-graz.ac.at) wrote on MMDXX September MCMXCIII
> >> in <URL:news:397e202d.213784325@news>:
> >> )) Jim Cook wrote:
> >> )) >What are the opinions here? When would it be better to use 'for' or
> >> )) >'foreach?'
> >> ))
> >> )) trust the docs.
> >>
> >> 'for' is more than twice as fast [1] as 'foreach'.
> >>
> >> [1] to type
> >>
> >> Abigail
> >
>
> <snipped silly benchmarks>
hummph! :-)
> >Am I missing something totally obvious?
> >
> >I'm all ears....
>
> Yeah, you're missing Abigail's joke. Read it again carefully and notice
> the [1]...
Oh duh! I was looking at that too, but didn't meke the connection...
Goodness, I need to get out more.
thanks,
Steve
------------------------------
Date: Wed, 26 Jul 2000 17:35:25 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: When to use for and foreach?
Message-Id: <snu8atp3j128@corp.supernews.com>
Steven May (stevenjm@telisphere.com) wrote:
: Abigail wrote:
: > 'for' is more than twice as fast [1] as 'foreach'.
: >
: > [1] to type
:
: Ahhh... when????...
: I always thought they were pretty close to the same, given
: the same basic operation. This one got me going a bit, so
: I ran some benchmarks on it...
Um, dude? She was *joking*. Read her footnote again. 'for' and
'foreach' are literally synonyms, which compile into utterly identical
code. The presence of both in the language is pure syntactic sugar, like
the y/tr thing.
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Turning and turning in the widening gyre
| The falcon cannot hear the falconer." - Yeats, "The Second Coming"
------------------------------
Date: 26 Jul 2000 16:24:58 GMT
From: nobody@contract.East.Sun.COM (Nobody)
Subject: Re: Why use anonymous?
Message-Id: <8ln3cq$44r$1@eastnews1.east.sun.com>
In article <MPG.13e952d8398d5c9a98968c@news>,
jason <elephant@squirrelgroup.com> wrote:
>Nobody writes ..
>>In article <397CA69B.A9495E2D@west.net>, John Callender <jbc@west.net> wrote:
>>>awilcox@contract.East.Sun.COM wrote:
>>>>
>>Hmmm. I've built these kinds of structures before, but never thought of them
>>as 'anonymous', since they were simply part of a larger structure that did
>>have a name. The example that the interview twit used was a single unnamed
>>hash...
>
<snip>
>
>#!/usr/bin/perl -w
>use strict;
>
># create an anonymous hash and assign it's reference to $h
>my $h = { name => 'jason king'
> , email => 'elephant@squirrelgroup.com'
> , newsgroup => 'c.l.p.misc'
> };
>
Okay, I think my problem is probably more a semantic one than a
Perl one. I would never use the term 'anonymous' to refer to the
above, though I do see where it's coming from. To me, that's just
indirect addressing a.k.a. references a.k.a. pointers (my first
programming language back in 1982 was Pascal :-)
I've run into this 'language barrier' before. I learned most of my
programming/design skills from the engineering side, where they eschewed
computer-science/theory terminology in favor of more hardware-oriented
terms (ie., addressing instead of referencing, interrupts instead of
events, etc...) Of course, they probably did it on purpose, since those
two departments had something of a holy war going on while I was attending
college. Neither thought the other should have anything to do with programming
or, god forbid, systems administration. Hence, I was clueless when asked about
things like semaphores and polymorphism, but once those terms were defined for
me, it was "Oh yeah, I've done that, but we callled it..."
Anita
------------------------------
Date: Wed, 26 Jul 2000 11:24:39 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Why won't "use strict;" work?
Message-Id: <22695-397F10C7-49@storefull-248.iap.bryant.webtv.net>
tadmc@metronet.com (Tad=A0McClellan) wrote:
>I want to know his experience
>level so that I will know how to
>approach giving him answers.
I thought my experience level (or lack thereof) was obvious. Anyhow,
here is where I am. I've learned a little abot scalars, arrays,
conditionals, string matching, and now a bit about file I/O.
I've only written one script before this one, and it was modified from
someone else's, and did not use strict.
Someone in another group posted a basic counter that I tried to use. It
keep resetting, so I did some research and discovered that it needed to
be locked.
Later, I discovered that the codes were quite sloppy, and that many
things in it were missing. There's more, but that should tell you enough
about the "volumes" I have to learn.
I do realize that I bit off more than I could chew AFTER I got into it.
I thought a counter would be simpler, but didn't know. Being an
compulsive(anal retentive?) perfectionist, I have a problem stopping
until something is almost perfect. Not good, IMO, as too much time is
spent that should probably be put into other venues with higher
priorities.
So, that's where I stand "status quo".
Regards,
Dennis=A0=A0=A0=A0
------------------------------
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 3810
**************************************