[7978] in Perl-Users-Digest
Perl-Users Digest, Issue: 1603 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 8 17:07:21 1998
Date: Thu, 8 Jan 98 14:00:23 -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 Thu, 8 Jan 1998 Volume: 8 Number: 1603
Today's topics:
Re: 100.90 NOT 100.90000000000000568 HELP (Chris Adams)
[BOOK RECOMMENDATION] Effective Perl nospam@no.uce.please
Re: Calling 'require' on an arbitrary module (Earl Hood)
Re: Database File Manipulation? <rootbeer@teleport.com>
Re: file glob restrictions?! <rootbeer@teleport.com>
Re: how does 'require' work? <rootbeer@teleport.com>
How to Tar & unzip Perl mods on CPAN site on Win32? <emorr@fast.net>
Oraperl problem <donner@lanl.gov>
Re: Perl CGI - Apache 1.2 <mhazen@franklin.uga.edu>
Re: Perl editor needed (Matthew Cravit)
Re: perl manipulation of dbf(dBASE) or db(Paradox) file (bgeer)
Re: Perl to EXE <moc.care@hcajp - Reverse to get address>
Re: Perl to EXE <James.Cherry.0504266@nortel.ca>
Re: Perl to EXE <tchrist@mox.perl.com>
Re: PERLIPC - FIFO: parent, child, stalled! (Chip Salzenberg)
Re: print SOCK "Whatever"; (Josh Kortbein)
RE:running a program from PERL and capturing the output <barnett@houston.Geco-Prakla.slb.com>
Re: Search/sorting question (and what does "Can't use " <ajh@rtk.com>
Re: Search/sorting question <bowlin@sirius.com>
Simple string length <geoffrey.conner@gsc.gte.com>
Re: Simple string length (Joel Coltoff)
Re: Simple string length (Kevin Reid)
Stored Procedures using Oraperl <rarun@geocities.com>
Re: Testing for valid RegExps? (Ilya Zakharevich)
Re: Testing for valid RegExps? <mhazen@franklin.uga.edu>
Text::Wrap mod needed for HTML <romeyde@mc0115.mcclellan.af.mil>
undumping perl <James.Cherry.0504266@nortel.ca>
Re: Unpacking length-infor style data. <rootbeer@teleport.com>
Win32 module with Perl 5.004_2 <bowlin@sirius.com>
Re: Would yo explain the Perl "pack" command to me? (Josh Kortbein)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 8 Jan 1998 20:35:22 GMT
From: cadams@ro.com (Chris Adams)
Subject: Re: 100.90 NOT 100.90000000000000568 HELP
Message-Id: <693daa$6if$1@news.ro.com>
According to William R. Ward <hermit@cats.ucsc.edu>:
>Zenin <zenin@best.com> writes:
>> William R. Ward <hermit@cats.ucsc.edu> wrote:
>> : If you want to round to the hundredths use this:
>> : my $rounded = int (( $orig * 100 ) + .5 ) / 100;
>> $rounded = sprintf ('%.2f', $orig);
>
>You're right, that is actually faster. I came up with the arithmetic
>method because I thought it would be faster, but apparently it isn't.
>Here's the results using Benchmark to time:
The arithmetic method is faster when you compare it to a sprintf that
works. :-)
You had:
sprintf('.2f', $value);
instead of:
sprintf('%.2f', $value); # note the %
With the correct sprintf, I get
Benchmark: timing 100000 iterations of arith, sprintf...
arith: 2 secs (-0.02 usr 2.24 sys = 2.22 cpu)
sprintf: 8 secs ( 0.17 usr 8.98 sys = 9.15 cpu)
I expect printing a constant string is a _lot_ faster than doing math.
--
Chris Adams - cadams@ro.com
System Administrator - Renaissance Internet Services
I don't speak for anybody but myself - that's enough trouble.
------------------------------
Date: 8 Jan 1998 19:06:01 GMT
From: nospam@no.uce.please
Subject: [BOOK RECOMMENDATION] Effective Perl
Message-Id: <69382p$t8i$2@schbbs.mot.com>
In article <34B32AE7.FCD3088@5sigma.com>,
"Joseph N. Hall" <joseph@5sigma.com> writes:
> Of course, I also have an intermediate to advanced Perl book
> hitting the shelves. Hope you'll take a look at it too.
> Buy both! :-)
Thats what I did ;-)
I just received my copy of "Effective Perl" this week. I like it a
*lot* - I can't say enough good thinks about it. Its certainly not for
someone just learning the language. But for someone whose just
starting to get it under their belt (or have done so for a while now)
its fantastic. Its loaded with lots of short+sweet tips and trick for
effective perl style, performance, programming functionality, etc.
Despite the fact that I've been using Perl for more than five years, I
still learned a lot from this book, and I very much like the way the
vast majority of the material was presented. I think the author was
very faithful to his intent of creating a Perl equivalent of Scott
Meyer's "Effective C++" books. While it is true the book isn't
comprehensive (nor does it try to be), I think it ranks right up there
in importance with the newly revised edition of O'Reillys "Programming
Perl" (the "Camel" book). I truly feel that "Effective Perl" belongs
on every serious Perl programmer's bookshelf.
Book info follows:
Effective Perl Programming: Writing Better Programs with Perl
by: Joseph Hall, Randal L. Schwartz
Addison-Wesley, December 1997,
ISBN: 0-201-41975-0
For online info, see:
http://www.effectiveperl.com/
http://cseng.aw.com/bookdetail.qry?ISBN=0%2D201%2D41975%2D0&ptype=0
The top-level TABLE OF CONTENTS follows (the detailed TOC can be found
at the www.effectiverperl.com website):
* Foreword by Randal Schwartz
* Preface
* Acknowledgements
* Introduction
* Basics
* Idiomatic Perl
* Regular Expressions
* Subroutines
* References
* Debugging
* Using Packages and Modules
* Writing Packages and Modules
* Object-Oriented Programming
* Miscellany
* Appendix A: sprintf
* Appendix B: Perl Resources
* Index
Just another satisfied Perl book reader :-)
--
Brad Appleton <bradapp@enteract.com> | http://www.enteract.com/~bradapp/
"And miles to go before I sleep." | 3700+ WWW links on CS & Sw-Eng
------------------------------
Date: 8 Jan 1998 20:48:56 GMT
From: ehood@medusa.acs.uci.edu (Earl Hood)
Subject: Re: Calling 'require' on an arbitrary module
Message-Id: <693e3o$2kv@news.service.uci.edu>
In article <34b3c6cc.94569@nntp.netcom.net.uk>,
Tom Hukins <tom@NOSPAMeborcom.com> wrote:
>I have an animal, $animal, which needs feeding. If it's a bird
>I'll give it seed, if it's a dog I'll give it dog food. However,
>there are thousands of animals in the world, and this could be
>any one of them. Fortunately, $animal knows what it is; if it's a
>dog it contains $animal->{'creature'} contains 'Dog', if it's a
>bird $animal->{'creature'} contains 'Bird'.
>
>What my animal feeding code would do is something like this:
> $creature = $animal->{'creature'};
> require "Animal::$creature";
> Animal::$creature->feed($animal);
If a string is used as an argument to require, it is treated as
a filename. Do the following instead:
require "Animal/$creature.pm";
Just replace "::" with "/" and add the .pm extension.
--ewh
--
Earl Hood | University of California: Irvine
ehood@medusa.acs.uci.edu | Electronic Loiterer
http://www.oac.uci.edu/indiv/ehood/ | Dabbler of SGML/WWW/Perl/MIME
------------------------------
Date: Thu, 8 Jan 1998 13:45:02 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Georgiadis <michael.georgiadis@btinternet.com>
Subject: Re: Database File Manipulation?
Message-Id: <Pine.GSO.3.96.980108134325.26818h-100000@user2.teleport.com>
On Thu, 8 Jan 1998, Michael Georgiadis wrote:
> i want to be able to write a script
[ details of script snipped ]
> any suggestions??
You should be able to do this once you've learned Perl. There are some
good books listed in the perlbook manpage. If you get stuck, please post
again and let us know how far you've gotten. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 8 Jan 1998 13:32:18 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Jeffrey R. Drumm" <drummj@mail.mmc.org>
Subject: Re: file glob restrictions?!
Message-Id: <Pine.GSO.3.96.980108132209.26818g-100000@user2.teleport.com>
On Thu, 8 Jan 1998, Jeffrey R. Drumm wrote:
> Looking through the Todo list on my local installation of Perl, I
> noticed that "built-in globbing" is listed as a "vague possibility".
>
> Has this changed at all?
The Perl development team is working on it. It's a tough nut to crack,
since there are so many different kinds of machines out there - we need
something that works in "the same way" on all flavors of Unix, as well as
MacOS, Win32, OS/2, and about mumblety-mumble other platforms. But it's on
the developers' table.
This would be a lot simpler if there weren't any backwards compatibility
issues, of course. But we have to allow for some weird tricks that have
been tried with globbing. For example, some people use <~username> to
discover the home directory of a user.
> I've heard numerous times that trusting csh is unwise, given its
> variability across Unices.
Yes, and its various bugs. That's one reason that globbing is disabled
when taint checks are on. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 8 Jan 1998 13:47:13 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Georgiadis <michael.georgiadis@btinternet.com>
Subject: Re: how does 'require' work?
Message-Id: <Pine.GSO.3.96.980108134541.26818i-100000@user2.teleport.com>
On Thu, 8 Jan 1998, Michael Georgiadis wrote:
> when you say
>
> require cgi-lib.pl;
> where does this library need to be installed?
Somewhere along @INC, as documented in the perlfunc manpage. But you
should use CGI.pm or another module instead of cgi-lib.pl for any new
scripts.
Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 08 Jan 1998 20:55:29 GMT
From: "Edward Morris, Jr." <emorr@fast.net>
Subject: How to Tar & unzip Perl mods on CPAN site on Win32?
Message-Id: <34B53D7D.2CED@fast.net>
Is there a "tar -xvzf perlmod.tar" for Win NT???
ed
------------------------------
Date: Thu, 08 Jan 1998 13:27:59 -0700
From: Donner Holten <donner@lanl.gov>
Subject: Oraperl problem
Message-Id: <34B536CE.1C25CD8E@lanl.gov>
I'm having problems with an oracle script. I can't seem to log onto
oracle because the program can't find something called orlon. Any help
would be appreciated. Thanks.
Donner
--------------------------- Program
-------------------------------------
#! /opt/oracle/src/oraperl-v2.4/oraperl -w
# Specify Username
$user_name="snoopydog";
# Specify Password
$passwd="cic2";
# Specify Database
# $database='T:128.165.128.115/1525:pcsr';
$database='pcsr';
# Log on to Oracle
$lda=&ora_login($database, $user_name, $passwd) || die;
# Open a cursor and execute the querry.
$csr=&ora_open($lda, "select initcap(name), grp, email from phone_file
where znu
m = '121870'") || die;
@results=&ora_fetch($csr);
# Close a cursor and
# Disconnect the database server
&ora_close($csr);
&ora_logoff($lda);
# Check if any results were found.
if(@results == 0)
{
print "No results found.\n";
}
else
{
print "Results found.";
}
---------------------------- Resulting Output
---------------------------------
congress 22: ./testprog1
1: | malloc: got ora_debug 34 bytes at 40018bc8
2: <userinit
3: >ora_login
4: | entry: ora_login("pcsr", "snoopydog", "cic2")
5: | >ora_getlda
6: | | entry: ora_getlda(void)
7: | | >ora_getcursor
8: | | | entry: ora_getcursor(void)
9: | | | malloc: got a cursor at 0x400215c8
10: | | | malloc: got a csr at 0x40010888
11: | | | exit: returning 0x400215c8
12: | | <ora_getcursor
13: | | malloc: got hda at 0x40012c08
14: | | exit: returning 0x400215c8
15: | <ora_getlda
16: | >set_sid
17: | | entry: set_sid(pcsr)
18: | | info: setting ORACLE_SID to pcsr
19: | <set_sid
/usr/lib/dld.sl: Unresolved symbol: orlon (code) from ./testprog1
IOT trap (core dumped)
----------------------------------------------------------------------------
Again, thanks for your time.
------------------------------
Date: Thu, 08 Jan 1998 15:46:23 -0500
From: Mark Hazen <mhazen@franklin.uga.edu>
To: Rich Capenegro <rcapenegro@brookdale.cc.nj.us>
Subject: Re: Perl CGI - Apache 1.2
Message-Id: <34B53B1F.85DF3537@franklin.uga.edu>
[posted and mailed]
Rich Capenegro wrote:
> I am having problems running ANY Perl scripts with Apache 1.2 under
> FreeBSD. Whenever I run a Perl script The server returns Internal Server
> Error, and in the error log it says Premature end of script headers. I know
Your problem is more than likely that your CGI script doesn't return the
approriate HTTP headers. Try adding a line which says:
print "Content-type: text/html\n\n";
...before any other output occurs in your script, and see if that solves your
problem. Personal Web Server is extremely fault-tolerant (it fills in the blank
for you), whereas mod_perl under Apache assumes that hey, you better know what
you're doing. I kind of understand their point. :)
Hope this helps,
-mh.
----
. _+m"m+_"+_ Mark Hazen Network Administrator, Dean's Office
d' Jp qh qh The Franklin College of Arts & Sciences
Jp O O O The University of Georgia (706)542-1546
Yb Yb dY dY
O "Y5m2Y" " even the mightiest wave starts out as a ripple.
"Y_ why make waves when it's easier to nurture ripples?
------------------------------
Date: 8 Jan 1998 11:52:46 -0800
From: mcravit@best.com (Matthew Cravit)
Subject: Re: Perl editor needed
Message-Id: <693aqe$8i9$1@shell3.ba.best.com>
In article <1d2dgnb.19ax3jx1jym91uN@slip166-72-108-220.ny.us.ibm.net>,
Kevin Reid <kpreid@ibm.net> wrote:
>Okay, so (most) everybody on this thread is saying Emacs is great, but
>is there a Macintosh version?
Yes, there is. However, it's a port of Emacs 18.something, and I'm not
sure whether either perl-mode.el or cperl-mode.el will work with it
(I've not yet tried them). But, if you want it, it's available at
ftp://ftp.cs.cornell.edu/pub/parmet/
I'm still trying to find out if there's a port of Emacs 19 to the Mac,
though.
/MC
--
Matthew Cravit, N9VWG | Experience is what allows you to
E-mail: mcravit@best.com (home) | recognize a mistake the second
mcravit@taos.com (work) | time you make it.
------------------------------
Date: 8 Jan 1998 12:59:32 -0700
From: bgeer@xmission.xmission.com (bgeer)
Subject: Re: perl manipulation of dbf(dBASE) or db(Paradox) files?
Message-Id: <693b74$mej$1@xmission.xmission.com>
Eric Bohlman <ebohlman@netcom.com> writes:
>Don Hayward <don@marinelab.sarasota.fl.us> wrote:
>: I'm looking for perl modules to read, write, etc. (dbf) dBASE and (db)
>: Paradox files. Thanks for any help.
>The modules on CPAN for manipulating .dbf files go by the name of XBase
>or Xbase (these are two different modules with somewhat different
>capabilities). I don't know offhand what's available for Paradox, but if
>there is something, it's likely to be on CPAN.
Check out
"Wotsit's File Format Collection
http://www.wotsit.demon.co.uk
I also found some Paradox info at www.borland.com - sorry, don't have
the exact URL.
The version of xbase I downloaded is read-only & doesn't handle
Clipper index files, so I have programmed my own using the info from
these & related cites.
Cheers, Bob
--
<> Robert Geer & Donna Tomky / * <>
<> bgeer@xmission.com | _o * o * o <>
<> Salt Lake City, Utah | -\<, * <\ </L <>
<> U S A | O/ O __ /__, /> <>
------------------------------
Date: Thu, 8 Jan 1998 14:03:29 -0600
From: "Phil Jach - Reverse to get address" <moc.care@hcajp - Reverse to get address>
Subject: Re: Perl to EXE
Message-Id: <34b53108.0@news1.ibm.net>
WWW: http://www.demobuilder.com
This is where you can find it.
Robert A. Thompson wrote in message <34B50AEC.BAC3E072@unx1.shsu.edu>...
>I have seen a program on the web once that will convert a perl script to
>an .exe If anyone knows where I may find this could they please let me
>know.
>
>Thanks in advance,
>
>Robert A.Thompson
>
------------------------------
Date: Thu, 08 Jan 1998 14:25:55 -0600
From: James Cherry <James.Cherry.0504266@nortel.ca>
Subject: Re: Perl to EXE
Message-Id: <34B53653.4FB0@nortel.ca>
It's not a deception.
Program's called "undump". Platform specific. use Perl -u to gen
the core file, but you must have a specially linked version of
perl or undump will not work on some platforms.
--
/* ~ nortel wireless ~ nortel wireless ~ nortel wireless ~ *\
|* James J. Cherry | NORTEL/CDMA-2N32 | 972/685-8152 (ESN 445) *|
|* "Irritation is the loofa for the mind." - not Nancy Liebowitz *|
\*---------------------------------------------------------------*/
------------------------------
Date: 8 Jan 1998 20:45:54 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl to EXE
Message-Id: <693du2$rof$1@csnews.cs.colorado.edu>
In comp.lang.perl.misc,
"Phil Jach - Reverse to get address" <moc.care@hcajp - Reverse to get address> writes:
:WWW: http://www.demobuilder.com
:This is where you can find it.
Yes, but it doesn't do what you think it does. What good
is a tar file with the a.out and script bundled together,
or at least the moral equivalent of the same?
--tom
--
Tom Christiansen tchrist@jhereg.perl.com
"If ease of use is the highest goal, we should all be driving golf carts."
--Larry Wall
------------------------------
Date: Thu, 08 Jan 1998 20:17:42 GMT
From: chip@mail.atlantic.net (Chip Salzenberg)
Subject: Re: PERLIPC - FIFO: parent, child, stalled!
Message-Id: <693c7o$66u$1@cyprus.atlantic.net>
On Sat, 3 Jan 1998, Jihad Battikha wrote:
> If I open the FIFO for read before the fork, the entire script will
> block at that point -- unless there's something I'm missinge here.
Yes, you're missing the O_NDELAY option of open(), which you can use
if you C<use Fcntl> and call sysopen() instead of open().
--
Chip Salzenberg - a.k.a. - <chip@pobox.com>
** Perl Training from Stonehenge Consulting Services: (503) 777-0095 **
"I stopped that bus and I saved them kids!" "All except one -- the one
you let drive!" "He showed me his license..." "He was seven!!!" // MST3K
------------------------------
Date: Thu, 08 Jan 1998 15:05:03 -0600
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: print SOCK "Whatever";
Message-Id: <kortbein-0801981505030001@ip120.waddells.com>
In article <34B4FB11.2F32@swol.de>, Tobias Bugala <TobiasBugala@swol.de> wrote:
> Why dosen't it work?
>
> Well, I open up a Socket-Connection to a server, get the answer by
>
> read SOCK, $c, 1;
> print "read OK\n";
> while ($c ne chr 10)
> {
> print ord $c, "\n";
> read SOCK, $c, 1;
> }
>
> but if I want to reply by
>
> print SOCK "Anything";
>
> I don't get an answer. If I type exactly the same strings in a
> telnet-session it works.
>
> Can someone help me?
>
> TOBI
This news server (mine) sucks, so maybe someone else has replied to this
without my knowledge, but -
Does your code do anything at ALL, in terms of server response? If not
maybe you need to close your file/socket handle, since the input/output
to/from it may be buffered. Or, you could look up to $| variable. If the
script is completing, though, then the filehandle should be closed
automagically whether you do it or not. Then I don't know what to tell
you, except that your script isn't doing what you think it is doing. But
you know that. :)
HTH,
Josh
--
___________________________________________________________________________
"So, would you say it's about time for our viewers to... crack each others'
heads open and feast on the goo inside?"
"Yes. Yes I would, Kent."
------------------------------
Date: Thu, 08 Jan 1998 13:48:51 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: RE:running a program from PERL and capturing the output
Message-Id: <34B52DA3.FFF83C92@houston.Geco-Prakla.slb.com>
Craig Girard wrote:
>
> I am trying to run a program on unix through PERL and capture its output.
> The command is "run showpages". This works fine at the command prompt but
What is your path set to inside your Perl script? Use print
$ENV{PATH} to find out. You will probably be surprised. :-)
> when I use open (PAGES, "run showpages |"); I get errors saying it doesn't
> exist. I have also tried SYSTEM as well, that did not work either. Any
> suggestions?
>
Other than the above? Sure. Use absolute path to your command. Always
a better option. Also, to capture output, do something like:
$output = `/path/to/your/program/run showpages`; --or--
open(PAGES, "/path/to/your/program/run showpages|") or die "Cannot open
pipe: $!\n";
Always check return codes if possible.... Might just tell you a whole
lot about what is wrong. I.E. No such file or directory because it does
not exist in your path....
> Thank you
HTH.
Dave
--
"Security through obscurity is no security at all."
-comp.lang.perl.misc newsgroup posting
------------------------------------------------------------------------
* Dave Barnett U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------
------------------------------
Date: Thu, 8 Jan 1998 12:38:06 -0800
From: "Aaron Harsh" <ajh@rtk.com>
Subject: Re: Search/sorting question (and what does "Can't use "my $a" in sort comparison" mean?)
Message-Id: <693dcs$af0$1@brokaw.wa.com>
Kevin J. Lin wrote in message <34B4F2F8.C62C819C@wx3.com>...
>... The database (MS
>Excel) sorts starting with all numbers, then going to numbers with
>characters. So 99999 is BEFORE 1111X, but after 11111.
>
>In the PERL script I have been doing a comparison of the int() values,
>which obviously is no longer going to work. Here's a sample line
>showing the comparison:
>
> if (int($code) < int($order_code)) {
> $slot=$slot+$division;
> }
>
>How might I rewrite my comparison routine to search through the list the
>way Excel has chosen to sort them (ie., numbers first, then strings).
I hope you don't care if your solution is elegant or readable. Here' s my
stab at it:
sub excel_sort($$) {
my ( $x, $y ) = @_;
sub is_numeric($) {
$_[0] =~ /^\d+$/;
}
return ( is_numeric($y) <=> is_numeric($x) )
|| ( is_numeric($x) ? ( $x <=> $y ) : ( $x cmp $y ) );
}
# Use it like this:
if ( excel_sort($code, $order_code) < 0 ) {
$slot=$slot+$division;
}
Although it might sort by case differently than Excel does.
I noticed an odd (mis?)feature in Perl 5.003 when I was writing this. If I
renamed the $x and $y variables as $a and $b, perl wouldn't let me use them
with the <=> or cmp operators ("Can't use "my $a" in sort comparison").
This only appears to happen when they're named $a and $b, though -- this
code runs fine. And if I use 'local ( $a, $b )', then the code runs fine.
The error goes away on perl5.004_1, but it still seems puzzling. I couldn't
find anything about it in perlop or perldiag.
Aaron Harsh
ajh@rtk.com
------------------------------
Date: Thu, 08 Jan 1998 12:47:26 -0800
From: Jim Bowlin <bowlin@sirius.com>
To: kevin@wx3.com
Subject: Re: Search/sorting question
Message-Id: <34B53B5E.869A426@sirius.com>
Kevin J. Lin wrote:
>
> Thanks;
>
> That's a good solution, but I'm not sure it will work in my case. The
> client provides the data, at which point the two are already in the same
> file. The script which runs on the file doesn't really have time to
> sort the file again.
>
> Perhaps my question my be better posed to an excel newsgroup, on how
> excel might sort the data better prior to export.
>
> Thanks anyway!
This should work:
@keys = qw( 11232 1223123xxx 212222y 11500 );
@sorted = sort { $isNaN = $b =~ /\D/ <=> $a =~ /\D/ or
$isNaN ? $a cmp $b : $a <=> $b} @keys;
print join("\n", @sorted);
-- Jim
------------------------------
Date: Thu, 8 Jan 1998 19:49:00 GMT
From: Geoffrey Conner <geoffrey.conner@gsc.gte.com>
Subject: Simple string length
Message-Id: <34B52DAC.4770@gsc.gte.com>
Hi, I am new to Perl and am trying to do something similar to strlen in
C. I am going to read in a phone number from user input on a web page,
and by the length of digits determine if the phone number is internal,
or external. I tried some things like:
$count = ($string=~ tr/.//);
but no luck there. It sounds simple, but I must be overlooking
something.
Thanks in Advance
Geoff
------------------------------
Date: Thu, 8 Jan 1998 20:29:26 GMT
From: joel@wmi0.wmi.com (Joel Coltoff)
Subject: Re: Simple string length
Message-Id: <693cv4$hn4@netaxs.com>
In article <34B52DAC.4770@gsc.gte.com>,
Geoffrey Conner <geoffrey.conner@gsc.gte.com> wrote:
>Hi, I am new to Perl and am trying to do something similar to strlen in
>C.
If I were trying to do "exactly" the same thing as strlen in C
I would use the docs and learn about the operator called
length
If I needed to do something "similar" I would first need to know
what that meant. When you've defined your problem better and
can't find the answer you need in the docs get back to us again
and we'll try to help.
Good luck.
--
Joel Coltoff
I'd explain it, but there's a lot of math. -- Calvin
------------------------------
Date: Thu, 8 Jan 1998 16:28:55 -0500
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Simple string length
Message-Id: <1d2joyn.1l52zod19g4chsN@slip166-72-108-161.ny.us.ibm.net>
Geoffrey Conner <geoffrey.conner@gsc.gte.com> wrote:
> Hi, I am new to Perl and am trying to do something similar to strlen in
> C. I am going to read in a phone number from user input on a web page,
> and by the length of digits determine if the phone number is internal,
> or external. I tried some things like:
> $count = ($string=~ tr/.//);
> but no luck there. It sounds simple, but I must be overlooking
> something.
>
> Thanks in Advance
>
> Geoff
Here's a solution that will ignore dashes:
#!perl -w
sub numlength ($) {
my $temp;
return ($temp = $_[0]) =~ s/\d//g;
}
print numlength("1-800-555-1234"), "\n";
--
Kevin Reid
------------------------------
Date: Thu, 08 Jan 1998 14:44:51 -0500
From: Arun <rarun@geocities.com>
Subject: Stored Procedures using Oraperl
Message-Id: <34B52CB3.A9E15DB4@geocities.com>
Hello,
Is it possible to invoke a Oracle stored procedure using Oraperl (DBI or
DBD)?
Any sample code would be much appreciated.
Thanks
Arun
------------------------------
Date: 8 Jan 1998 20:09:43 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Testing for valid RegExps?
Message-Id: <693bq7$6rq$1@mathserv.mps.ohio-state.edu>
[A complimentary Cc of this posting was sent to Tom Christiansen
<tchrist@mox.perl.com>],
who wrote in article <692jsn$sa3$1@csnews.cs.colorado.edu>:
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc,
> Andrew Johnson <ajohnson@gpu.srv.ualberta.ca> writes:
> :is there any reason not to eval the regex against a literal rather
> :than setting up a variable?
>
> None that I can think of.
Note that doing
$regexpq = "blah";
$dummy = "";
$good = eval '/$regexp$dummy/; 1';
may move compilation of RE to runtime, thus avoiding a memory leak due
to a failing eval.
Ilya
------------------------------
Date: Thu, 08 Jan 1998 15:18:40 -0500
From: Mark Hazen <mhazen@franklin.uga.edu>
Subject: Re: Testing for valid RegExps?
Message-Id: <34B534A0.F523E60C@franklin.uga.edu>
Thanks for all of the suggestions. It amazes me that after three years of
(admittedly
bad) hacking out scripts with Perl, the things I forget are the most
obvious. ::sigh::
And hey, I never meant to start *that* big of a thread... :)
eval(pack
'h*',"072796e6470222a45737470214e6f64786562702055627c602841636b65627c222b3");
-mh.
----
. _+m"m+_"+_ Mark Hazen Network Administrator, Dean's Office
d' Jp qh qh The Franklin College of Arts & Sciences
Jp O O O The University of Georgia (706)542-1546
Yb Yb dY dY
O "Y5m2Y" " even the mightiest wave starts out as a ripple.
"Y_ why make waves when it's easier to nurture ripples?
------------------------------
Date: Thu, 08 Jan 1998 12:11:27 -0800
From: Derek Romeyn <romeyde@mc0115.mcclellan.af.mil>
Subject: Text::Wrap mod needed for HTML
Message-Id: <34B532EF.2B828BA0@mc0115.mcclellan.af.mil>
I am still nearly new to perl and having a slight problem. One of my
scripts accepts a text area form from an HTML page. When the page is
processed and then redisplayed later on, I use the Text::Wrap function
to display the text area data since IE does not insert line feeds.
My problem is that if people put in HTML commands such as bold facing or
underlining it throws off the Text::Wrap module. <B></B>, 7 Characters
there that get counted but not displayed and causes the line to end
prematurely.
Been trying to figure out how to modify Text::Wrap to watch for html
commands, basically don't count any thing with < and > around it. I'm
guessing the reg expression is something like /<[^>]*/ just don't know
what to do with it.
Could someone perhaps post necessary mods to Text::Wrap that I could
apply? Would be highly appreciative.
--
... Derek W Romeyn..................LinuX, it's not just for breakfast
... NCI Information Systems, Inc..............anymore. Ask for it by
... romeyde@deepwell.com.......................................NAME!!!
------------------------------
Date: Thu, 08 Jan 1998 13:29:45 -0600
From: James Cherry <James.Cherry.0504266@nortel.ca>
Subject: undumping perl
Message-Id: <34B52929.2183@nortel.ca>
"The Perl language has a mechanism for dumping a compiled Perl script
to a core file. Such core files can be undumped in conjunction with the
Perl binary. For this to work the Perl binary must have been built with
archive rather than shared libraries."
Anyone have a clue how to do this?
/* ~ nortel wireless ~ nortel wireless ~ nortel wireless ~ *\
|* James J. Cherry | NORTEL/CDMA-2N32 | 972/685-8152 (ESN 445) *|
|* "Irritation is the loofa for the mind." - not Nancy Liebowitz *|
\*---------------------------------------------------------------*/
------------------------------
Date: Thu, 8 Jan 1998 13:20:59 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: Unpacking length-infor style data.
Message-Id: <Pine.GSO.3.96.980108131322.26818f-100000@user2.teleport.com>
On 8 Jan 1998, Richard Caley wrote:
> If I have data of the form
> 2-byte-length
> that-many-bytes
> another-2-byte-length
> that-many-bytes
> ...
>
> is there some neat way I am not spotting to extract the byte
> sequences, say into an array?
I think that the best way might be to use unpack, something like this.
while (length $data) {
my $len = unpack "s", $data;
push @list, unpack "x2a$len", $data;
$data = substr($data, $len+2);
}
Not amazingly neat, but it should do the job. Hope this helps!
--
Tom Phoenix http://www.teleport.com/~rootbeer/
rootbeer@teleport.com PGP Skribu al mi per Esperanto!
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
Ask me about Perl trainings!
------------------------------
Date: Thu, 08 Jan 1998 12:54:41 -0800
From: Jim Bowlin <bowlin@sirius.com>
Subject: Win32 module with Perl 5.004_2
Message-Id: <34B53D11.15875A43@sirius.com>
I am having a heap of trouble with this module.
[not to mention some problems with posting this message.
I apologize now for reposting a 3rd time. This is my first
post that is not a reply.]
For example: I can't get either
Win32::NetAdmin::UserCreate($server, $self->{user}, $self->{password},
0, $temp->{priv}, '', '', $temp->{flags}, $self->{script})
or
Win32::AdminMisc::UserSetAttributes($server, $self->{user},
$self->{fullname}, $self->{password}, '', '', '', '', '', '')
to work. I've tried many variations. They return false but
I can not find any error messages.
Also the masks in the Win32::FileSecurity seem messed up.
For example: when Windoze says that a user has read(RX) permission,
the mask is set to 001200A9 while the full complement of masks is
reported to be:
0000ffff SPECIFIC_RIGHTS_ALL
00010000 DELETE
00020000 READ_CONTROL STANDARD_RIGHTS_EXECUTE
STANDARD_RIGHTS_READ STANDARD_RIGHTS_WRITE
00040000 WRITE_DAC
00080000 WRITE_OWNER
000f0000 STANDARD_RIGHTS_REQUIRED
00100000 SYNCHRONIZE
00120000 R READ
00130000 C CHANGE
001f0000 STANDARD_RIGHTS_ALL
001f01ff F FULL
01000000 ACCESS_SYSTEM_SECURITY
02000000 MAXIMUM_ALLOWED
10000000 GENERIC_ALL
20000000 GENERIC_EXECUTE
40000000 GENERIC_WRITE
80000000 GENERIC_READ
What boat did I miss?
------------------------------
Date: Thu, 08 Jan 1998 15:14:49 -0600
From: kortbein@iastate.edu (Josh Kortbein)
Subject: Re: Would yo explain the Perl "pack" command to me?
Message-Id: <kortbein-0801981514490001@ip120.waddells.com>
In article <34B2C79B.5ABFB4D2@vec.net>, David <dperdue@vec.net> wrote:
> Hi,
>
> The subject line says it all. I don't no exactly what the pack command
> does.
> I don't konw when it might be used. I don't understand what the
> templates are telling the program.
David,
You might want to find a book on machine architecture, or maybe just a
nice C book. I think what you want to look into is binary representation
of numbers, etc. Also the differences, in C, between a short, long, char,
etc. - stuff that's not too obvious in perl since its typing (meaning, how
it cares about what kind of information variables, etc., are) is pretty
loose.
The things pack() does are either related to converting between different
number formats (i.e., the ways in which the numbers are stored
internally), or converting between similar data like ASCII characters,
etc.
HTH,
Josh
--
___________________________________________________________________________
"So, would you say it's about time for our viewers to... crack each others'
heads open and feast on the goo inside?"
"Yes. Yes I would, Kent."
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
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 1603
**************************************