[11021] in Perl-Users-Digest
Perl-Users Digest, Issue: 4621 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jan 11 17:02:16 1999
Date: Mon, 11 Jan 99 14:00:22 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 11 Jan 1999 Volume: 8 Number: 4621
Today's topics:
Re: Active State package questions dturley@pobox.com
Re: Active State package questions <mclellan@ReactionDesign.com>
Re: Active State package questions <ludlow@us.ibm.com>
Re: Bar code gif generation (Leo Schalkwyk)
Re: calling a c pgm with PERL system (what is syntax?) (Tad McClellan)
Re: Can I execute Perl Scipt from VB ? <pixel_@geocities.com>
Re: CGI.pm tables dturley@pobox.com
CONCLUSIVE PROOF: Jesus *is* King of the Jews ! ! ! <dave@quik.demon.co.uk>
Re: help needed to find the size of a file using perl (Tad McClellan)
International Language Support (rick)
Intro To Perl Tutorial - Boulder 1/26-28/99 <johnd@xor.com>
Re: line-length limitations <framsing@unr.edu>
Perl 5.0005_02 fails "make test", db-btree and db-hash (Rob Tanner)
perl cgi (win95) doesn't work with CGI.pm (Edwin Litterst)
Re: Perl Criticism <design@raincloud-studios.com>
Perl Magick, under NT4, installation trouble ( CL.EXE ) <mroark@amerisale.com>
Re: Perl TK text question <lusol@Pandora.CC.Lehigh.EDU>
Re: Rambling through hash.... <design@raincloud-studios.com>
Re: rpm 5.005_?? ? <pixel_@geocities.com>
Re: Seeking crypt/des entirely in Perl (no C) <richardsonja@logica.com>
Re: Shame: Deleting List Elements (Tad McClellan)
Re: Someone asked how to capitalise first letter of eac (Martien Verbruggen)
Re: Sorting question (Charles DeRykus)
substituting an exact negated string: can I? <mmorgan@gladstone.uoregon.edu>
unpack?? Or how to extract binary data written by C++. <allen@mango.com>
Re: Verify an email address (Tad McClellan)
Re: Year 2038 problem (John Moreno)
Yet another REGEX question <death@N-O-S-P-A-M.solaris1.mysolution.com>
Re: Yet another REGEX question <pixel_@geocities.com>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 Jan 1999 20:48:29 GMT
From: dturley@pobox.com
Subject: Re: Active State package questions
Message-Id: <77do2s$8j3$1@nnrp1.dejanews.com>
In article <77dk2r$4sl$1@nnrp1.dejanews.com>,
Brian Lavender <blavender@spk.usace.army.mil> wrote:
> Where do I find what modules have been compiled into packages for the PPM
> (Perl Package Manager)? I can't find a list on the http://www.ActiveState.com
> website. I need to know that DBI, DBD for ODBC, and DBD for Oracle are
there is a list at http://www.ActiveState.com/packages/default.prk?list=1
____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 11 Jan 1999 13:23:20 -0800
From: "Clifton L. McLellan" <mclellan@ReactionDesign.com>
Subject: Re: Active State package questions
Message-Id: <19um2.650$6P4.7928@news.connectnet.com>
I highly recommend this route. After installing ActiveState and while
connected to the internet, you can go to a command shell and type
ppm search
or, interactively, type
ppm
and then
search
If you see a package you want (like, say, DBD-Oracle) just type
install DBD-Oracle
To verify you have the latest version available at the archive, use
verify
Hey, I show the following:
...
Package 'DBD-Oracle' is up to date.
Package 'DBI' is up to date.
Package 'DBD-ODBC' is up to date.
...
Almost as god as CPAN, though much more limited.
--
Hope this helps,
Clifton L. McLellan
dturley@pobox.com wrote in message <77do2s$8j3$1@nnrp1.dejanews.com>...
>In article <77dk2r$4sl$1@nnrp1.dejanews.com>,
> Brian Lavender <blavender@spk.usace.army.mil> wrote:
>> Where do I find what modules have been compiled into packages for the PPM
>> (Perl Package Manager)? I can't find a list on the
http://www.ActiveState.com
>> website. I need to know that DBI, DBD for ODBC, and DBD for Oracle are
>
>there is a list at http://www.ActiveState.com/packages/default.prk?list=1
>
>____________________________________
>David Turley
>dturley@pobox.com
>http://www.binary.net/dturley/
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 11 Jan 1999 15:39:26 -0600
From: James Ludlow <ludlow@us.ibm.com>
Subject: Re: Active State package questions
Message-Id: <369A6F8E.523E6FE7@us.ibm.com>
Brian Lavender wrote:
> Where do I find what modules have been compiled into packages for the PPM
> (Perl Package Manager)? I can't find a list on the http://www.ActiveState.com
http://www.activestate.com/packages/zips/
--
James Ludlow (ludlow@us.ibm.com)
(Any opinions expressed are my own, not necessarily those of IBM)
------------------------------
Date: 11 Jan 1999 20:50:21 GMT
From: schalkwy@minnie.RZ-Berlin.MPG.DE (Leo Schalkwyk)
Subject: Re: Bar code gif generation
Message-Id: <77do6d$2of$1@fu-berlin.de>
If you're working on unix,
GhostScript can produce a ppm file from a PostScript file,
and ppmtogif converts that to gif. This is packaged in
pstogif which happens to be a perl script. I
don't know where we got it but the following is from the comments and is
probably enough to help you find it (if you don't already have it!)
# pstogif.pl v1.0, July 1994, by Nikos Drakos <nikos@cbl.leeds.ac.uk>
# Computer Based Learning Unit, University of Leeds.
#
# Accompanies LaTeX2HTML Version 96.1
#
# Script to convert an arbitrary PostScript image to a cropped GIF image
# suitable for incorporation into HTML documents as inlined images to be
# viewed with WWW browsers.
#
# This is based on the pstoepsi script
# by Doug Crabill dgc@cs.purdue.edu
#
lucinda.moutou@digital.com wrote:
: Hi,
: I need to generate barcode GIFs (or jpegs). The perl module for this
: purpose generates postscript. Also, there is a postscript/TT font available
: that does barcodes. Finally, there must be someone who's done this before.
: From this one need and three pieces, can anybody suggest how to connect point
: A to point B? (ie convert ps to gif, print fonts as gifs, or other solution)
: Thanks,
: Lucinda
: -----------== Posted via Deja News, The Discussion Network ==----------
: http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
--
------------------------------------------------------------
schalkwy@mpimg-berlin-dahlem.mpg.de
------------------------------
Date: Mon, 11 Jan 1999 14:23:20 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: calling a c pgm with PERL system (what is syntax?)
Message-Id: <ojmd77.989.ln@magna.metronet.com>
Michael J. Wrobel (mjw@hrb.com) wrote:
: I have a perl cgi script where I want to use system to call a C
: program. I want to pass paramaters to this c executable
That part you do the same way as you would from the command line.
: and return 2
: parameters.
Unix utilities (even custom ones) can only return one value,
commonly known as the "exit value".
The "exit value" is usually zero for success and non-zero
if there was a problem.
You cannot get it to _return_ two parameters, you can get it
to _output_ two parameters though.
Is that what you mean?
: Would anyone know the syntax of this problem?
How to capture the standard output of a program is given
in the documentation for system() in the perlfunc.pod man page.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 11 Jan 1999 20:28:46 +0100
From: Pascal Rigaux <pixel_@geocities.com>
Subject: Re: Can I execute Perl Scipt from VB ?
Message-Id: <4wsodhpq1d.fsf@dre2.polytechnique.fr>
"Barry G. Sumpter" <bsumpter@msn.com.au> writes:
> Thanks for that - but how do I get Perl to return
> an error code thru the Shell command?
>
exit <error code> does this.
(try perl -e "exit 3" ; echo $? )
Hope it helps, Pixel
------------------------------
Date: Mon, 11 Jan 1999 19:53:47 GMT
From: dturley@pobox.com
Subject: Re: CGI.pm tables
Message-Id: <77dks9$5p7$1@nnrp1.dejanews.com>
In article <77dehm$vns$1@nnrp1.dejanews.com>,
shaundoolan@my-dejanews.com wrote:
> When using CGI.pm to print my html, I'm having trouble printing values of
> variables inside the code for printing the table cell. I can't get it to
> evaluate these variables with the way I currently have it.....any suggestions?
>
> I'm trying to do the following:
>
> print Tr([td({-colspan=>'2'},
> ['Description:<br><i>$description</i><br>'])]);
>
The string that contains your variables is in single-quotes. Variable to not
get interpolated in single quotes. Try:
["Description:<br><i>$description</i><br>"])]);
> Also, is there any way to use the standard methods for using other tags inside
> the table cell? I'm guessing I need a totally different approach here.....
print Tr(td({-colspan=>'2'},
'Description:',br,i($description),br));
____________________________________
David Turley
dturley@pobox.com
http://www.binary.net/dturley/
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Mon, 11 Jan 1999 18:57:12 +0000
From: Dave Storey <dave@quik.demon.co.uk>
Subject: CONCLUSIVE PROOF: Jesus *is* King of the Jews ! ! !
Message-Id: <sjPWDEAImkm2EwXd@quik.demon.co.uk>
I figure he tail-gated AndersonRM ? Then the question becomes how ARM
got in ..
In article <Pine.HPP.3.96.990111185405.20337C-100000@mbox.ki.se>,
Dominic-Luc Webb molmed <domweb@mbox.ki.se> writes
>One thing for sure... Jesus was not an amateur astronomer
>and was never known for building telescopes which makes me
>wonder how he ended up here at alt...astro
>
>
>Cheers,
>Dominic
<snip>
Rgds
Dave Storey
------------------------------
Date: Mon, 11 Jan 1999 14:41:51 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: help needed to find the size of a file using perl
Message-Id: <fmnd77.hc9.ln@magna.metronet.com>
amit saha (amit@remarq.com) wrote:
: I need to know the size of a file. How can I do so using perl ?
: Please, help me with some sample code.
print "a_file is ", -s 'a_file', " bytes\n";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 16:01:47 -0500
From: "Pat(rick) Meehan" <meehan@us.ibm.com>
Subject: International Language Support
Message-Id: <369A66BB.41C6@us.ibm.com>
Is there any ILS for Perl? If so, where? If not, are there plans to IL
Perl ...
--
_/_/ _/ _/_/_/_/ | Pat(rick) Meehan (WWW & I trade patches)
_/ _/ _/ _/ |
_/_/_/_/ _/ _/_/_/ | email: mailto:meehan@us.ibm.com
_/ _/ _/ _/ |
_/ _/ _/_/_/ _/ | Phone:(914) 433-7916 :: fax:(914) 433-8363
------------------------------
Date: Mon, 11 Jan 1999 14:04:38 -0700
From: John Donnelly <johnd@xor.com>
Subject: Intro To Perl Tutorial - Boulder 1/26-28/99
Message-Id: <369A6766.2C05@xor.com>
Openings exist (3) in the upcoming Intro To Perl tutorial at our
training facility in Boulder, CO. Class size is limited to 10
registrants in order to enhance the learning environment in a
lecture/lab presentation. Contact me for registration information.
--John Donnelly, Training Coordinator
XOR Network Engineering, Inc.
http://www.xor.com/; johnd@xor.com; 303-448-4816
*****
Introduction to Perl for Programmers
(Three Day Hands-on Lecture/Lab)
Tuesday - Thursday, January 26-28, 1999 (Boulder, CO)
Tom Christiansen, Perl Consultancy
Tuition: $995
Tom Christiansen has over fifteen years experience in pro-
gramming, administering, and teaching about UNIX and Inter-
net systems. He has been involved with Perl since day zero
of its initial public release in 1987. Co-author of the 2nd
editions of Programming Perl, Learning Perl, and Learning
Perl on Win32 Systems from O'Reilly and Associates, Tom is
also the developer of the www.perl.com website, major care-
taker of Perl's online documentation, co-author of the Perl
Frequently Asked Questions list, and president of The Perl
Journal. Tom served two terms on the USENIX Association
Board of Directors. He holds undergraduate degrees in Com-
puter Science and Spanish and a Masters in Computer Science
from the University of Wisconsin - Madison.
Designed to be programmer-friendly and platform-neutral,
Perl is a high-level, general-purpose programming language
that makes easy and medium-hard tasks easy and seriously
non-trivial tasks possible. Now moving into its second
decade, Perl has become the language of choice across all
platforms for programmers engaged in rapid prototyping, sys-
tem utilities, software tools, system management tasks, data
base access, graphical programming, and world wide Web pro-
gramming.
NOTE: While this course is based on the current release of
Perl (version 5.004), it is not intended to be a detailed
discourse on all advanced programming constructs now
afforded by that release. It is a jump-start introduction
to Perl for experienced programmers, not an advanced course
for Perl programmers.
Who should attend:
This three-day course is an intensive introduction designed
with programmers in mind, preferably those with backgrounds
in C programming, shell scripting, or both.
Prerequisites:
Ability to edit files with a UNIX text editor. While some
previous exposure to Perl is beneficial, it's not essential.
Because Perl incorporates aspects of more than a dozen
well-known UNIX tools, experienced UNIX programmers and
administrators will come up to speed on Perl very rapidly,
but programmers on other platforms can also learn and use
Perl.
Topics Include:
+ Detailed Descriptions and Numerous Examples of:
Syntax and semantics of the language, its data types, and data
structures
Operators and control flow
Regular expressions
I/O facilities
User-defined functions
Writing and using library modules
+ An easy introduction to Perl's object-oriented programming
mechanisms
------------------------------
Date: Mon, 11 Jan 1999 11:47:16 -0800
From: Fred Ramsing <framsing@unr.edu>
To: Rick Delaney <rick.delaney@home.com>
Subject: Re: line-length limitations
Message-Id: <Pine.GSO.3.96.990111114547.19561A-100000@equinox>
On Sun, 10 Jan 1999, Rick Delaney wrote:
>
> Fred Ramsing wrote:
> >
> > while (<INPUT>) {
> > chomp $_;
> > @line = split (/ |\t/ );
>
> This should be faster and might even be noticeable for such a large
> file:
>
> @line = split /[ \t]/;
>
> I leave the Benchmark'ing to you.
about 15% faster.
Fred
------------------------------
Date: Mon, 11 Jan 1999 13:37:31 -0800
From: rtanner@linfield.edu (Rob Tanner)
Subject: Perl 5.0005_02 fails "make test", db-btree and db-hash tests
Message-Id: <rtanner-1101991337310001@wildflower.linfield.edu>
I built Perl 5.0005_02 on Salaris 2.6 and ran "make test". Everything is
okay except db-btree.t #36 and db-hash.t #31. In both cases, what is
being tested is the R_NOOVERWRITE flag. No idea what's causing the
problem. I presume I've either misconfigured something or am missing some
library on the Solaris box.
Have any ideas.
Thanx, Rob
_ _ _ _ _ _ _ _ _ _
/\_\_\_\_\ /\_\ /\_\_\_\_\_\
/\/_/_/_/_/ /\/_/ \/_/_/_/_/_/ QUIDQUID LATINE DICTUM SIT,
/\/_/__\/_/ __ /\/_/ /\/_/ PROFUNDUM VIDITUR
/\/_/_/_/_/ /\_\ /\/_/ /\/_/
/\/_/ \/_/ /\/_/_/\/_/ /\/_/ (Whatever is said in Latin
\/_/ \/_/ \/_/_/_/_/ \/_/ sounds profound)
Rob Tanner
UNIX and Networks Manager
Linfield College, McMinnville, OR
(503) 434-2558 <rtanner@linfield.edu> _____________________________________________________________________
------------------------------
Date: Mon, 11 Jan 1999 21:26:28 GMT
From: el@fiz-karlsruhe.de (Edwin Litterst)
Subject: perl cgi (win95) doesn't work with CGI.pm
Message-Id: <369a6b07.2599230@news>
A small demo perl script works nice if called from the command line
but doesn't return anything if CGI.pm is included:
use Cgi;
print "Content-Type: text/plain\n\n";
print "Hello, World!\n";
The directory which contains the libs is part of the @INC.
I read the CGI FAQ as well as the Win32 FAQ but nothing seems to
apply.
Thanks in advance for every help,
Eddie
------------------------------
Date: 11 Jan 1999 21:14:56 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Perl Criticism
Message-Id: <77dpkg$3e8@bgtnsc03.worldnet.att.net>
>> >> Example #2, for instance. I have written
>> mission critical military applications<<
use COFFEE::Filter
Open(GROUND_COFFEE, "Sanka");
While(GROUND_COFFEE){
push(@water,$_);
}
Close(GROUND_COFFEE);
my @condiments=('sugar','milk')
&addcondiments(@condiments);
&drink()|| Die("This coffee stinks private!");
1;
>>...The same people that put NT on submarines.
Am I the only person who sees a really good "Blue Screen" joke
there?
CT
------------------------------
Date: Mon, 11 Jan 1999 15:18:52 -0600
From: "Micah Roark" <mroark@amerisale.com>
Subject: Perl Magick, under NT4, installation trouble ( CL.EXE )
Message-Id: <BTtm2.1599$nJ.8077@typhoon01.swbell.net>
I am trying to install Perl Magick, the perl interface to Image Magick
(command-line image manipulation) from
http://www.wizards.dupont.com/cristy/
(Perl Magick: http://www.wizards.dupont.com/cristy/www/perl.html)
Summary: after all the hard work, it turns out I am missing CL.EXE , so
cannot continue.
Unfortunately, Image Magick and Perl Magick must be setup on NT in my case,
therefore the installation has proven quite painful. After wrestling with
ActiveState's Perl 316, and discovering that I only had the core, and that I
needed the "ActivePerl" distribution which includes the normal modules
needed for MakeFiles (this is all new to me), I am finally ready
to run "nmake" to install perlmagick. I do not have access to a copy of
Microsoft Visual C++, so to get nmake, I had to search the net for it. I
found an obscure link to support files hidden deep within
microsoft.com/support (no where could you find this link in microsoft's
support section) which produced a distributable version of NMAKE.EXE for
NT4/win32.
Upon downloading and running Nmake on the makefile
perl Makefile.pl
..../nmake
..../nmake install
nmake reports a fatal error, unable to locate CL.EXE. Ah, so cl.exe is not
included with the Microsoft distribution of nmake. (which brings to mind,
why distribute nmake for use with net scripts if you are only going to need
cl.exe anyway??? again, microsoft shines through with pure brilliance.)
At any rate, I am unable to find CL.EXE anywhere. I'm hoping someone reading
this has run into something similar with Perl Magick or another script using
C in the installation scheme. Does anyone know where a copy exists? This is
not for the distribution of a commercial product (we are not making any
money by using cl.exe). Thanks,
Micah Roark mroark@amerisale.com
------------------------------
Date: 11 Jan 1999 19:07:17 GMT
From: "Stephen O. Lidie" <lusol@Pandora.CC.Lehigh.EDU>
Subject: Re: Perl TK text question
Message-Id: <77di55$b7q@fidoii.cc.Lehigh.EDU>
Tom Turton <tturton@cowboys.anet-dfw.com> wrote:
> Thanks Stephen, that did indeed do the trick.
I forgot to mention last time, there's an entire group devoted to Perl/Tk:
comp.lang.perl.tk, so direct questions there (-:
> I noticed you used a 'Scrolled' widget with a 'Text' parameter. Is there an
> equivalent 'Text' widget similar to the book example (with the dashes in front of
> the options)?
Oh, you can use Text like you were. The Scrolled() method just add scrollbars
to the standard Text widget.
> I don't seem to turn up any documents on Tk via manpages or perldoc (currently we
> have Perl version 5.004_02 on our system). Perhaps the docs are referenced another
> way?
But what Tk version? Try:
perldoc Tk::Text
Or get the source distribution yourself and look in the .../pod directory.
------------------------------
Date: 11 Jan 1999 21:26:18 GMT
From: "Charles R. Thompson" <design@raincloud-studios.com>
Subject: Re: Rambling through hash....
Message-Id: <77dq9q$6j5@bgtnsc03.worldnet.att.net>
>Looks ok to me, but I'd use ``$rm_data{$item}'' instead of
``rm_data{$item}''.
The code got trimmed. Same thing happened with the cgi
newsgroup. Strange.
>The keys will be 'out of order' for reasons of efficiency.
>Use 'sort' to arrange them - (sort keys %whatever).
So unless I really need to sort them for reasons of output or
something, I'm left to believe it's best to just leave it as is.
Thanks. CT
------------------------------
Date: 11 Jan 1999 21:02:05 +0100
From: Pascal Rigaux <pixel_@geocities.com>
Subject: Re: rpm 5.005_?? ?
Message-Id: <4waezpbmte.fsf@dre2.polytechnique.fr>
Yeoh Yiu <squid@panix.com> writes:
> Is there a red hat/intel rpm for a perl 5.005_??
>
> http://www.redhat.com/support/linux-info/pkglist/PByName.html
> lists only perl-5.004-6.
>
go to filewatcher.org, search for perl*005*i386*, you'll find :
ftp://contrib.redhat.com/libc6/i386/
3689k 1998-08-11 i perl-5.005_02-1.i386.rpm ->rh c. i386 gl
Hope it helps, Pixel.
------------------------------
Date: Mon, 11 Jan 1999 21:06:49 -0000
From: "James Richardson" <richardsonja@logica.com>
Subject: Re: Seeking crypt/des entirely in Perl (no C)
Message-Id: <77dp5d$n52@romeo.logica.co.uk>
b_rosser@yahoo.com wrote in message <77d6un$oh3$1@nnrp1.dejanews.com>...
>Hi. I'd like to develop a perl script on a machine to which I
>have no System Administrator privileges, and which also has
>no C compiler, so I don't have the option of installing the
>CPAN Crypt modules (from what I've seen I gather they all rely on
>some C code?).
>
>Is there any module/code for two-way encryption which is
>written entirely in perl? Performance is not too much of an
>issue unless it's really horrible!
>
>Thanks,
I amswered just this question (sort of!) about 3 weeks ago on
comp.lang.perl.modules.... check the answer there. In the site i referred to
you can find an 'in perl' version of DES 64 bit ecb encryption.
Cheers
James
------------------------------
Date: Mon, 11 Jan 1999 12:04:34 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Shame: Deleting List Elements
Message-Id: <ifed77.pm8.ln@magna.metronet.com>
Michael Nguyen (ez062634@mailbox.ucdavis.edu) wrote:
: I know this might sound stupid but as i recall the last element of a
: splice command determines the length of the list that is to be produced.
: i'm probably wrong so please correct me.
It is not helpful to post incorrect information.
It is hurtful to do so.
If you think you are wrong, then don't post it.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 21:57:22 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Someone asked how to capitalise first letter of each word
Message-Id: <6tum2.65$Ax2.2245@nsw.nnrp.telstra.net>
In article <776b05$ial$1@samba.rahul.net>,
morris@rahul.net (Steve Morris) writes:
> This one will work if you agree with Perl's definition of the start of a
> word.
It's a bit funny that you reply to a post that refers to perlfaq4, and
then post the solution that that specific faq says is wrong in some
cases.
Martien
--
Martien Verbruggen |
Webmaster www.tradingpost.com.au | I think I think, therefore I think I
Commercial Dynamics Pty. Ltd. | am.
NSW, Australia |
------------------------------
Date: Mon, 11 Jan 1999 20:18:51 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Sorting question
Message-Id: <F5EwFF.H9s@news.boeing.com>
In article <773jbk$gai$1@ocean.cup.hp.com>,
Ilya <no_spam_ilya@napavlly.rose.hp.com> wrote:
>
>
>If I have an array that I want to sort by 2 fields, I do:
>
> @new_lines=sort by_components @new_lines;
>
> sub by_components
> {
> (split(/\s+/,$a))[$key1] cmp (split(/\s+/,$b))[$key1]
> ||
> (split(/\s+/,$a))[$key2] cmp (split(/\s+/,$b))[$key2];
> }
>
>
>This will sort the array first by $key1 field and then by $key2 field. My
>problem is that sometimes not all lines have $key2 field, i.e. lines that
>are not long enough. Everything sorts fine even in that case, but I get
>annoying messages of the type:
>
>Use of uninitialized value at ./convert_all.pl line 200.
>
The problem is that the key will produce an
undefined array member for short lines. The
undefined will generate the warning, e.g.,
perl -we '$r = undef cmp "string"'
Use of uninitialized value at -e line 1.
So you can use either of these:
sub by_components {
local $^W = 0;
...
}
or,
sub by_components {
((...[$key1] || '') cmp ((...[$key2] || '')
||
((...[$key1] || '') cmp ((...[$key2] || '')
}
BTW, if you're sorting many items, best to avoid the
repetitive splits.
hth,
--
Charles DeRykus
------------------------------
Date: Mon, 11 Jan 1999 13:52:00 -0800
From: "M. Morgan" <mmorgan@gladstone.uoregon.edu>
Subject: substituting an exact negated string: can I?
Message-Id: <77dre9$ep1$1@pith.uoregon.edu>
Hello,
I want to get rid of anything between < and > from form data unless it is a
hyperlink.
Taking from this form parser (asterisks showing the line I want to modify):
sub Parse_Form {
if ($ENV{'REQUEST_METHOD'} eq 'GET') {
@pairs = split(/&/,
$ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST') {
read (STDIN, $buffer,
$ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
if ($ENV{'QUERY_STRING'}) {
@getpairs =split(/&/, $ENV{'QUERY_STRING'});
push(@pairs,@getpairs);
}
} else {
print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}
foreach $pair (@pairs) {
($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%([a-fA-F0-9][a-fA-F0-9])/
pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/
pack("C", hex($1))/eg;
$value =~s/<!--(.|\n)*-->//g; #
*****************************************************
if ($formdata{$key}) {
$formdata{$key} .= ", $value";
} else {
$formdata{$key} = $value;
}
}
}
1;
I want to change the line: $value =~ s/<!--(.|\n)*-->//g; (shown by
asterisks) to something like the following:
$value =~ s/<[^a href]*?>//gi;
The only problem is that the substitution is looking for any one of the
letters: a, space, h, r, e, and f. It won't allow me to substitute a
negated string of this form. Is there a way to negate 'a href' without the
brackets? How else might I go about this? The goal is to remove any HTML
and SSI except for hyperlinks that a person may enter into a form. I know I
can see if I can match something I don't want in the form data and tell the
user not to do that but I would rather have the script remove it.
Thanks for any help you can offer.
-Mike Morgan
------------------------------
Date: Mon, 11 Jan 1999 16:18:06 -0500
From: "Steve Allen" <allen@mango.com>
Subject: unpack?? Or how to extract binary data written by C++.
Message-Id: <77dpqf$lke$1@ligarius.ultra.net>
I'm a little slow today, so I must be missing the simple key to my problem.
I've done lots of perl that wrestles with textual data, but I'm not sure how
to deal with binary data. I tried to use unpack, and can't quite figure out
how to apply it here. I have a binary file written by a c++ program that I
would like to read in perl. The data was written via a c++ struct
struct Thing {
unsigned long arg1;
unsigned long arg2;
unsigned short arg3;
};
(This is a much simplified example). I can open the file, seek to the
records of interest and read them into a string. i.e.
open( . . . .)
seek(FILE,somewhere,0);
read(FILE, $buffer, $size_of_Thing);
But now what? As I understand it $buffer is packed with binary data that
isn't text. Unpack seems to be the method to use but I've never quite
figured out how to use it to exract arg2 in this case. I suppose I could
just do a bunch of seeks and read one int at a time, but that *has* to be
the worse way to do this.
Any clues, or even a pointer to a useful unpack example would be
appreciated. The Perl book doesn't seem to make it clear to me.
Tanks tons.
Steve
------------------------------
Date: Mon, 11 Jan 1999 12:07:24 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Verify an email address
Message-Id: <sked77.pm8.ln@magna.metronet.com>
John Moreno (phenix@interpath.com) wrote:
: anybody
: can be wrong (hell, *I* was wrong once).
I thought I was wrong once, but I wasn't, so I was ;-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 11 Jan 1999 15:06:13 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Year 2038 problem
Message-Id: <1dlh340.crmeq325lqk4N@roxboro0-056.dyn.interpath.net>
Gareth Rees <garethr@cre.canon.co.uk> wrote:
> Trond Michelsen <mike@crusaders.no> wrote:
> > the date-rollover is not your biggest problem if you're still using a
> > 32-bit computer in 2038.
>
> What if you want to represent dates 40 years in the future?
Change the relevant functions to use a unsigned 32-bit int (unless
you're using a mac which already uses a unsigned 32-bit value, but
starts counting in 1904, in which case you've got to make some bigger
changes).
Or more simply -- don't keep the time in seconds if you don't have to.
If you are recording birthdays, or deaths, or when a loan comes due or
anything else that is in the distant future you don't need the precision
of using seconds, and so to represent it in a platform independent
manner it's better NOT to.
--
John Moreno
------------------------------
Date: Mon, 11 Jan 1999 15:50:30 -0500
From: "K.T." <death@N-O-S-P-A-M.solaris1.mysolution.com>
Subject: Yet another REGEX question
Message-Id: <77dnv0$ams$1@nnrp03.primenet.com>
Anyone know how to do this?
string1<TAB>string2<TAB>number3<TAB>string4<NEWLINE>
any of the strings or numbers can be not present so it might be <TAB><TAB>
convert to
"string1","string2",number3,"string4"<NEWLINE>
Heres what I got so far:
s/\t/\","/g; - converts all tabs to ","
s/^/\"/; - adds in " at beg of line
s/\n/\"\n/; - adds in " at end of line
But I cannot figure out how to unquote the number...anyone got any ideas?
------------------------------
Date: 11 Jan 1999 22:04:04 +0100
From: Pascal Rigaux <pixel_@geocities.com>
Subject: Re: Yet another REGEX question
Message-Id: <4w1zl1bjy3.fsf@dre2.polytechnique.fr>
> string1<TAB>string2<TAB>number3<TAB>string4<NEWLINE>
>
> convert to
>
> "string1","string2",number3,"string4"<NEWLINE>
maybe a solution
join ",",
map { /string/ ? "\"$_\"" : $_ }
split /\t+/, $_;
But first you have to chop the newline (and put it back if you want).
The /\t+/ can be replaced by /\t/ depending on what you want (\t\t -> ,, or ,)
Hope it helps, Pixel.
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 4621
**************************************