[10336] in Perl-Users-Digest
Perl-Users Digest, Issue: 3929 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 8 14:07:15 1998
Date: Thu, 8 Oct 98 11:00:20 -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 Thu, 8 Oct 1998 Volume: 8 Number: 3929
Today's topics:
Re: Are there any "perl.newbie" group or forum? <mp@mkt2mkt.com>
Re: Are there any "perl.newbie" group or forum? (Craig Berry)
Brining a TK Main Window to the front <cmihaly@fa.disney.com>
cgi REMOTE_USER variable question sherman@cdg.stsv.seagate.com
Re: cgi REMOTE_USER variable question <Tony.Curtis+usenet@vcpc.univie.ac.at>
Code set support <nkanth@cnd.hp.com>
Re: eq on if statement causing problems with string <jdporter@min.net>
Re: Exporting environment variables to parent shell <halfdan@no-junkmail.please.pison.com>
Re: Exporting environment variables to parent shell (Matt Knecht)
Re: foreach peculiarities (Tad McClellan)
Re: high level (UNIX) system summary <bruce.w.mohler@saic.com>
Re: how can i call another CGI prog on the net ? (Doran L. Barton)
How to disable signals to fork processes <cmihaly@fa.disney.com>
Re: mSQL2 Perl5 Insert Status Checking <chi@cybie.com>
Re: Need help refining this <aqumsieh@tigre.matrox.com>
Re: need help refining this (Mark-Jason Dominus)
Re: NEEDED: A good perl programer to... droby@copyright.com
pattern matching thayner@taxcut.com
Re: PERL, C++ Software Test Engineer-Chandler, AZ droby@copyright.com
Re: POLL: Perl features springing into your face (M.J.T. Guy)
Re: Problems with substr <uri@camel.fastserv.com>
SSL (secure sockets) with perl <sasjpl@sas.com>
Re: SSL (secure sockets) with perl (Mads Toftum)
Re: strange problem with shift()... <aqumsieh@tigre.matrox.com>
Re: strange problem with shift()... <uri@camel.fastserv.com>
test: tap, tap, is this thing on baillie@my-dejanews.com
Re: When did you last use AWK (was Re: free book on sh/ (Jari Aalto+mail.perl)
wildcard expansion in filenames ??? (Stephen Elias)
Re: wildcard expansion in filenames ??? (Tad McClellan)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 08 Oct 1998 09:20:39 -0800
From: madame philosophe <mp@mkt2mkt.com>
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <361CF463.2C10C2E8@mkt2mkt.com>
John Porter wrote:
> madame philosophe wrote:
> >
> > People seek the newsgroups because they need help, not because they
> > are stupid.
>
> The issue is about maximizing the value of this (or any) newsgroup,
> both to the querant, and to others. Being lazy is not an excuse --
> cute aphorisms not withstanding.
Yes, I agree.
>
>
> > If the people at this group are tired of hearing the same questions.
> > why doesn't someone start a newbie perl newsgroup?
>
> This question has already been discussed, and answered.
> Many times.
> But you wouldn't know that, would you?
Ha Ha.
>
>
> > As the web grows there will be more newbies. GET USED TO IT.
>
> No, it's not that simple.
>
> "People are going to come and deposit bodily excretions in your
> sandbox. Get used to it." No, I'm sorry. There are trends which
> must be resisted, however futile it turns out to be.
Oh, come ON!!! Are you telling me nebie questions are likened to excrement?
Shame on you.
I would hate to think if such a thing were to happen in real life. But
actually it does...ever been to Paris? They love their dogs there...(If
you've seen the movie Ready to Wear" they have a lot of fun with the "stepping
in dog poo in Paris" jokes.) Paris is so wonderful that you do get used to the
poo, and you learn to have the atennas up to walk around it. Paris is a
wonderful sandbox and the poo is there to stay.
I know this is getting away from Perl, but you brought up the sandbox and I
think if Perl could be Paris and I were an expert rather than a just a pert, I
too would be used to poo.
>
>
> > It doesn't take a lot of brains to take pot shots to well meaning people.
>
> You would know...
I know you are.. but what am I? ;=}
mp
------------------------------
Date: 8 Oct 1998 17:09:27 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: Are there any "perl.newbie" group or forum?
Message-Id: <6virk7$oep$1@marina.cinenet.net>
madame philosophe (mp@mkt2mkt.com) wrote:
: > "People are going to come and deposit bodily excretions in your
: > sandbox. Get used to it." No, I'm sorry. There are trends which
: > must be resisted, however futile it turns out to be.
:
: Oh, come ON!!! Are you telling me newbie questions are likened to
: excrement? Shame on you.
Folks, if we don't start using precise language to discuss this issue,
we're sunk. Nobody (whose posts I've seen) is comparing *all* newbie
questions to excrement. Quite a few of us are comparing *FAQs* (typically
posted by newbies) to excrement, or spam, or other messy, annoying things.
You can't rationally debate this topic until you make a clear division
between the postings of ignorant but well-intentioned newbies who have
made the best use they know how of all resources at their disposal, and
the postings of those who ask FAQs because they can't be bothered to read
any of the available doc before asking thousands of people to do their
homework for them.
---------------------------------------------------------------------
| Craig Berry - cberry@cinenet.net
--*-- Home Page: http://www.cinenet.net/users/cberry/home.html
| "Ripple in still water, when there is no pebble tossed,
nor wind to blow..."
------------------------------
Date: Thu, 08 Oct 1998 10:26:36 -0700
From: Chris Mihaly <cmihaly@fa.disney.com>
Subject: Brining a TK Main Window to the front
Message-Id: <361CF5CC.B539D966@fa.disney.com>
Is there a Tk method that will raise the main Tk window to the top of
the stacking order? I would like to make my main application window
come to the top when the backgroup processing for a particular step
invoked by the app is completed. Is there a way to do this in Tk? Can
I get an X11 like X11_Protocol module and raise the Tk window that way
(how do I get the window object/id from Tk?
Thanks for any help
Chris
------------------------------
Date: Thu, 08 Oct 1998 15:53:47 GMT
From: sherman@cdg.stsv.seagate.com
Subject: cgi REMOTE_USER variable question
Message-Id: <6vin6c$jo$1@nnrp1.dejanews.com>
greetings,
i'm writing a cgi script in perl where i want to verify that the name the user
enters in a form can be checked against the cgi variable $REMOTE_USER. the
problem is that i can't seem to get perl to return the value of $REMOTE_USER.
i have a stub of a cgi script in sh, where a line like:
echo REMOTE_USER = $REMOTE_USER
returns the name of the remote user. in perl, the value is null.
i've tried $ENV{$REMOTE_USER}, $ENV{REMOTE_USER}, $<, and even $>, and all
the permutations of escaping characters. at best, i get "webuser", the
special user that apache httpd runs as, but not the name of the real user.
since i can get a value from sh, i believe that $REMOTE_USER is available.
can anyone help in retrieving this value from a perl script instead of a sh
script?
thanks in advance!
-sherman
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 08 Oct 1998 19:44:47 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: cgi REMOTE_USER variable question
Message-Id: <83k92baqy8.fsf@vcpc.univie.ac.at>
Re: cgi REMOTE_USER variable question, sherman
<sherman@cdg.stsv.seagate.com> said:
sherman> greetings, i'm writing a cgi script in perl where i
sherman> want to verify that the name the user enters in a
sherman> form can be checked against the cgi variable
sherman> $REMOTE_USER. the problem is that i can't seem to
sherman> get perl to return the value of $REMOTE_USER.
sherman> i've tried $ENV{$REMOTE_USER}, $ENV{REMOTE_USER},
sherman> $<, and even $>, and all the permutations of
$< and $> are the user as whom the CGI script is running,
which is probably "nobody" and is a local UNIX uid.
$ENV{REMOTE_USER} should work.
sherman> escaping characters. at best, i get "webuser", the
sherman> special user that apache httpd runs as, but not the
sherman> name of the real user.
Aha, I were right :-)
sherman> since i can get a value from sh, i believe that
sherman> $REMOTE_USER is available. can anyone help in
sherman> retrieving this value from a perl script instead of
sherman> a sh script?
You're sure the perl script is running from a location
inside the protected realm space, and not from somewhere
unprotected?
use CGI;
my $ru = remote_user();
perldoc CGI
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: Thu, 08 Oct 1998 10:16:16 -0600
From: Srikanth Natarajan <nkanth@cnd.hp.com>
Subject: Code set support
Message-Id: <361CE550.241281CC@cnd.hp.com>
Hi
I would like to know to what extent does perl support
single and multi-byte codesets.
Any pointers would help a lot.
I am in the process of internationalizing a perl
app.
Srikanth
------------------------------
Date: Thu, 08 Oct 1998 13:45:40 -0400
From: John Porter <jdporter@min.net>
Subject: Re: eq on if statement causing problems with string
Message-Id: <361CFA44.ADCFB51B@min.net>
brian d foy wrote:
>
> In article <x3y3e90qic3.fsf@tigre.matrox.com>, Ala Qumsieh <aqumsieh@tigre.matrox.com> posted:
>
> >What if there wasn't enough disk space?
>
> open doesn't know how much space you are going to need.
It knows how much it's going to need for itself, if it has
to allocate a directory entry...
--
John "Many Jars" Porter
baby mother hospital scissors creature judgment butcher engineer
------------------------------
Date: Thu, 08 Oct 1998 18:03:22 +0100
From: Halfdan Ingvarsson <halfdan@no-junkmail.please.pison.com>
Subject: Re: Exporting environment variables to parent shell
Message-Id: <361CF05A.B5FBC0D7@no-junkmail.please.pison.com>
I R A Aggie wrote:
> That would be a security flaw, and can not be done. Would you really
> want a program to reset your environment?
Umm. Yes. That's why I asked (after finding that the demon.co.uk server,
I was pointed to, for the FAQ was down, FYI Mr. McClellan).
What's happening is that I'm trying to use tcsh's 'cwdcmd' alias to
change the 'MAKEFLAGS' environment variable. This is so that depending
on which development structure I'm in (I've got lots) it modifies the
'MAKEFLAGS' variable to point to a new include directory.
I could of course make a gmake wrapper to do that for me, but I was
wondering if this were at all possible (becuase then I wouldn't have to
do it for loads of other tools). I guess it's probably more of a
question for the comp.unix folks.
Ciao,
H.
-==["The only decent thing to do behind a persons back is to pat it"]==-
- Sleep? Isn't that some inferior substitute for caffeine? -
- Unspam: remove the 'no-junkmail.please.' bit -
------------------------------
Date: Thu, 08 Oct 1998 17:54:43 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Exporting environment variables to parent shell
Message-Id: <D%6T1.346$wV1.1878679@news2.voicenet.com>
Halfdan Ingvarsson <halfdan@no-junkmail.please.pison.com> wrote:
>I R A Aggie wrote:
>> That would be a security flaw, and can not be done. Would you really
>> want a program to reset your environment?
>
>Umm. Yes. That's why I asked (after finding that the demon.co.uk server,
>I was pointed to, for the FAQ was down, FYI Mr. McClellan).
The comp.unix.shell FAQ is availible in *many* places. Try doing a
search for it. If you are unsure how to search, check out
www.yahoo.com.
When you find it, check out:
2.8 - How do I {set an environment variable, change directory} inside
a program or shell script and have that change affect my current shell?
>I could of course make a gmake wrapper to do that for me, but I was
>wondering if this were at all possible (becuase then I wouldn't have to
>do it for loads of other tools). I guess it's probably more of a
>question for the comp.unix folks.
Followups set.
--
Matt Knecht - <hex@voicenet.com>
------------------------------
Date: Thu, 8 Oct 1998 12:10:58 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: foreach peculiarities
Message-Id: <2nriv6.75f.ln@flash.net>
brian d foy (comdog@computerdog.com) wrote:
: In article <x3yhfxfyw9z.fsf@tigre.matrox.com>, Ala Qumsieh <aqumsieh@tigre.matrox.com> posted:
: >comdog@computerdog.com (brian d foy) writes:
: >> In article <x3y1zokqhsc.fsf@tigre.matrox.com>, Ala Qumsieh <aqumsieh@tigre.matrox.com> posted:
: >> >foreach takes a LIST .. not an ARRAY! (be sure you make a distinction
: >> >between lists and arrays ... sometimes this is crucial!)
^^^^^^^^^
^^^^^^^^^
But he didn't say that foreach() was one of those times ;-)
Did seem to be the implication though.
: so foreach can take an array.
example of when it _is_ one of those times:
=item push ARRAY,LIST
^^^^^
Maybe this is what Ala meant?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 08 Oct 1998 08:14:56 -0700
From: Bruce Mohler <bruce.w.mohler@saic.com>
Subject: Re: high level (UNIX) system summary
Message-Id: <361CD6F0.2EE74568@saic.com>
Thanks, Russ. That was *exactly* what I was looking for!
Bruce
Russ Allbery wrote:
> Bruce Mohler <bruce.w.mohler@saic.com> writes:
>
> > Has anyone written a Perl script to perform a high level system summary:
> > hardware (vendor, model, amount of memory, disks, CD-ROMs, tapes, etc.),
> > software (OS version, patches installed, common utilities installed,
> > NFS?, NIS?, DNS?, etc.), general configuration (survey of syslog,
> > password/group files, local printers configured, backups, etc.).
>
> <URL:http://www.magnicomp.com/sysinfo/sysinfo.shtml>
>
> This won't do everything that you're looking at doing above, but it's a
> good place to get started (and better than trying to do it all in Perl,
> since a lot of that information requires fairly low-level interfaces to
> obtain).
>
> --
> #!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
> $^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
> 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
> rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print
--
Bruce W. Mohler 619-458-2675 (voice)
SAIC/ITS/Server Support 619-535-7806 (fax)
Sr UNIX system administrator 888-781-5697 (pager)
mailto:bruce.w.mohler@saic.com
Of course my password is the same as my pet's name.
My dog's name is Q47pY!3, but I change it every 90 days.
------------------------------
Date: 8 Oct 1998 10:03:41 -0600
From: fozz@xmission.xmission.com (Doran L. Barton)
Subject: Re: how can i call another CGI prog on the net ?
Message-Id: <6vinot$o3f$1@xmission.xmission.com>
fkoehler@num.math.uni-goettingen.de writes:
>i have the following problem: I would like to start another CGI prog from
>within mz perl prog which is located on some server on the net and I would
>like to pass paramters to it. How can i do this ? I think I have to use
>something likea HTTP command or NET command..... How can realize this in PERL
>? Anybody can help ?
The Perl module LWP realizes many things like this.
<URL:http://www.perl.com/CPAN/modules/by-module/LWP/libwww-perl-5.36.tar.gz>
Seems like what you want to do is write a Perl script that essentially
behaves like a WWW browser. That is one thing LWP lets you do- write HTTP
clients in Perl. :-)
Have fun.
-=Fozz
--
Doran L. Barton = fozz@xmission.com && http://www.xmission.com/~fozz/;
"Where do you want Microsoft to go today?" --Ron Barry <ronb@cc.usu.edu>
"This may seem a bit weird, but that's okay, because it is weird."
-- Larry Wall <lwall@sems.com> in the Perl v5 man page
------------------------------
Date: Thu, 08 Oct 1998 10:31:03 -0700
From: Chris Mihaly <cmihaly@fa.disney.com>
Subject: How to disable signals to fork processes
Message-Id: <361CF6D7.6A3741B3@fa.disney.com>
I have lots of scripts that fork and pipe information between these
processes. Most of them are one way fork/pipe invoked by open -| calls,
but some are two way pipes opened by IPC::open2 or IPC::open3. My
problem is that ^C or ^Z break these pipes. How can I fork processes so
that only my main app gets the signals (I can catch and deal with them
there) and not my forked processes? I tried to find it in the FAQ,
maybe its there but I couldn't find it, I did see the stuff on the
signals (although some of the links couldn't be found from my machine
for some reason).
Chris
--
Christopher Mihaly Email: cmihaly@fa.disney.com
Walt Disney Feature Animation Phone: (818) 526-3231
500 S. Buena Vista St. Fax: (818) 526-3319
Burbank, CA 91521-4806
------------------------------
Date: Thu, 08 Oct 1998 09:34:22 -0700
From: Chi Yu <chi@cybie.com>
Subject: Re: mSQL2 Perl5 Insert Status Checking
Message-Id: <361CE98E.7B27FBA6@cybie.com>
> is this Msql.pm? you can check the special $Msql::errmsg variable. IIRC,
> that is also available as $dbh->errmsg. for the DBI module, you would
> check $dbh->errstr.
Pardon my ignorance, but I have no clue.
My script has the following line:
use lib '/u/local/msql2/perl'; # include for mSQL version 2+
Does that indicate to you which module I am using? Given a choice, which
is preferred? Where can I find documentation on the commands for each
version? Working examples would be great too.
Back to the question... Are you saying it is not reliable to check the
query handle for the results?
e.g. $sth = $dbh->query($sql_statement)
if ($sth) {
# for a select statement #
if (($sth->numrows) > 0) {
# rows were selected #
...
# for an insert statement #
if ($sth == 1) {
# row was inserted #
# I noticed this condition was true on a successful insert
# but this is an inconsistent way to check the status.
...
Thanks a million!
Chi Yu
------------------------------
Date: 08 Oct 1998 10:52:41 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: Need help refining this
Message-Id: <x3yemsjyukm.fsf@tigre.matrox.com>
Eric Bohlman <ebohlman@netcom.com> writes:
>
> baillie@my-dejanews.com wrote:
> : Basically, this is my first perl program, and I'd like to have it more compact
> : (in the tradition of perl), as well as optimize it some. Any help would be
> : appreciated!
>
>
> : #!/usr/bin/perl -w
>
> Using -w is always a good sign. Next, I'd suggest that you
>
> use Strict;
>
I agree on the -w part .. but I would suggest that he
use strict;
not Strict .. It was probably a typo, but someone that doesn't know
what strict is might not recognize that.
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: 8 Oct 1998 13:39:06 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: need help refining this
Message-Id: <6vitbq$v6$1@monet.op.net>
In article <6via61$d0u$1@nnrp1.dejanews.com>, <baillie@my-dejanews.com> wrote:
>if(defined($ARGV[0])) {
> $host=$ARGV[0];
> system "rsh $host alex-sched -LP 0 > /tmp/opck.cache";
>} else {
> $host='localhost';
> system "alex-sched -LP 0 > /tmp/opck.cache";
>}
Five lines become four, a variable disappears, and you get some error
checking:
$command = 'alex-sched -LP 0';
$command = "rsh $ARGV[0] $command" if $ARGV[0];
open (FILE, "$command |")
or die "Couldn't execute `$command'; aborting";
Also, you no longer have to manage a file. That is a big win. Files suck.
>while(<FILE>) {
> if(/^Total Bytes to Backup/) {
> chomp($to_store=$_);
> $to_store=~tr/[a-z A-Z:]//d;
> $to_store/=1024;
> }
Four lines become three:
while (<FILE>) {
if (/Total Bytes to Backup/) {
($to_store) = /(\d+)/ ; # Extract the first number from this line
$to_store /= 1024;
}
> if(/^Current KBytes Stored/) {
> chomp($store_array[$i]=$_);
> $i++;
> }
> }
Three lines become two, and we get rid of two unnecessary variables:
elsif (/^Current KBytes Stored/) {
($amount_stored) = /(\d+)/; # Extract number from this line
# You never use the @store_array, so I got rid of it.
}
}
>close(FILE) or die "Couldn't close file: $!";
Good! But I would change the message to
close(FILE) or die "Couldn't finish command `$command': $!";
>unlink("/tmp/opck.cache") or warn "Couldn't remove file: $!";
>
> # Use the last value of the array for the current
> # amount of data that's been stored
>$amount_stored=$store_array[$#store_array];
> # Is this (below) right?..to grep out only the numbers
>$amount_stored=~tr/[a-z A-Z:]//d;
>undef(@store_array);
>undef($i);
7 lines are replaced by zero!
>$cntr=2;
This isn't doing anything; you reinitialize $cntr to 0 later on.
>$screen_width=`tput cols`;
>$percentage=($amount_stored/$to_store)*100;
>$vis_disp=($amount_stored/$to_store)*$screen_width;
>
>printf "\t$host amount to store\t=\t%.0f\n", $to_store;
>print "\t\tamount stored\t\t=\t$amount_stored\n";
>
>system "tput smso"; # Is there a better way to do this (curses)?
All this stuff is plausible, but see below for a different approach.
>for($cntr=0; $cntr<=$vis_disp; $cntr++) {
> print "=";
>}
Three lines become one line, and a variable disappears:
print "=" x $vis_disp; # I think yours printed one too many?
>printf "\t\t\t\t\tOpcard is%2d", $percentage;
I personally would have gotten `percentage' into the right format the
first time:
$percentage = sprintf "%2d", 100*($amount_stored/$to_store);
...
print "\t\t\t\t\tOpcard is $percentage";
Then the `print' statement reads naturally, and related things (the
computation and the formatting for $percentage) are together.
>system "tput rmso";
It bugs me to have all these `system' commands interspersed into the
`prints'. It looks messy! It's hard to understand what the output
will look like. You are inviting buffering problems. I think it
would be better to take a different approach.
You suggested using a module; I think Term::Cap would be suitable
here. But here's a different approach:
foreach $escape (qw(rmso bold smso cols)) {
$T{$escape} = qx{tput $escape};
}
Now the escape codes are available there when you need them, and you
don't have to bust up the output, so it's easier to see what is going
to come out:
print "$T{rmso}$T{bold}\t\t\t\t\tOpcard is $percentage$T{rmso}% complete\n\n";
You might like to have the code names in caps?
foreach $escape (qw(rmso bold smso cols)) {
$T{uc $escape} = qx{tput $escape};
}
print "$T{RMSO}$T{BOLD}\t\t\t\t\tOpcard is $percentage$T{RMSO}% complete\n\n";
I liked them better in lowercase, but it's up to you.
So here's the reworked version of the program:
#!/usr/bin/perl
$command = 'alex-sched -LP 0';
$command = "rsh $ARGV[0] $command" if $ARGV[0];
$host = $ARGV[0] || 'localhost';
open (ALEX, "$command |")
or die "Couldn't execute `$command'; aborting";
while (<ALEX>) {
if (/Total Bytes to Backup/) {
($to_store) = /(\d+)/ ;
$to_store /= 1024;
} elsif (/^Current KBytes Stored/) {
($amount_stored) = /(\d+)/;
}
}
close(ALEX) or die "Couldn't finish command `$command': $!";
# Get terminal escape sequences for output formatting
foreach $escape (qw(rmso bold smso cols)) {
$T{$escape} = qx{tput $escape}; # `T' for `Terminal'
}
$percentage= sprintf "%2d", ($amount_stored/$to_store)*100;
printf "\t$host amount to store\t=\t%.0f\n", $to_store;
print "\t\tamount stored\t\t=\t$amount_stored\n";
print $T{smso},
( '=' x ($amount_stored/$to_store) * $T{cols} ), ">\n",
$T{rmso};
print "$T{bold}\t\t\t\t\tOpcard is $percentage$T{rmso}% complete\n\n";
It's gone from 37 lines to 20, lost a bunch of superfluous variables,
has better error checking, no longer uses a temporary file, calls
`tput rmso' only once instead of twice, and I think it's clearer than
it was before.
Hope this helps. Now you know how to find the last instance without
saving all the previous instances into an array.
------------------------------
Date: Thu, 08 Oct 1998 15:50:16 GMT
From: droby@copyright.com
Subject: Re: NEEDED: A good perl programer to...
Message-Id: <6vimvo$gg$1@nnrp1.dejanews.com>
In article <6vguob$bcm$7@marina.cinenet.net>,
cberry@cinenet.net (Craig Berry) wrote:
> David Formosa (dformosa@zeta.org.au) wrote:
> : In <6vg9gv$o8l$1@news.interlog.com> dragnet@internalysis.com (Marc
Bissonnette) writes:
> :
> : > I'll charge the $$,
> :
> : You charge based on PID?
>
> I find that adds to the excitement value of the whole process. You just
> have to be careful to avoid working on a freshly booted machine.
>
Yet another reason to prefer Linux to NT. ;-)
VMS can produce some wonderfully giant PIDs though, immediately upon boot.
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 08 Oct 1998 15:05:43 GMT
From: thayner@taxcut.com
Subject: pattern matching
Message-Id: <6vikc7$s0b$1@nnrp1.dejanews.com>
I have two groups of files (one file from each group is supposed to match the
other) which should contain an identical list of field names. Does anyone
have code that can do this. Thanks.
Thompson Hayner
Here is the first one which I'll call Sample.id. Aside from comment lines
(with a ! in from of them), the first column contains the field names that I
need to determine if they are in the second file.
! Old KB data removed 4/18/97
! text = filename
! USXXXXQ1 = USXXXXQ1 1
!: mapping pulled at Bev's rqst FC 9/20/96
!
!
!: what was attwks was moved to mwks, and then this file
!: was made into a dummy shell FC 8/28/96
!
NameFirst 14 1 0 none fpers SelfNameFirst ^1^
NameMI 14 1 0 none fpers SelfNameFirst ^1^
NameLast 14 1 0 none fpers SelfNameFirst ^1^
NameSuffix 14 1 0 none fpers SelfNameFirst ^1^
SSN 14 1 11 none fpers SSN ^1^
Field1 1 1 0 none 0 0 ^000^
Field2 1 1 1 none 0 0 ^000^
Field3 4 1 45 none 0 0 ^000^
Field4 1 1 13 none 0 0 ^000^
Here is the second sample.frm
! !: what was attwks was moved to mwks, and then this file !: was made into a
dummy shell FC 8/28/96 ! 3 3 {$y}*xx FB D N B (Form 1040) 3 3OMB No.
xxxx-xxxx FB B
DDDDDDDDDDDDDDDDDADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDEDDDDDDDDDDDDDDDD
D FN __________ _ ____________________ ___ 3SSN: ___________@ NameFirst
NameMI NameLast NameSuffix SSN F B
DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDADDDDDDDDDDDDDDDD
D
Field 1 ___________________
@Field1
FN
Field 2 _
@Field2
FB
G
Field 3 __________
@Field3
FI
Field 4 [_]
@Field4
FN
G X
MDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
IRS #H920-TaxCut. For Paperwork Reduction Act Notice, see IRS Instructions.
FB
I
MDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
FN
M END OF FORM
F R N
MDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD
FN
%
FormName [form name]
Title [title]
MbrScreenGp N
FirstInScnGp N
LastInScnGp N
NumCopies 1
ChecklistIndex 0
UserScnNameIndex 0
TaxFormScn Y
ScreenId 0
Print Y
AccIndex 10
%
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 08 Oct 1998 16:03:02 GMT
From: droby@copyright.com
Subject: Re: PERL, C++ Software Test Engineer-Chandler, AZ
Message-Id: <6vinnm$1g0$1@nnrp1.dejanews.com>
In article <361BFFAB.464EE0BD@home.com>,
ESS <paulg3@home.com> wrote:
> Perm Career opportunity:
>
> We are offering a $2000 Finder?s Fee for any referral who get placed by
> our corporate client. Paid 5 days after we receive our check!
>
Ok. Here's a referral. misc.jobs.offers
This is not a job posting newsgroup.
>
> *Minimum Requirements:
> Three years experience in software testing.
> 2 years programming experience with PERL
> Programming Experience with C++
> Experience with UNIX, OS/2, MS-Windows operating systems.
> Experience with MS-Word
>
So experience with WordPerfect instead of MS-Word would disqualify someone who
has the rest of these, right?
--
Don Roby
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 8 Oct 1998 11:11:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: POLL: Perl features springing into your face
Message-Id: <6vi6lj$md4$1@pegasus.csx.cam.ac.uk>
Hallvard B Furuseth <h.b.furuseth@usit.uio.no> wrote:
>Ilya Zakharevich writes:
>>> barewords - if you want a quoted string, for gosh sakes put $#@!
>>> quotes around it!
>>
>> Definitely I like barewords where they are unambiguous: in ->{foo},
>> foo => and `use foo'.
>
>...until someone invents a keyword `foo', or feeds a keyword to a
>script which generates code like `$x->{foo}':-(
>
> $ perl5 -wle 'print {time => 5}->{time};'
> Ambiguous use of time => resolved to "time" => at -e line 1.
> Ambiguous use of {time} resolved to {"time"} at -e line 1.
> 5
Use an up-to-date Perl, e.g.
$ perl5.005 -wle 'print {time => 5}->{time};'
5
$
This bug will also be mended in the forthcoming perl5.004_05 maintenance
release.
Mike Guy
------------------------------
Date: 08 Oct 1998 12:55:22 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: "John J. Alesse" <jja@inforonics.com>
Subject: Re: Problems with substr
Message-Id: <sard883ro1x.fsf@camel.fastserv.com>
>>>>> "JJA" == John J Alesse <jja@inforonics.com> writes:
JJA> I have attached substr_test.pl. Please try to reproduce the problem and
JJA> let me know what you think is wrong.
this program can't compile under perl. perhaps you forgot to decode it
before you posted it. perl is plain text, so most readers can handle
it. do not post programs as attachments
JJA> IyEvdXNyL2xvY2FsL2Jpbi9wZXJsIC13CiMKIyBUaGlzIGNvbW1hbmQgbGluZSB0ZXN0IHdp
<snip of binary goobeldygook>
JJA> dGVzdF9zdWJzdHI7CiZjaGVja19pdDsK
JJA> --------------5D19730D277E--
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 8 Oct 1998 16:41:47 GMT
From: "John Leveille" <sasjpl@sas.com>
Subject: SSL (secure sockets) with perl
Message-Id: <F0Ip1p.Bp6@unx.sas.com>
I snarfed some great code from a couple old editions of Linux Journal (March
97 and May 97) that describes how to create simple clients and simple
servers in perl. That code has been working great for a variety of
purposes. I made and http client out of it that I use on a regular basis.
They just put up some secure web servers on our intranet and my client can't
talk to them.
Any idea how to get perl to talk SSL (secure sockets)?
Thanks,
John
--
sasjpl@sas.com
------------------------------
Date: Thu, 08 Oct 1998 17:37:43 GMT
From: mt@dev.null (Mads Toftum)
Subject: Re: SSL (secure sockets) with perl
Message-Id: <361cf842.34740817@news.inet.tele.dk>
>Any idea how to get perl to talk SSL (secure sockets)?
Grab Net::SSLeay from CPAN.
vh
Mads Toftum, QDPH
som pe USENET reprfsenterer sig selv og ingen andre.
------------------------------
Date: 08 Oct 1998 10:46:27 -0400
From: Ala Qumsieh <aqumsieh@tigre.matrox.com>
Subject: Re: strange problem with shift()...
Message-Id: <x3yg1czyuv0.fsf@tigre.matrox.com>
Peter Smith <psmith01@mindspring.com> writes:
> What don't I understand about push()?? Perl??
The problem is not in push() or in Perl .. it's in your isMatch()
subroutine. See below.
>
>
> #### BEGIN PROGRAM ####
>
> #Create array
> @Array = ();
>
> #Read each line/record
> while($line = <STDIN>) {
> #Chop-off newline for output brevity sake
> chop($line) if $line =~ /\n$/;
Why do that when you have chomp() ?? chomp() removes the newline
character *if it exists at the end of the string* and returns the
number of characters removed.
chomp $line;
But that is not the problem .. read on ..
>
> #Set 'duplicate' marker -> returns true or false
> $match = &isMatch($line);
>
> #If not already in @Array, then add it
> if($match eq "false")
> {
> push(@Array,"$line"); #Produces good output
> #push(@Array,"$line\n"); #Produces bad output
Assume you use the second push statements with the \n appended to each
element in the array. See further down.
> }
> }
>
> #Print out unique records
> &printRecords();
>
>
> ############################################
> # SUBROUTINES
> ############################################
> sub printRecords()
> {
> foreach (@Array)
> {
> print STDOUT "$_";
> }
> }
>
> #This subroutine looks at the global @Array
> sub isMatch()
> {
> #Pass-in record just read from STDIN
> local($var) = shift;
>
> foreach $line (@Array)
> {
The problem is here! $line will contain the element (1,2,3..) followed
by a carriage return. Since you have already stripped $var of its \n
character, $line will NEVER be equal to $var.
"5" is NOT equal to "5\n"
> if($line eq $var)
> {
> return "true";
> }
> }
> return "false";
> }
> #### END PROGRAM ####
>
>
> #Here is the 'Good' output - all unique records:
> 12345
>
> #Here is the 'Bad' output - not all unique records:
> 1
> 2
> 3
> 4
> 5
> 3
> 4
> 5
> 3
> 4
> 5
>
> The input file looks exactly like the 'bad' output above...
Hope this helps,
--
Ala Qumsieh | No .. not Just Another
ASIC Design Engineer | Perl Hacker!!!!!
Matrox Graphics Inc. |
Montreal, Quebec | (Not yet!)
------------------------------
Date: 08 Oct 1998 12:44:12 -0400
From: Uri Guttman <uri@camel.fastserv.com>
To: rjk@coos.dartmouth.edu (Ronald J Kimball)
Subject: Re: strange problem with shift()...
Message-Id: <sarg1czrokj.fsf@camel.fastserv.com>
>>>>> "RJK" == Ronald J Kimball <rjk@coos.dartmouth.edu> writes:
RJK> I'm afraid that your program is about as non-Perlish as you could get.
RJK> Here is the program again, as a Perl programmer might write it:
RJK> #### BEGIN PROGRAM ####
RJK> while(defined($line = <STDIN>)) {
RJK> push(@Array, $line)
RJK> if (not $seen{$line}++);
RJK> # use a hash to keep track of which lines have been seen before
RJK> }
RJK> print @Array;
RJK> #### END PROGRAM ####
and here is how a lazy perl programmer might write it:
# BEGIN ONE LINER
perl -lne 'print unless $seen{$_}++'
# END ONE LINER
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 08 Oct 1998 16:14:30 GMT
From: baillie@my-dejanews.com
Subject: test: tap, tap, is this thing on
Message-Id: <6viod6$26t$1@nnrp1.dejanews.com>
Damn DejaNews
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 08 Oct 1998 19:01:17 +0300
From: jari.aalto@poboxes.com (Jari Aalto+mail.perl)
To: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: When did you last use AWK (was Re: free book on sh/sed/awk)
Message-Id: <ptrzpb759gy.fsf@olkikukka.i-have-a-misconfigured-system-so-shoot-me>
mjd@plover.com (Mark-Jason Dominus) writes:
>
> In article <6umbv5$cio$1@gellyfish.btinternet.com>,
> Jonathan Stowe <gellyfish@btinternet.com> wrote:
> >But apart from that I cant think of a possible situation where I might use
> >AWK nowadays. But of course others may differ in their opinion.
Think again. :-)
I use AWK all the time instead of perl for handling my email with
procmail, because
-- AWK is smaller binary
-- AWK startup time is faster
-- Email messages are short, so AWK is as fast as perl.
The most crucial part is the system load that Perl would cause for
each 1000 incoming email I get per day from various mailing lists.
"Pick the right tool for the job at hand".
[In spite of that, I'm a heavy Perl programmer]
HP-UX 10.20:
-r-xr-xr-x 1 bin bin 135168 Jun 12 1995 /usr/bin/awk
-rwxrwxr-x 2 linjamak guru 834537 Nov 21 1997 /opt/local/lib/Perl5.004_04/bin/perl
jari
------------------------------
Date: Thu, 08 Oct 1998 16:19:10 GMT
From: steven_elias@ml.com (Stephen Elias)
Subject: wildcard expansion in filenames ???
Message-Id: <361ce570.165045793@news.ml.com>
Hi,
Can I have a wildcard pattern as an ARG to a perl program
and have it process whatever files it finds ???
See below
Thanks
c:\>copy con logit.pl
while ($line = <>) {
print $line ;
}
^Z
1 file(s) copied.
c:\>logit.pl log1.log
LOG FILE 1
c:\>logit.pl *.log
Can't open *.log: Invalid argument
c:>logit.pl log1.log log2.log log3.log log4.log
LOG FILE 1
LOG FILE 2
LOG FILE 3
LOG FILE 4
c:>
------------------------------
Date: Thu, 8 Oct 1998 12:15:08 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: wildcard expansion in filenames ???
Message-Id: <suriv6.75f.ln@flash.net>
Stephen Elias (steven_elias@ml.com) wrote:
: Can I have a wildcard pattern as an ARG to a perl program
: and have it process whatever files it finds ???
perldoc -f glob
perldoc -f opendir
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 12 Jul 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 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3929
**************************************