[18293] in Perl-Users-Digest
Perl-Users Digest, Issue: 461 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Mar 10 14:05:46 2001
Date: Sat, 10 Mar 2001 11:05:09 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984251109-v10-i461@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sat, 10 Mar 2001 Volume: 10 Number: 461
Today's topics:
Re: Broken Win32 signals! What to do? (Clinton A. Pierce)
Re: CGI won't work in Netscape browser <flavell@mail.cern.ch>
Re: CONVERT ASCII text string to BINARY with perl cgi <nospamplease@thankyou.com>
Re: CONVERT ASCII text string to BINARY with perl cgi <bart.lateur@skynet.be>
Re: create a text file in DOS format. <mischief@velma.motion.net>
Re: create a text file in DOS format. <flavell@mail.cern.ch>
Re: create a text file in DOS format. <bart.lateur@skynet.be>
Re: create a text file in DOS format. <bart.lateur@skynet.be>
Re: create a text file in DOS format. <flavell@mail.cern.ch>
Re: File filters in File::Find (was:Trying to capture c <mumble[anti-spam]@maths.uct.ac.za>
Re: File filters in File::Find (was:Trying to capture c (Tad McClellan)
Re: File filters in File::Find (was:Trying to capture c <mumble[anti-spam]@maths.uct.ac.za>
Re: File filters in File::Find (was:Trying to capture c <bart.lateur@skynet.be>
Re: Help Matt with small programs <tzz@beld.net>
Re: Help Matt with small programs (Abigail)
Re: How to get perl not to convert decimal character <dersgniw@fuse.net>
Re: Macbeth and Perl threads <dan@tuatha.sidhe.org>
Maintaining the number format and not exponential <m0rejunkmail@nospam.home.com>
Re: Maintaining the number format and not exponential <uri@sysarch.com>
Re: Passing command line arguments to script <mischief@velma.motion.net>
Re: PLEASE HELP - Problem with CGI script <mischief@velma.motion.net>
Re: PLEASE HELP - Problem with CGI script <qlindsay@gte.net>
Re: scalar(localtime) in reverse? <mischief@velma.motion.net>
Re: scalar(localtime) in reverse? (Peter Scott)
Re: Trying to capture current directory in variable <mumble[anti-spam]@maths.uct.ac.za>
Re: Trying to capture current directory in variable <mumble[anti-spam]@maths.uct.ac.za>
Re: Trying to capture current directory in variable <mumble[anti-spam]@maths.uct.ac.za>
Use module without installing! <Hamed53@btinternet.com>
Re: Use module without installing! <jbranton.remove_dot_and_everything_else@clara.net>
XS - typemap void ? <mpapesch@gmx.de>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 10 Mar 2001 18:25:19 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Broken Win32 signals! What to do?
Message-Id: <jkuq6.45107$W05.8959650@news1.rdc1.mi.home.com>
[Posted and mailed]
In article <3tajat0bnlp155ctel9ce67nvo21klajcl@4ax.com>,
Sean O'Leary <soleary@erols.com> writes:
> local $SIG{'__DIE__'} = \$handler;
>
> sub handler {
> use Mail::Mailer;
> # Send me some email
> }
>
> at the top of my program and then I would be all good. It was after
> this really didn't work ( the program would die during compilation
> complaining of weird things, like modules I'm not even using
> (Tie::Registry, specifically) saying that it couldn't find some module
> or other. ) I moved this to a BEGIN block, and that was no better. I
> also tried the use sigtrap, and the results were a little bit
> different, but still not too good.
>
> It was after all this experimentation that I began to comprehend how
> bad the Win32 signal situation was. But many of the docs said you
It's that bad, but __DIE__ and __WARN__ are only pseudo-signals and work
rather well in my experience.
The idea here is to Keep It Simple, Stupid. If you have something that
throws an exception and dies occasionally, wrap it in an eval{} and catch
it yourself. This is the real solution.
If you ARE going to have to set up a handler, remember: you're script is
_dying_. Keep what you're going to do to a minimum. For external signals
(INT, HUP, ALRM) you're limited to just setting a flag safely (sometimes).
This is Win32 and those signals don't work. But the idea remains the same,
do as little as necessary.
--
Clinton A. Pierce Teach Yourself Perl in 24 Hours *and*
clintp@geeksalad.org Perl Developer's Dictionary -- May 2001
"If you rush a Miracle Man, for details, see http://geeksalad.org
you get rotten Miracles." --Miracle Max, The Princess Bride
------------------------------
Date: Sat, 10 Mar 2001 16:26:02 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: CGI won't work in Netscape browser
Message-Id: <Pine.LNX.4.30.0103101608200.5062-100000@lxplus003.cern.ch>
On Sat, 10 Mar 2001, Chris Stith wrote:
> cdh <cdh@ala.net> wrote:
> > Richard wrote:
>
> >> I have quite a few scripts running online and today noticed they are not
> >> executing when i try and run them from Netscape browser.
Thats; complete nonsense, and demonstrates a vital lack of
comprehension by the original poster in how the parts of the WWW fit
together. CGI scripts don't run "in" a browser, and browsers aren't
concerned with the details of how a WWW document was generated - only
with its validity as specified by the interworking specification (in
this case, HTTP - RFC2616 etc.).
> >> When executed, all I get is the HTML code that is processed
> from the script.
As Chris remarks below, Netscape is working correctly, whereas IE is
violating the interworking specification.
> >> I have no idea what is going on.
check.
> > Try putting
> > print "Content-type: text/html\n\n";
> > at the beginning of your script.
Well, I'd have to say "try learning CGI". The need for that detail
will then become obvious. However, in the present (c.l.p.misc)
context, the answer would be "use CGI.pm", rather than messing around
with the detailed nuts and bolts. When the O.P has understood how to
do it properly "by hand", they'll be in a position to decided whether
they still want to use CGI.pm (would be my normal recommendation) or
not; but until they reach that stage, which they clearly haven't yet,
I would simply repeat "use CGI.pm" to take care of the details for
them.
> > Yes, Netscape is a piece of crap, so is IE, Mozilla,
> > Opera and every other browser I've tried. You simply
> > have a choice of your favorite "piece of crap".
Well, there's something in that! If only one could take the best bits
out of all the available browsers and put them all together without
the crap...
> > crap. It's simply adhering to the specs which those
> > other browsers are not doing.
Indeed!
> Actually, in the case of Opera, it will guess the MIME
> content type based on filename if the headers are
> missing.
Actually, in the case of Opera, it has the ability to override the
MIME content type - which is technically a violation of protocol -
in order to compensate for blunders by server admin or CGI programmer
etc. BUT this option is supposed to be disabled by default, and only
enabled at the request of the browser user (who is then presumed to
understand the consequences of what they are doing). Opera's
documentation stated that the default was to have this feature turned
off - but I found that on a fresh installation the default setting was
the opposite, so I called-in a bug on that.
> This can be disabled, [...]
Overriding an incorrect content-type is certainly a violation of HTTP
protocol. Guessing the type when none is present is a different
question, though. Do we really know that none was present? I would
have expected a web server (when handling a parsed-headers script) to
supply its own - most commonly 'text/plain' - if the script omitted to
supply one.
> This is a discussion best continued elsewhere.
You're absolutely right, but as you'd brought the issue up, I thought
it best to make a comment nevertheless.
Unfortunately the automoderation bot of comp.infosystems.www.authoring.cgi
doesn't permit the usual technique of cross-posting and setting f'up
to the more relevant group, but that's where the general problem topic
would belong. The issue of specific browser behaviour should of
course be taken up on the relevant c.i.w.browsers.* group, if not on
opera's own newsgroups.
cheers
------------------------------
Date: Sat, 10 Mar 2001 12:02:53 -0500
From: "null" <nospamplease@thankyou.com>
Subject: Re: CONVERT ASCII text string to BINARY with perl cgi
Message-Id: <98dmn7$6r2$1@bob.news.rcn.net>
I saw ur reply to my post a few minutes after it posted and have made a lot
of progress since then using GD.pm. My host had installed an older version
(that output gifs, but not png), so I'm uploading the current GD.pm to my
account today.
Your advice was invaluable.
thanks,
brian
"Charles K. Clarkson" <c_clarkson@hotmail.com> wrote in message
news:0F23C444413EAE38.7DCF473B112DF7DC.9191584DDEEF1580@lp.airnews.net...
> brian <nospamplease@thankyou.com> wrote
> :
> : I want to do something that it seems hasn't been done very many times
> : before - I want to send a string to a perl cgi script (probably from a
> : shockwave or flash movie) and output a binary file (like png, gif, jpeg,
> : etc). I've skimmed the gif89a spec
> : (http://www.dcs.ed.ac.uk/home/mxr/gfx/2d/GIF89a.txt) and I
> : understand that it will be a pain to get my concept going (chunk this,
> : chunk that), but I don't care. This is a personal project and I'm not
> : operating under a strict time constraint.
>
> Try the modules at: http://search.cpan.org/Catalog/Graphics/.
>
> :
> : I've searched with Google and through all of the Usenet archives without
> : really finding anything. I did locate the page for the HandyCrypt perl
> : module, which includes a function that is supposed to handle ascii to
> binary
> : conversion, but I'm on virtual hosting and I don't think that I can be
> : installing my own modules. Basically I'm looking for a script that will
> : perform ascii text to binary conversions that I can install in my
cgi-bin
> : and hack into until it does what I want it to do.
>
> You can install modules anywhere you like. No need to wait for
> your host to do it for you. Look in the perl documentation for the
> 'lib' module or use the -I switch.
> http://www.perl.com/CPAN-local/doc/manual/html/pod/perlrun.html
> 'Directories specified by -I are prepended to the search path
> for modules (@INC)'
>
> HTH,
> Charles K. Clarkson
>
>
>
------------------------------
Date: Sat, 10 Mar 2001 18:44:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: CONVERT ASCII text string to BINARY with perl cgi
Message-Id: <6ctkat4i049glc9mg3reov6u06ibub3k2p@4ax.com>
null wrote:
> I want to send a string to a perl cgi script (probably from a
>shockwave or flash movie) and output a binary file (like png, gif, jpeg,
>etc).
Look at the modules GD and Image::Magick. Both allow you to create
images by script. Both are just interfaces to free third party programs.
Start by looking at their docs at CPAN: <http://search.cpan.org/>
--
Bart.
------------------------------
Date: Sat, 10 Mar 2001 15:04:46 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: create a text file in DOS format.
Message-Id: <takgke8aubrmfa@corp.supernews.com>
Renato Santos <Bing@home.com> wrote:
> How do I create a text file in UNIX perl that
> is in DOS format rather than UNIX?
DOS and Windows use the network line ending.
End all your lines with qq{\r\l} or preferably
qq{\015\012}.
You could also send the file via FTP in ASCII
mode, but if you transfer them in compressed
archive files it might be easier to write them
how Windows wants them in the first place.
> I tried the
> system("/bin/UNIX2DOS $file1 $file2"); but it
> keeps giving me a server error.
I don't have this program, but are you sure it's
all uppercase? I also don't think it'd be a
client/server program.
> I'm using the perl script to create a text
> file from a user input and the file has to
> be read by an NT machine.
You could convert it there if you had ActiveState
Perl available.
> I also tried using the binmode function after
> I open the filehandle but that did not work
> either.
That only makes a difference _on_ DOS, Windows,
or some other system where there is a distinction
between text and binary files. In Unix, a text
file is something that you can read and a line
ending is what certain libraries and the text
editor consider a certain character. On DOS, the
whole OS sees things differently between a binary
and a text file. Since you're on a Unix flavor
when writing the file with your program, binmode()
has no effect.
> The file looks fine in UNIX but when I open
> it in WindowsNT it is all just one long line.
> The carriage return for each line is ignored.
It's not ignored. DOS just doesn't call a
carriage return a newline. A newline to DOS
is a carriage retuirn and linefeed back to
back, just like an old teletype.
The standard DOS editor, EDIT.COM, might fix
this if you open the file and save it with that
on DOS/Windows/NT. It has been known to change
\r, \l, or \l\r into \r\l in certain versions.
This is a work around instead of a fix, but it's
handy to know.
> Any clue? I'm really a newbie with PERL so
> please excuse me if this question is too trivial.
This doesn't have to do much with Perl or with perl,
and I'm not sure how it applies to PERL, since that
looks like an acronym, and Perl isn't one. ;-) This
is a portability issue between operating systems.
It can be handled in Perl, but it can also apply to
other languages.
Chris
--
Christopher E. Stith
Product shown enlarged to make you think you're getting more.
------------------------------
Date: Sat, 10 Mar 2001 16:07:32 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: create a text file in DOS format.
Message-Id: <Pine.LNX.4.30.0103101559070.5062-100000@lxplus003.cern.ch>
On Sat, 10 Mar 2001, Tad McClellan wrote:
> Just write Unix files on Unix and DOS files on DOS.
>
> Use "text mode" when transferring the files with FTP, and the
> ftp program will convert the line endings for you!
Don't forget that "DOS" format implies a DOS 8-bit coding (CP850 in
most Latin-1 locales - apparently it's often still CP437 in the USA,
which I discovered to my surprise recently), whereas (again in Latin 1
locales) unix would use iso-8859-1. So, conversion between the two
formats, in general, calls for an 8-bit transcoding in addition to the
resolution of newline representations.
I've met half a dozen implementations of tools called dos2unix and
unix2dos. About half of them performed this 8-bit transcoding, and
half of them didn't. About two thirds of them never even mentioned
the issue in their man pages. So beware.
The same issue comes up with implementations of FTP. And again, some
of them do and some of them don't - as a (sometimes optional) addition
to handling the newline representation issue. Again, beware (and
Windows brings yet another area of concern, namely the characters in
the range 128 to 159 decimal, which are displayable characters in
Windows-1252 which don't exist in iso-8859-1).
Newlines are almost trivial in comparison with the problems caused by
miscoding of 8-bit characters ;-}
--
This .sig only acknowledges that the message was displayed on
the recipient's machine. There is no guarantee that the
content has been read or understood.
------------------------------
Date: Sat, 10 Mar 2001 15:21:27 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: create a text file in DOS format.
Message-Id: <ehhkatkkcrne1pqgbdrm8c2mpakn9f3fst@4ax.com>
Renato Santos wrote:
>How do I create a text file in UNIX perl that is in DOS format rather
>than UNIX?
>I also tried using the binmode function after I open the filehandle but
>that did not work either.
No, that works to make a Unix compatible file on Windows.
Try doing
s/\n/\015\012/g;
before printing the output.
Or, set $\ to "\015\012", and NEVER print a newline yourself, but rather
rely on the system adding one after every single print statement. Thus,
a print() prints one line.
--
Bart.
------------------------------
Date: Sat, 10 Mar 2001 15:36:00 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: create a text file in DOS format.
Message-Id: <3fikatgk39rijtklb7ufgggvsctlrm32op@4ax.com>
Alan J. Flavell wrote:
>Don't forget that "DOS" format implies a DOS 8-bit coding (CP850 in
>most Latin-1 locales - apparently it's often still CP437 in the USA,
>which I discovered to my surprise recently), whereas (again in Latin 1
>locales) unix would use iso-8859-1.
But the OP said he wants to read it on NT. NT is mostly ISO-8859-1
compatible. So actually, he doesn't really want a DOS file, but only a
text file with DOS line endings.
--
Bart.
------------------------------
Date: Sat, 10 Mar 2001 18:43:43 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: create a text file in DOS format.
Message-Id: <Pine.LNX.4.30.0103101836390.5062-100000@lxplus003.cern.ch>
On Sat, 10 Mar 2001, Bart Lateur wrote:
> >Don't forget that "DOS" format implies a DOS 8-bit coding (CP850 in
> >most Latin-1 locales - apparently it's often still CP437 in the USA,
> >which I discovered to my surprise recently), whereas (again in Latin 1
> >locales) unix would use iso-8859-1.
>
> But the OP said he wants to read it on NT.
Yes: I had, after all, remarked later in the posting that it's
different under Windows.
> NT is mostly ISO-8859-1 compatible.
Their Latin-1 coding is registered at IANA as Windows-1252. It
coincides exactly[1] with the displayable characters of iso-8859-1,
but it uses the range 128-159 decimal (which the iso-8859-* codes
reserve for control functions) for additional displayable characters.
> So actually, he doesn't really want a DOS file, but only a
> text file with DOS line endings.
Yes, it seems you're right in this case. Which adds another reason
for being careful ;-)
all the best
[1] Note that this property is a peculiarity of Latin-1 Windows.
When you compare iso-8859-7 with Greek Windows coding, or the iso
Baltic codings with Windows Baltic, etc., it turns out that they
aren't exactly the same, not even in the range 160-255 decimal.
Sorry for that digression...
------------------------------
Date: Sat, 10 Mar 2001 18:03:59 +0200
From: "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za>
Subject: Re: File filters in File::Find (was:Trying to capture current directory in variable)
Message-Id: <98djb4$2ut0$1@news.adamastor.ac.za>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:40fiat0ljra2hijpic7kue0l9v2uhotjqb@4ax.com...
> "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> wrote:
>
> >I am a Perl newbie writing a program that does a tree-walk; I want to
store
> >the original working directory in a variable (without using files, as
write
> >access may not be assumed). The motivation is to change back to that
> >directory as part of program completion.
>
> use Cwd; my $curdir = cwd; print "Current directory: $curdir\n";
>
> But, as Randal Schwartz already wrote: when writing a directory tree
> walker program, you first response should be File::Find.
Hokay, I've now done that and discover that
http://www.perl.com/pub/doc/manual/html/lib/File/Find.html describes
use File::Find;
find(\&wanted, '/foo','/bar');
sub wanted { ... }
and tells in detail what the first parameter is. Experimentation reveals
that '/foo' is the starting directory of the walk but I can't figure out
what '/bar' is.
I piously hoped that it was a filter and I tried '*.html' (cuz those are the
only files I want to process) but nope. Having had my mind blown dy
discovering that I don't have to code a tree-walk, I hopefully await a
revelation that I won't have to code a filtering process either.
Any ideas on what '/bar' is good for (leaving it out seems to cause perl no
hassles), and how to find documentation answering this without posting
newbie questions?
------------------------------
Date: Sat, 10 Mar 2001 16:28:46 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: File filters in File::Find (was:Trying to capture current directory in variable)
Message-Id: <slrn9akibl.k2d.tadmc@tadmc26.august.net>
Michael Rolfe <mumble[anti-spam]@maths.uct.ac.za> wrote:
>"Bart Lateur" <bart.lateur@skynet.be> wrote in message
>news:40fiat0ljra2hijpic7kue0l9v2uhotjqb@4ax.com...
>> "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> wrote:
>>
>> >I am a Perl newbie writing a program that does a tree-walk
>> But, as Randal Schwartz already wrote: when writing a directory tree
>> walker program, you first response should be File::Find.
>
>Hokay, I've now done that and discover that
>http://www.perl.com/pub/doc/manual/html/lib/File/Find.html describes
You can get the very same information right from your very
own hard drive by typing:
perldoc File::Find
No need to go surfing about the web for access to standard docs
that you already have :-)
>use File::Find;
> find(\&wanted, '/foo','/bar');
> sub wanted { ... }
>
>and tells in detail what the first parameter is. Experimentation reveals
>that '/foo' is the starting directory of the walk but I can't figure out
^^^^^^^^^^^^^^^^^^^^^^
one of the starting directories
>what '/bar' is.
another starting directory.
Arguments after the first one are a list of starting directories.
>Having had my mind blown dy
>discovering that I don't have to code a tree-walk, I hopefully await a
>revelation that I won't have to code a filtering process either.
You do have to code it, but it is brain-dead simple:
sub wanted {
return unless /\.html$/;
# process *.html files here
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 10 Mar 2001 19:12:26 +0200
From: "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za>
Subject: Re: File filters in File::Find (was:Trying to capture current directory in variable)
Message-Id: <98dnbf$4l$1@news.adamastor.ac.za>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9akibl.k2d.tadmc@tadmc26.august.net...
> Michael Rolfe <mumble[anti-spam]@maths.uct.ac.za> wrote:
[...]
> sub wanted {
> return unless /\.html$/;
>
> # process *.html files here
> }
Hot damn. Tx. Love that "unless". I'm beginning to enjoy Perl.
------------------------------
Date: Sat, 10 Mar 2001 18:06:29 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: File filters in File::Find (was:Trying to capture current directory in variable)
Message-Id: <83rkatcr6n4ei2jjbgs6vrttuki8s6g68q@4ax.com>
"Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> wrote:
>Hokay, I've now done that and discover that
>http://www.perl.com/pub/doc/manual/html/lib/File/Find.html describes
>
>use File::Find;
> find(\&wanted, '/foo','/bar');
> sub wanted { ... }
>
>and tells in detail what the first parameter is. Experimentation reveals
>that '/foo' is the starting directory of the walk but I can't figure out
>what '/bar' is.
Yet another starting directory? You can have more than one. You can even
use plain files.
use File::Find;
find sub { print "$File::Find::name:\t".(-d $_ ?'D':'F')."\n" },
@ARGV;
There, now you can try it from the command line.
--
Bart.
------------------------------
Date: 10 Mar 2001 11:48:20 -0500
From: Ted Zlatanov <tzz@beld.net>
Subject: Re: Help Matt with small programs
Message-Id: <m3snkl8t9n.fsf@heechee.beld.net>
abigail@foad.org (Abigail) writes:
> {local $, = " ";
> print grep {$_ % 5 == 0} 0 .. 99
> }
>
> with the added benefit of not printing a trailing space.
Perhaps a less obfuscated choice might be:
print join ' ', grep {$_ % 5 == 0} 0 .. 99;
since it avoids localized variables and $,
--
Teodor Zlatanov <tzz@iglou.com>
"Brevis oratio penetrat colos, longa potatio evacuat ciphos." -Rabelais
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: 10 Mar 2001 18:31:46 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Help Matt with small programs
Message-Id: <slrn9aksoi.t7a.abigail@tsathoggua.rlyeh.net>
Ted Zlatanov (tzz@beld.net) wrote on MMDCCXLVIII September MCMXCIII in
<URL:news:m3snkl8t9n.fsf@heechee.beld.net>:
"" abigail@foad.org (Abigail) writes:
""
"" > {local $, = " ";
"" > print grep {$_ % 5 == 0} 0 .. 99
"" > }
"" >
"" > with the added benefit of not printing a trailing space.
""
"" Perhaps a less obfuscated choice might be:
""
"" print join ' ', grep {$_ % 5 == 0} 0 .. 99;
""
"" since it avoids localized variables and $,
$_ is localized.
But why do you make the suggestion localized variables are bad?
Abigail
--
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'
------------------------------
Date: Sat, 10 Mar 2001 13:29:38 -0500
From: "Brian" <dersgniw@fuse.net>
Subject: Re: How to get perl not to convert decimal character
Message-Id: <taksm0bhbb3v2f@corp.supernews.com>
"Chris Stith" <mischief@velma.motion.net> wrote in message
news:tak80dhjs4is90@corp.supernews.com...
> As the OP clarified for me in email, his main concern isn't the
> quoting and unquoting of characters. That's a bit of a red herring.
>
> His problem was that his data, which he was joing with pipes then
> splitting on pipes, could sometimes contain the very character
> in the data itself on which he was trying to split.
>
> Using a character very unlikely to be in the data elements is
> therefore a good fix.
I'm glad someone understands my problems. :-)
------------------------------
Date: Sat, 10 Mar 2001 15:36:03 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Macbeth and Perl threads
Message-Id: <DRrq6.21071$Ok4.2308800@news1.rdc1.ct.home.com>
Peter van den Hamer <vdhamer@msn.com> wrote:
> Question: is it possible for one Perl (5.005-type) thread to kill
> another thread in that thread's sleep?
Nope. You can't do this safely with threads in general, and perl's
threads are no exception.
Dan
------------------------------
Date: Sat, 10 Mar 2001 18:01:40 GMT
From: FORM Rookie <m0rejunkmail@nospam.home.com>
Subject: Maintaining the number format and not exponential
Message-Id: <3AAA70EB.D8AA4A5B@home.com>
Hello,
Just trying to figure out how to maintain the format of the number
displayed. Basically, I was adding a number to a variable and the result
was an exponential number. I really need the format of the display to
remain the same as the data number.
Ex:
$adder = 5;
$form_data = $formdata{'data'}; #data=123456789123456
$result = $adder + $form_data;
print "$result";
#the result comes out as an exponential number 1.123456789123e+15
#actual result that I wanted should read 123456789123461
Thanks for your help,
FORM Rookie
------------------------------
Date: Sat, 10 Mar 2001 18:53:10 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Maintaining the number format and not exponential
Message-Id: <x74rx1cv6y.fsf@home.sysarch.com>
>>>>> "FR" == FORM Rookie <m0rejunkmail@nospam.home.com> writes:
FR> Hello,
FR> Just trying to figure out how to maintain the format of the number
FR> displayed. Basically, I was adding a number to a variable and the result
FR> was an exponential number. I really need the format of the display to
FR> remain the same as the data number.
FR> $adder = 5;
FR> $form_data = $formdata{'data'}; #data=123456789123456
that is stored as is in a perl scalar as a string.
FR> $result = $adder + $form_data;
now the string has to be converted to a number and it is too big to
store in a perl scalar as an integer. so it is converted to a float. the
+5 won't even be noticed as it is below the right most digits of the
float's mantissa.
FR> print "$result";
FR> #the result comes out as an exponential number 1.123456789123e+15
well, it is now a float number. use Math::BigInt to keep it as a long
integer.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Sat, 10 Mar 2001 14:18:14 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Passing command line arguments to script
Message-Id: <takdt6c0i63654@corp.supernews.com>
Brian McCann <bmccann@naisp.net> wrote:
> Hi,
> This build script prompts the user for a tag
> such as PCS-1-0-0-Build45, when
[snip]
> My question is, is there away to pass the tag
> PCS-1-0-0-Build45 on the command line so I don't
> have to prompt the user for it, also is there a
Yes. Run `perldoc perlvar' and search for `@ARGV'
to find out the specifics.
The short story is that @ARGV stores the arguments
to the program. $ARGV[0] is the first argument (not
counting the program name like in C -- that's a
different variable in Perl, which is call $0 and is
also documented in perlvar). $ARGV[1] is the second
argument, and so on.
You can read these yourself or you can get modules
from CPAN to work with options on your behalf.
> way to have a switch on the command line so if I
> don't want to build to a tag the script would
> ignore the first two system functions and just
> execute the third in the script below.
What I do if I want a default behavior that may be
changed by command line options is to set a variable,
check @ARGV, and possibly assign to the prestated
control variable again based on the user's input.
###--- _begin_untested_example_code_ ---
use module_which_contains_subs_1_through_3;
my $all_sections = 0;
my $tag = '';
foreach(@ARGV) {
$all_sections = 1, next if $_ eq '-t';
$tag = $_;
}
if( $all_sections ) {
sub1($tag);
sub2($tag);
sub3();
} else {
sub3();
}
###--- _end_untested_example_code_ ---
The above, for simplicity's sake, assumes your actions
are broken out into subs in a module. For a program so
short as yours, I'd just replace the subroutine calls
above with the actual system() statements.
I may not have the sub calls exactly right, either. I'm
sure it's clear to you whether or not each of the calls
really needs to know the value of `$tag'.
> what I'm looking for is something that looks like this
> C:\javatagbuild.plx -t PCS-1-0-0-Build45 this would
> build a tagged build
> and
> c:\javatagbuild.plx without any switch or argument
> would only execute this:
> system ("cd d:\\AppsTagBuild\\$tag\\source \&\& cvs
> -d :pserver:build\@scrumhalf:/cvs/cvsroot checkout
> -r $tag Applications" );
> and the code that follows.
The above should be easily coerced into such actions,
as could other, similar approaches.
Chris
--
Christopher E. Stith
If they can get you asking the wrong questions, they don't
have to worry about the answers.
-- Thomas Pynchon, Gravity's Rainbow
------------------------------
Date: Sat, 10 Mar 2001 14:33:31 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: PLEASE HELP - Problem with CGI script
Message-Id: <takeprcuo28ncf@corp.supernews.com>
Amal Banerjee <dakupoto@americanmaid.ece.utexas.edu> wrote:
> Could some Perl/CGI guru please help me? I have a
> html file containing a form, from inside of which
> I invoke a CGI script. Now what I am trying to do
> is open a simple text file from inside the CGI
> script, and write some text into it. However, this
> file is never getting created. The following code
> block shows this:
> open(FILEHAN, ">dat.txt") ||
> die "File could not be opened!\n";
> print FILEHAN "This is a test.";
> close(FILEHAN);
This code does not show this problem. The problem
lies elsewhere -- probably in either file permissions
or web server configuration.
> I am not getting any error message either. Could
> someone please point out what I might be doing
> wrong? Thanks in advance for your help!
You're likely not getting any error message in the
browser because you are using die() to report any
errors. This is not CGI friendly. Either use a
module like CGI::Carp that facilitates putting
fatal errorrs to a browser or do a print() then an
exit(). I'd recommend using CGI::Carp.
Chris
--
Christopher E. Stith
Where there's a will, there's a lawyer.
------------------------------
Date: Sat, 10 Mar 2001 18:40:05 GMT
From: "Q" <qlindsay@gte.net>
Subject: Re: PLEASE HELP - Problem with CGI script
Message-Id: <9yuq6.533$oj3.165000@dfiatx1-snr1.gtei.net>
Your script works. You have some other problem. maybe file permissions or
where your script is residing on the serve.
"Amal Banerjee" <dakupoto@americanmaid.ece.utexas.edu> wrote in message
news:Pine.SOL.3.93.1010309213551.23675A-100000@americanmaid.ece.utexas.edu..
.
>
> Could some Perl/CGI guru please help me? I have a html file containing
> a form, from inside of which I invoke a CGI script. Now what I am
> trying to do is open a simple text file from inside the CGI script,
> and write some text into it. However, this file is never getting
> created. The following code block shows this:
>
> open(FILEHAN, ">dat.txt") || die "File could not be opened!\n";
> print FILEHAN "This is a test.";
> close(FILEHAN);
>
> I am not getting any error message either. Could someone please
> point out what I might be doing wrong? Thanks in advance for your
> help!
>
>
------------------------------
Date: Sat, 10 Mar 2001 14:25:19 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: scalar(localtime) in reverse?
Message-Id: <takeaf8usqmc83@corp.supernews.com>
Bart Lateur <bart.lateur@skynet.be> wrote:
> Bart Lateur wrote:
>> /^\w+ (\w+) (\d+) (\d+):(\d+):(\d+) (\d+)$/
> My tests have shown that localtime() puts two spaces
> in front of the day of month, so make that regex:
> /^\w+ (\w+) +(\d+) (\d+):(\d+):(\d+) (\d+)$/
> In fact, you can replace any " " with " +", but
> that's the only one that matters.
Good thing you used a `+', because if you had used two
spaces I don't think it would work for double-digit
days of the month. It appears to me that it uses one
space between the month and day of month and left pads
the day of month with a space for values less than ten.
Chris
p.s. it seems my tagline generator wanted to be
vaguely on topic with the rest of my post
--
Christopher E. Stith
People understand instinctively that the best way for
computer programs to communicate with each other is
for each of the them to be strict in what they emit,
and liberal in what they accept. The odd thing is that
people themselves are not willing to be strict in how
they speak, and liberal in how they listen.
-- Larry Wall, 2nd State of the Onion Address, August 1998
------------------------------
Date: Sat, 10 Mar 2001 18:20:04 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: scalar(localtime) in reverse?
Message-Id: <ofuq6.24967$V6.94423@news1.gvcl1.bc.home.com>
In article <3aa982ab$1_1@news2.uncensored-news.com>,
"Brian J" <sorryno@email.at.all> writes:
>Is there anyway, for example, that 'Tue Jan 2 16:32:11 2001' can be
>turned back into the number of seconds since the Unix epoch. I'm sure
>it can be done with some complex mathematics, but is there a function
>built in that will let me do this?
Not built in, but if you get Date::Parse (http://search.cpan.org/search?dist=TimeDate),
it's easy enough:
$ perl -MDate::Parse -le '$x = localtime; print $x; $y = str2time($x); \
print $y; print scalar localtime($y)'
Sat Mar 10 10:24:20 2001
984248660
Sat Mar 10 10:24:20 2001
--
Peter Scott
------------------------------
Date: Sat, 10 Mar 2001 16:50:47 +0200
From: "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za>
Subject: Re: Trying to capture current directory in variable
Message-Id: <98df1r$2r3m$1@news.adamastor.ac.za>
"Chris Stith" <mischief@velma.motion.net> wrote in message
news:taidbjohh42q96@corp.supernews.com...
> Tom Scheper <tom@power.net.uk> wrote:
> > On Fri, 9 Mar 2001 17:11:59 +0200, "Michael Rolfe"
> > <mumble[anti-spam]@maths.uct.ac.za> shed a beam of light on us:
>
> >>Hi.
> >>
> >>I am a Perl newbie writing a program that does a tree-walk; I want to
store
> >>the original working directory in a variable (without using files, as
write
> >>access may not be assumed). The motivation is to change back to that
> >>directory as part of program completion.
> >>
> >>I am using ActiveState perl, v5.6.0 under Windows 98.
> >>
> >>It seems to me that what I should do is
> >>
> >>$OriginalDirectory = `cd` ;
>
> > `cd` doesn't return anything. The reason why you might see a path if
> > you type it in the shell you're using is because your shell shows it,
> > not the cd command. Try doing it this way:
Ach,so? <makes note>
> It does return something for me, and I'm testing on Windows 98 SE
> with:
>
> C:\WINDOWS>perl -v
>
> This is perl, v5.6.0 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
>
> Copyright 1987-2000, Larry Wall
>
> Binary build 623 provided by ActiveState Tool Corp.
> http://www.ActiveState.com
> Built 16:27:07 Dec 15 2000
>
> The following works for me:
>
> perl -e "$OD = `cd`; print $OD;"
Nope; it only seems to work cuz the shell prints the cwd to STDOUT (I went
there before positng.
> > $OriginalDirectory=chomp(`pwd`);
>
> > There will more than likely be a perl equivalent, which is better to
> > use, but I don't know by heart what it is.
>
> How about a Windows equivalent, since that's where the user is.
> There is no `pwd' command on Windows 98.
What he said.
> The OP might try
>
> $OriginalDirectory = `command /c cd`;
>
> which launches a new command interpreter, runs the command,
> then exits the CI and returns. It also works for me, albeit
> more slowly and with more overhead.
But not for me. I dint expect it to cuz, in the days of MS-DOS <choke,
wheeze> `command /c cd` was essentially the same as `cd` (except for more
overhead).
> But, since this is Perl, and the interpreter comes with many,
> many standard modules, one of them being Cwd, I'd suggest that
Hel-lo! <Thinks: "What are these?><flip, flip, page, page, perldoc, perldoc,
read, read>Ah-ha! Thank you; most useful. I am enlightened and...
> Michael and Tom both read up on Cwd.
use Cwd ;
$OriginalDirectory = cwd ;
...works like a charm.
Thank you, thank you, thank you, Mrs. Tittlemouse.
> Type the following at a command prompt:
>
> `perldoc Cwd'
>
> Chris
>
> --
> Christopher E. Stith
> Disclaimer: Actual product may not resemble picture in ad in any way.
>
------------------------------
Date: Sat, 10 Mar 2001 17:06:08 +0200
From: "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za>
Subject: Re: Trying to capture current directory in variable
Message-Id: <98dfuj$2rbn$1@news.adamastor.ac.za>
"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:40fiat0ljra2hijpic7kue0l9v2uhotjqb@4ax.com...
> "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> wrote:
>
> >I am a Perl newbie writing a program that does a tree-walk; I want to
store
> >the original working directory in a variable (without using files, as
write
> >access may not be assumed). The motivation is to change back to that
> >directory as part of program completion.
>
> use Cwd; my $curdir = cwd; print "Current directory: $curdir\n";
Noted; tx.
> But, as Randal Schwartz already wrote: when writing a directory tree
> walker program, you first response should be File::Find.
Tx4this2U&Randal, ticuly as my sucky newsfeed didn't give me his post.
Armed with new knowledge on existence of standard modules will pursue
hotleigh.
> --
> Bart.
------------------------------
Date: Sat, 10 Mar 2001 17:08:12 +0200
From: "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za>
Subject: Re: Trying to capture current directory in variable
Message-Id: <98dg2e$2rbp$1@news.adamastor.ac.za>
"Richard J. Rauenzahn" <nospam@hairball.cup.hp.com> wrote in message
news:984175443.648880@hpvablab.cup.hp.com...
> "Michael Rolfe" <mumble[anti-spam]@maths.uct.ac.za> writes:
> >Hi.
> >
> >I am a Perl newbie writing a program that does a tree-walk; I want to
store
> >the original working directory in a variable (without using files, as
write
> >access may not be assumed). The motivation is to change back to that
> >directory as part of program completion.
>
> Just in case you meant, "to change back to the directory *after* program
> completion," you don't need to do anything. When the Perl program
Yiz; dat's zigackly what I meant.
> exits, it will return to the original directory (which batch files
> *don't* do.)
Good gravy. It does? Hmmmm. Tx.
<Thinks: all that time and effort, leading to "What you need to do is
nothing." Ah, well, it's all part of that character-building newbie
experience<twitch>...>
> I guess DOS batch files are one reason many are surprised that they
> can't change the environment from within a Perl script.
>
> Rich
>
> --
> Rich Rauenzahn ----------+xrrauenza@cup.hp.comx+ Hewlett-Packard Company
> Technical Consultant | I speak for me, | 19055 Pruneridge Ave.
> Development Alliances Lab| *not* HP | MS 46TU2
> ESPD / E-Serv. Partner Division +--------------+---- Cupertino, CA 95014
------------------------------
Date: Sat, 10 Mar 2001 14:40:00 -0000
From: "Hamed Nik" <Hamed53@btinternet.com>
Subject: Use module without installing!
Message-Id: <98defl$kih$1@neptunium.btinternet.com>
hi, i have a question, can you please direct where i can find info about it,
or if you could please give me an answer.
i am trying to use the Date::Calc module, but unfortunately because i am on
a shared server, my host wouldnt allow me to install this module for thei
own reasons.
they told me that you can use the module from your own cgi-bin directory,
but i personally dont think that cant be done in Date::Calcs case, can you
please tell me how to use this or any other modules without installing it
directory to perl?
thank you in advanced
hamed
------------------------------
Date: Sat, 10 Mar 2001 16:18:11 +0000
From: Joe Branton <jbranton.remove_dot_and_everything_else@clara.net>
Subject: Re: Use module without installing!
Message-Id: <Wssq6.11698$HR6.1081874@nnrp4.clara.net>
use FindBin;
use lib $FindBin::Bin;
should allow you to use any module in the directory your script lives in.
Joe.
Hamed Nik wrote:
> hi, i have a question, can you please direct where i can find info about it,
> or if you could please give me an answer.
>
> i am trying to use the Date::Calc module, but unfortunately because i am on
> a shared server, my host wouldnt allow me to install this module for thei
> own reasons.
>
> they told me that you can use the module from your own cgi-bin directory,
> but i personally dont think that cant be done in Date::Calcs case, can you
> please tell me how to use this or any other modules without installing it
> directory to perl?
>
> thank you in advanced
> hamed
>
>
>
>
------------------------------
Date: Sat, 10 Mar 2001 16:44:27 +0100
From: Matthias Papesch <mpapesch@gmx.de>
Subject: XS - typemap void ?
Message-Id: <98di2u$52f$07$1@news.t-online.com>
Hi,
I'm trying to create a PERL interface for a c-library and encountering a
few problems.
The header file contains many typedefs, such as INT32, FLOAT64, ... ,which
can easily be covered in the typemap.
The problem occurs with VOID for void.
These lines work
>>>
void
sample_func(arg1)
INT32 arg1
<<<
while the following won't
>>>
VOID
sample_func(arg1)
INT32 arg1
<<<
Is there any way to typemap void ?
TIA,
Matthias
------------------------------
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 V10 Issue 461
**************************************