[8754] in Perl-Users-Digest
Perl-Users Digest, Issue: 2371 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 21 18:07:21 1998
Date: Tue, 21 Apr 98 15:00:36 -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 Tue, 21 Apr 1998 Volume: 8 Number: 2371
Today's topics:
'each' and recursion, do they mix? <jll@skynet.be>
Re: 'wait' under perl5.004 (possibly a perl bug?) <rootbeer@teleport.com>
Adding users from a web script using system <sgray@medicine.adelaide.edu.au>
Re: Array / List question <jdporter@min.net>
beginnings.... (Kevan)
Re: beginnings.... <bennett.aaron.abo@harte-hanks.com>
Re: beginnings.... <due@discovernet.net>
Re: Command line instructions don't execute in Win95 (Andrew M. Langmead)
Deleting a Line of Text, but keeping the file tidy <chad@umr.edu>
die diff 5.003 and 5.004? ()
Re: GCC and Solaris can't handle dynamic load ? <Steinar.Kleven@ahs.hist.no>
Re: Help with regular expression <quentin@jihad.amd.com>
Re: Help! <franzen@pmel.noaa.gov>
Re: How can I get the correct answer? (Jon Bell)
Re: How can I get the correct answer? <quentin@jihad.amd.com>
Re: How can I get the correct answer? (Jason Gloudon)
Re: How can I get the correct answer? (Tad McClellan)
Re: How to load the module with calculated name? (Andrew M. Langmead)
Re: Pattern Matching on HighBit Characters (Andre L.)
Re: Pattern Matching on HighBit Characters (Charles DeRykus)
Problem With "gethostbyaddr". <Rodney.Wines@ahqps.alcatel.fr>
processes in perl for NT <michele.quici@compaq.com>
Re: regular expression question (John Moreno)
Re: running perl at command line with arguments: script <andrewf@cp.pathfinder.com>
Re: Snobby news group <bmb@ginger.libs.uga.edu>
Re: subtitube variable into system command <rootbeer@teleport.com>
SUIDPERL (G. E. Terry)
Re: Time : Year2000 & 2038 code question <rootbeer@teleport.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 21 Apr 1998 22:19:07 +0200
From: Jean-Louis Leroy <jll@skynet.be>
Subject: 'each' and recursion, do they mix?
Message-Id: <VA.00000030.00a10056@enterprise>
Hello,
it seems that 'each' uses a single iterator per hash. That's
disappointing, and makes 'each' unsuitable for recursive algorithm that
iterate over the same hash at different levels of recursion. Hence my
questions:
1) Can I say 'local' to something and have it save & restore the
iterator?
2) If not, what is the most efficient *and* reentrant way of iterating
over a hash, besides the obvious 'foreach my $val (keys %h)...'?
TIA.
Jean-Louis Leroy
http://ourworld.compuserve.com/homepages/jl_leroy/
------------------------------
Date: Tue, 21 Apr 1998 20:00:28 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Michael Francis FIR LDN <Michael.Francis@gs.com>
Subject: Re: 'wait' under perl5.004 (possibly a perl bug?)
Message-Id: <Pine.GSO.3.96.980421125815.21174X-100000@user2.teleport.com>
On Tue, 21 Apr 1998, Michael Francis FIR LDN wrote:
> I have attached a simple program that exhibits this problem.
> Am I doing something wrong or is this a bug?
I think you're doing something wrong. :-) But I'm not sure. Fix your test
code to check for all possible errors - including especially a failed fork
call - and let us know if it still shows a problem. I can't duplicate it
on my system, though.
Good luck!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: 21 Apr 1998 08:42:13 GMT
From: "Stephen Gray" <sgray@medicine.adelaide.edu.au>
Subject: Adding users from a web script using system
Message-Id: <01bd6d01$85a01e20$4dae7f81@sgray.public-health.adelaide.edu.au>
Hi,
I'm trying to create a script to add new users to Windows NT using
information entered on a web page. The command to actually create the user
is just "system('net user /add')". This works from the command line but not
when running under a web server. I assume this is a problem with
permissions, but I have given the IIS_GUESTANON user created by IIS Admin
permissions and it still won't work. Have also tried NetAdmin::UserCreate,
but same deal. Does anyone know what might be going on?
Thanks,
Steve Gray
------------------------------
Date: Tue, 21 Apr 1998 13:19:19 GMT
From: John Porter <jdporter@min.net>
Subject: Re: Array / List question
Message-Id: <353C9E59.5CEF@min.net>
Larry Rosler wrote:
>
> > DB<1> @i = (1,2,3,4);
>
> I'm baffled by this. What does @i[@i] have to do with the last element
> in @i? As I read this, it is an array slice, whose value for the data
> shown above should be ( 2, 3, 4, undef ). Its length is 4, so squaring
> it gives 16, regardless of the values in the array. Try it again with
> other values, and you will see.
It looks like you're assuming that an array slice in a scalar context
yields the length of the slice, but that is not correct.
It yields the last element of the array, which in this case is undef.
undef squared is 0.
On the other hand, I gave (unintentionally) a different case that what
A.P. was orginally talking about. He was using an "identity" array,
i.e. @i = ( 0 .. $n ).
So to repeat the experiment with an identity array:
DB<1> @i = ( 0 .. 3 );
DB<2> x @i ** 2;
0 16
DB<3> x @i[@i] ** 2;
0 9
Thus we confirm again that @i[@i] is NOT the same as @i in a
scalar context, even when @i is an identity array.
John Porter
------------------------------
Date: 21 Apr 1998 13:24:18 GMT
From: in5109@wlv.ac.uk (Kevan)
Subject: beginnings....
Message-Id: <6hi6m2$rll@ccuh.wlv.ac.uk>
Where do I begin? I've read the FAQ's etc before posting, but I still need to
to ask these Questions.
The scenario is as follows.
I've gotta write a CGI script in Perl. I want to run it on a stand alone
machine initially, and after the testing etc, I've got the blessing of my
Webmaster to put it on the Apache server we use. So...
I need to get Perl and install it onto a Windows 95 machine.
What version should I be looking for?
How much space will it take up?
Is there a site it can be downloaded from simply?
And which files should I download?
Can I run it from within Windows 95? or will I need to quit to "virtual DOS"
to run it?
I'm actually intending to create a Web based booking system. Is this a
reasonable proposition? And I currently know very little Unix stuff.
If these are dumb questions, I apologise in advance, but I can't seem to find
this stuff out anywhere and believe me, I've looked. (I work in a library)
Peter Kendal
21/04/98
------------------------------
Date: Tue, 21 Apr 1998 09:44:36 -0400
From: Aaron Bennett <bennett.aaron.abo@harte-hanks.com>
Subject: Re: beginnings....
Message-Id: <353CA2C4.4E772861@harte-hanks.com>
Kevan wrote:
>
> I need to get Perl and install it onto a Windows 95 machine.
> What version should I be looking for?
> How much space will it take up?
> Is there a site it can be downloaded from simply?
> And which files should I download?
> Can I run it from within Windows 95? or will I need to quit to "virtual DOS"
> to run it?
One suggestion:
If you're intending to run the script under UNIX, you might wish to
develop it under Linux -- which will run on whatever hardware you're
running 95 on now.
--
------------------------------
Aaron Bennett
UNIX Systems Administrator
Harte-Hanks Response Management Boston
bennett.aaron.abo@harte-hanks.com
------------------------------
Date: 21 Apr 1998 14:29:39 GMT
From: "Allan M. Due" <due@discovernet.net>
Subject: Re: beginnings....
Message-Id: <6hiagj$6a7$0@206.165.146.159>
Peter,
A quick search of Yahoo (of all things) produces:
http://www.yahoo.com/Computers_and_Internet/Programming_Languages/Perl/Windo
ws/
Which includes ActiveState's web site http://www.activestate.com/ where you
can download Perl for Windows and find answers to some of your questions.
Also Robins Perl for Windows page, which has some information
http://www.geocities.com/SiliconValley/Park/8312/
and Joe's Perl for Win32 Page which has even more information
http://www.netaxs.com/~joc/perlwin32.html
Active State's Perl only takes up about 4 megs as I have it installed
and the download is 1.4 megs. It runs in a DOS box under Windows 95. I use
UltraEdit as my perl text editor and you can acutally run your perl code
from within UE and then capture the output to a listbox within UE to look at
the output. I find this very helpful when debugging.
You will also need a web server installed on your system. One of the
two sites given above has a listing of Win95 servers, some of which are
free. Stay away from MS PWS. I use O'Reilly's Website 1.1 which is still
free on the O'Reilly site.
HTH
Allan M. Due
Due@discovernet.net
Due@WhiteCrow.net
"There are two major products that come out of Berkeley: LSD and UNIX. We
don't believe this to be a coincidence."
-Jeremy S. Anderson
------------------------------
Date: Tue, 21 Apr 1998 14:30:36 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Command line instructions don't execute in Win95
Message-Id: <Errpn0.7Lu@world.std.com>
"Allan M. Due" <due@discovernet.net> writes:
>perl -e "print 'JaPHW';"
>works just fine under win95. However, I would still like to understand why
>this is different. Again, sorry for the double post.
The command shell that come with Windows 95 does not have the rich set
of quoting options that Unix shells have. Single quotes are not
treated as quotes, just another character.
perl -le "for(@ARGV){print}" 'this is in single quotes'
When you work on a one liner in which perl needs double quotes you
might want to use perl's generic quoting operators, as shown in the
perlop man page.
perl -e "print map {qq#$_\n#} @ARGV" 'this is in single quotes'
--
Andrew Langmead
------------------------------
Date: Tue, 21 Apr 1998 19:24:48 GMT
From: "Chad Peterson" <chad@umr.edu>
Subject: Deleting a Line of Text, but keeping the file tidy
Message-Id: <01bd6d5b$227fe320$86a72682@P1207393.MDC.COM>
Ok, suppose I have a data file with variable length lines such as
-----
Line One
Line Two
Line Three
Line Four
-----
Now, I want to remove line #3 from this file.
I'll use:
$oldstring="Line Three";
s/$oldstring//;
And this theorertically leaves:
-----
Line One
Line Two
Line Four
-----
What if I don't want a blank line in there? I'm sure you guys know a simple
way to do this, or I'm sure you'll very quickly point me in the correct
direction.
ALso, I did try s/$oldstring/\b/; thinking that \b might backspace it up..
but it just leaves a funky ascii character.
I'm using Perl5 under win95.
Thanks a lot.
Chad Peterson
chad@NOSPAMumr.edu
------------------------------
Date: 21 Apr 1998 13:53:07 GMT
From: v2matt@btv.ibm.com ()
Subject: die diff 5.003 and 5.004?
Message-Id: <6hi8c3$i9s$1@mdnews.btv.ibm.com>
I know you shouldn't catch errors this way, but I am
curious to way it works in perl5.003 and not in
perl5.004. See script below:
#!/usr/bin/perl
`ls -M` or die "I DIED:$!\n";
On 5.003, $! is set to "Invalid argument", while
on 5.004, $! has nothing.
Just curious,
Matt
------------------------------
Date: Tue, 21 Apr 1998 15:28:17 +0200
From: Steinar Kleven <Steinar.Kleven@ahs.hist.no>
Subject: Re: GCC and Solaris can't handle dynamic load ?
Message-Id: <353C9EF1.3ED9295F@ahs.hist.no>
Maybe you need an library entry point.
I don't know how unix is doing this, but on a NT box you'll have to include
your own DllEntry() in the extension source, or use the default Dll 'entry'
function in the libraries provided by VC++ or BC++.
ie. your OS need a given function to start of from, and it has to be
exported.
This is my guess anyway.
Steinar
Zachary Kessin wrote:
> Philippe Lavoie <lavoie@zeus.genie.uottawa.ca> writes:
>
> > Hi,
> >
> > I'm wondering why gcc can't handle dynamic loading with perl 5.004_4.
> >
> > It fails the make test with a missing main() symbol (pretty odd for a
> > dynamic load).
>
> I have had the exact same problem under hp-ux 10.20, using gcc 2.7 and
> 2.8.
>
> --Zach Kessin
------------------------------
Date: 21 Apr 1998 08:33:06 -0500
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: Help with regular expression
Message-Id: <ximn2dffgfh.fsf@jihad.amd.com>
>>>>> "Mark" == Mark Fergusson <mferg@hal.ddntl.didata.co.za> writes:
Mark> Please can someone help me with the following:
Mark> $DATE="03/30/98" $TIME="14:49:43"
Mark> How do I get: $NEWDATE="1998-03-30 14:49:43"
$DATE =~ s|(\d\d)/(\d\d)/(\d\d)|($3+1900) . "-$1-$2 $TIME"|e;
$NEWDATE = $DATE;
This handles the year reasonably robustly (assuming correct input).
Note the /e (or |e) argument to s||| that allows for Perl expressions
on the RHS of the substitution.
I could not compress this to one line (the ultimate $NEWDATE assignment).
How can I say something like $NEWDATE = $DATE =~ s/something/else/?
--
Quentin Fennessy AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals
------------------------------
Date: Tue, 21 Apr 1998 12:48:55 -0700
From: Nathan Franzen <franzen@pmel.noaa.gov>
Subject: Re: Help!
Message-Id: <Pine.SOL.3.96.980421123811.24504C-100000@corona.pmel.noaa.gov>
On Tue, 21 Apr 1998, Keith L. Miller wrote:
> I have a small problem with perl and a null string. When I read in a
> colan delimeted data file and one field is empty, I can't get perl to
> do anything with it. Ex:
A few comments on your program. In general you'll want to use the -w
switch.
> open (IN, filename); ### check the return value of the open
> while(<IN>){
> @fields = split(/:/, $_);
>
> if($fields[0] =~ /\0/){ # Attemp 1 ## why are you trying to
## match a bare zero?
>
> if(length($fields) < 1){ # Attemp 2 ## now you are using
## the scalar $field
## *not* the 1st
## element of @field
>
> Also, here's an interesting note. If I print the length of the blank
> field, it always comes up 38 UNLESS the filed is longer than 38, then
> it comes out with the correct length.
That seems odd, but it works properly for me. Here's a new version of
your piece of code (entered at the command line):
corona{franzen}: perl
while(<>){
@fields = split /:/, $_;
if ($fields[0] =~ m/\S/){ print "----> words\n"}; #match non-whitespace
if ($fields[0] !~ m/\S/){
print "----> blank\n";
print length($fields[0]), "\n"; #what's length of blank field?
}
}
__END__
test :123:more text
----> words
:456:still more text
----> blank
19
another test:789:and still some more text
----> words
Study that documentation!
Hope this helps,
Nathan
------------------------------
Date: Tue, 21 Apr 1998 13:22:12 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: How can I get the correct answer?
Message-Id: <ErrMH1.Gq8@presby.edu>
James Yang <James_Yang@via.com.tw> wrote:
>
>But I got the following result after I execute this program
>
>55.46 + 50 -100 = 5.46000000000001
>1553.05 + 50 - 1600 = 3.04999999999995
>
>Is it a bug or I can get the correct answer in the other way?
It's the inevitable consequence of storing numbers in a floating-point
binary format. Many decimal fractions have no exact binary equivalents at
all, let alone ones that can be represented in 32 bits (or 64 bits...
whatever Perl normally uses). So you get "truncation errors" when you
store those numbers.
--
Jon Bell <jtbell@presby.edu> Presbyterian College
Dept. of Physics and Computer Science Clinton, South Carolina USA
[ Information about newsgroups for beginners: ]
[ http://www.geocities.com/ResearchTriangle/8211/ ]
------------------------------
Date: 21 Apr 1998 08:36:35 -0500
From: Quentin Fennessy <quentin@jihad.amd.com>
Subject: Re: How can I get the correct answer?
Message-Id: <ximlnszfg9o.fsf@jihad.amd.com>
James- check out sprintf/printf to produce your answers
as you expect them.
perldoc -f printf
perldoc -f perlfaq4
look for
=head2 Does perl have a round function? What about ceil() and floor()?
--
Quentin Fennessy AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals
------------------------------
Date: Tue, 21 Apr 1998 13:58:40 GMT
From: jgloudon@hyssop.bbn.com.bbn.com (Jason Gloudon)
Subject: Re: How can I get the correct answer?
Message-Id: <slrn6jp9g9.7np.jgloudon@hyssop.bbn.com>
James Yang <James_Yang@via.com.tw> wrote:
.
.
>But I got the following result after I execute this program
>
>55.46 + 50 -100 = 5.46000000000001
>1553.05 + 50 - 1600 = 3.04999999999995
>
>Is it a bug or I can get the correct answer in the other way?
This is due to the inaccuracy of the binary represention of real numbers that
your computer (and most everyone else's) uses. Printing your results using
printf "%.2f" will give more credible looking output.
--
Jason Gloudon
------------------------------
Date: Tue, 21 Apr 1998 06:42:56 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: How can I get the correct answer?
Message-Id: <0o0ih6.s25.ln@localhost>
James Yang (James_Yang@via.com.tw) wrote:
: But I got the following result after I execute this program
: 55.46 + 50 -100 = 5.46000000000001
: 1553.05 + 50 - 1600 = 3.04999999999995
: Is it a bug or I can get the correct answer in the other way?
You could get the answer the Usual Way.
That is, do it like the answer to your Frequently Asked Question
says to...
"Why am I getting long decimals (eg, 19.9499999999999) instead
of the numbers I should be getting (eg, 19.95)?"
Please check to see if your question has been asked and answered
already before asking it yet again.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 21 Apr 1998 14:05:44 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: How to load the module with calculated name?
Message-Id: <ErroHL.D13@world.std.com>
prikryl@dcse.fee.vutbr.cz (Petr Prikryl) writes:
>Please, how can I load the module when its name was calculated (read
>from the input text file into a variable). The module is placed in
>the subdirectory which was also calculated (it is not in @INC).
Well, the perlfunc man page says that "use" is equivalent to:
BEGIN {
require Module;
Module->import(LIST);
}
so if you just perform the individual steps, you could get something
roughly equivalent. (Being in a BEGIN block allows it to do things
that will effect the compilation of the rest of the script.) There may
be some differences if you load the module after compilation.
I guess you could also simply do:
eval "use lib '$directory';use $module";
die $@ if $@;
to alter @INC and load the module, but the compile time vs. runtime
differences still remain.
--
Andrew Langmead
------------------------------
Date: Tue, 21 Apr 1998 16:14:23 -0500
From: alecler@cam.org (Andre L.)
Subject: Re: Pattern Matching on HighBit Characters
Message-Id: <alecler-2104981614230001@dialup-24.hip.cam.org>
Perllocale contains info about international issues (perl-related, that is).
It's not the first time I see someone using terms like "junk", "funny
characters" or "crazy characters" when referring to letters with
diacritical marks.
I know this place of surely full of educated Americans who don't consider
the character sets from other cultures as full of "junk", so I will try
not to get angry.
BTW, the accent "that goes up and to the right" is called an acute accent,
and it is a very cute accent indeed.
Andre (with an e acute)
====================
In article <353CE731.8E86245F@micro.ti.com>, Holly Sommer
<hsommer@micro.ti.com> wrote:
> At least, I *think* that is what the problem is.
>
> I have a textfile which is full of junk, and I want to
> strip out the junk. Simple s/<junk>//g , you'd think, except
> that the junk I want to strip out starts with what *LOOKS*
> like a Capital-A-accent with the accent that goes up and
> to the right (not sure what the proper word for that character
> is).
>
> I emailed this question to a listserv, and the junk that I
> pasted into my mailer came out as a bunch of `=E0=E00=E00=E000
> looking junk, which is considerably different from the
> HHCapital-A-accented stuff I copied and pasted. In fact, when
> I paste it here in this post, the junk comes out as just
> zeroes, so...
>
> How the heck do I get a pattern match on this?
>
> Thanks!
>
> Holly, been gone for a couple months from clpm
------------------------------
Date: Tue, 21 Apr 1998 19:52:11 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Pattern Matching on HighBit Characters
Message-Id: <Ers4Iz.CJx@news.boeing.com>
In article <353CE731.8E86245F@micro.ti.com>,
Holly Sommer <hsommer@micro.ti.com> wrote:
>At least, I *think* that is what the problem is.
>
>I have a textfile which is full of junk, and I want to
>strip out the junk. Simple s/<junk>//g , you'd think, except
>that the junk I want to strip out starts with what *LOOKS*
>like a Capital-A-accent with the accent that goes up and
>to the right (not sure what the proper word for that character
>is).
>
>I emailed this question to a listserv, and the junk that I
>pasted into my mailer came out as a bunch of `=E0=E00=E00=E000
>looking junk, which is considerably different from the
>HHCapital-A-accented stuff I copied and pasted. In fact, when
>I paste it here in this post, the junk comes out as just
>zeroes, so...
octally identify the junk , e.g.,
perl -ne 'for(split //,$_) {printf "%s=%o ",$_,ord $_}' junkfile
then sweep out same , e H=310, e.g.,
perl -pe 'tr /\310//d' junkfile > dejunkedfile
HTH,
--
Charles DeRykus
------------------------------
Date: Tue, 21 Apr 1998 15:33:05 +0200
From: Rodney Wines <Rodney.Wines@ahqps.alcatel.fr>
Subject: Problem With "gethostbyaddr".
Message-Id: <353CA011.FAD85240@ahqps.alcatel.fr>
I've got what I thought was a simple problem. I want to scan a Netscape web
server access log,and translate IP addresses to host names. I don't want the
web server to do this, because it is a single threaded task in the server I've
got, and would slow down the server by quite a bit (according to Netscape).
The code I've written to do this is:
#!/usr/local/bin/perl
#Scan server logfiles and convert IP addresses to hostnames.
use English;
use Socket; #No, we're not using sockets. I just needed AF_INET
#defined foruse by gethostbyaddr.
$OUTPUT_AUTOFLUSH = 1; #Don't do any buffering.
...
while (<LOG>) {
($ip, $rest) = split ' ', $_, 2; #Grab the IP address.
$ips{$ip}++;
$node_name{$ip} ||=
gethostbyaddr(pack('C4', split /\./, $ip), AF_INET) ||
'Location.Unknown';
print CONVERTED "$node_name{$ip} $rest";
}
========================
The code actually works; it takes off and runs great for 20 or 30 seconds, then
it will just hang for long periods of time.
I thought at first that the problem was with DNS; a long time-out for IP
addresses without host names. However, I added a print statement to dump each
IP address, and I noticed that the program would hang on addresses which I could
resolve instantly with "nslookup", and it would even hang on addresses that it
had seen before, so it appears I might not be caching addresses as I had hoped.
Does anyone have any suggestions? I'd appreciate it if you could respond by
E-mail, because I don't get to read news very often.
I'm using Perl 5.004_04 on Solaris 2.5.1 with recommended patches through March.
Thanks,
Rodney
------------------------------
Date: Tue, 21 Apr 1998 13:33:02 GMT
From: "msnews.microsoft.com" <michele.quici@compaq.com>
Subject: processes in perl for NT
Message-Id: <01bd6d2a$0010d8c0$39cb3d9b@C2334.gor.eur.compaq.com>
I want to start a child process and after some processing kill it, in Perl
under Windows NT. Is anybody able to help me on how to achieve this ?
On Unix it is not difficult but on NT it seems to be.
Thanks a lot,
Michele Quici
------------------------------
Date: Tue, 21 Apr 1998 14:14:44 GMT
From: phenix@interpath.com (John Moreno)
Subject: Re: regular expression question
Message-Id: <1d7txvz.r2zbywmc1gmvN@roxboro0-025.dyn.interpath.net>
David Oswald <doswald@xmission.com> wrote:
> On 17 Apr 1998 06:07:49 GMT, cberry@cinenet.net (Craig Berry) wrote:
>
> >John Cartwright (jcartwright@wans.net) wrote:
> >: I'm trying to build a regular expression that will return only the
> >: signifigant digits to the right of the decimal point. For instance, if
> >: my value is "1.01200", what I would like to get back is "012".
> >: Although I've tried a number of alternatives, I was using something
> >: like:
> >:
> >: $a = "1.01200";
> >: $a =~ s/^(\d+\.) (\d+)0+$/$2/;
> >:
> >: unfortunately, this returns the whole number "1.012". Can someone help
> >: me out?
> >
> > $a =~ s/.*\.(\d+?)0*$/$1/;
>
> I posted that same regex solution a couple of days ago and someone wrote
> back to say that the non-greedy quantifier wasn't necessary. However, I've
> read it and re-read it, and agree with you that it is necessary. I can't
> imagine a situation where the above regex would work properly without
> non-greedy matching of \d+?
Well, that depends upon what you mean by non-greedy.
The solution I came up with is this:
$\ = "\n";
$a = "1.01200";
$a=$1 if $a =~ /(\d+\.*\d*)/; # make sure it's just a number
$a =~ s/.*\.(0*)(.)(\2*)(.{0,1}).*/$1$2$3$4/;
print $a;
It also depends upon what you mean by "significant", the above regex
shows up to three different numbers, instead of just going out to the
2nd or 3rd place. IOW if you have a number like "1.000111111125648" it
will print "00011111112". Zero or more "0"'s followed by the next digit
as many times as it is present, followed by a different digit if present
(which is why I have the first regex and assignment - to make sure that
nothing is there but numbers and possibly one period).
--
John Moreno
------------------------------
Date: Tue, 21 Apr 1998 16:12:37 -0400
From: "Andrew F. Lee" <andrewf@cp.pathfinder.com>
Subject: Re: running perl at command line with arguments: script.cgi?text=text
Message-Id: <Pine.GSO.3.95.980421160517.13834A-100000@cp.pathfinder.com>
On Mon, 13 Apr 1998, Adam Klein wrote:
> I am trying to debug a script at the command line, and I was wondering if
> there was a way to have the argument entered at the command line as it does
> work when running the actual cgi application from the web page.
>
> For example the script looks like this:
>
> www.../cgi-bin/script.cgi?testtext
>
> how does it work at the command line:
>
> perl script.cgi ????? <--- what do I put here?
>
> Could anyone help me?
>
> Thanx,
> Adam
I was like you, once ... debugging cgi's by hand, writing to log files
and wishing I could call my cgi instead of httpd ...
But no more! :-)
Seriously, use CGI;
$query = new CGI;
$Name_o_a_variable = $query->param("Name_o_the_thing");
AND! You can run it from command line, feeding it name, value pairs.
Not to mention it is Free ... :-)
Cheers!
-------------------------------------------------------------
Andrew F. Lee | |
Software Engineer | parenttime.com |
email: andrewf@pathfinder.com | 1271 Avenue of the Americas |
Phone: (212) 522-2769 | New York, N.Y. 10020 |
-------------------------------------------------------------
When I say, "Ignore the man behind the curtain."
That is because there is no man behind the curtain.
------------------------------
Date: Tue, 21 Apr 1998 10:07:27 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Snobby news group
Message-Id: <Pine.A41.3.96.980421100303.70330B-100000@ginger.libs.uga.edu>
Hear! Hear!
On Mon, 20 Apr 1998, Keith G. Murphy wrote:
> Maybe the "snobbery" is cathartic for them? If so, be snobby as hell,
> but stick around and help us! :-)
----------------
Brad Baxter, UGA
------------------------------
Date: Tue, 21 Apr 1998 20:04:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: johnvun <johnvun@asiapac.net>
Subject: Re: subtitube variable into system command
Message-Id: <Pine.GSO.3.96.980421130337.21174Y-100000@user2.teleport.com>
On Tue, 21 Apr 1998, johnvun wrote:
> system ("perl -p -i -e "s/shop/shop$ptt/g;" mcc$ptt");
You have qouble quotes inside of a double-quoted string! Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Tue, 21 Apr 98 19:14:17 GMT
From: admin@net-ops.net (G. E. Terry)
Subject: SUIDPERL
Message-Id: <6hir6a$p0q$1@ns2.adult-host.net>
I keep getting the error message:
Insecure $ENV{ENV} while running setsuid at .........Line 19 chunk 2
It repeats this for every file I am trying to write to....
Here is the script.
#! /usr/bin/perl -wU
#
#
#
$| =1;
sub BEGIN {
unshift @INC, '..';
}
use CGI qw(:cgi-lib);
&ReadParse (*input);
# variables
$ENV{'PATH'} = '/bin:/usr/bin:/usr/sbin:/etc/vmail';
$username = $input{'username'};
$password = $input{'password'};
$uid = `cat .uid`;
$uid++;
open (UID, ">.uid");
print UID "$uid";
close (UID);
$sid = `cat .sid`;
$sid++;
open (SID, ">.sid");
print SID "$sid";
close (SID);
&CryptData;
open (PASSWD, ">>/etc/vmail/passwd.mailxxx.com");
print PASSWD
"$username:x:$uid:11::/vhome/adult-host.net/$username:/bin/false\n";
close (PASSWD);
open (SHADOW, ">>/etc/vmail/shadow.mailxxx.com");
print SHADOW "$username:$passwd:$sid:-1:99999:-1:-1:-1:\n";
close (SHADOW);
print "Content-type: text/html\n\n";
print "<HTML>\n";
print "<HEAD>\n<TITLE>User Added!!</TITLE>\n</HEAD>\n";
print "<BODY>\n\nUser $username Added\n";
print "</BODY>\n</HTML>\n";
sub CryptData {
$passwd = crypt($password, Mx);
}
exit;
Any help would be appreciated
------------------------------
Date: Tue, 21 Apr 1998 20:16:18 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Tony Moran <tmoran@iol.ie>
Subject: Re: Time : Year2000 & 2038 code question
Message-Id: <Pine.GSO.3.96.980421131335.21174a-100000@user2.teleport.com>
On 21 Apr 1998, Tony Moran wrote:
> Hi, in reviewing perl code for compliancy, I came across this in
> a function that calls localtime() and then does:
>
> $year += ($year < 70) ? 2000 : 1900;
If $year is the value from localtime, this looks a lot like a bug. Call it
a Y1969 bug. :-)
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
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 2371
**************************************