[17354] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4776 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 31 14:15:34 2000

Date: Tue, 31 Oct 2000 11:15:21 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <973019721-v9-i4776@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 31 Oct 2000     Volume: 9 Number: 4776

Today's topics:
    Re: rename and unlink fail nodezero@my-deja.com
    Re: reseting the $digit values (Keith Calvert Ivey)
    Re: reseting the $digit values <celliot@tartarus.uwa.edu.au>
    Re: reseting the $digit values nobull@mail.com
        Rounding numbers in perl oarend@my-deja.com
    Re: Rounding numbers in perl (Clay Irving)
    Re: Rounding numbers in perl <rmore1@my-deja.com>
    Re: Rounding numbers in perl <adamf@box43.gnet.pl>
    Re: signal "CTRL-x" <cpegbeggar@mail.com>
    Re: system command (Doug McLaren)
    Re: TTL in UDP <bkennedy99@home.com>
    Re: What about CGI.pm? <jeff@vpservices.com>
    Re: Working with time <sariq@texas.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Tue, 31 Oct 2000 16:33:21 GMT
From: nodezero@my-deja.com
Subject: Re: rename and unlink fail
Message-Id: <8tms8h$uig$1@nnrp1.deja.com>

This is the origional poster, but on a different email address.

My script does work at the command line, i guess that means
apache runs perl differently?

A failure is if the function returns zero.

Should I write a separate script and run it from my script to rename
or delete a file?




In article <slrn8vt6b3.84.clay@panix3.panix.com>,
  clay@panix.com (Clay Irving) wrote:
> On Tue, 31 Oct 2000 00:27:21 -0500, Ryan Kuhn <
rkuhn@akicommunications.com>
> wrote:
>
> >I have a set of files, readable and writeable to every user and I
use rename
> >and unlink with them in my perl cgi script, run by apache. Both
of those
> >functions fail to work, yet I can modify those files and create
new ones
> >within this script.
>
> Readable and writeable by *every* user? -- Does that include
nobody?
>
> You don't mention what is the failure -- That might be a clue.
>
> You also fail to mention if the program works correctly from the
command
> line -- If so, that's an FAQ.
>
> --
> Clay Irving <clay@panix.com>
> As soon as questions of will or decision or reason or choice of
action
> arise, human science is at a loss.
> - Noam Chomsky
>


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 31 Oct 2000 14:09:48 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: reseting the $digit values
Message-Id: <39ffd258.41884687@news.newsguy.com>

"Cam" <celliot@tartarus.uwa.edu.au> wrote:

>The values in the $1, $2  inside the loop are from the first regex.
>What can I do??

Check to see that your match succeeds before you use $1 and
friends.  Otherwise you'll run into the problem you're having
now.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


------------------------------

Date: Tue, 31 Oct 2000 23:13:01 +0800
From: "Cam" <celliot@tartarus.uwa.edu.au>
Subject: Re: reseting the $digit values
Message-Id: <39fee1df$0$25560@echo-01.iinet.net.au>

Keith Calvert Ivey <kcivey@cpcug.org> wrote in message
news:39ffd258.41884687@news.newsguy.com...
| "Cam" <celliot@tartarus.uwa.edu.au> wrote:
|
| >The values in the $1, $2  inside the loop are from the first regex.
| >What can I do??
|
| Check to see that your match succeeds before you use $1 and
| friends.  Otherwise you'll run into the problem you're having
| now.
|
| --
| Keith C. Ivey <kcivey@cpcug.org>
| Washington, DC

Yes your right.  Thankyou,

Cheers
Cam




------------------------------

Date: 31 Oct 2000 17:44:06 +0000
From: nobull@mail.com
Subject: Re: reseting the $digit values
Message-Id: <u9vgu8sy6x.fsf@wcl-l.bham.ac.uk>

"Cam" <celliot@tartarus.uwa.edu.au> writes:

> I have a regex inside a loop after another regex outside the loop.
> Inside the loop the values of $1....  are the ones from the regex used
> before outside the loop.
> Can I reset these values or over ride them somehow?

An sucessful match will override them.  An unsucessful one won't.

So to reset them you can use:

/()/;

>   for ($i=0;$i<1;$i++)
>        {
>     $mid =~
> /(.*?)(\\cell[\s\\].*?)(\\cell[\s\\].*?)(\\cell[\s\\].*?)(\\cell[\s\\].*?)(\
> \cell[\s\\].*)/;
>    $temp2 .=
> $1.$2.$summary_ref->{'BUF'}[$i][0].$3.$summary_ref->{'BUF'}[$i][1].$4.$summa
> ry_ref->{'BUF'}[$i][2].$5.$summary_ref->{'BUF'}[$i][3].$6;
>     }

You are clearly assuming that the match above will always succeed.
IMNSHO a good habit in such situations is to simply tag "or die" onto
the end of any statement you are assuming will never return 0.  If
your assumption was correct then no harm is done, if your assumption
was wrong you'll find out so explicitly rather than have to work it
out from possibly misleading side effects.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Tue, 31 Oct 2000 17:54:44 GMT
From: oarend@my-deja.com
Subject: Rounding numbers in perl
Message-Id: <8tn10v$32e$1@nnrp1.deja.com>

Is there a subroutine of some kind to round a number in Perl? Or does
anybody have an idea of how one can do it himself? If so, please add
how you can have a subroutine return a value - I'm not that familiar
with the language yet.

Oliver


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: 31 Oct 2000 18:10:26 GMT
From: clay@panix.com (Clay Irving)
Subject: Re: Rounding numbers in perl
Message-Id: <slrn8vu2oi.a8h.clay@panix6.panix.com>

On Tue, 31 Oct 2000 17:54:44 GMT, oarend@my-deja.com <oarend@my-deja.com> wrote:

>Is there a subroutine of some kind to round a number in Perl? Or does
>anybody have an idea of how one can do it himself? If so, please add
>how you can have a subroutine return a value - I'm not that familiar
>with the language yet.

You'd think a question like this would be in the FAQ...

-- 
Clay Irving <clay@panix.com>
An unimaginable toy is useful for breaking other toys. And your little
dog, too! 


------------------------------

Date: Tue, 31 Oct 2000 18:30:43 GMT
From: Rich More <rmore1@my-deja.com>
Subject: Re: Rounding numbers in perl
Message-Id: <8tn34j$51l$1@nnrp1.deja.com>

In article <8tn10v$32e$1@nnrp1.deja.com>,
  oarend@my-deja.com wrote:
> Is there a subroutine of some kind to round a number in Perl? Or does
> anybody have an idea of how one can do it himself? If so, please add
> how you can have a subroutine return a value - I'm not that familiar
> with the language yet.

=================
It depends on how you want to round the number.
For a good discussion on rounding see the book "Perl Cookbook" from
www.ora.com
Question 2.3  Rounding Floating Point Numbers...

From perldoc perlfunc
============
    int      Returns the integer portion of EXPR.  If EXPR is
             omitted, uses $_.  You should not use this function
             for rounding: one because it truncates towards 0,
             and two because machine representations of floating
             point numbers can sometimes produce counterintuitive
             results.  For example, int(-6.725/0.025) produces
             -268 rather than the correct -269; that's because
             it's really more like -268.99999999999994315658
             instead.  Usually, the sprintf(), printf(), or the
             POSIX::floor and POSIX::ceil functions will serve
             you better than will int().
============
For more information, see Perl's online help...
perldoc -f int
perldoc -f sprintf
perldoc POSIX ( for ceil and floor functions )


--
=============================
Richard More
http://www.richmore.com/


Sent via Deja.com http://www.deja.com/
Before you buy.


------------------------------

Date: Tue, 31 Oct 2000 19:48:58 +0100
From: Adam <adamf@box43.gnet.pl>
Subject: Re: Rounding numbers in perl
Message-Id: <39FF141A.7853@box43.gnet.pl>

oarend@my-deja.com wrote:
> 
> Is there a subroutine of some kind to round a number in Perl? Or does
> anybody have an idea of how one can do it himself? If so, please add
> how you can have a subroutine return a value - I'm not that familiar
> with the language yet.

look into:
# perldoc perlfaq4  
Q: "Does Perl have a round() function? ..."

--
Adam.


------------------------------

Date: Tue, 31 Oct 2000 23:48:48 +0800
From: Beggar <cpegbeggar@mail.com>
To: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: signal "CTRL-x"
Message-Id: <39FEE9E0.9A9E012B@mail.com>

Yes ....I also think it's a combination of keystroke....
so how to get such combination of key ?

thanks!


Tony Curtis wrote:

> >> On Tue, 31 Oct 2000 01:15:25 +0800,
> >> Beggar <cpegbeggar@mail.com> said:
>
> > Hi all, How to capture the signal "CTRL-x" in perl?
> > Actually, is it considered as a signal ?
>
> C-x is a key stroke (combination).  It is not normally
> associated with a signal (maybe under DOS?).  Do you mean
> C-z or C-c by any chance?
>
> Perhaps if you explain what you actually want your
> application to do at a higher level, it will be easier to
> see how to help...
>
> In the meantime, "perldoc perlipc"
>
> hth
> t
> --
> Eih bennek, eih blavek.



------------------------------

Date: Tue, 31 Oct 2000 16:58:14 GMT
From: dougmc@frenzy.com (Doug McLaren)
Subject: Re: system command
Message-Id: <GSCL5.26608$Fe4.665937@typhoon.austin.rr.com>

In article <39fe4bdb@cs.colorado.edu>,
Tom Christiansen <tchrist@perl.com> wrote:

| Eh?  Of course the foregrounded job will have all members of its
| process group receive a SIGINT if ^C (or, more correctly stated,
| whatever your interrupt character should happen to be) is typed on
| the controlling tty.  This is true no matter what.  It is also true,
| however, that both system() and backticks ignore SIGINT in the
| parent, so it appears as though they never "get" the signal.  But
| these both work the same way.

Perhaps I should have been more clear.

We've got two commands -

   perl -e 'system "sleep 600" ; print "Done!\n"'
   perl -e '`sleep 600` ; print "Done!\n"'

If we run the first one, and after a few seconds press ^C (or whatever
your interrupt character should happen to be, of course) we'll then be
greeted with a `Done!' message.

If we run the second and do the same, we will not see the `Done!'
message.  Obviously something is different.  

It doesn't appear to be OS specific - at least it seems to work this
way in Solaris, AIX, FreeBSD and Linux, and with several different
perl versions.  (I didn't try any non *nix OS's ... it wouldn't
surprise me at all if they work differently.)

It's a minor nit, yes, but ultimately the two variations do not appear
to work *quite* the same way, at least from the user's perspective.

It's not hard to understand why they're different, but the only point
I'm trying to make here is that they are a little different.

-- 
Doug McLaren, dougmc@frenzy.com
If at first you don't succeed, then skydiving is not for you.


------------------------------

Date: Tue, 31 Oct 2000 16:08:18 GMT
From: "Ben Kennedy" <bkennedy99@home.com>
Subject: Re: TTL in UDP
Message-Id: <S7CL5.80079$td5.12276007@news1.rdc2.pa.home.com>


"Pierre Wijkman" <pierre@dsv.su.se> wrote in message
news:8tgp82$m1t$1@news.kth.se...
> How do I set TTL in a UDP socket handle?, is it possible?

Short of creating the packet yourself and sending it through a raw device, I
don't think this is possible.  Though you may be able to do some kernel
hacking to change the default TTL for all packets, I'm not sure.

--Ben Kennedy




------------------------------

Date: Tue, 31 Oct 2000 07:05:20 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: What about CGI.pm?
Message-Id: <39FEDFB0.57DF1323@vpservices.com>

Bart Lateur wrote:
> 
> Jeff Zucker wrote:
> 
> >  #!/usr/local/bin/perl
> >  use Benchmark;
> >  Benchmark::timethis( 100,
> >     sub { do 'CGI.pm'; my $q=new CGI; print $q->header; }
> >  );
> 
> That wonb't help much. It will read the module from file ONCE, and
> compile/execute it 100 times. After the first time, the file is in a
> disk buffer, so loading will be mluch faster. And yes, it's that
> *reading from disk* of the 200k source that is much of the overhead.

Thanks, Bart, I wasn't sure it was actually testing what I wanted it to
test. But may I ask how you came to your conclusion?  I guess I was
going by what perldoc -f do says:

   ... code evaluated with `do FILENAME' ... does reparse
   the file every time you call it, so you probably don't want to
   do this inside a loop.

But I don't know, does "reparse" here refer only to compiling, but not
reading?  If so, then I don't see any information about reading in the
docs for either do() or Benchmark.

In any case, surely the entire time to read and compile CGI.pm is still
only a fraction of a second? (assuming, as someone else pointed out,
that one is not doing the sensible thing and using it with mod_perl)

-- 
Jeff


------------------------------

Date: Tue, 31 Oct 2000 15:47:38 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: Working with time
Message-Id: <39FEE999.F9C5EDBA@texas.net>

Larry Rosler wrote:
> 
> In article <t67L5.7$Bf7.170632704@news.frii.net> on Mon, 30 Oct 2000
> 04:50:33 GMT, Chris Fedde <cfedde@fedde.littleton.co.us> says...
> > In article <8tij4d$f25$1@nnrp1.deja.com>, Mario  <diab.lito@usa.net> wrote:
> > >In article <39fc1449$1@nexus.comcen.com.au>,
> > >  "Kiel Stirling" <taboo@comcen.com.au> wrote:
> > >> Is there an easy way to subtract time ?
> > >>
> > There are several modules in CPAN to choose from. I've used
> > Time::ParseDate, Date::Manip, and the venerable Date::Calc for work
> > like this.  There are several other choices that might also be
> > worth considering.
> 
> Indded.  For example, on might simply read the FAQ.
> 
> perlfaq4: "How can I compare two dates and find the difference?"

Which, for some reason, leaves out the useful information found in:

perlfaq4: "How can I take a string and turn it into epoch seconds?"

- Tom


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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.

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 V9 Issue 4776
**************************************


home help back first fref pref prev next nref lref last post