[24311] in Perl-Users-Digest
Perl-Users Digest, Issue: 6502 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun May 2 14:05:44 2004
Date: Sun, 2 May 2004 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 2 May 2004 Volume: 10 Number: 6502
Today's topics:
Can perl be used for cookie setting? <dannywork5@hotmail.com>
Re: Changing from C thought to Perl <dformosa@zeta.org.au>
Re: comparing decimal numbers <thens@NOSPAMti.com>
CRC on Unix vs Win32 (Frank Sconzo)
Re: free source search engine (simple) ## comments? <gnari@simnet.is>
Re: generating time series graphs with perl (Anno Siegel)
How to call another program <David@Grey.con>
Re: How to call another program <tony_curtis32@_SPAMTRAP_yahoo.com>
Re: How to call another program <jurgenex@hotmail.com>
Re: How to call another program <David@Grey.con>
Re: How to call another program <gnari@simnet.is>
Re: How to make a Perl program do concurrent downloadin (Bryan Castillo)
Re: Longest match wins - how to do it Perl way? <postmaster@castleamber.com>
Re: MSSQL 2000 Connect Success <gnari@simnet.is>
Re: MSSQL 2000 Connect Success <***************>
Re: MSSQL 2000 Connect Success <invalid-email@rochester.rr.com>
Re: n00b needs help pls. <user@unknown.invalid>
Re: OSs with Perl installed <postmaster@castleamber.com>
Perl Embedding Question <titus@nospam.com>
Re: Perl Embedding Question <Peter_member@newsguy.com>
Re: regex question ... <jhalbrook@bjc.org>
Re: regex question ... <jhalbrook@bjc.org>
Re: regex question ... <gnari@simnet.is>
Regexp question... (Andrew)
Re: Regexp question... <xxala_qumsiehxx@xxyahooxx.com>
Re: Regexp question... <noreply@gunnar.cc>
Re: regular expression error <nospam@nospam.com>
Re: single-byte values <1usa@llenroc.ude>
Re: single-byte values (Don Stock)
Re: single-byte values <bik.mido@tiscalinet.it>
Re: single-byte values <matternc@comcast.net>
XMLRPC::Transport::HTTP Problem. <craig@codenation.REMOVEME.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 02 May 2004 18:00:13 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: Can perl be used for cookie setting?
Message-Id: <NGalc.93810$Gd3.22108107@news4.srv.hcvlny.cv.net>
I wrote some javascript to retrive/set cookie for user.
The code just puts the reffering id passed in URL somewhere on the website
for tracking purposes.
I don't like how the code can be seen by all users if the wanted to. I
would also prefer something server side.
Is there a way I can use PERL to create a cookie in the same fashion?
Just put a call to a cgi script in the header or body of all web pages to
return the cookie info or set it if need be.
Thanks in advance
------------------------------
Date: 02 May 2004 23:28:34 +1000
From: ? the Platypus {aka David Formosa} <dformosa@zeta.org.au>
Subject: Re: Changing from C thought to Perl
Message-Id: <m3llkb3qm5.fsf@dformosa.zeta.org.au>
Rob Perkins <rob_perkins@hotmail.com> writes:
> Vetle Roeim <vetro@online.no> wrote:
>
> >* Rob Perkins
> >>
> >> Someone who doesn't know Perl, but knows programming, ought to be able
> >> to read the code, much the same way as a well-read German speaker can
> >> make out the gist of Dutch when he reads it.
> >
> > Why? Is the same true for languages like Common Lisp? For an
> > example: if I know C++, should I be able to read CL code? :)
>
> Name six useful products written for a non-programming end user, in
> Common Lisp.
And this is relivent why? Forth could have been as much used as an
example as common lisp.
[...]
> Well *my* point is that since Perl can be organized in such a way that
> a C, Pascal, Java, or BASIC programmer could easily see the algorithm,
> people who share code ought to program for readability. That's "why".
Shouldn't it be organized in a way that a Perl programer could easily
see the algorithm?
--
Please excuse my spelling as I suffer from agraphia. See
http://dformosa.zeta.org.au/~dformosa/Spelling.html to find out more.
Free the Memes.
------------------------------
Date: Sun, 2 May 2004 19:34:11 +0530
From: Thens <thens@NOSPAMti.com>
Subject: Re: comparing decimal numbers
Message-Id: <20040502193411.66eeacdf@asiclindt001>
On Fri, 30 Apr 2004 19:15:19 GMT
spamtotrash@toomuchfiction.com (Kevin Collins) wrote:
> In article <20040430235408.43bdb167@asiclindt001>, Thens wrote:
> > Hi,
> >
> > I have to compare two decimals numbers 1.5.0 and 2.1.1. The trouble is they
> > originate from string. Hence I get warnings that say " Argument "1.5.0" isn't
> > numeric in numeric ge" ...
>
> No, those are strings - a decimal number does not contain more than 1 decimal
> point.
Thanks to all those who corrected me. I figured it out now. Effect of late night coding :(
Regards,
Thens.
------------------------------
Date: 2 May 2004 10:21:23 -0700
From: frank.sconzo@dowjones.com (Frank Sconzo)
Subject: CRC on Unix vs Win32
Message-Id: <5d56563e.0405020921.534a9e76@posting.google.com>
Hi,
I'm writing a perl module that sends rich-text messages to Microsoft
Outlook recipients from Unix. This involves generating CRCs of the
plaintext and rtf versions of the mail message.
Unfortunately, when I use perl modules to generate the CRC, the values
do not match those that the Outlook Client is expecting.
For example, I used the crc32 function from Digest::CRC to determine
the CRC of the string ABCD. I also sent a message from an Outlook
client containing only ABCD as the body text.
Digest::CRC::crc32 gives me the following for the CRC of ABCD:
db 17 20 a5
But the Outlook attachment contains a CRC of ABCD as:
b9 ff 53 fa
Anyone know why these wouldn't match?
If not, anyone know a way to reverse engineer the CRC Algorithm
Outlook uses based on an examination of computed CRCs from different
message texts? I can
run different texts through Outlook, snoop the attachments, and
extract the CRCs to get sample data.
I've checked the Microsoft documentation to see what they say about
the CRC, but it doesn't say anything about the algorithm or polynomial
value used to compute the CRC. It only mentions the following for the
field where it expects the CRC to be defined:
The PR_RTF_SYNC_BODY_CRC property contains the cyclical redundancy
check (CRC) computed for the message text. The RTFSync function
computes the CRC using only the characters that it considers to be
significant to the message. For example, some white space and other
ignorable characters are omitted from the CRC:
http://msdn.microsoft.com/library/en-us/mapi/html/_mapi1book_pr_rtf_sync_body_crc.asp
Thanks for insight anyone can provide!
Regards,
Frank
------------------------------
Date: Sun, 2 May 2004 10:14:45 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: free source search engine (simple) ## comments?
Message-Id: <c72hjl$n5$1@news.simnet.is>
"Robin" <webmaster @ infusedlight . net> wrote in message
news:c71ii0$aah$1@reader2.nmix.net...
>
[snip discussion about how his script can compromise his site]
> >
> > do you want a demonstration ?
>
> true, they'd still have to guess the password though :-)
Robin, you are not *listening*.
I was telling you: your search script gave me the password.
look at your blog if you need proof:
http://www.infusedlight.net/robin/blogger.pl
this would not be a big deal, it it was *just* your personal
blog software, but you have been offering your software
to other people without adequate warnings about not
using it for real.
gnari
------------------------------
Date: 2 May 2004 14:24:36 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: generating time series graphs with perl
Message-Id: <c730b4$o8r$1@mamenchi.zrz.TU-Berlin.DE>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in comp.lang.perl.misc:
> On 30 Apr 2004 12:06:20 GMT,
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > I'd describe that as a parametric plot of an arbitrary curve. The
> > Z values play the role of the curve parameter.
> >
> >> If you get gnuplot to plot a three-dimensional chart, switch off
> >> display of the time axis and labels, and rotate it appropriately, you
> >> might just have what you're looking for.
> >>
> >> Any other package that does three-d charts and that lets you do a
> >> straight projection and switch off axes probably will do as well.
> >
> > Any package that allows you to draw lines from one point to another
> > could basically do it. Assuming we have move_to( $x, $y) and
> > draw_to( $x, $y) (a la postscript), and the data is given in two
> [...]
>
> But then you'd still have to do the work of scaling the thing, and
> drawing the axes yourself :)
>
> Basically, what you say above is true of almost any line chart.
It's even true of any vector graphics, if you will, but that wasn't my
point.
The OP seemed to be unclear about what type of graphics is needed
for this kind of plot. So I threw in the term "parametric plot",
and gave a definition in terms of line drawing. That doesn't come
across very well in my post.
Anno
------------------------------
Date: Sun, 02 May 2004 16:07:00 GMT
From: David Grey <David@Grey.con>
Subject: How to call another program
Message-Id: <40951635.75EEA9C9@Grey.con>
How do you call another program from within the perl script
and not loose control. When I try:
#!/usr/bin/perl
$Query_File = $ENV{QUERY_STRING};
print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
it goes to domain.com and that is the last it is heard from, and
for some reason you have to put something like:
$Query_File = $ENV{QUERY_STRING};
in or all you get is an error. I am sure there is a command that
allows you to call another program from another domain then
come back and finish the job. Can you use LWP::UserAgent;
to execute a program and then have the rest of the program
finish what it is doing afterward?
------------------------------
Date: Sun, 02 May 2004 11:15:47 -0500
From: Tony Curtis <tony_curtis32@_SPAMTRAP_yahoo.com>
Subject: Re: How to call another program
Message-Id: <877jvu9558.fsf@limey.hpcc.uh.edu>
>> On Sun, 02 May 2004 16:07:00 GMT,
>> David Grey <David@Grey.con> said:
> How do you call another program from within the perl script
> and not loose control. When I try:
> #!/usr/bin/perl
use strict;
use warnings;
> $Query_File = $ENV{QUERY_STRING};
"perldoc CGI" to handle submitted data cleanly.
> print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
> it goes to domain.com and that is the last it is heard from,
That's correct behaviour.
> and for some reason you have to put something like:
> $Query_File = $ENV{QUERY_STRING}; in or all you get is an
> error.
I'm afraid that is nonsense.
> I am sure there is a command that allows you to call another
> program from another domain then come back and finish the
> job. Can you use LWP::UserAgent; to execute a program and
> then have the rest of the program finish what it is doing
> afterward?
You don't "call another program", you submit data to a URL.
(There might be a program of some kind implementing the
response to you from wherever the request is handled, but that
is irrelevant.)
"perldoc lwpcook" has various examples for LWP. Construct the
request and send it off. Parse the response for what you need
and carry on processing...
hth
t
------------------------------
Date: Sun, 02 May 2004 16:32:53 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to call another program
Message-Id: <Vo9lc.68359$G_.54268@nwrddc02.gnilink.net>
David Grey wrote:
> How do you call another program from within the perl script
perldoc -f system
perldoc -f exec
perldoc perlop and look for qx
...
> and not loose control.
Well, not sure what you mean by "loose control" but I'm guessing mabye you
want to execute you script and the other program in parallel? Then use
fork() to spawn a new process and then exec() to the other program in the
child process. That way the parent process can still do whatever it wants to
do.
> When I try:
>
> #!/usr/bin/perl
>
> $Query_File = $ENV{QUERY_STRING};
>
> print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
>
> it goes to domain.com and that is the last it is heard from, and
> for some reason you have to put something like:
> $Query_File = $ENV{QUERY_STRING};
>
> in or all you get is an error. I am sure there is a command that
> allows you to call another program from another domain
What is "call another program from another domain" supposed to mean?
There are no domains in Perl programs.
> then
> come back and finish the job. Can you use LWP::UserAgent;
> to execute a program and then have the rest of the program
> finish what it is doing afterward?
What does all this have to do with executing program?
jue
------------------------------
Date: Sun, 02 May 2004 17:06:44 GMT
From: David Grey <David@Grey.con>
Subject: Re: How to call another program
Message-Id: <40952431.C2232C1F@Grey.con>
Jürgen Exner wrote:
> David Grey wrote:
> > How do you call another program from within the perl script
>
> perldoc -f system
> perldoc -f exec
> perldoc perlop and look for qx
> ...
>
> > and not loose control.
>
> Well, not sure what you mean by "loose control" but I'm guessing mabye you
> want to execute you script and the other program in parallel? Then use
> fork() to spawn a new process and then exec() to the other program in the
> child process. That way the parent process can still do whatever it wants to
> do.
Would this be getting close:
while (-1) {
sleep 3;
forktest();
sleep 12;
}
# The rest of the program below
sub forktest {
FORK: {
$Query_File = $ENV{QUERY_STRING};
print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
} return;
}
>
>
> > When I try:
> >
> > #!/usr/bin/perl
> >
> > $Query_File = $ENV{QUERY_STRING};
> >
> > print "Location: http://www.domain.com/cgi-bin/copyprog.pl\n\n";
> >
> > it goes to domain.com and that is the last it is heard from, and
> > for some reason you have to put something like:
> > $Query_File = $ENV{QUERY_STRING};
> >
> > in or all you get is an error. I am sure there is a command that
> > allows you to call another program from another domain
>
> What is "call another program from another domain" supposed to mean?
> There are no domains in Perl programs.
>
> > then
> > come back and finish the job. Can you use LWP::UserAgent;
> > to execute a program and then have the rest of the program
> > finish what it is doing afterward?
>
> What does all this have to do with executing program?
>
> jue
------------------------------
Date: Sun, 2 May 2004 18:00:16 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: How to call another program
Message-Id: <c73csg$403$1@news.simnet.is>
"David Grey" <David@Grey.con> wrote in message
news:40952431.C2232C1F@Grey.con...
>
[snip discussion about execution and fork]
forget about fork here. that only came up because you
were talking about 'executing a script', when what
you want to do is to submit a HTTP request in the
middle of a cgi process.
read Tony's post in this thread.
gnari
------------------------------
Date: 2 May 2004 09:10:27 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: How to make a Perl program do concurrent downloading?
Message-Id: <1bff1830.0405020810.6d4803c3@posting.google.com>
"Adlene" <Adlene3352@hotmail.com> wrote in message news:<c6vvmn$ck4$1@mawar.singnet.com.sg>...
> Hi, there:
>
> I wrote a program to download 500,000 HTML files from a website, I
> have compiled all the links in a file. my grabber.pl will download all of
> them...
Depending on who owns the Internet site, they may find it rude that
you want to dowload so many files and that you may want to take as
much resources as possible from their web server. Perhaps you should
find a different way of retrieving the data, such as contacting the
web site administrator and tell them what you want to do, they may
give you a tar gzipped file of the site??
>
> I have a fast internet connection. I think it is better to run multiple
> downloads at
It may be better for you, but that is questionable for everyone else.
Here is some information on web robots. You might want to do some
more searching though on web robots.
http://www.phantomsearch.com/usersguide/R04Robot.htm
<from the above URL>
The Four Laws of Web Robotics
Law One: A Web Robot Must Show Identification
Phantom supports this. You can set the "User-Agent" and "From E-Mail"
fields in the preferences dialog. Both of these are reported in the
HTTP header when Phantom makes requests of remote Web servers.
Law Two: A Web Robot Must Obey Exclusion Standard
Phantom fully supports the exclusion standard.
Law Three: A Web Robot Must Not Hog Resources
Phantom only retrieves files it can index (unless mirroring with
binaries option on) and restricts its movement to the path specified
by starting point s. You can also set the minimum time between hits on
the same server. Generally, 60 seconds is considered polite.
For busy sites a greater hit rate may be acceptable, but do not assume
whether a site is "busy" or notÑ contact the webmaster first. When
crawling your own server, of course, you can set the hit interval to
anything you like, including zero.
Law Four: A Web Robot Must Report Errors
Phantom can show you links that are no longer valid. Please contact
the Webmaster and pass this information on if broken URLs are found.
> same time, but $INET = new Win32::Internet() only allows one at a
> time...what
> may I do?
>
> I also found, occassionally the grabber just hang somewhere...In such
> situation I
> need to bypass $INET->FetchURL($url), write the offending URL in an error
> file
> and continue on to next iteration...How may I do that?
>
> Best Regards,
> Adlene
------------------------------
Date: Sun, 02 May 2004 01:02:50 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: Longest match wins - how to do it Perl way?
Message-Id: <40948f0f$0$209$58c7af7e@news.kabelfoon.nl>
Bob Walton wrote:
> print "<A HREF=\"MAILTO:$MAIL{$1}->{mail}\">$MAIL{$1}->{name}</A>";
using qq() you don't need to escape the " inside, or you can use single
quotes for the href value.
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
------------------------------
Date: Sun, 2 May 2004 10:02:16 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: MSSQL 2000 Connect Success
Message-Id: <c72gs8$hs$1@news.simnet.is>
"Henry Williams" <***************> wrote in message
news:vgl890tuhdp9fem2rb92qs6mb3r69cfno9@4ax.com...
> On Sat, 01 May 2004 02:06:23 GMT, Bob Walton
> <invalid-email@rochester.rr.com> wrote:
>
>
> >
> >Well, you would be far better off if you:
> >
> >
> > use DBI;
> >
> >rather than Win32::ODBC. With DBI, when you graduate to a better
> >database and/or OS, you won't have to modify any of your code except for
> >the connection string.
>
>
> Well Bob I was under the possibly mistaken impression that DBI did not
> "do" windows. That is, MS SQL DB's
>
> Hence the existence of something like Win32::ODBC
>
> I might have missed something!
maybe DBD::ODBC ?
gnari
------------------------------
Date: Sun, 02 May 2004 06:27:40 -0500
From: Henry Williams <***************>
Subject: Re: MSSQL 2000 Connect Success
Message-Id: <vhl990lubpk3hsr6f6kouf2c3677fhqda1@4ax.com>
On Sun, 2 May 2004 10:02:16 -0000, "gnari" <gnari@simnet.is> wrote:
>>
>> I might have missed something!
>
>maybe DBD::ODBC ?
>
>gnari
>
>
quoted from somewhere on the 'net
"By far the most recommended method of
accessing a database via Perl is through the DBI module. Using the
DBD::ODBC connectivity, you can not only make queries to an MS SQL
Server, your code also becomes almost completely portable, meaning
that even if you move your database to another OS or another platform,
your Perl code will require little to no modification to make the
migration. "
and then you have:
http://www.northbound-train.com/perl/article/Article.html
So many choices!
http://www.roth.net/perl/odbc/faq/
It begs the question, and I dare not pose it here...
if you have :
DBD::ODBC
and
DBD::ADO
why is there a
Win32::ODBC
It would be interesting to have them all contrasted to show the
benefits of each.
I was just happy to get one of them to work
------------------------------
Date: Sun, 02 May 2004 17:44:38 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: MSSQL 2000 Connect Success
Message-Id: <40953366.7020104@rochester.rr.com>
Henry Williams wrote:
> On Sun, 2 May 2004 10:02:16 -0000, "gnari" <gnari@simnet.is> wrote:
...
> It begs the question, and I dare not pose it here...
>
> if you have :
> DBD::ODBC
> and
> DBD::ADO
> why is there a
> Win32::ODBC
>
...
There is a Win32::ODBC because Dave Roth decided to write it. Same deal
with DBI, DBD::ODBC and DBD::ADO, and the other 4000+ modules. As to
why Dave decided to write Win32::ODBC, I can only speculate. Perhaps he
liked Micro$loth's way of accessing databases? Maybe it predated DBI
and DBD::ODBC?
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: Sun, 02 May 2004 04:08:47 GMT
From: Koncept <user@unknown.invalid>
Subject: Re: n00b needs help pls.
Message-Id: <020520040008553510%user@unknown.invalid>
In article <409430F8.4070501@rochester.rr.com>, Bob Walton
<invalid-email@rochester.rr.com> wrote:
> Based on the program you've already written, you should
> be able to handle that.
>
> --
> Bob Walton
> Email: http://bwalton.com/cgi-bin/emailbob.pl
>
Thanks for the advice Bob. Great tips.
--
Koncept <<
"The snake that cannot shed its skin perishes. So do the spirits who are
prevented from changing their opinions; they cease to be a spirit."
-Nietzsche
------------------------------
Date: Sun, 02 May 2004 01:11:25 -0500
From: John Bokma <postmaster@castleamber.com>
Subject: Re: OSs with Perl installed
Message-Id: <40949114$0$193$58c7af7e@news.kabelfoon.nl>
Matt Garrish wrote:
> 1,000 people who prefer Movie Maker for *personal use*. I don't believe for
> a minute that Linux (or any OS I can think of) is any immediate threat to
> Microsoft in that regard. As an OS in a work environment, however, Windows
> is garbage. Aside from all the security holes that keep our tech support
> group running around after viruses,
Strange, since I never have any kind of virus on my Windows computers,
for years (no active ones that is). Making users limited, not
Administrator, and use Thunderbird / Firefox instead of OE / IE helps a lot.
> the systems just don't work. Worse, the
> so-called "mcse" people don't have a clue how to fix them.
The viruses shouldn't be active on your system in the first place.
I am very afraid, if you so called tech support was given GNU / Linux
systems they would configure those systems in such a way that they would
suffer from similar problems, or worse.
> The sad reality
> is their answer to everything is to re-install the system (and what choice
> do you have half the time anyway, it's faster than trying to debug).
If you have no clue how to keep a system clean in the first place, maybe.
> Microsoft's advantage was the difficulty of use of other operating systems
> at the time, plus the notion they pushed that any idiot could maintain them
> (i.e., dump your high priced unix specialists).
>
> I'm as inclined to believe that Microsoft will survive in the business
> market, however, as I was that Nortel was really on the rebound. I also
> found it ridiculous that Linux was being pushed so hard as an imminent
> toppler of Microsoft in the nineties when it was still in its infancy.
And as a desktop system, it still is, IMHO.
--
John MexIT: http://johnbokma.com/mexit/
personal page: http://johnbokma.com/
Experienced Perl programmer available: http://castleamber.com/
------------------------------
Date: Sun, 02 May 2004 12:34:24 GMT
From: "Steve Titus" <titus@nospam.com>
Subject: Perl Embedding Question
Message-Id: <kV5lc.77738$yv.2740594@twister.southeast.rr.com>
I am a veteran Perl user, but a newbie embedder. I am trying to figure
out the best way to solve a problem I have. Please read along--any
advice is appreciated.
TASK: I am talking to a networked camera via HTTP, and the URLs I need
to send and the requests I get back are a variety of fairly complicated
and not always consistent text strings. THE GOAL: I need to interface
with the camera from a C/C++ program.
APPROACH: the camera came with a hard-copy manual that spelled out all
the camera params and commands, syntax, etc. I slapped all the info into
a config file in my own white-space-delimited column format that is
pretty simple to read and understand. As far as parsing goes, I figure
there are 4 general approaches I could have taken:
1. Hack something together using sscanf, strtok, and their ilk, and not
have it robust, but get it working quickly. NOT AN OPTION.
2. Do it "right" in C using lex/yacc, bison/flex, etc. I have done
parsers in this manner, but generally takes longer than using a Perl
approach, and you have to debug the grammar corner cases, etc.
3. Embed Perl into the C program and use Perl for all the text munging.
Has the added advantage of being flexible, not having to recompile when
config file changes, yada.
4. Do the config file in standardized text format like XML, and it may
not be too readable to humans, but I am sure there are some free
libraries that will parse it easily and hand me my data in C nicely.
COMMENTS WELCOME on which approach is best...but I chose 3.
Now to the Perl question:
PERL EMBEDDING: I read the manual and got ExtUtils::Embed working just
fine. I created 3 simple classes: perl_hash, perl_array, and
perl_scalar, in C++, and wrote a simple wrapper class that contains the
Perl interpreter and has one method -- call(). You can call any perl
function you like, hand it a C++ perl_array (@_) that you've filled
inside C/C++ and get back a perl_array as a result from call() after it
invokes Perl. It works great, and I was very proud of myself for taking
a general embedding approach that would work in mutliple projects! But....
PROBLEM: the problem is that I just let ExtUtils::Embed spew out all the
compile and link flags that I used for building, and when I run the
executable on another machine, it barfs with different messages about
shared libararies (depending on machine on which it is run), with 2
representative error messages being:
cperltest: error while loading shared libraries: libperl.so: cannot open
shared object file: No such file or directory
cperltest: /lib/i686/libc.so.6: version `GLIBC_2.3' not found (required
by cperltest)
QUESTIONS:
I have a basic understanding of what shared libraries are and how they
work, but I am not knowledgable about GLIBC compatibilities, or about
the "best" way to attain the following goal: I want someone to be able
to write a C/C++ program that links against my Cperl library, and as far
as they are concerned, it will just work.
1. Is this possible?
2. Could someone please give me a short primer on the way that GCC build
env, user environment (e.g. LD_LIBRARY_PATH), and Perl environment (how
Perl was built, etc), all influence what the "right" answer is to
solving this problem? All these issues have me confused!
3. What approach should I take? The ground rules are that all the boxes
I am working with will all have basically same O/S -- all Red Hat boxes
that look pretty much like
Linux 2.4.20-19.7smp #1 SMP Tue Jul 15 13:34:04 EDT 2003 i686 unknown
but they may have slightly different Perl versions installed in slightly
different places. SHould I compile everything statically so that my
cperl.a essentially contains a stand-alone Perl? How would I go about
doing this if it's possible?
4. How do you figure out what shared libraries an executable depends on?
5. How do you statically compile an executable (gcc version 3.2.3) so
that it depends on NOTHING?
6. Should I even try to compile statically, or can I somehow keep things
the way they are, and just have everyone add a few things to their
LD_LIBRARY_PATH on my behalf? Any philosophical and pratical help would
be great...
Any and all help is so greatly appreciated! Thanks!
Steve
------------------------------
Date: 2 May 2004 06:58:29 -0700
From: Peter <Peter_member@newsguy.com>
Subject: Re: Perl Embedding Question
Message-Id: <c72uq509oe@drn.newsguy.com>
In article <kV5lc.77738$yv.2740594@twister.southeast.rr.com>, Steve Titus
says...
> 4. How do you figure out what shared libraries an executable depends on?
Run your program with strace.
If you are using the default Perl installation in redhat9, all your perl*
dependencies will be in /usr/lib/perl5.
The remaining nonperl-specific stuff you can easily track with strace.
Hope this helps!
Peter
------------------------------
Date: Sun, 2 May 2004 10:16:04 -0500
From: "JK" <jhalbrook@bjc.org>
Subject: Re: regex question ...
Message-Id: <109a45k5ma5bf2f@corp.supernews.com>
I get the following error when using the Regexp::Common
/home/domain/public_html/cgi-bin/script.pl: /usr/bin/perl
: bad interpreter: No such file or directory
JK"Abigail" <abigail@abigail.nl> wrote in message
news:slrnc98gfe.egl.abigail@alexandra.abigail.nl...
> JK (jhalbrook@bjc.org) wrote on MMMDCCCXCVI September MCMXCIII in
> <URL:news:1097q608hqj454c@corp.supernews.com>:
> <> I'm trying to convert URLs in text strings to hyperlinks. My script:
>
> use Regexp::Common;
>
> $string =~ s!$RE{URI}{HTTP}{-keep}!<a href = "$1">$1</a>!g;
> print $string;
>
>
> Abigail
> --
> sub camel
(^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
> h[{e
**###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
>
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@
#@);
> print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.|
|d)&&$llama."\n");
------------------------------
Date: Sun, 2 May 2004 10:38:22 -0500
From: "JK" <jhalbrook@bjc.org>
Subject: Re: regex question ...
Message-Id: <109a5fdcn6a8e9b@corp.supernews.com>
I changed the use statement to:
use Regexp::Common qw /!delimited/;
and it works fine, this way.
fyi
JK
"JK" <jhalbrook@bjc.org> wrote in message
news:109a45k5ma5bf2f@corp.supernews.com...
> I get the following error when using the Regexp::Common
>
> /home/domain/public_html/cgi-bin/script.pl: /usr/bin/perl
> : bad interpreter: No such file or directory
>
> JK"Abigail" <abigail@abigail.nl> wrote in message
> news:slrnc98gfe.egl.abigail@alexandra.abigail.nl...
> > JK (jhalbrook@bjc.org) wrote on MMMDCCCXCVI September MCMXCIII in
> > <URL:news:1097q608hqj454c@corp.supernews.com>:
> > <> I'm trying to convert URLs in text strings to hyperlinks. My
script:
> >
> > use Regexp::Common;
> >
> > $string =~ s!$RE{URI}{HTTP}{-keep}!<a href = "$1">$1</a>!g;
> > print $string;
> >
> >
> > Abigail
> > --
> > sub camel
> (^#87=i@J&&&#]u'^^s]#'#={123{#}7890t[0.9]9@+*`"'***}A&&&}n2o}00}t324i;
> > h[{e
>
**###{r{+P={**{e^^^#'#i@{r'^=^{l+{#}H***i[0.9]&@a5`"':&^;&^,*&^$43##@@####;
> >
>
c}^^^&&&k}&&&}#=e*****[]}'r####'`=437*{#};::'1[0.9]2@43`"'*#==[[.{{],,,1278@
> #@);
> > print+((($llama=prototype'camel')=~y|+{#}$=^*&[0-9]i@:;`"',.|
> |d)&&$llama."\n");
>
>
------------------------------
Date: Sun, 2 May 2004 15:42:16 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: regex question ...
Message-Id: <c734ps$2tb$1@news.simnet.is>
"JK" <jhalbrook@bjc.org> wrote in message
news:109a45k5ma5bf2f@corp.supernews.com...
> I get the following error when using the Regexp::Common
>
> /home/domain/public_html/cgi-bin/script.pl: /usr/bin/perl
> : bad interpreter: No such file or directory
most likely, this has nothing to do with Regexp::Common,
but rather with your script.pl
you did not by any chance transfer it from windows to
the server with FTP in binary mode ?
it looks like there are carriage returns in the source.
try changing the first line to;
#!/usr/bin/perl --
or even:
#!/usr/bin/perl -w --
gnari
------------------------------
Date: 2 May 2004 10:00:26 -0700
From: myfam@surfeu.fi (Andrew)
Subject: Regexp question...
Message-Id: <c5826e91.0405020900.5593ab71@posting.google.com>
I am composing SQL from my perl code.
Using regexp to strip off ||','|| from the end of select query.
Using something like
$select =~ s/\|\|\'\,\'\|\|$//;
Not being regexp virtuoso, would like to ask if it possible to escape
group of characters instead of escaping each one, i.e. something like:
$select =~ s/\||','||$//;
Thanks,
Andrew
------------------------------
Date: Sun, 02 May 2004 17:05:21 GMT
From: Ala Qumsieh <xxala_qumsiehxx@xxyahooxx.com>
Subject: Re: Regexp question...
Message-Id: <lT9lc.59018$YF6.41468@newssvr25.news.prodigy.com>
Andrew wrote:
> I am composing SQL from my perl code.
> Using regexp to strip off ||','|| from the end of select query.
> Using something like
>
> $select =~ s/\|\|\'\,\'\|\|$//;
You don't need to escape single quotes or commas since they are not
special regexp characters.
> Not being regexp virtuoso, would like to ask if it possible to escape
> group of characters instead of escaping each one, i.e. something like:
>
> $select =~ s/\||','||$//;
A quick glance into perlre gives you the answer:
$select =~ s/\Q||','||\E$//;
--Ala
------------------------------
Date: Sun, 02 May 2004 19:19:02 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regexp question...
Message-Id: <c73b12$hfqig$1@ID-184292.news.uni-berlin.de>
Ala Qumsieh wrote:
> Andrew wrote:
>> Not being regexp virtuoso, would like to ask if it possible to
>> escape group of characters instead of escaping each one, i.e.
>> something like:
>>
>> $select =~ s/\||','||$//;
>
> A quick glance into perlre gives you the answer:
>
> $select =~ s/\Q||','||\E$//;
Actually, *you* just gave the answer, Ala, without any need for the OP
to look in perldoc perlre. ;-) (To OP: It's a good idea to do so anyway.)
Two further comments:
- \E right before $ is apparently redundant.
- See also perldoc -f quotemeta.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 02 May 2004 16:40:42 +0300
From: grom <nospam@nospam.com>
Subject: Re: regular expression error
Message-Id: <4094FA5A.9090705@nospam.com>
Thanks a lot.
It's work.
Richard Morse wrote:
> In article <408d49bd@news.barak.net.il>,
> Roman Kaganovich <nospam@nospam.com> wrote:
>
>
>> s/\((\d+\.\d+|\d+?)(\s+?)(\d+\.\d+|\d+?)/$x * $1 $y * $3/ex;
>>
>>Scalar found where operator expected at ./col.pl line 10, near "$1 $y"
>> (Missing operator before $y?)
>>syntax error at ./col.pl line 10, near "$1 $y"
>
>
> In your substitute, you are using the 'e' flag. This causes the
> substituted value to be treated as an expression. If you run the
> following program:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> my $x = 5;
> $1 = 6;
> my $y = 7;
> $3 = 8;
>
> my $z = $x * $1 $y * $3;
>
> print $z;
>
> __END__
>
> you get the same error. This is because your haven't told perl how to
> combine $1 and $y -- perhaps you meant:
>
> ($x * $1) * ($y * $3)
> or
> ($x * $1) + ($y * $3)
> or
> ($x * $1) . ($y * $3)
> or even
> ($x * $1) x ($y * $3)
>
> How is perl to know?
>
> You probably (based on the context, and my guess) want
>
> ($x * $1) . ' ' . ($y * $3)
>
> HTH,
> Ricky
>
------------------------------
Date: 2 May 2004 06:49:21 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude>
Subject: Re: single-byte values
Message-Id: <Xns94DD1CB732AAEasu1cornelledu@132.236.56.8>
dbsx@yahoo.com (Don Stock) wrote in
news:8cf7ae36.0405011829.35ae482e@posting.google.com:
> here's an interesting problem I had today. I wrote a perl script to
> compare two binary files byte-by-byte, ignoring certain offsets that
> contain timestamps and such. So I did this:
...
> # if mismatch
> if ($a != $b) {die "*** mismatch\n"}
Had you had
use strict;
use warnings;
at the top of your script, you would have received a warning:
Argument "D" isn't numeric in numeric ne (!=) at C:\Home\compare.pl line
18.
Also, $a and $b have special meanings, see perldoc -f sort.
--
A. Sinan Unur
1usa@llenroc.ude (reverse each component for email address)
------------------------------
Date: 2 May 2004 08:59:52 -0700
From: dbsx@yahoo.com (Don Stock)
Subject: Re: single-byte values
Message-Id: <8cf7ae36.0405020759.2a5082f4@posting.google.com>
> Had you had
>
> use strict;
> use warnings;
>
> at the top of your script, you would have received a warning:
>
> Argument "D" isn't numeric in numeric ne (!=) at C:\Home\compare.pl line
> 18.
I tried it and got this:
Can't locate warnings.pm in @INC (@INC contains: c:/Perl/lib
c:/Perl/site/lib .) at compare.pl line 2.
BEGIN failed--compilation aborted at compare.pl line 2.
I don't seem to have that package anywhere under /Perl. I'll try to
rustle it up.
I don't understand the warning. Given that every scalar has both a
numeric value and a string value (conceptually speaking, I prefer
putting it that way rather than saying that perl stores everything as
a string and converts as necessary, which to my mind is really just an
implementation detail), how can a scalar *not* be numeric? Or is it
saying that the string-to-numeric conversion forced the value to 0
because there were no leading digits in the string?
> Also, $a and $b have special meanings, see perldoc -f sort.
good point. Calling sort will clobber those vars. I knew that, but
had become unwary. I'll start using $x and $y instead.
thanks!
don
p.s. I've become quite fond (overnight it seems) of thinking of chr
and ord as type-shifters rather than as returning a string or numeric
value respectively. E.g.:
given the statement "$x = 'a';":
num str
--- ---
$x 0 97 (i.e. "a")
ord $x 97 57 55 (i.e. "97")
here, ord shifts 97 from str to num and recomputes str
given the statement "$x = 97;":
num str
--- ---
$x 97 57 55 (i.e. "97")
chr $x 0 97 (i.e. "a")
here, chr shifts 97 from num to str and recomputes num
------------------------------
Date: Sun, 02 May 2004 18:02:02 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: single-byte values
Message-Id: <5em990hbb75m0eq3v420h266hdqqn91d0o@4ax.com>
On 1 May 2004 19:29:30 -0700, dbsx@yahoo.com (Don Stock) wrote:
>here's an interesting problem I had today. I wrote a perl script to
>compare two binary files byte-by-byte, ignoring certain offsets that
>contain timestamps and such. So I did this:
Well, this has very few to do with your post, but you *may* still be
interested: just a few days ago I wanted to test a few CDRWs I have
because they had given me a few errors, so I created a test directory
with 699 1Mb random binary files[*] that I subsequently verified with
the following script:
#!/usr/bin/perl -l
use strict;
use warnings;
use constant LEN => 0x100_000;
die "Usage: $0 dir1 dir2\n" unless @ARGV==2;
s|/$||,-d or
die "`$_': doesn't exist or is not a directory\n"
for @ARGV;
undef $/;
for ('001'..'699') {
warn "Comparing $ARGV[0]/$_ and $ARGV[1]/$_\n";
open my $fh1, '<:raw', "$ARGV[0]/$_" or die $!;
open my $fh2, '<:raw', "$ARGV[1]/$_" or die $!;
my $err=LEN - (my $tmp=<$fh1>^<$fh2>) =~ tr/\0//d;
print "$_: $err errors" if $err;
}
__END__
Please note that I'm not claiming that this -definitely ad hoc- script
is particularly smart or elegant, but indeed it worked, and reliably
too, it seems!
Also, having heard so many times that this is not the most efficient
way to slurp in entire files, I thought that it would have run much
more slowly than it actually did...
Note: it may seem from both scripts pasted here that I'm an
(unnecessary-)interpolation maniac, but in fact I generally try to
avoid them if possible. This is not the case with these
quickly-conjured-up scripts.
[*] Using the following script, FWIW:
#!/usr/bin/perl
use strict;
use warnings;
$/=\0x100_000;
open my $fh, '<:raw', '/dev/urandom' or die $!;
for ('001'..'699') {
open my $out, '>:raw', "test/$_" or die $!;
print $out scalar <$fh>;
}
__END__
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
Date: Sun, 02 May 2004 12:17:34 -0400
From: Chris Mattern <matternc@comcast.net>
Subject: Re: single-byte values
Message-Id: <sZ6dnf12YYO9ggjdRVn_iw@comcast.com>
Don Stock wrote:
>> Had you had
>>
>> use strict;
>> use warnings;
>>
>> at the top of your script, you would have received a warning:
>>
>> Argument "D" isn't numeric in numeric ne (!=) at C:\Home\compare.pl line
>> 18.
>
> I tried it and got this:
>
> Can't locate warnings.pm in @INC (@INC contains: c:/Perl/lib
> c:/Perl/site/lib .) at compare.pl line 2.
> BEGIN failed--compilation aborted at compare.pl line 2.
>
> I don't seem to have that package anywhere under /Perl. I'll try to
> rustle it up.
>
You probably have an old perl. What does "perl -v" say? In any case,
using "perl -w" will get you most of what "use warnings;" does. If your
perl is too old to have warnings, then you can't add it on. You'll
have to upgrade your perl to get it.
> I don't understand the warning. Given that every scalar has both a
> numeric value and a string value (conceptually speaking, I prefer
> putting it that way rather than saying that perl stores everything as
> a string and converts as necessary, which to my mind is really just an
> implementation detail), how can a scalar *not* be numeric? Or is it
> saying that the string-to-numeric conversion forced the value to 0
> because there were no leading digits in the string?
>
Bingo. This is a *warning*, not an *error*. It's saying, "I'm doing
number stuff with these, but they don't look like numbers, so I'm
doing conversions that likely aren't what you meant..."
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: Sun, 02 May 2004 17:36:30 +0100
From: Craig Dunn <craig@codenation.REMOVEME.net>
Subject: XMLRPC::Transport::HTTP Problem.
Message-Id: <4095238E.1020706@codenation.REMOVEME.net>
Hi,
I wonder if someone can help me with this - it's probably trivial but I
cant find anything on google...
I'm writing an XMLRPC server using XMLRPC::HTTP::Transport to run as a
daemon. I want calls to the server to be passed off to
Codenation::XML::Handler; (the server runs under
Codenation::Server::HTTP::XMLRPC), however. I have a method in the
Handler package called test, and I want to call it via XMLRPC.
My server code includes:
use XMLRPC::Lite;
use XMLRPC::Transport::HTTP;
@::ISA = qw(XMLRPC::Server::Parameters);
sub new {
my $class = shift;
return bless {
_xmlrpc => XMLRPC::Transport::HTTP::Daemon
->new(LocalPort => 8080)
} , $class;
}
sub run {
my $self = shift;
$self->{_xmlrpc}->dispatch_to('Codenation::XML::Handler');
$self->{_xmlrpc}->handle;
return $self;
}
....
If I make an XMLRPC connection to call test, I get a 'file not found'
error returned from the client. It works if I call the method as
Codenation.XML.Handler.test.
Is there a way to get around this, I dont want to have to specify the
full package name, and I understood that dispatch_to should take care of
that anyway.
Any help would be appreciated.
Thanks in advance.
Craig
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 6502
***************************************