[10043] in Perl-Users-Digest
Perl-Users Digest, Issue: 3636 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Sep 4 14:05:52 1998
Date: Fri, 4 Sep 98 11:00:22 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 4 Sep 1998 Volume: 8 Number: 3636
Today's topics:
Re: #!/usr/bin/perl not working? (Randy Kobes)
Re: #!/usr/bin/perl not working? (Karlon West)
[Q] Copying directories <ramune@zarathustra.calstatela.edu>
Re: Beginner's question <aqumsieh@tigre.matrox.com>
Calling perl from html (Michael A. McGuire)
Re: Calling perl from html <cajun@expert.cc.purdue.edu>
Re: COBOL and Perl (Shaun C. Murray)
Re: creating directories <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: Error message.....Perl.exe did not produce a valid <Art.vanMeeteren@fmr.com>
Frames and CGI.pm: How to send output to two frames? <verzani@postbox.csi.cuny.edu>
Re: Frames and CGI.pm: How to send output to two frames <Tony.Curtis+usenet@vcpc.univie.ac.at>
help needed -> cgi-answer <georgjansen@sagja.com>
Re: help needed -> cgi-answer (Steve Linberg)
Help with regular expression nguyen.van@imvi.bls.com
Re: how does one charge credit cards online (Jay Flaherty)
HTML2PS: problem with JPEG files <yvan.vandenbogaerde@haven.antwerpen.be>
If/Then Statement <cajun@expert.cc.purdue.edu>
Re: Is perl millennium compliant ? (Craig Berry)
ISO C (YACC) to parse Perl data structures <glew@cs.wisc.edu>
Module expects file, have variable - solution w/o temp <paul@neolution.com>
Re: Module expects file, have variable - solution w/o t (Sean McAfee)
Re: or vs || with open function (Mike Wescott)
Re: Perl & Java - differences and uses <pats@acm.org>
Perl5.005_02 build: "Thread.xs", line 465: undefined sy <sobek@irit.fr>
Please help ! <rizwan.q@usa.net>
Re: regex word boundary question (M.J.T. Guy)
Re: Regexp to toggle a part of a string <jhi@alpha.hut.fi>
Re: Regexp to toggle a part of a string (Craig Berry)
Re: Search <perlguy@inlink.com>
Re: Trouble compiling Perl5.005_02: malloc.c <sobek@irit.fr>
Re: Why Perl ? (M.J.T. Guy)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 4 Sep 1998 16:08:25 GMT
From: randy@theory.uwinnipeg.ca (Randy Kobes)
Subject: Re: #!/usr/bin/perl not working?
Message-Id: <slrn6v04j6.don.randy@theory.uwinnipeg.ca>
On Fri, 04 Sep 1998 10:43:49 -0400, Dennis M. Parrott <dparrott@ford.com> wrote:
>Jeff Pinyan wrote:
>>
>> > Andrew Mulvey <triangle@iinet.net.au> wrote:
>> >
>> > I can easily run perl scripts I have written in Linux (RH5.0) by typing
>> > "perl exename" at the shell prompt but even if i start the script with
>> > #!/usr/bin/perl my script won't run simply by entering its name at the
>> > prompt (and yes i have set the file the script is saved in as executable
>> > by u, g and o). The perl exe is sitting in /usr/bin btw.
>>
>> It might be the curse of the screwy path.
>> Try typing ./exename instead of just exename. If that works, then that
>> means that for some fruity reason, the . directory is not in your path.
>> It needs to be added to your path.
>>
>depending on who set up the path for Andrew, it *may* have been left
>out on PURPOSE. I don't remember where I read it, but, there are some
>admins who consider having "." in the PATH as a security risk (and I
>may not have the whole story here either -- it may well relate to the
>position of "." in the PATH)
Hi,
Although not a perl question, the answer may be of interest ...
Having "." in your PATH open up one possibility of the following
scenario: suppose someone places an executable script in a
publicly-accessable directory like /tmp, calls it 'perl', and has
in it the action
rm -rf $HOME
A user working in /tmp, whose PATH searches "." before the
directory where the "real" perl resides, who then types
perl
will find the outcome not what she/he expected ... That is why
"." may have been removed from the PATH, or at least placed so
that "." is searched last.
--
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: 4 Sep 1998 17:09:16 GMT
From: karlon@bnr.ca (Karlon West)
Subject: Re: #!/usr/bin/perl not working?
Message-Id: <6sp6rs$i7l@crchh14.us.nortel.com>
Randy Kobes (randy@theory.uwinnipeg.ca) wrote:
> On Fri, 04 Sep 1998 10:43:49 -0400, Dennis M. Parrott <dparrott@ford.com> wrote:
> >depending on who set up the path for Andrew, it *may* have been left
> >out on PURPOSE. I don't remember where I read it, but, there are some
> >admins who consider having "." in the PATH as a security risk (and I
> >may not have the whole story here either -- it may well relate to the
> >position of "." in the PATH)
> Hi,
> Although not a perl question, the answer may be of interest ...
> Having "." in your PATH open up one possibility of the following
> scenario: suppose someone places an executable script in a
> publicly-accessable directory like /tmp, calls it 'perl', and has
> in it the action
> rm -rf $HOME
> A user working in /tmp, whose PATH searches "." before the
> directory where the "real" perl resides, who then types
> perl
> will find the outcome not what she/he expected ... That is why
> "." may have been removed from the PATH, or at least placed so
> that "." is searched last.
Another reason for not having it in the path at all, is that other
commands could be located in the publically available directories:
commands such as "rolgin", and "ps-ef" no, I did not misspell those, but
I do all the time at the command line when I meant to type the real
thing: "rlogin" and/or "ps -ef". If I'm in a directory that has those
defined, who knows what I'll be running.
Karlon
------------------------------
Date: 4 Sep 1998 09:32:20 -0700
From: Graffiti <ramune@zarathustra.calstatela.edu>
Subject: [Q] Copying directories
Message-Id: <6sp4mk$h2v$1@zarathustra.calstatela.edu>
Hi all,
Is there a way to do something like:
use File::Copy;
move("/tmp/dir1","/tmp/dir2");
across filesystems? I need to move a directory from one
filesystem to another, and was wondering if there was an
easy way to do it. The above didn't work. It complained
of a cross-device link. :/
-- DN
------------------------------
Date: 04 Sep 1998 11:26:57 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Beginner's question
Message-Id: <x3y4sunaofy.fsf@tigre.matrox.com>
Kamran <kamrani@ifi.uio.no> writes:
>
> Hi
>
> How do I tell perl to extract text between to pattern encounter ?
Assuming you slurped in your whole file (or whatever part of it you
need) into a single scalar (complete with \n's and all) called $line,
you can do the following:
$pattern = "public";
$match = $line =~ /$pattern(.*?)$pattern/s;
> -------------
>
> Thanks in advance
>
> Kmaran
s/Kmaran/Kamran/;
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: Fri, 4 Sep 98 16:16:12 GMT
From: mcguirema@utk.edu (Michael A. McGuire)
Subject: Calling perl from html
Message-Id: <mcguirema.1255313412D@news.utk.edu>
I have a perl script that I want to run when my web page loads. I have not
been able to find out how to do this.
I have tried <!-- #exec cgi..... without success.
Thanks.
+-------------------------------------------+-----------------------------+
| Michael A. McGuire, (423) 974-1594 voice | There are more cockroaches |
| mcguirema@utk.edu (423) 974-4810 fax | than people in the world. |
| Unix Systems Group - (USG) | This does not make them a |
| University of Tennessee Knoxville | superior lifeform. |
+-------------------------------------------+-----------------------------+
| http://www.cas.utk.edu/CAS/CAS_sections/COS/Mac/ |
| http://www.public.usit.net/mcguire/ayso1266/ |
+-------------------------------------------+-----------------------------+
------------------------------
Date: Fri, 4 Sep 1998 11:30:26 -0500
From: "Jonathan M. Hartman" <cajun@expert.cc.purdue.edu>
To: "Michael A. McGuire" <mcguirema@utk.edu>
Subject: Re: Calling perl from html
Message-Id: <Pine.GSO.3.96.980904112934.23453E-100000@expert.cc.purdue.edu>
Your web server might not be set up to parse SSI's. View the HTML source,
and see if it spit the exec statement back out at you. If so, then it
isn't configured for it.
-Jon Hartman
On Fri, 4 Sep 1998, Michael A. McGuire wrote:
> I have a perl script that I want to run when my web page loads. I have not
> been able to find out how to do this.
>
> I have tried <!-- #exec cgi..... without success.
>
> Thanks.
>
> +-------------------------------------------+-----------------------------+
> | Michael A. McGuire, (423) 974-1594 voice | There are more cockroaches |
> | mcguirema@utk.edu (423) 974-4810 fax | than people in the world. |
> | Unix Systems Group - (USG) | This does not make them a |
> | University of Tennessee Knoxville | superior lifeform. |
> +-------------------------------------------+-----------------------------+
> | http://www.cas.utk.edu/CAS/CAS_sections/COS/Mac/ |
> | http://www.public.usit.net/mcguire/ayso1266/ |
> +-------------------------------------------+-----------------------------+
>
>
==============================================================================
||||||||"If you can't take the heat, STAY OUT OF THE FIREWALL!" -Me ||||||||||
==============================================================================
||Out the Token Ring, through the router, down the fiber, off another router,|
||||||||||| down the T1, past the firewall...nothing but Net.|||||||||||||||||
==============================================================================
------------------------------
Date: 4 Sep 1998 16:20:03 GMT
From: scm@enterprise.net (Shaun C. Murray)
Subject: Re: COBOL and Perl
Message-Id: <6sp3vj$ld4$1@news.enterprise.net>
In article <tgu32qv43y.fsf@noise.bsd.uchicago.edu>,
d-edwards@nospam.uchicago.edu says...
>
>Obviously if one doesn't know the syntax of a language, getting
>semantics out of a particular utterance in the language is going
>to be tricky; that doesn't seem to me to be peculiar to perl though.
Sure but designing a language that involves cryptic symbols which have to be
learned rather than english words seems a bit silly to me. COBOL isn't
prefectly natural but parsers weren't up to much back in the 1960's.
I'd hope that any modern language would have a better parser so you could
express yourself in a more naturalistic way.
>(I haven't understood any of the (really _very_ few) lines of COBOL
>I've seen; does that mean COBOL is bad, or just that I should learn
>COBOL syntax before trying to parse COBOL (for semantics)?)
I find that difficult to believe. I came to COBOL straight from BASIC and it
didn't take me very long to undertand how to lay out a program in the correct
sections. The actual syntax is simple. Usually you can just type what your
thinking and compile it straight away.
eg.
perform test-data until data-rec is true
move 10 to percentage
display "hello"
open input data-file
read data-record
at end
display "end of file"
not at end
add 1 to rec-no
end-read
close data-file
stop run
It's verbose but then so is English. The punctuation makes sense. No curley
braces, semi-colons or colons in sight. I don't want to learn shorthand as
only people who know shorthand can read it.
--
Shaun
scm@enterprise.net PGP Key available
------------------------------
Date: 04 Sep 1998 18:00:31 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: creating directories
Message-Id: <7xaf4f6f6o.fsf@salome.vcpc.univie.ac.at>
Re: creating directories, tripredacus
<tripredacus@earthling.net> said:
tripredacus> I'm just learning Perl, so please forgive my
tripredacus> ignorance.... Is there a Perl command that can
tripredacus> create subdirectories?
==> perldoc -f mkdir
==> perldoc File::Path;
tripredacus> If there is, can that command be fixed to CHMOD them too?
Nooo, you use `chmod' to chmod files.
==> perldoc -f chmod
(Would you use `vi' to chmod files? :-)
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Fri, 04 Sep 1998 12:38:59 -0400
From: Art vanMeeteren <Art.vanMeeteren@fmr.com>
Subject: Re: Error message.....Perl.exe did not produce a valid header
Message-Id: <35F017A3.595BE499@fmr.com>
I've narrowed it down to something very weird.....
It doesn't seem to be calling the required libraries correctly when it is
run with the web server.... here is the code sample.
( main.pl file )
#!/Perl/5.00502/bin/MSWin32-x86-object/perl
####################################################
require("library2.pl");
print "Content-type: text/html\n\n";
&httpHeader();
&httpFooter();
####################################################
(library2.pl file)
####################################################
sub httpHeader {
print "<HTML>
<HEAD>
Hello there did it work\n";
return 1;}
#####################################################
sub httpFooter {
print "</BODY>\n</HTML>\n";
return 1;}
#####################################################
1;
So when I run this in DOS... it works fine. But when I run it from the
Netscape 3.51 server.... it spits out:
[04/Sep/1998:10:07:12] failure: for host 172.22.13.190 trying to GET
/shell/Entrance.pl, cgi-parse-output reports: the CGI program
C:\Perl\5.00502\bin\MSWin32-x86-object\Perl.exe did not produce a valid
header (program terminated without a valid CGI header (check for core
dump or other abnormal termination)
As soon as I comment out the require command.... it works fine. Well...
obviously it can't include the library function....but... the file executes
none the less.
What the heck is causeing this....this is very frustrating because I have
soooo much other stuff to learn and get through to get bogged down by these
"features"... can anyone suggest a more effiicient tool to debug this stuff
with.
Art
Art vanMeeteren wrote:
> Hello.... I've been working on taking over some code for about 3 days
> now... and I'll have the code all set... run it in a DOS screen... and
> it produces the HTML code that I want... so then I load it on the server
> and run it and get this error message:
>
> [04/Sep/1998:10:07:12] failure: for host 172.22.13.190 trying to GET
> /shell/Entrance.pl, cgi-parse-output reports: the CGI program
> C:\Perl\5.00502\bin\MSWin32-x86-object\Perl.exe did not produce a valid
> header (program terminated without a valid CGI header (check for core
> dump or other abnormal termination)
>
> Its really starting to piss me off... cause after I run that
> application... I have another that is VERY simple... and it does the
> same thing... then I change a few line... add a comment or blank line...
> then it works again.... But I can't get the big app to work.
>
> Does anyone have a better way to check code or how do I debug this to
> get it to work.... or better yet... what the hell does this damn error
> messsage mean... I can't find it in any documentation.
>
> Thanks for your help.
>
> Art
------------------------------
Date: 04 Sep 1998 02:53:19 -0500
From: John Verzani <verzani@postbox.csi.cuny.edu>
Subject: Frames and CGI.pm: How to send output to two frames?
Message-Id: <m3ww7kuxe8.fsf@wiener.math.csi.cuny.edu>
Here's my problem:
I have a frameset containing 3 frames. One is a form which in turn
updates another frame. I would like to then update yet another frame
without the user having to do anything. I don't think this can be done
in HTML, so I'm looking for a perl solution. My script is using
CGI.pm. I thought I could do this with a combination of a fork and a
redirect command like this:
## do work...
if (fork) {
## update one frame
} else {
## update the next frame
$q->redirect(...)
}
I don't seem to be able to set a target parameter to the redirect and
consequently only the one frame is updated. Is there some other way to
get around this?
Many thanks
John Verzani
------------------------------
Date: 04 Sep 1998 18:05:28 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Frames and CGI.pm: How to send output to two frames?
Message-Id: <7x90jz6eyf.fsf@salome.vcpc.univie.ac.at>
Re: Frames and CGI.pm: How to send output to two frames?,
John <verzani@postbox.csi.cuny.edu> said:
John> Here's my problem:
John> I have a frameset containing 3 frames. One is a form
John> which in turn updates another frame. I would like to
John> then update yet another frame without the user having
John> to do anything.
The method `header()' lets you choose the -target frame.
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Fri, 04 Sep 1998 17:38:30 +0200
From: georgjansen <georgjansen@sagja.com>
Subject: help needed -> cgi-answer
Message-Id: <35F00964.873369A6@sagja.com>
I post my form from a frameset , and now I want to get the answer in
another frame.
Real stupid problem.
------------------------------
Date: Fri, 04 Sep 1998 13:09:03 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: help needed -> cgi-answer
Message-Id: <linberg-0409981309030001@projdirc.literacy.upenn.edu>
In article <35F00964.873369A6@sagja.com>, georgjansen
<georgjansen@sagja.com> wrote:
> I post my form from a frameset , and now I want to get the answer in
> another frame.
> Real stupid problem.
Perhaps. Why not ask in an html or cgi group?
_____________________________________________________________________
Steve Linberg National Center on Adult Literacy
Systems Programmer &c. University of Pennsylvania
linberg@literacy.upenn.edu http://www.literacyonline.org
------------------------------
Date: Fri, 04 Sep 1998 17:01:09 GMT
From: nguyen.van@imvi.bls.com
Subject: Help with regular expression
Message-Id: <6sp6cm$7v8$1@nnrp1.dejanews.com>
Hi Perl Gurus,
I have a list of access files which I pulled out from other place to the
place where my perl script runs. I successfully pull out these access files
to place and put this list of files in an array. I want to process these
files and redirect the output to one file (i.e this file containing all
patterns which I want to pull out from the array). The following is a example
of my access files. I want to pull out field 7 (i.e X?crno=7034572&mkt=****)
and field 11 to the rest (i.e "http://bellsouth.bigfoot.com/SEARCH"
"Mozilla/2.0 (compatible ; MSIE 3.02; Update a; AK; AOL 3.0; Windows 95)"). I
tried to do it but having problem with it. Can any one help me out? Thank in
advance.
Van Nguyen
152.163.195.181 - - [30/Jul/1998:00:01:07 -0400] "GET X?crno=7034572&mkt=****
HT TP/1.0" 200 14122 "http://bellsouth.bigfoot.com/SEARCH" "Mozilla/2.0
(compatible ; MSIE 3.02; Update a; AK; AOL 3.0; Windows 95)"
152.163.204.136 - - [30/Jul/1998:00:01:37 -0400] "GET / HTTP/1.0" 200 23641
"htt p://www.florida.com/realestate/cities.html" "Mozilla/2.0 (compatible;
MSIE 3.02; Update a; AOL 3.0; Windows 95)"
209.214.81.7 - - [30/Jul/1998:00:01:37 -0400] "POST / HTTP/1.0" 200 5587
"http:/ /yp.bellsouth.com/" "Mozilla/4.04 [en] (WinNT; I)"
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Fri, 04 Sep 1998 17:34:41 GMT
From: fty@utk.edu (Jay Flaherty)
Subject: Re: how does one charge credit cards online
Message-Id: <35f02471.193008246@alder>
On 4 Sep 1998 13:58:50 GMT, impactid@pantheon.yale.edu () wrote:
>hi all... i'm putting together a mini shopping site online
>but don't know how to take credit card numbers and charge
>them... i.e. after i get their cc number.. how do i intreface
>with the bank and deduct that amount from their account?
>how do i even validate that they're really who say who they
>are...
>
>thanks! (i'm on a unix - solaris2.5 platform if that matters)
>
>cwu@geocities.com
Check out cybercash - http://www.cybercash.com
jay
------------------------------
Date: 4 Sep 98 16:30:40 GMT
From: "Yvan Vandenbogaerde" <yvan.vandenbogaerde@haven.antwerpen.be>
Subject: HTML2PS: problem with JPEG files
Message-Id: <01bdd821$5b5af550$ff80800a@ahlan921>
Hello,
I'm trying to convert HTML to PS files with the html2ps (version 1.0b1)
script for Perl on Windows NT 4.0. All seems to work well except that I
always get an error message like:
Corrupt JPEG data: 1 extraneous bytes before marker 0xdb
Output file write error --- out of disk space?
The HTML file contains one or more inline JPEG images which are converted
with DJPEG. I've already tried other JPEG images with the same result and
converting the JPEG file with DJPEG on the command line works fine.
Maybe the second message is related to the first because I have plenty of
room left on my disk.
The text is converted to PS without problem but the image is only partially
converted.
Can someone tell me what I have done wrong or give me a clue ?
Yvan Vandenbogaerde
P.S. I'm running Perl 5.005_02 on Windows NT.
------------------------------
Date: Fri, 4 Sep 1998 11:28:24 -0500
From: "Jonathan M. Hartman" <cajun@expert.cc.purdue.edu>
Subject: If/Then Statement
Message-Id: <Pine.GSO.3.96.980904112626.23453D-100000@expert.cc.purdue.edu>
if (!open(MESSAGE, "/export/home/CAM/cam/rm/logs/$job_id"))
{$error = 'Couldn\'t open file log file!';}
Why won't the previous statement set the variable, when the file doesn't
exist?
-Jon
==============================================================================
||||||||"If you can't take the heat, STAY OUT OF THE FIREWALL!" -Me ||||||||||
==============================================================================
||Out the Token Ring, through the router, down the fiber, off another router,|
||||||||||| down the T1, past the firewall...nothing but Net.|||||||||||||||||
==============================================================================
------------------------------
Date: 4 Sep 1998 17:38:04 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Is perl millennium compliant ?
Message-Id: <6sp8hs$l60$1@marina.cinenet.net>
David Cantrell (NukeEmUp@ThePentagon.com) wrote:
: On 03 Sep 1998 17:43:43 -0400,
: Dean Pentcheff <dean2@mail.biol.sc.edu> enlightened us thusly:
: >Les George <georgelj@boat.bt.com> writes:
: >> Does snybody knwo if the current releases of perl have been certified
: >> for millennium compliance ?
: >
: >Hmmm... Let's see:
: [snip]
: > my(@date_sequence) = ( 991229, 991230, 991231, 000101 );
: [snip]
: > Bummer. Y2K failure ...
:
: Programmer error, not language error.
s/error/joke/;
$original_post .= ' :)';
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Fri, 04 Sep 1998 12:37:21 -0500
From: Andy Glew <glew@cs.wisc.edu>
Subject: ISO C (YACC) to parse Perl data structures
Message-Id: <35F02551.C4A2E123@cs.wisc.edu>
Brief
====
Does anyone have, in a convenient form, C or YACC that can parse Perl data
structures, specifically hashes { field1 => val1, field2 => val2 }
and arrays [ val0, val1, val2 ], and produce a fairly
conventional C data structure for these?
Background
=========
I am working with a moderately large C program, not written by me.
I want to save some data structures to a file, and then in a later run of the program
restore these data structures from the file. The data structures can structs and arrays,
but are strictly hierarchical.
This is the sort of thing that, in Perl, is a one liner, using Data::Dumper and eval.
Q: is there some fairly standard C tool that can accomplish this? I don't think
there is, although perhaps one could be written that looks at the data structure
declarations in the header files and generates the appropriate code.
Aside: C++ is not, unfortunately, an option. Besides, C++ doesn't get me too far
- I would still have to write the methods.
Since this is a programming task that is performed rather often, it occurs to me
that a solution more generic than the typical ad-hoc approach might be good.
My current mindset is to write to save/print-out routine by hand, customized,
and have it print out a fairly generic format such as Perl's array and hash notation.
And then to have a generic routine restore/read-in from the Perl syntax text data
structure, into a generic hash of arrays. Finally, I would have custom code copy
from the generic data structure read in to the custom C data structure (which is
rather closely tuned, used unions, etc., to conserve space)).
I.e. basically I am thinking just to borrow a Perl data structure lexer/parser
to read in, so I can through out all of the parsing stuff, and concentrate on the
data structure manipulations that are particular to my program.
However, if anyone has any better suggestions that solve my overall problem
- generic save/restore of arbitrary, already written, C data structures, that use
tricks such as unions, with the simplifying assumption of strict hierarchy, I'll
appreciate them.
---
Please respond to me by email, in addition, perhaps, to posting to these newsgroups
if the answer is worth sharing.
glew@cs.wisc.edu
------------------------------
Date: Fri, 04 Sep 1998 16:15:23 GMT
From: "paul" <paul@neolution.com>
Subject: Module expects file, have variable - solution w/o temp file?
Message-Id: <vmUH1.2324$lR.9309530@news21.bellglobal.com>
Hello all,
I have a little project using the Html::Parser
(http://theory.uwinnipeg.ca/CPAN/data/HTML-Parser/HTML/TokeParser.html)
I want to extract the URLs from a variable I have, for example $text. $text
is html and can include one or more links (<a href=address>description</a>).
I would like the output to look like this:
description (address)
description (address)
...
The TokeParser documentation looks very, very promising, with me being able
to do something like this to a file:
use HTML::TokeParser;
$p = HTML::TokeParser->new(shift||"file.html");
while (my $token = $p->get_tag("a")) {
my $url = $token->[1]{href} || "-";
my $text = $p->get_trimmed_text("/a");
print "$text ($url)\n";
}
The outstanding issue is, of course, that I don't have a file, I have a
variable.
The documentation is clear on the requirement for a file:
$p = HTML::TokeParser->new( $file );
The object constructor needs a file name or a reference to some file
handle object as argument. If a file name (plain scalar) is passed to the
constructor and the file can't be opened for reading, then the constructor
will return an undefined value.
Is there any way to use TokeParser with a variable instead of with a file?
Short of writing to a temporary file?
Thanks,
Paul
------------------------------
Date: Fri, 04 Sep 1998 17:30:29 GMT
From: mcafee@choplifter.rs.itd.umich.edu (Sean McAfee)
Subject: Re: Module expects file, have variable - solution w/o temp file?
Message-Id: <VsVH1.1047$F7.4360841@news.itd.umich.edu>
In article <vmUH1.2324$lR.9309530@news21.bellglobal.com>,
paul <paul@neolution.com> wrote:
>I have a little project using the Html::Parser
>(http://theory.uwinnipeg.ca/CPAN/data/HTML-Parser/HTML/TokeParser.html)
>I want to extract the URLs from a variable I have, for example $text. $text
>is html and can include one or more links (<a href=address>description</a>).
>I would like the output to look like this:
>description (address)
>description (address)
>...
>The TokeParser documentation looks very, very promising, with me being able
>to do something like this to a file:
[snip]
>The outstanding issue is, of course, that I don't have a file, I have a
>variable.
>Is there any way to use TokeParser with a variable instead of with a file?
>Short of writing to a temporary file?
A tied filehandle will do the trick. I checked out HTML::TokeParser, and
it only calls read() on the file or handle you pass it, so I rolled a tied
filehandle class which solves your problem:
----------------------------------------------------------------------
package ReadScalar;
sub TIEHANDLE {
my ($pkg, $scalar) = @_;
bless [ $scalar, 0 ], $pkg;
}
sub READ {
my ($self, $buf, $len, $offset) = ($_[0], \$_[1], @_[2,3]);
my $result = substr($self->[0], $self->[1], $len);
substr($$buf, $offset, $len) = $result;
$self->[1] += length $result;
length $result;
}
----------------------------------------------------------------------
(I was surprised to see that a module to do this isn't already on CPAN;
maybe I didn't look hard enough.)
Anyway, either put the above code in your program, or put it in a separate
file and use or require it, then do something like this:
$myhtml = "<html><head><title>PERL</title></head><body></body></html>";
tie *HTML, 'ReadScalar', $myhtml;
$p = new HTML::TokeParser(\*HTML);
while (my $token = $p->get_tag("a")) {
# ...
}
--
Sean McAfee | GS d->-- s+++: a26 C++ US+++$ P+++ L++ E- W+ N++ |
| K w--- O? M V-- PS+ PE Y+ PGP?>++ t+() 5++ X+ R+ | mcafee@
| tv+ b++ DI++ D+ G e++>++++ h- r y+>++** | umich.edu
------------------------------
Date: 04 Sep 1998 12:57:20 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
To: Liznet@cookwood.com
Subject: Re: or vs || with open function
Message-Id: <x4lnnz7r51.fsf@cygnus.ColumbiaSC.NCR.COM>
In article <35F00AE8.E644E3C9@cookwood.com> Liz Castro writes:
> On page 191 of the 2nd edition Camel, under the explanation for the open
> function, it says:
> "(And you must also be careful to use "or die" after the statement rather than
> "|| die", because the precedence of || is higher than list operators like open.)
> Throughout the 2nd edition Llama book, Schwartz consistently uses "|| die".
> And in all the scripts I've downloaded and looked over, they also use "||
> die".
> What's the deal?
The || statements also parenthesized the arguments to open,
open(DEVNULL, "< /dev/null") || die "WTF? $!";
explicitly overriding precedence. Peronally, I prefer the || forms
in most cases to the "or" forms, the former being easier to scan
visually. But with both forms in wide use, one has to be ready to
read/write/debug/maintain code of either style.
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: 04 Sep 1998 09:17:33 PDT
From: Patricia Shanahan <pats@acm.org>
Subject: Re: Perl & Java - differences and uses
Message-Id: <35F01218.7215509E@acm.org>
The main thing is to learn plenty of languages, and think about their
uses. Learning programming languages is a skill in its own right, and
one that improves with practice. You never know when you will hit a
problem that can best be solved in some language you don't know (yet).
Jim wrote:
>
> Thanks to all for your input. It seems that it is worth learning both in
> time, since I am already doing a course on C++ so the transition to java
> shouldn't be that difficult and I'm pretty handy at Perl already.
>
> I know my question was a bit provocative but I stated in the subject that I
> was looking for the "differences and uses" and was also careful to make the
> subject "Perl & Java" rather than "Perl V Java".
------------------------------
Date: 04 Sep 1998 18:55:32 +0200
From: Ralph SOBEK <sobek@irit.fr>
Subject: Perl5.005_02 build: "Thread.xs", line 465: undefined symbol: YIELD
Message-Id: <aug1e7ddh7.fsf@irit.fr>
This concerns building perl 5.005_02 under Solaris 2.5! The build
went well until:
Making Thread (dynamic)
Writing Makefile for Thread
mkdir ../../lib/auto/Thread
cp Thread/Signal.pm ../../lib/Thread/Signal.pm
cp Thread/Specific.pm ../../lib/Thread/Specific.pm
cp Thread.pm ../../lib/Thread.pm
cp Thread/Semaphore.pm ../../lib/Thread/Semaphore.pm
cp Thread/Queue.pm ../../lib/Thread/Queue.pm
../../miniperl -I../../lib -I../../lib ../../lib/ExtUtils/xsubpp -typemap ../../lib/ExtUtils/typemap -typemap typemap Thread.xs >Thread.tc && mv Thread.tc Thread.c
cc -c -O -DVERSION=\"1.0\" -DXS_VERSION=\"1.0\" -KPIC -I../.. Thread.c
"Thread.xs", line 465: undefined symbol: YIELD
"Thread.c", line 811: cannot recover from previous errors
Can someone tell me what went wrong?
Thanks to all!
--
Dr. Ralph P. Sobek Disclaimer: The above ruminations are my own.
Ralph.Sobek@irit.fr Addresses are ordered by importance.
sobek@irit.fr If all else fails, try:
newsmaster@irit.fr, postmaster@irit.fr sobek@diva.eecs.berkeley.edu
Ph:(+33)[0]561558618 FAX:(+33)[0]561556258 http://www.irit.fr/SSI/~Ralph.Sobek/
===============================================================================
The truth about the Past is really all we have to guide us in the Present
-- Mary Benson (1964)
------------------------------
Date: Fri, 4 Sep 1998 09:31:40 -0700
From: "Rizwan Qazi" <rizwan.q@usa.net>
Subject: Please help !
Message-Id: <6sp4jn$m11$1@nntp2.ba.best.com>
Hello everybody!
We are trying to set up Perl to access Oracle database.
Our Oracle engine is on a Sun Sparcstation. How do we go about it? Our
clients are Windows 95 machines.
Secondly what is the difference between Oraperl and Perl? Is Oraperl a
seperate product?
Thanks and regards,
Rizwan Qazi
------------------------------
Date: 4 Sep 1998 16:40:44 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: regex word boundary question
Message-Id: <6sp56c$dc9$1@pegasus.csx.cam.ac.uk>
Paul Phillips <paul@partitura.com> wrote:
>
>/\b\+\b/; #matches "x+y" but not "++" or " + "
>
>That does not make sense. As I read it, the first "\b" is a word
>boundary, the next "\" escapes the "+" so it is a real plus and not a
>multiplier (so there is one "+"), then the final "\b" is again a word
>boundary. So to me it matches " + " (space on either side of the plus)
>and not the other two choices. Am I dense and missing something here,
>or is this a typo in the book?
You are missing the definition of "word" in Perl. Or to be more precise,
the definition of a "word" character. Here are a few extracts from
"perldoc perlre":
\w Match a "word" character (alphanumeric plus "_")
\W Match a non-word character
\b Match a word boundary
A word boundary (\b) is defined as a spot between two
characters that has a \w on one side of it and a \W on the
other side of it (in either order), counting the imaginary
characters off the beginning and end of the string as
matching a \W.
Both "+" and " " are \W characters, so you wouldn't expect a match.
Mike Guy
------------------------------
Date: 04 Sep 1998 18:50:54 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
To: jwagner@digilog.de
Subject: Re: Regexp to toggle a part of a string
Message-Id: <oeebtov3mht.fsf@alpha.hut.fi>
This will do. (At first I though of using /e but that's actually not
needed, the substitution part of the s-operator is already in
doublequoted context)
perl -pwe 'BEGIN{%toggle=qw(ON OFF OFF ON)};s/\bStatus = (ON|OFF)\b/Status = $toggle{$1}/'
--
$jhi++; # http://www.iki.fi/~jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: 4 Sep 1998 17:45:36 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Regexp to toggle a part of a string
Message-Id: <6sp900$l60$2@marina.cinenet.net>
Joerg Wagner (jwagner@digilog.de) wrote:
: I want to change a line of text which looks like /Status = (ON|OFF)/
: where I want to toggle ON to OFF and vice versa. In other words I want to
: replace ON by OFF and OFF by ON.
: Can I do that in just _one_ regexp???
Presuming original line is in $_, and is known to be of the form above
already:
s/(ON|OFF)/$1 eq 'ON' ? 'OFF' : 'ON'/e;
Or:
my %onoff = ( ON => 'OFF', OFF => 'ON' );
s/(ON|OFF)/$onoff{$1}/;
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Fri, 4 Sep 1998 15:55:30 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Search
Message-Id: <35F00D72.E21AE1E0@inlink.com>
I have a simple example of searching a data file on http://webreview.com
HTH
--
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
$ Brent Michalski $
$ -- Perl Evangelist -- $
$ E-Mail: perlguy@technologist.com $
$ Resume: http://www.inlink.com/~perlguy $
$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
------------------------------
Date: 04 Sep 1998 18:51:48 +0200
From: Ralph SOBEK <sobek@irit.fr>
Subject: Re: Trouble compiling Perl5.005_02: malloc.c
Message-Id: <auiuj3ddnf.fsf@irit.fr>
Simply to get malloc to compile I had to manually add the following
two lines to config.sh:
malloctype='void *'
freetype='void'
Should Configure have done this automatically? Or is this a bug?
A good weekend to all!
--
Dr. Ralph P. Sobek Disclaimer: The above ruminations are my own.
Ralph.Sobek@irit.fr Addresses are ordered by importance.
sobek@irit.fr If all else fails, try:
newsmaster@irit.fr, postmaster@irit.fr sobek@diva.eecs.berkeley.edu
Ph:(+33)[0]561558618 FAX:(+33)[0]561556258 http://www.irit.fr/SSI/~Ralph.Sobek/
===============================================================================
The truth about the Past is really all we have to guide us in the Present
-- Mary Benson (1964)
------------------------------
Date: 4 Sep 1998 17:14:36 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Why Perl ?
Message-Id: <6sp75s$ej2$1@pegasus.csx.cam.ac.uk>
In article <6shjlf$7e5$1@nnrp1.dejanews.com>, <dn5006@my-dejanews.com> wrote:
>Try the following script:
>
>#!/usr/bin/perl
>print ":-) ";
>while (<>) { print eval; print ( ($@ || "\n") . ":-)" ) }
The traditional way of doing (almost) this is
perl -wde 42
You don't even have to write a script. And the Perl debugger gives
you history as well.
Mike Guy
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3636
**************************************