[11867] in Perl-Users-Digest
Perl-Users Digest, Issue: 5467 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 23 18:07:25 1999
Date: Fri, 23 Apr 99 15:00:21 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 23 Apr 1999 Volume: 8 Number: 5467
Today's topics:
Re: -n vs open <aqumsieh@matrox.com>
Re: Calculating distance between zip codes <cassell@mail.cor.epa.gov>
Re: Calculating distance between zip codes <jhi@alpha.hut.fi>
Re: Calling other perl scripts <cassell@mail.cor.epa.gov>
Re: chomp-ing from the FRONT end (Larry Rosler)
Re: Compiling perl regex lib into other progs <cassell@mail.cor.epa.gov>
Re: Different between recurrence and looping <rharper@intouchsurvey.com>
Easier way to dereference quotes? <kkwiatek@nist.gov>
Re: Easier way to dereference quotes? <dgris@moiraine.dimensional.com>
embedding Perl in C <sjang@qualcomm.com>
Re: Encrypt/Decrypt <gregm@well.com>
Re: FAQ 8.47: How do I keep my own module/library direc <cassell@mail.cor.epa.gov>
Re: how to merge? <hector29@wwww.icubed.com>
Re: need CGI programmers???? latsharj@my-dejanews.com
Re: newbie with a "howto" question <ebohlman@netcom.com>
Re: NN? ['Nother Newbie Question] (Randal L. Schwartz)
Re: Perl and ASP <cassell@mail.cor.epa.gov>
Re: Perl CGI and HTML... <emschwar@rmi.net>
Re: printf problem (Larry Rosler)
Re: Problems with the connect function (Larry Rosler)
Re: regex: I see THAT it works, but I don't see WHY sstarre@my-dejanews.com
Re: regex: I see THAT it works, but I don't see WHY sstarre@my-dejanews.com
Re: regex: I see THAT it works, but I don't see WHY (Abigail)
Re: scriptlet to add line breaks at even multiples?- GR <webmaster@counsel.net>
Re: Sorting Array of Arrays (Larry Rosler)
Re: Sorting Array of Arrays <cassell@mail.cor.epa.gov>
Re: split help <aqumsieh@matrox.com>
Re: split help (Bart Lateur)
System Call Help <rp7667@email.sps.mot.com>
Wanted: Win32 binaries of Perl/Tk <acruz@acacio.com>
Re: Wanted: Win32 binaries of Perl/Tk <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 23 Apr 1999 15:34:51 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: -n vs open
Message-Id: <x3yk8v3t9k5.fsf@tigre.matrox.com>
sandoz@umbc.edu (James W. Sandoz) writes:
> If I include the -n switch at the shebang line and run
> while(<>){
> $tot++;
> $comments++ if m/^\s*#/;
> $blank++ if m/^\s*\n/;
> }
> The script doesn't count the shebang line and I'm wondering why.
[snip]
> from perldoc perlrun
> -n causes Perl to assume the following loop around your
> script, which makes it iterate over filename arguments
> somewhat like sed -n or awk:
> while (<>) { ...
> # your # script # goes # here
> }
The docs that you refer to are pretty clear about it. Using the -n
automatically places the while() loop around your script. So, when you
run the script, the first line (which happens to be the shebang) is
read into $_, and then *YOUR* while() loop iterates over the rest of the
file. So you lost the first line.
I think it's pretty clear. Do you find it confusing?
HTH,
Ala
------------------------------
Date: Fri, 23 Apr 1999 13:42:39 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Calculating distance between zip codes
Message-Id: <3720DB3F.45002FA8@mail.cor.epa.gov>
M.J.T. Guy wrote:
>
> David Cassell <cassell@mail.cor.epa.gov> wrote:
> >
> >Get the Math::Trig module from CPAN (or ActiveState if you're using
> >their build of Perl).
>
> No need to go to CPAN. That's a built-in in current versions of Perl.
>
> Mike Guy
Oh. Duh. I downloaded a bunch of the Math::* modules, and I was
thinking that it was one of the downloadees. Pardonnez-moi.
Hmm.. let's see... Hey! It's even part of the install for the
5.004_04 version on the Solaris network. How convenient.
I don't have an earlier version around to check. How long has
Math::Trig been a part of the install?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 23 Apr 1999 23:57:24 +0300
From: Jarkko Hietaniemi <jhi@alpha.hut.fi>
Subject: Re: Calculating distance between zip codes
Message-Id: <oeeemlbukaz.fsf@alpha.hut.fi>
David Cassell <cassell@mail.cor.epa.gov> writes:
> I don't have an earlier version around to check. How long has
> Math::Trig been a part of the install?
Math::Trig since 5.004 (or, if you are into gory details, 5.003_97a),
Math::Trig with great_circle_distance() since 5.005_03.
--
$jhi++; # http://www.iki.fi/jhi/
# There is this special biologist word we use for 'stable'.
# It is 'dead'. -- Jack Cohen
------------------------------
Date: Fri, 23 Apr 1999 13:29:34 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Calling other perl scripts
Message-Id: <3720D82E.A3ED9D66@mail.cor.epa.gov>
Gala Grant wrote:
>
> I need to know how to call another perl script from within a script. I know
> about "use" with modules, but it didn't seem like that would be the right
> thing to use. I want to be able to execute the entire script while inside
> the other.
I assume from your mention of `use' that you want to, in essence, read
in another file of Perl statements|subroutines|trafe and have those
execute in your program. The answer is
do 'filename.pl';
Hmm. Didn't I just type this a few hours ago in another thread? :-)
If you want to execute another program externally, then you
are looking at system(), exec(), ``, qx//, or open() depending on
your goals. But I'm guessing that you're interested in number one
up above.
> Thanks,
You're welcome,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 13:25:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: chomp-ing from the FRONT end
Message-Id: <MPG.118a771430d0efc8989929@nntp.hpl.hp.com>
In article <MPG.118a69447362723e989927@nntp.hpl.hp.com> on Fri, 23 Apr
1999 12:26:34 -0700, Larry Rosler <lr@hpl.hp.com> says...
...
> chomp (remove the substring $/ if it is at the end of the string):
>
> substr($string, 0, length $/) = "" if index($string, $/) == 0;
>
> $string =~ s%$/%%;
Where, oh where, has my little anchor gone?
$string =~ s%^$/%%;
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 14:00:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Compiling perl regex lib into other progs
Message-Id: <3720DF59.E8925323@mail.cor.epa.gov>
Andrey Zmievski wrote:
>
> Is it possible to take Perl regex library and use it for other programs? Has
> anyone done it? I've looked at the code and it seems pretty much tied to the
> Perl engine...
There are other halfway-decent regex libraries out there which aren't
tied to Perl. Look at the rx C library, for instance.
Or you could just embed the Perl interpreter in your C/C++ program.
Or you could use JPL to do something similar with Java.
But why not just use Perl for your programming needs? Perl doesn't
do everything, but it does a lot of things very well. It makes simple
things easy, and hard things possible. What more can you ask of a
programming language?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 20:03:30 GMT
From: Russell Harper <rharper@intouchsurvey.com>
Subject: Re: Different between recurrence and looping
Message-Id: <3720D2EA.D94ADDD@intouchsurvey.com>
I think you mean recursive call or recursion. There are cases where using
loop logic to solve a problem is much harder than by recursion. A well
known example is the Tower of Hanoi problem. With recursive logic, the
problem is trivial, I wouldn't attempt it with any other approach. Good
luck... /Russell
Carfield Yim wrote:
> It seen that looping can do the work of recurrence call, is there any
> different other than concept? Why do we need to study more?
------------------------------
Date: Fri, 23 Apr 1999 17:13:22 +0100
From: "Keith Kwiatek" <kkwiatek@nist.gov>
Subject: Easier way to dereference quotes?
Message-Id: <7fqm4u$so0$1@news.nist.gov>
Hello,
I have a PERL DBI CGI program that takes data from a user and tries to
insert it into the database. If the data has a backtick/quote ( ' or ") then
the sql to update/insert fails... Do I have to deference every quote in
every field in order to update/insert? OR is there an easier way that doing
string replacements on all the fields before I insert/update?
Please post or email me at kkwiatek@nist.gov
Thanks!
------------------------------
Date: 23 Apr 1999 15:13:45 -0600
From: Daniel Grisinger <dgris@moiraine.dimensional.com>
Subject: Re: Easier way to dereference quotes?
Message-Id: <m3r9pbxcom.fsf@moiraine.dimensional.com>
"Keith Kwiatek" <kkwiatek@nist.gov> writes:
> Do I have to deference every quote in every field in order to
> update/insert?
man DBI, look for quote().
dgris
--
Daniel Grisinger dgris@moiraine.dimensional.com
perl -Mre=eval -e'$_=shift;;@[=split//;;$,=qq;\n;;;print
m;(.{$-}(?{$-++}));,q;;while$-<=@[;;' 'Just Another Perl Hacker'
------------------------------
Date: Fri, 23 Apr 1999 14:36:10 -0700
From: Soo Jang <sjang@qualcomm.com>
Subject: embedding Perl in C
Message-Id: <3720E7CA.7F4B979A@qualcomm.com>
Does anybody know the performance difference between a regular
C program and an embedded Perl in C program
to perform the same task?
Thanks for your help,
Soo
------------------------------
Date: Fri, 23 Apr 1999 13:31:45 -0700
From: Greg McCann <gregm@well.com>
Subject: Re: Encrypt/Decrypt
Message-Id: <3720D8B1.D3E28C19@well.com>
vilo@commercialnetworks.com wrote:
>
> Is there any encryption perl library (or any other utility for perl) to
> encrypt data before storing them into file and then decrypt them after
> reading them from file?
See if http://reference.perl.com/query.cgi?security helps.
Greg
--
======================
Gregory McCann
http://www.calypteanna.com
"Be kind, for everyone you meet is fighting a great battle." Saint Philo of
Alexandria
------------------------------
Date: Fri, 23 Apr 1999 14:19:33 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: FAQ 8.47: How do I keep my own module/library directory?
Message-Id: <3720E3E5.EF400600@mail.cor.epa.gov>
Tom Christiansen wrote:
>
> [snip of well-written text]
> except that the lib module checks for machine-dependent
> subdirectories. See Perl's the lib manpage for more information.
^^^^^^^
Umm, is that like women's lib, but for adjectives?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 16:52:55 -0400
From: Jon Milliren <hector29@wwww.icubed.com>
To: bing-du@tamu.edu
Subject: Re: how to merge?
Message-Id: <Pine.BSF.4.05.9904231652400.49926-100000@wwww.icubed.com>
On Wed, 21 Apr 1999 bing-du@tamu.edu wrote:
> Hello,
>
> I know how to use 'split' to cut a string. How to merge all the elements (but
> seperated by space) of a list?
Join
------------------------------
Date: Fri, 23 Apr 1999 20:11:47 GMT
From: latsharj@my-dejanews.com
Subject: Re: need CGI programmers????
Message-Id: <7fqk60$gpa$1@nnrp1.dejanews.com>
In article <3720ADBD.E015B333@mail.cor.epa.gov>,
David Cassell <cassell@mail.cor.epa.gov> wrote:
> cindycrawford@my-dejanews.com wrote:
> >
> > need a CGI programmer?
> > check our website at
> > http://cgi-shop.com
>
> Yep, I sure need a CGI programmer.. who doesn't know the difference
> between CGI and Perl.
>
> Wait a minute.. Cindy Crawford? CGI programmer?
>
> Of course? Let's match her up with that guy with the 'adult'
> web sites who was looking for CGI help! Talk about your perfect
> match...
ROTFLOL!! Thanks David.
--
Regards,
Dick
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Apr 1999 21:32:54 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: newbie with a "howto" question
Message-Id: <ebohlmanFAnvuu.554@netcom.com>
David Cassell <cassell@mail.cor.epa.gov> wrote:
: And it also depends on the question itself. A Perl question is
: more likely to get an answer than some html or Os question dressed up
^^^^^^^^^^
: in a llama's coat. Or a question about WebTV, or shell programming,
^^^^^^^^^^^^^^^^^
: or ...
This metaphor deserves to be used as frequently as the one that calls
perl 4 a "dead flea-bitten camel carcass."
------------------------------
Date: 23 Apr 1999 13:43:58 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: NN? ['Nother Newbie Question]
Message-Id: <m11zhb2hkh.fsf@halfdome.holdit.com>
>>>>> "Mark" == Mark Stegemeyer <marksteg@teleport.com> writes:
Mark> PS- Anybody know if Randal Schwartz went to Gladstone High School? I went
Mark> there with one, but it sounds so much like a bad pick-up line I'm
Mark> embarrassed to ask him directly!
Yes Mark, and I remember you!
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Fri, 23 Apr 1999 13:46:43 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl and ASP
Message-Id: <3720DC33.F4C9607F@mail.cor.epa.gov>
Jalil Feghhi wrote:
>
> Is it possible to use Perl (instead of VBScript or JScript) in ASP pages?
Yes. If you download the ActiveState build of Perl, you'll have
access to PerlScript, which works as VBScript and JavaScript in ASP
pages.. only better. And faster, according to benchmarks published on
the win32-perl-users listserv.
Even better, when you install as suggested above, the on-line HTML
docs include a good discussion of getting PerlScript working on a
variety of servers. So read those docs! Then enjoy all the benefits
of Perl.
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: 23 Apr 1999 14:57:32 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Perl CGI and HTML...
Message-Id: <xkfd80vgimb.fsf@valdemar.col.hp.com>
Wesley Bohannon <rxmx80@email.sps.mot.com> writes:
> How do you send the following HTML code from a Perl CGI and have the
> browser execute it rather than just print it?
The same way you'd send the following HTML code from a C program, or a
python program, or a (*shudder*) Visual Basic program. Which is to say,
this is not a Perl question at all.
> <!--#include virtual="/Engineering/Test/testengfooter.txt"-->
Hint: This is not HTML. Well, if you wanna get picky, it's an HTML
comment. And surprisingly, it's well-formed.
> This is a common file for our web page format and I can't figure out why
> it works for standard HTML, but doesn't work when it is sent thru CGI??
There's your key word: CGI. Read the FAQ for the cgi newsgroup. Or
possibly the comp.infosystems.www.servers group pertaining to your
platform.
Try:
comp.infosystems.www.authoring.cgi
comp.infosystems.www.servers.{mac|ms-windows|unix|misc}
> Any help out there?
Not here.
-=Eric
------------------------------
Date: Fri, 23 Apr 1999 13:22:56 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: printf problem
Message-Id: <MPG.118a767821c160c0989928@nntp.hpl.hp.com>
In article <l4rpf7.b39.ln@magna.metronet.com> on Fri, 23 Apr 1999
09:04:21 -0400, Tad McClellan <tadmc@metronet.com> says...
> #!/usr/bin/perl -w
> use strict;
>
> my @values = unpack('a1a2a3', 'abbccc');
>
> my $string_format = "Values: %s %s %s\n";
> my @string_values = ($values[0], $values[1], $values[2]);
>
> printf($string_format, @string_values);
All those variables and all that copying are giving me a mild headache.
:-)
What about just:
printf "Values: %s %s %s\n", unpack 'a1a2a3', 'abbccc';
or dispensing with printf entirely for this trivial operation:
print join(' ', 'Values:', unpack 'a1a2a3', 'abbccc'), "\n";
(with a variable for 'abbccc' to make it useful :-).
--
Larry 'help stamp out temporary variables' Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 14:28:51 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problems with the connect function
Message-Id: <MPG.118a85ea955e7ad398992b@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <37208e2a@cs.colorado.edu> on 23 Apr 1999 09:13:46 -0700, Tom
Christiansen <tchrist@mox.perl.com> says...
> In comp.lang.perl.misc, John L Singleton <jsinglet@jaguar.ir.miami.edu>,
> whose slightly-longer-than regulation signature is
...
> writes the following...
...
> :print "<BODY BGCOLOR=FFFFFF TEXT=000000 LINK=0000FF VLINK=800080>\n" ;
>
> You forgot to quote those values. This is not complaint.
Agreed, it is not complaint, but it *is* compliant. :-)
>From the HTML 3.2 specification at
<URL:http://www.w3.org/TR/REC-html32>:
HTML allows CDATA attributes to be unquoted provided the attribute value
contains only letters (a to z and A to Z), digits (0 to 9), hyphens
(ASCII decimal 45) or, periods (ASCII decimal 46).
[sic] for the sick punctuation. :-)
...
> :print '<font face="Arial" size="2">Your selected user IS logged in. Below
>
> Why do you change the font? Don't you respect your users' choices?
> I'm certainly glad that I have configured the web proxy I use to ignore
> such usurpations of my ability to make my own choices.
>
> I don't see <font> in the HTML 3.2 spec. Where did
Probably you mean 'face'. <FONT> is certainly there:
FONT
<!ELEMENT FONT - - (%text)* -- local change to font -->
<!ATTLIST FONT
size CDATA #IMPLIED -- [+]nn e.g. size="+1", size=4 --
color CDATA #IMPLIED -- #RRGGBB in hex, e.g. red: color="#FF0000" --
>
...
> Well, class, your call: what grade does this program deserve?
No comment on your skewering of the Perl code. But you were at least a
tiny bit too harsh about the unquoted HTML.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 20:24:55 GMT
From: sstarre@my-dejanews.com
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <7fqkuj$hco$1@nnrp1.dejanews.com>
Thank-You al for the assistance, I'm working through examples now making sure
i unserstand what you've explained. It seems from the discussion that Mr ? is
a somewhat complicated little fellow!
Cheers,
S
In article <m37lr3z2y8.fsf@moiraine.dimensional.com>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Fri, 23 Apr 1999 20:26:09 GMT
From: sstarre@my-dejanews.com
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <7fql0u$hg8$1@nnrp1.dejanews.com>
Thank-You all for the assistance, I'm working through examples now making
sure I unserstand what you've explained. It seems from the discussion that Mr
? is a somewhat complicated, and possibly contraversial little fellow!
Cheers,
S
In article <m37lr3z2y8.fsf@moiraine.dimensional.com>,
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 23 Apr 1999 21:43:05 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: regex: I see THAT it works, but I don't see WHY
Message-Id: <7fqph9$gbl$1@client2.news.psi.net>
Tad McClellan (tadmc@metronet.com) wrote on MMLXI September MCMXCIII in
<URL:news:639pf7.qe8.ln@magna.metronet.com>:
##
##
## m/::(.*)::/ (if there wasn't greediness) can match that
## string all of these ways:
##
##
## : my $s='my ::x1:: ::x2:: would have to be ::x3::';
## ^^^^^^
##
## : my $s='my ::x1:: ::x2:: would have to be ::x3::';
## ^^^^^^^^^
##
## : my $s='my ::x1:: ::x2:: would have to be ::x3::';
## ^^^^^^^^^^^^^
##
## : my $s='my ::x1:: ::x2:: would have to be ::x3::';
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
##
## : my $s='my ::x1:: ::x2:: would have to be ::x3::';
## ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
##
##
## Perl can only match one of the alternatives.
##
## It allows you to choose to match greedily (the last one), or
## non-greedily (the first one).
Of course, any one of them can be matched.
/::(?:(?:[^:]+|(?::(?!:)))*::){2}(?:[^:]+|(?::(?!:)))*::/
to match the third example.
Abigail
--
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")
-> define ("foldoc", "perl")) [0] -> print'
------------------------------
Date: Fri, 23 Apr 1999 13:44:11 -0700
From: "Counsel.Net" <webmaster@counsel.net>
Subject: Re: scriptlet to add line breaks at even multiples?- GRACIAS!
Message-Id: <3720DB9B.27B03199@counsel.net>
You guys are wonderful!!! I want each of your bosses phone numbers, I'm
going to call them and demand you get raises. :o)
Bob Reap
Counsel.Net
==
David Cantrell wrote:
>
> On Tue, 20 Apr 1999 22:55:01 -0400, "David Clarke"
> <clarked@hunterdon.csnet.net> enlightened us thusly:
>
> >
> >Counsel.Net wrote in message <371C263B.A747D8FA@counsel.net>...
> >>Hi all,
> >>
> >>Is there a simple solution for adding linebreaks on long fields? I have
> >>a field fed by a web form which I want to wrap at about 80 characters.
> >
> >You might also try write, and formatted output. I know that it is not a
> >regexp, but it does split output at word boundaries.
>
> Or look at Text::Wrap
>
> [Copying newsgroup posts to me by mail is considered rude]
>
> --
> David Cantrell, part-time Unix/perl/SQL/java techie
> full-time chef/musician/homebrewer
> http://www.ThePentagon.com/NukeEmUp
------------------------------
Date: Fri, 23 Apr 1999 13:34:26 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting Array of Arrays
Message-Id: <MPG.118a792ef02bbac098992a@nntp.hpl.hp.com>
[Posted and a courtesy copy mailed.]
In article <3720bdb4.1511936@proxy.reston.tnsi.com> on Fri, 23 Apr 1999
18:45:40 GMT, Kent Kling <kkling@tnsi.com> says...
> #!/usr/bin/perl -w
Good, but where is 'use strict;'?
> open( FD, "</u/kkling/myfile.txt");
Where is the code that deals with failure to open the file?
> $row=0;
> while ( <FD> )
> {
> $row++;
> my @line = split;
> @LoL[$row] = [ @line ];
> }
@LoL = map { [ split ] } <FD>; # :-)
> /u/kkling/myfile.txt looks like
>
> 7033250001 100 123
> 7031239900 56 23
> 7021231231 123 190
> 5141231233 12 723
> 2121212809 912 542
>
> how can I sort these? Do anyone have a clue how I can use sort on a
> List of Lists ( Array of Arrays ) @LoL ?
Those who have read perlfaq4: "How do I sort an array by (anything)?"
are sure to have a clue.
--
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Fri, 23 Apr 1999 13:54:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Sorting Array of Arrays
Message-Id: <3720DDE8.F8CA57B3@mail.cor.epa.gov>
Kent Kling wrote:
>
> [snip of code {which could be improved on} and file structure]
>
> how can I sort these? Do anyone have a clue how I can use sort on a
> List of Lists ( Array of Arrays ) @LoL ?
Oddly enough, this gets asked so often that it's in the FAQ.
Did you use `perldoc -q' to search for it?
In perlfaq4:
"How do I sort an array by (anything)?
And it even has a helpful pointer to
http://www.perl.com/CPAN/doc/FMTEYEWTK/sort.html
which has even more explanation.
But since you used -w on your shebang line, I'm willing to give you
the benefit of the doubt. :-)
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
Date: Fri, 23 Apr 1999 14:26:31 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: split help
Message-Id: <x3ylnfjtcq0.fsf@tigre.matrox.com>
oekilla@aol.com (RemarQ User) writes:
> I have a tab delimited file and all the words are in quotes.I can split the
> words by using split(/\t, $_) but how can I get rid of the " around my
> words. I tried split(/"\t\"/, $_) but the very first word has one " to the
> left of it?
I can't be certain without more information, but I suspect this will
help you:
while (<FILE>) {
chomp;
tr/"//d;
@a = split;
bla(bla, bla) || bla;
}
HTH,
Ala
------------------------------
Date: Fri, 23 Apr 1999 21:01:00 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: split help
Message-Id: <3720dea2.550513@news.skynet.be>
RemarQ User wrote:
>I have a tab delimited file and all the words are in quotes.I can split the
>words by using split(/\t, $_) but how can I get rid of the " around my
>words. I tried split(/"\t\"/, $_) but the very first word has one " to the
>left of it?
There's a FAQ posted just now which probably applies to this case:
>FAQ 4.29: How can I split a [character] delimited string except when inside
>[character]? (Comma-separated files)
Because, if the strings are quoted, that could mean that the data may
contain tabs.
But anyway: try something like:
@part = split/\t/;
foreach (@part) {
s/^"// and s/"$//;
}
Bart.
------------------------------
Date: Fri, 23 Apr 1999 13:35:15 -0700
From: Omar Soto <rp7667@email.sps.mot.com>
Subject: System Call Help
Message-Id: <3720D975.43AEF7EC@email.sps.mot.com>
This is a multi-part message in MIME format.
--------------DE522C7741EA6B524E7F3409
Content-Type: text/plain; charset=us-ascii; x-mac-type="54455854"; x-mac-creator="4D4F5353"
Content-Transfer-Encoding: 7bit
Hello:
I am calling a scripts of Perl Programs from a Shell
Script. From inside the Perl Program, I call another Perl
Program. It works if I call the invoking PERL program from the
command line, but it does not work when I call it from the Shell
Script. The Code and the Dumps Follow:
$Path_OUT = "/users/sotoo/data/";
$Path_Data = "/users/sotoo/data/";
$comm[0] = "$pwd" . "wfrphr.pl";
$comm[1] = "$Path_Data" . "stats.dat";
$comm[2] = "$Path_OUT" . "spdat.htm";
print ("@comm\n");
$status = system(@comm);
print ("$status\t$?\n");
$comm[0] = "$pwd" . "wfrphr.pl";
$comm[1] = "$Path_Data" . "stats.curr";
$comm[2] = "$Path_OUT" . "spcurr.htm";
print ("@comm\n");
$status = system(@comm);
print ("$status\t$?\n");
I am double cheking the inputs and the return values. After the
shell script that run the programs is called, the output from
the print statements is:
/mount/s/users/sotoo/pscripts/master/wfrphr.pl
/users/sotoo/data/stats.dat /users/sotoo/data/spdat.htm
65280 65280
/mount/s/users/sotoo/pscripts/master/wfrphr.pl
/users/sotoo/data/stats.curr /users/sotoo/data/spcurr.htm
65280 65280
What can I do to correct this.
Omar Soto
--------------DE522C7741EA6B524E7F3409
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Omar Soto
Content-Disposition: attachment; filename="vcard.vcf"
begin: vcard
fn: Omar Soto
n: Soto;Omar
org: Motorola
adr;dom: ;;1300 N. Alma School Rd;Chandler;Arizona;85224;
email;internet: rp7667@email.sps.mot.com
title: Software Applications Engineer
tel;work: (602)814-4614
tel;fax: (602)814-3519
tel;home: Pager: 1-800-315-2617
x-mozilla-cpt: ;0
x-mozilla-html: FALSE
version: 2.1
end: vcard
--------------DE522C7741EA6B524E7F3409--
------------------------------
Date: Fri, 23 Apr 1999 16:41:46 +0100
From: "Acacio Cruz [@Dynamac]" <acruz@acacio.com>
Subject: Wanted: Win32 binaries of Perl/Tk
Message-Id: <372094BA.519F8EC@acacio.com>
Where can I download a binary of Perl/Tk ??
I searched CPAN, Perl.org, Hotbot and Altavista and no luck. :(
Any ideas?
--
Acacio Cruz acruz@acacio.com
Senior Network Architect Personal WWW site: http://www.acacio.com
Dynamac Corp. PGP Public Key: http://www.acacio.com/~acruz/Acacio.pgp
------------------------------
Date: Fri, 23 Apr 1999 14:34:44 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Wanted: Win32 binaries of Perl/Tk
Message-Id: <3720E774.41EE279C@mail.cor.epa.gov>
Acacio Cruz [@Dynamac] wrote:
>
> Where can I download a binary of Perl/Tk ??
> I searched CPAN, Perl.org, Hotbot and Altavista and no luck. :(
Don't bother. You've got a modern version of ActiveState Perl, right?
Use the ppm program that came with it.
At the command prompt type:
ppm install Tk
and sit back while the program does its stuff. In a minute or three,
you'll have all necessary files downloaded, and placed in all the
necessary directories, with all the scads of useful documentation
placed in the right areas.
Far easier than messing with a binary and trying to make sure
you get everything put in the right places. Especially when
there are plenty of little pieces to account for.
I just let ppm install Tk on a win98 box while I was typing this.
The install finished first. :-)
David
P.S. Dynamac? There are a host of Dynamac folks here at the lab.
Same company?
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior Computing Specialist phone: (541) 754-4468
mathematical statistician fax: (541) 754-4716
------------------------------
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 5467
**************************************