[16083] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3495 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 27 21:05:29 2000

Date: Tue, 27 Jun 2000 18:05:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <962154312-v9-i3495@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Jun 2000     Volume: 9 Number: 3495

Today's topics:
    Re: "Bare words" (Keith Calvert Ivey)
    Re: $/ behaviour <bwalton@rochester.rr.com>
    Re: $/ behaviour ghelm@hypercom.com
    Re: \ and single quote <news@webneeds.com>
    Re: \ and single quote <bwalton@rochester.rr.com>
        Finding the directory of the current script conic@bigpond.com
        Help with 'If' condition - newbie (Mtshupp)
    Re: Help with 'If' condition - newbie <lauren_smith13@hotmail.com>
    Re: Help with 'If' condition - newbie (Bart Lateur)
    Re: how could I upload the files with a specified user  (David Efflandt)
    Re: Insecure dependency when trying to unlink files? <blavender@spk.usace.army.mil>
    Re: Insecure dependency when trying to unlink files? (David Efflandt)
    Re: Oracle minimum install for perl DBI on Linux (Malcolm Dew-Jones)
    Re: Perl/cgi newbie questions <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: perldoc & perlop man page? invinfo@my-deja.com
    Re: perldoc & perlop man page? <lauren_smith13@hotmail.com>
    Re: perldoc & perlop man page? (Bart Lateur)
    Re: Problem writing a binary file to another location <bwalton@rochester.rr.com>
        Question on integers (Young H Lee)
    Re: Question on integers (Steven Smolinski)
    Re: Ranking numbers (Abigail)
    Re: Ranking numbers (Abigail)
    Re: Script cron problems <todd@mrnoitall.com>
        split regex <trw@uakron.edu>
    Re: Such an easy task, open and write to a file, here i <bwalton@rochester.rr.com>
        system() failed but exited ok! gdig321@my-deja.com
    Re: Teen Volenteers WANTED (Keith Calvert Ivey)
        V4 vs V5 sourcing problem <rrauer@mitre.org>
    Re: V4 vs V5 sourcing problem (Brandon Metcalf)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 28 Jun 2000 00:28:46 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: "Bare words"
Message-Id: <395a4617.1653266@nntp.idsonline.com>

SPAM+indigo@dimensional.com (Tim) wrote:

>    %h = (x => 'abc'); # Always correct
>    $h{x} = 'abc';     # Less correct
>    $x = abc;          # Bad developer, no cookie

I'd say that the first and the second are at exactly the same
level of correctness (which is "Always correct").  They're very
similar, generally hash-related autoquoting.  What makes you
think there's a difference?

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


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Tue, 27 Jun 2000 22:05:01 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: $/ behaviour
Message-Id: <3980B0FA.FF1D9EEF@rochester.rr.com>

awkster@my-deja.com wrote:
 ...
> ### The following ignores $/ ######
> 
> $cnt = 0;
> 
> foreach $arr(@arr){
>    ++$cnt;
>    $len = length($arr);
>    print "$cnt $len $arr\n";
> }

That is correct -- the value of $/ will not influence the above code. 
I'm trying to figure out why you would expect that code to be influenced
in any way by $/.  Did you read the perlvar section about $/?
-- 
Bob Walton


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

Date: Tue, 27 Jun 2000 23:00:43 GMT
From: ghelm@hypercom.com
Subject: Re: $/ behaviour
Message-Id: <8jbbmh$4fq$1@nnrp1.deja.com>

In article <3980B0FA.FF1D9EEF@rochester.rr.com>,
  Bob Walton <bwalton@rochester.rr.com> wrote:
> awkster@my-deja.com wrote:
> ...
> > ### The following ignores $/ ######
> >
> > $cnt = 0;
> >
> > foreach $arr(@arr){
> >    ++$cnt;
> >    $len = length($arr);
> >    print "$cnt $len $arr\n";
> > }
>
> That is correct -- the value of $/ will not influence the above code.
> I'm trying to figure out why you would expect that code to be
influenced
> in any way by $/.  Did you read the perlvar section about $/?
> --
> Bob Walton
>

Yes I am guilty of not reading PERLVAR...
My apologies...
Just grabbed a copy and reading it now.
Think I'm getting the picture.

Thank You

$/	  The input record separator, newline by default.  Works
like awk's
	  RS variable, including treating blank	lines as delimiters if
set to
	  the null string.  You	may set	it to a	multicharacter string to
	  match	a multi-character delimiter.  Note that	setting	it to
"\n\n"
	  means	something slightly different than setting it to	"", if
the
	  file contains	consecutive blank lines.  Setting it to	"" will
treat
	  two or more consecutive blank	lines as a single blank	line.
	  Setting it to	"\n\n" will blindly assume that	the next input
	  character belongs to the next	paragraph, even	if it's	a
newline.
	  (Mnemonic: / is used to delimit line boundaries when quoting
	  poetry.)


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


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

Date: Tue, 27 Jun 2000 16:05:07 -0600
From: "Dan Manion" <news@webneeds.com>
Subject: Re: \ and single quote
Message-Id: <7nb65.385$o7.112035@news.uswest.net>

I'm afraid you've not left much for us to discuss.  Maybe post the actual
line that you saw this so we can get a sense for what context this statement
was used in and why.   You cannot post ///// by itself and expect that it
would make sense to anyone.

"-newbie" <-newbie_member@newsguy.com> wrote in message
news:8jb3io$e1d@drn.newsguy.com...
> Sorry if this upsets you, but it was the first message ever I sent to this
> group. Did anyone discussed this before?
>
> TIA
>
> -gl
>
> In article <3958FAA0.A6EC0B3F@attglobal.net>, Drew says...
> >
> >-newbie wrote:
> >>
> >> Hi gurus:
> >>
> >> I have trouble to understand this one:
> >>
> >> 'three \\\'s: "\\\\\"';
> >>
> >> I understood the first part: the first \ escapes the second \; the
third \
> >>escapes the single ' right before the letter "s"; but I am trying to
confirm the
> >>second part: the first \ right after " escapes the second \; the third \
escapes
> >>the forth \ and last \ right before " stay it is because of the single
quote; am
> >> I right?
> >
> >It is good manners not to start a new thread to discuss the same matter
> >that you were previously discussing in a prior thread.
> >
> >Please keep that in mind.
>
>




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

Date: Tue, 27 Jun 2000 22:31:02 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: \ and single quote
Message-Id: <3980B714.DC551199@rochester.rr.com>

-newbie wrote:
> 
> Hi gurus:
> 
> I have trouble to understand this one:
> 
> 'three \\\'s: "\\\\\"';
> 
> I understood the first part: the first \ escapes the second \; the third \
> escapes the single ' right before the letter "s"; but I am trying to confirm the
> second part: the first \ right after " escapes the second \; the third \ escapes
> the forth \ and last \ right before " stay it is because of the single quote; am
> I right?
 ...
> -gl
You've got it right.  If you haven't discovered it yet, do:

    perldoc perlop

at your command prompt, and look for the section on q/ .  The second
sentence details the behavior you are asking about.
-- 
Bob Walton


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

Date: Wed, 28 Jun 2000 00:50:41 GMT
From: conic@bigpond.com
Subject: Finding the directory of the current script
Message-Id: <8jbi4t$94r$1@nnrp1.deja.com>

Is there a way for a script to realise what directory it is in?  I want
to examine files that are in the same directory as the script, but also
to be able to move the script to any directory without changing it.


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


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

Date: 27 Jun 2000 23:24:00 GMT
From: mtshupp@aol.com (Mtshupp)
Subject: Help with 'If' condition - newbie
Message-Id: <20000627192400.01182.00000102@ng-ft1.aol.com>

Hello,

Perl newbie here -- I'm attempting to modify a script;  I'm trying to describe
a condition such that if a subtotal is less than 6.00, a shipping fee is 2.00; 
6.00 - 9.99, shipping fee is 3.00;  ...and so forth.  The amounts are
arbitrarily set.

So far, I have:

{

local ($shipping_price) = @_;

$ship = 2.00;

if ($shipping_price == 0)
        {
        $ship = 0;
        }
elsif ($shipping_price < 6.00)
        {
        $ship = $ship;
        }
else


 ...and I'm kind of stuck after that (if that's even close).

I'd be very grateful for any help pointing me in the right direction.  The
amounts I'm trying to use are:

 Subtotal is:       Shipping is:

  0.00 -  5.99              2.00
  6.00 -  9.99              3.00
10.00 - 14.99              3.50
15.00 - 19.99              4.00
20.00 - up                 5.00

Thanks very much in advance for any help,
Mike



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

Date: Tue, 27 Jun 2000 16:47:50 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Help with 'If' condition - newbie
Message-Id: <8jbef4$3n7$1@brokaw.wa.com>


Mtshupp <mtshupp@aol.com> wrote in message
news:20000627192400.01182.00000102@ng-ft1.aol.com...
> Hello,
>
> Perl newbie here -- I'm attempting to modify a script;  I'm trying to
describe
> a condition such that if a subtotal is less than 6.00, a shipping fee is
2.00;
> 6.00 - 9.99, shipping fee is 3.00;  ...and so forth.  The amounts are
> arbitrarily set.
>
> So far, I have:
>
> {
>
> local ($shipping_price) = @_;
>
> $ship = 2.00;
>
> if ($shipping_price == 0)
>         {
>         $ship = 0;
>         }
> elsif ($shipping_price < 6.00)
>         {
>         $ship = $ship;
>         }
> else
>
>
> ...and I'm kind of stuck after that (if that's even close).
>
>  Subtotal is:       Shipping is:
>
>   0.00 -  5.99              2.00
>   6.00 -  9.99              3.00
> 10.00 - 14.99              3.50
> 15.00 - 19.99              4.00
> 20.00 - up                 5.00
>

{
   my ($shipping_price) = @_; # avoid 'local' unless absolutely unavoidable
   # www.plover.com/~mjd/perl/local.html

   my $ship = 0;
   if ($shipping_price < 6.00) {
      $ship = 2.00;
   } elsif ($shipping_price < 10.00) {
      $ship = 3.00;
   } elsif ($shipping_price < 15.00) {
      and so on and so on and so on.
   }
}

Lauren





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

Date: Wed, 28 Jun 2000 00:28:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Help with 'If' condition - newbie
Message-Id: <395a43ff.3098813@news.skynet.be>

Mtshupp wrote:

>I'd be very grateful for any help pointing me in the right direction.  The
>amounts I'm trying to use are:
>
> Subtotal is:       Shipping is:
>
>  0.00 -  5.99              2.00
>  6.00 -  9.99              3.00
>10.00 - 14.99              3.50
>15.00 - 19.99              4.00
>20.00 - up                 5.00

Can I put it in a loop?

	sub shippingcost {
	    my $price = shift;
	    my @range = ( [ 20.0 => 5.0], [ 15.0 => 4.0],
	      [ 10.0 => 3.5], [ 6.0 => 3.0], [ 0.0 => 2.0]);
	    # note the reversed order
	    foreach (@range) {
	        if ($price >= $_->[0]) {
	            return $_->[1];
	        }
	    }
	    return 0;
	}

Even without a loop, I think the reversed order ois benificial.

	sub shippingcost {
	    my $p = shift;
	    if($p >= 20) {
	        return 5;
	    } 
	    if ($p>= 15) {
	        return 4;
	    }
	    if ($p>= 10) {
	        return 3.5;
	    }
	    if ($p>= 6) {
	        return 3;
	    }
	    return 2;
	}

Note that I don't need "elsif" because I return from the sub in the
block for every succeeded test.

-- 
	Bart.


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

Date: 28 Jun 2000 00:53:06 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: how could I upload the files with a specified user and group?
Message-Id: <slrn8lij2u.too.efflandt@efflandt.xnet.com>

On 27 Jun 2000 09:45:26 GMT, TSOI_WING_SHING <wstsoi@ee.cuhk.hk> wrote:
>As title, thanks.

Net::FTP in the libnet group of modules.  If you are talking about CGI you
are in the wrong newgroup.  But you would need to run suid as root to do
that, which would likely require an suid C wrapper and some very careful
taint checking, not to mention authentication.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Tue, 27 Jun 2000 23:18:56 GMT
From: Brian Lavender <blavender@spk.usace.army.mil>
Subject: Re: Insecure dependency when trying to unlink files?
Message-Id: <8jbcof$548$1@nnrp1.deja.com>

How do I untaint the data? Or where do I look?


brian

In article <slrn8lhspj.aha.tadmc@magna.metronet.com>,
  tadmc@metronet.com (Tad McClellan) wrote:
> On Tue, 27 Jun 2000 18:05:55 GMT, Brian Lavender
<blavender@spk.usace.army.mil> wrote:
>
> >I have a script (happens to run within a CGI) where I want to remove
> >temp files which hold session information which have not been
accessed
> >within the last five minutes. I am running under -T flag. When I run
the
> >following script, I get the following error. What can I do to fix
this?
>
> Untaint the data before using it with unlink().
>
> ($_ comes from outside (from the filesystem) of your program,
>  it is tainted.
> )
>
> >[Tue Jun 27 09:34:54 2000] correspond.pl: Insecure dependency in
unlink
> >while running with -T switch
> >at /home/www/cgi-bin/correspond.pl line 804.
> >
> >  my @alltmpfiles = grep /\.cor\.db$/, readdir TMPDIR;
> [snip]
> >  foreach (@alltmpfiles) {
> [snip]
> >      unlink($_) or die "Couldn't unlink $_ : $!";
>
> --
>     Tad McClellan                          SGML Consulting
>     tadmc@metronet.com                     Perl programming
>     Fort Worth, Texas
>

--
Brian E. Lavender
US Army Corps of Engineers -- Programmer / Systems Analyst
Sacramento, CA    (916) 557-6623


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


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

Date: 28 Jun 2000 01:00:08 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Insecure dependency when trying to unlink files?
Message-Id: <slrn8lijg4.too.efflandt@efflandt.xnet.com>

On Tue, 27 Jun 2000, Brian Lavender <blavender@spk.usace.army.mil> wrote:
>How do I untaint the data? Or where do I look?

Start by typing the following on any system with Perl:  perldoc perlsec

>brian
>
>In article <slrn8lhspj.aha.tadmc@magna.metronet.com>,
>  tadmc@metronet.com (Tad McClellan) wrote:
>> On Tue, 27 Jun 2000 18:05:55 GMT, Brian Lavender
><blavender@spk.usace.army.mil> wrote:
>>
>> >I have a script (happens to run within a CGI) where I want to remove
>> >temp files which hold session information which have not been
>accessed
>> >within the last five minutes. I am running under -T flag. When I run
>the
>> >following script, I get the following error. What can I do to fix
>this?
>>
>> Untaint the data before using it with unlink().
>>
>> ($_ comes from outside (from the filesystem) of your program,
>>  it is tainted.
>> )
>>
>> >[Tue Jun 27 09:34:54 2000] correspond.pl: Insecure dependency in
>unlink
>> >while running with -T switch
>> >at /home/www/cgi-bin/correspond.pl line 804.
>> >
>> >  my @alltmpfiles = grep /\.cor\.db$/, readdir TMPDIR;
>> [snip]
>> >  foreach (@alltmpfiles) {
>> [snip]
>> >      unlink($_) or die "Couldn't unlink $_ : $!";

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: 27 Jun 2000 15:06:40 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Oracle minimum install for perl DBI on Linux
Message-Id: <39592570@news.victoria.tc.ca>

Kathryn Cassidy (hellbunnie@irelands-web.ie) wrote:
: Hi all,


:   The ORACLE_HOME environment variable must be set.
:   It must be set to hold the path to an Oracle installation directory
:   on this machine (or a compatible archtecture).
:   See the README.clients file for more information.

: $ORACLE_HOME is set.

Just a quick thought, is ORACLE_HOME exported?


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

Date: Tue, 27 Jun 2000 15:10:45 -0700
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Perl/cgi newbie questions
Message-Id: <39592665.B36ABD07@jpl.nasa.gov>

rickh wrote:
> #!/usr/bin/perl -w

No 'use strict;'?

> print <<HTML;
> Content-type: text /html\n\n
> <HTML><HEAD><TITLE></title><head><BODY>
> <p> Environment Variables
> <p>
> HTML
> 
> foreach (keys %ENV) {print "$_: $ENV{$_}<br>\n";}
> 
> Print <<HTML;
  ^
strict would have warned you about this typo.  Perl is case-sensitive.

> </body></html>
> HTML
> 
> When I access this program through my web browser, I get an "internal
> error.  Looking at the error_log it would appear that the Print <<HTML
> lines are the problem.  the error message indicates that they are not
> numeric and appearently the << is the numeric left shift operator.
> Question is What was the Print <<HTML line supposed to do?

Look up "perldoc -q 'here doc'".  

Jon
-- 
Knowledge is that which remains when what is
learned is forgotten. - Mr. King


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

Date: Tue, 27 Jun 2000 22:15:34 GMT
From: invinfo@my-deja.com
Subject: Re: perldoc & perlop man page?
Message-Id: <8jb91m$2bb$1@nnrp1.deja.com>

In article <8hmg23$90v$1@brokaw.wa.com>,
  "Lauren Smith" <lauren_smith13@hotmail.com> wrote:
>
> Helza <helza@planet.nl> wrote in message
> news:8hmfj3$8qphj$1@reader2.wxs.nl...
> On Windows systems you can go to Start->Programs->ActivePerl->Online
> Documentation
>
> You can find all the Perl documentation there.
>
> Lauren

Having come from a Sun-OS environment, I find the Windows
documentation, while Huge, a little hard to work with.
Can I actually use    perldoc -f built-in_function     ???

There are many core docs, modules documented, but no Search capability.

Any suggestions ?
TIA -
RJK  (NAR)
(312) 329-8696


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


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

Date: Tue, 27 Jun 2000 16:37:37 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: perldoc & perlop man page?
Message-Id: <8jbdrv$4u8$1@brokaw.wa.com>


<invinfo@my-deja.com> wrote in message news:8jb91m$2bb$1@nnrp1.deja.com...
> In article <8hmg23$90v$1@brokaw.wa.com>,
>   "Lauren Smith" <lauren_smith13@hotmail.com> wrote:
> >
> > On Windows systems you can go to Start->Programs->ActivePerl->Online
> > Documentation
> >
> > You can find all the Perl documentation there.
> >
> Having come from a Sun-OS environment, I find the Windows
> documentation, while Huge, a little hard to work with.
> Can I actually use    perldoc -f built-in_function     ???
>
> There are many core docs, modules documented, but no Search capability.

You can use perldoc to look up documentation on Windows, just like any other
platform.  (Well, there's the problem on Win9x where command.exe doesn't
handle scrolling very well, but I don't know if it's been fixed in 5.6)

I also believe that I saw a grep-like program in the Perl Cookbook a few
weeks ago when I was leafing through it.  That might be worth a look.  Also,
you might find something useful at the Perl Power Tools page
www.perl.com/pub/language/ppt/

Good luck!

Lauren





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

Date: Wed, 28 Jun 2000 00:15:23 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: perldoc & perlop man page?
Message-Id: <3959436a.2950296@news.skynet.be>

invinfo@my-deja.com wrote:

>Having come from a Sun-OS environment, I find the Windows
>documentation, while Huge, a little hard to work with.
>Can I actually use    perldoc -f built-in_function     ???

Yes.

I'd advise you to run it from an editor that captures the output, and
shows it in a window.

-- 
	Bart.


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

Date: Tue, 27 Jun 2000 22:09:30 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Problem writing a binary file to another location
Message-Id: <3980B1FB.E131E0A1@rochester.rr.com>

Jeremiah Adams wrote:
> 
> hi,
> 
> I am trying to get a file which is uploaded with a browser and write it to
> another directory. I am using cgi.mod to do the uploads. The upload works
> fine as well as saving it but the data is corrupted when saved and you
> cannot view the images.
> 
> There is no strict pragma because according to Stien (the mod's author) this
> creates problems.
> 
> Here is the source. Most of it comes straight from stein's web site.:
> #!/usr/bin/perl -w
> 
> # test for file upload
> use diagnostics;
> 
> use CGI::Carp qw(carpout fatalsToBrowser);
> 
> use CGI qw(:standard);
> $save_path = "/httpd/cgi-bin/tests/_temp";
> 
> print header,
>     start_html('file upload'),
>     h1('file upload');
> print_form()    unless param;
> print_results() if param;
> print end_html;
> 
> sub print_form {
>     print start_multipart_form(),
>        filefield(-name=>'upload',-size=>60),br,
>        submit(-label=>'Upload File'),
>        end_form;
> }
> 
> sub print_results {
>     my $length;
> 
>     my $file = param('upload');
>      my $m_save_path = "$save_path/file1.gif";
>     if (!$file) {
>         print "No file uploaded.";
>         return;
>     }
>    # print h2('File name'),$file;
>    # print h2('File MIME type'),
>    # uploadInfo($file)->{'Content-Type'};
>     while (<$file>) {
>         $length += length($_);
>    }
>    # print h2('File length'),$length;
> 
>     $file_type = uploadInfo($file)->{'Content-Type'};
> 
>     if ( $file_type eq 'image/gif' ) {
>         print h2('Correct File');
> 
>         # Copy a binary file to somewhere safe
>         open (OUTFILE,">> $m_save_path");
>         while ($bytesread=read($file,$buffer,$length)) {
>            print OUTFILE $buffer;
>         }
>     }
>     else {
>          print_bad_file();
>     }
> }
> sub print_bad_file {
>     print h2('Bad file type');
>     print p('Only select .gif or .jpg files.')
> }
You probably need to use binmode on the OUTFILE filehandle after opening
the file.  perldoc -f binmode .
-- 
Bob Walton


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

Date: 27 Jun 2000 23:45:06 GMT
From: yhlee@mail.med.upenn.edu (Young H Lee)
Subject: Question on integers
Message-Id: <8jbea2$1il$1@netnews.upenn.edu>

Hypothetically speaking, if I wanted to multiply two very large prime 
numbers, say with 150 digits each.. What do you guys suggest to implement 
this?  I was thinking a 150 indexed array, but that would get really 
complicated.  

Thanks.  Those of you who know the answer probably know why I want to know
this :)

I guess I might as well ask then, if I wanted to take the (mod large 
number) of a large number, what would be the best way?


--
-----
Young H. Lee

"Never try to teach a pig to sing.  It wastes your time and annoys the pig."



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

Date: Wed, 28 Jun 2000 01:01:16 GMT
From: sjs@yorku.ca (Steven Smolinski)
Subject: Re: Question on integers
Message-Id: <slrn8liji3.5m5.sjs@john.sympatico.ca>

Young H Lee <yhlee@mail.med.upenn.edu> wrote:
>Hypothetically speaking, if I wanted to multiply two very large prime 
>numbers, say with 150 digits each.. What do you guys suggest to implement 
>this?  I was thinking a 150 indexed array, but that would get really 
>complicated.  

Try:

perldoc Math::BigInt

NAME
       Math::BigInt - Arbitrary size integer math package
[...]


HTH.
Steve


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

Date: 27 Jun 2000 19:03:54 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Ranking numbers
Message-Id: <slrn8lidon.ka1.abigail@alexandra.delanet.com>

Colby Hansen (cghansen@micron.com) wrote on MMCDXCII September MCMXCIII
in <URL:news:8jb1il$ans$1@admin-srv3.micron.com>:
;; I need some help ranking some numbers.  Here's my list of numbers:
;; 
;; @list = (0,1,3,4,6,8,9,9,9,9,10,14,22,28,31,31,36)
;; 
;; I want to be able to change the list to:
;; 
;; @list = (1,2,3,4,5,6,8.5,8.5,8.5,8.5,11,12,13,14,15.5,15.5,17)


    #!/opt/perl/bin/perl -w

    use strict;

    my @list = (0,1,3,4,6,8,9,9,9,9,10,14,22,28,31,31,36);
    my %buckets;
    map {$buckets {$_} ++} @list;
    my $count = 1;
    @list = map  {$count += $buckets {$_};
                  ((2 * $count - $buckets {$_} - 1) / 2) x $buckets {$_}}
            sort {$a <=> $b} keys %buckets;

    local $" = ",";
    print "(@list)\n";
    __END__



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 27 Jun 2000 19:06:48 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: Ranking numbers
Message-Id: <slrn8lidu5.ka1.abigail@alexandra.delanet.com>

Colby Hansen (cghansen@micron.com) wrote on MMCDXCII September MCMXCIII
in <URL:news:8jb1nn$aob$1@admin-srv3.micron.com>:
[] Actually, I my changed list should look like this:
[] 
[] @list = (1,2,3,4,5,6,7.5,7.5,7.5,7.5,11,12,13,14,15.5,15.5,17)


Perhaps you should make up your mind and decide how you want your list
to look like.

It would also help to define how you want your list to look; from one
example, it's very hard to guess how that generalizes. I could give
an educated guess for the first posting, now that you changed your mind,
I dunno.

Perhaps all you want is:

    @list = (1,2,3,4,5,6,7.5,7.5,7.5,7.5,11,12,13,14,15.5,15.5,17);


regardless of what's in @list.



Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: Tue, 27 Jun 2000 18:22:59 -0600
From: Todd Anderson <todd@mrnoitall.com>
Subject: Re: Script cron problems
Message-Id: <39594552.76B2DD4A@mrnoitall.com>



gulgan@my-deja.com wrote:

> I have croned a script as root (let's not get into the discussion as to
> why it's a long sotry) and it doesn't seem to be running with root
> permissions.  It runs fine at command line but it fails when trying to
> run via cron.  Any ideas?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

Cron doesn't see relative paths. Convert all your global varibles to
absolute paths.
ie: $my_script = "my_script.cgi";
  ... to... $my_script = "/home/my/thingybob/my_script.cgi";



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

Date: Tue, 27 Jun 2000 19:58:55 -0400
From: "Todd W" <trw@uakron.edu>
Subject: split regex
Message-Id: <8jbf0k$mvn$1@kira.cc.uakron.edu>

I am trying to figure out how to split on only the last two underscores in
my string. Any1 mind helping? Thanks in advance.




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

Date: Tue, 27 Jun 2000 22:20:42 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Such an easy task, open and write to a file, here is my code, but no  worky
Message-Id: <3980B4A7.62DA7F0D@rochester.rr.com>

Ariel Lia wrote:
> 
> Hello,
> 
> I try to invoke this simple script by inserting:
> http://www.mydomain.com/cgi-bin/wwwboard/test_a.pl
> 
> into a browser and then clicking reload.  I have tried a number of
> variations.  I use lots of other scripts on this Unix webserver and have
> the latest perl installed.  I am very familiar with getting other
> people's scripts to run:  wwwboard, voting software scripts, etc...
> 
> And now I am trying to write my own simple stuff...  I just want to be
> able to create a file and write content to it.  Then concatenate content
> later on.
> 
> Any advice?  What is wrong with my code below?  It's a cut and paste
> froma working script.  Am i just executing the script incorrectly?
> 
> Thanks!
> 
> A
> 
> #!/usr/local/bin/perl
> 
> &new_file;
> 
> sub new_file {
> 
>    open(NEWFILE,">afraid") || print "<html><head><title>You
> Idiot</title></head><body>You Idiot</body></html>\n";
> 
>    print NEWFILE "<html>\n";
>    print NEWFILE "  <head>\n";
>    print NEWFILE "    <title>Hello</title>\n";
>    print NEWFILE "  </head>\n";
>    print NEWFILE "  <body>\n";
>    print NEWFILE "    <center>\n";
>    print NEWFILE "      <h1>hi</h1>\n";
>    print NEWFILE "    </center>\n";
>    print NEWFILE "<hr size=7 width=75%>\n";
> 
>    print NEWFILE "</body></html>\n";
>    close(NEWFILE);
> }
If I follow what you are trying to do correctly, you have two problems: 
First, your script needs to generate its output to STDOUT, not a file.
In other words, remove the open, close, and all the NEWFILE's in the
print's.  Second, you need an HTTP header on that output, generated from
something like:

    print "Content-type: text/html\n\n";

at the start of the output.  I'm assuming you know about making your
program executable, having it in the correct directory, and setting the
permissions properly.

You neglect to say exactly what *does* happen when you click on your
link.  500 error?
-- 
Bob Walton


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

Date: Wed, 28 Jun 2000 00:33:38 GMT
From: gdig321@my-deja.com
Subject: system() failed but exited ok!
Message-Id: <8jbh52$8c1$1@nnrp1.deja.com>

Hi, codes below is supposed to copy a file using
smbclient and obviously to die when the command failed.
but what happen is if the connection failed, script
does what i want, but if it connected through but
the file doesnot exist.  This code actually runs
through without the fail.  another words, system($command)
exited normally even though there was an error like that.
$? is always 0 in such case.

I had read the perldoc on perlipc/signal and faq, etc,
I could sorta understand why it failes, but without much
success to implement a solution to the code.

Can anyone help? what is the singal generates from the system()?
should i trap $SIG{CHLD} or something?  (I had also used
exec($command), but it doesnt return anything, which
wouldn't make the script useful in this case)

J.

sub copy_file {

    eval {

        local $SIG{ALRM} = sub { die "timeout: copying\n" };
        alarm $TIMEOUT;

        # copy
        $command = qq(smbclient //myhost/myshare -c 'get myfile.file
tofile.file');

        if (system($command)) {
            die "myhost smbclient failed: $!";
        }
        alarm 0;
    }; # end eval
    die if $@;
    return 0;
}


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


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

Date: Wed, 28 Jun 2000 00:09:35 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Teen Volenteers WANTED
Message-Id: <3959415e.443588@nntp.idsonline.com>

bart.lateur@skynet.be (Bart Lateur) wrote:
>Craig Berry wrote:
>
>>: '' Do you know c-c++, HTML, JAVA, JAVASCRIPT, xml or any other computer
>>: '' languages?
>>: '' Are you a teenager?
>>: '' Are you a web guru?
>>: '' Wanna get recognition?
>>: 
>>: Translated:  want to work hard for no pay?
>>
>>Hey, beats working hard for little pay at McDonald's.  Dan ought to invest
>>in a spell-checker, though.
>
>Hey? Do you know of a spell checker that is aware of the fact that XML
>and HTML are not computer languages?

They're not programming languages, but I wouldn't say they're
not computer languages.

I'm not sure how many spell checkers would complain about the
miscapitalization of "Java", "JavaScript", and "XML", though.
Probably some but not most.

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


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Tue, 27 Jun 2000 15:23:43 -0700
From: Ron Auer <rrauer@mitre.org>
Subject: V4 vs V5 sourcing problem
Message-Id: <3959296F.85BBA69@mitre.org>

I am working with a product called Tivoli and they package Perl 4.0. 
Well, I developed my script using Perl 5 (I didn't have 4 on my lab
server) and ftp'd file to the server with version 4.  Well, I have one
line of code that doesn't work in version 4 but works in 5.  I have
looked around to find an answer, and I hit a dead end.  Hope someone can
help.

To run Tivoli, I need to source it, so in ksh it is simply . .
/etc/Tivoli/setup_env.sh.  So, I simply put this into my script as: 


`. /etc/Tivoli/setup_evn.sh`

Under version 5, it works fine.  Under version 4 it fails.  It fails
with a:

Can't exec "/etc/Tivoli/setup_env.sh": Permission denied at
tivoli_test.pl line 32.

The /etc/Tivoli/setup_env.sh permissions are set to -rw-r--r-- so it has
to be a sourcing problem.  I can't reset permissions to be executable so
I have to find a way around the sourcing issue.  

Any thoughts/ideas/suggestions??  Thanks

Ron


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

Date: 28 Jun 2000 00:30:13 GMT
From: bmetcalf@baynetworks.com (Brandon Metcalf)
Subject: Re: V4 vs V5 sourcing problem
Message-Id: <8jbgul$k9d$1@bcrkh13.ca.nortel.com>

rrauer@mitre.org writes:

 > To run Tivoli, I need to source it, so in ksh it is simply . .
 > /etc/Tivoli/setup_env.sh.  So, I simply put this into my script as: 
 > 
 > 
 > `. /etc/Tivoli/setup_evn.sh`
 > 
 > Under version 5, it works fine.  Under version 4 it fails.  It fails
 > with a:
 > 
 > Can't exec "/etc/Tivoli/setup_env.sh": Permission denied at
 > tivoli_test.pl line 32.
 > 
 > The /etc/Tivoli/setup_env.sh permissions are set to -rw-r--r-- so it has
 > to be a sourcing problem.  I can't reset permissions to be executable so
 > I have to find a way around the sourcing issue.  

You only have to have read permission on a file to source it.

lovett (bmetcalf_9.1) tmp $ ls -l ll
-rw-r--r--   1 bmetcalf engineer      16 Jun 27 17:11 ll
lovett (bmetcalf_9.1) tmp $ . ./ll  
lovett (bmetcalf_9.1) tmp $ 

Also, even if you do get it to work, sourcing a script like that will
define things in the subprocess spawned by the ``, so it won't do you 
much good anyway.

Brandon


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

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 3495
**************************************


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