[7383] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1008 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 10 19:10:07 1997

Date: Wed, 10 Sep 97 16:00:22 -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           Wed, 10 Sep 1997     Volume: 8 Number: 1008

Today's topics:
     ANNOUNCE: Tom version 2.0 <jduncan@epitome.hawk.igs.net>
     Re: Building dynamically named arrays (Andrew M. Langmead)
     Compiling scripts (Ken Snyder)
     divide by zero problem in reports. (Nigel Reed)
     Re: divide by zero problem in reports. <kvan@diku.dk>
     Re: divide by zero problem in reports. (Tad McClellan)
     Re: divide by zero problem in reports. (Don Marti)
     Re: divide by zero problem in reports. <fawcett@nynexst.com.SPAMMERS-OFF-EARTH-NOW>
     Re: Finally! Something Perl can't do well! (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: h2ph (Mike Stok)
     Re: How can I prompt the user? <pbarone@rsa.hisd.harris.com>
     Is it possible to prompt a user? <poohba@io.com>
     Need a litlle hand on Netware-Perl: interfacing the ser <loekje@flatnet.tudelft.nl>
     Re: NEWBIE: Installing Perl on desk top <petri.backstrom@icl.fi>
     Re: Perl and Database (Faust Gertz)
     Re: Perl script question for gurus (Parillo)
     Re: PERL to restrict URL access <amit@csd.sgi.com>
     Proper argument processing <pbarone@rsa.hisd.harris.com>
     Q: Building Perl as shared object? <buttrick@sportingnews.com>
     Re:Split operator <ran@sgi.com>
     Saving state with CGI.pm <Rosie@dozyrosy.demon.co.uk>
     Re: Slogans (Was Re: perl and XEmacs) <hniksic@srce.hr>
     Re: What does "regexp *+ operand could be empty" mean? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 10 Sep 1997 21:11:14 GMT
From: James Duncan <jduncan@epitome.hawk.igs.net>
Subject: ANNOUNCE: Tom version 2.0
Message-Id: <5v72di$dbv$1@nadine.teleport.com>

About four months ago I posted an announcement for the Transportable
Object Model (Tom).  This went fairly unnoticed.  Now however, Tom has
been updated, modified, worked, etc, etc, etc. I would like to release it
on to CPAN once people have tried it out and given me some feedback. The
module and information regarding the module is available at
	http://www.hawk.igs.net/~jduncan/Tom/

The README follows.

--
James Duncan || jduncan@hawk.igs.net
IGS Hawkesbury Systems Administrator
Phone 613-632-4075  Fax 613-632-8137
web http://www.hawk.igs.net/~jduncan



  	     Transportable Object Model (Tom) Kit for Perl

			     Version 2.00

			      ( beta 2 )

		 Copyright (c) 1997, James Duncan

    This program is free software; you can redistribute it and/or modify
    it under the terms of either:

	a) the GNU General Public License as published by the Free
	Software Foundation; either version 1, or (at your option) any
	later version, or

	b) the "Artistic License" which comes with this kit.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See either
    the GNU General Public License or the Artistic License for more details.

    You should have received a copy of the Artistic License with this kit,
    in the file named "Artistic".  If not, you can get one from the Perl
    distribution. You should also have received a copy of the GNU General
    Public License, in the file named "Copying". If not, you can get one
    from the Perl distribution or else write to the Free Software
    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


TOM Kit, Version 2.0 (Beta 2)
-----------------------------
This, the newest version of the TOM (Transportable Object Model) features an
enhancement significant enough over the original, as to warrant a new major
version.  

Tom will be completely re-written for version 2.0, including some major
security enhancements (yes, register will be secure).

At this point (Beta 2), the module is still very incomplete, however,
containers created with Beta 2 will be fully compatible up to final release.  I
do not intend on changing the internal structure of the model.

The major enhancement is the ability to define transportable objects rather 
than just classes - this is a major step forward in my eyes.

I now believe that Tom 2.0 Beta 2 is worth more than any Tom 1.x release,
and I would like to make it available on CPAN for Beta 3.

Changes since Beta 1
--------------------
+ Ability to securely register functions
+ Added require like Tom::demand package
+ You can now 'insert' an object into a container
  rather than 'declare_object'.
+ Checks for existing packages
+ Cleanup function added
+ Documentation updated.
+ Included old tomcc until cc is rewritten into Tom-2
+ Added simple streaming protocol to Tom.  I will re-write this into
  another file, with much more functionality soon.








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

Date: Wed, 10 Sep 1997 20:38:32 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Building dynamically named arrays
Message-Id: <EGB808.L93@world.std.com>

Glen Culbertson <nnyxcu@ny.ubs.com> writes:

>'eval' is the secret here.
>Construct a string having the code you would write to do it directly,
>and then 'eval' the string. It's really magic!

He's probably better off using typeglobs rather than eval (since perl
5's multidim arrays and soft references can't fit into his spec.)
Using eval for this purpose entails quite a performance hit.

use Benchmark;

$key = 'ArrayOne';
$elem = 'one';
$data = 'I';

timethese(100000, {
	eval_way => q(eval "\$$key\{$elem\} = $data"),
	typeglob_way  => q(*hash=$key; $hash{$elem} = $data)
	}
);

Benchmark: timing 100000 iterations of eval_way, typeglob_way...
  eval_way: 70 secs (68.29 usr  0.11 sys = 68.40 cpu)
typeglob_way:  3 secs ( 3.01 usr  0.00 sys =  3.01 cpu)

Also in the way you suggest:

>$str = "\$$x[0]" . "{$x[1]} = $x[2]"; 

which is roughly what I did above, you would be safer doing:

$str = "\$$x[0]" . "{\$x[1]} = \$x[2]";

You're depending that the contents of $x[2] have no other special
meaning in perl and will be treated as barewords. What if $x[2]
contains the word "time"?

-- 
Andrew Langmead


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

Date: Wed, 10 Sep 1997 18:24:26 -0400
From: ksnyde@sapient.com (Ken Snyder)
Subject: Compiling scripts
Message-Id: <3416fe34.13818046@delphi>

I would love to discuss compiling PERL (through the alpha-3 Perl-to-C
compiler) with anyone who has relavent experience.  I have run into
problems compiling files that are larger than ~= 30k, where the
compiler can't handle the memory requirements of optimizations.
Without the optimizations the scripts do not offer any real
performance advantage (and are MUCH slower than a "dump-compiled"
script).

Also interested in if anyone has any performance characteristics of
Perl statically compiled versus shared libraries.

Does anyone know of any good literature available.  I've heard that
TPJ has an issue on compiling, anyone know which article?

I will check back on the list over the next couple of days but my
bandwidth is limited so I'd prefer an email if possible
(ksnyde@sapient.com).  

Thanks to any and all.  :^)




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

Date: 10 Sep 1997 18:11:32 GMT
From: nigelr@convex.hp.com (Nigel Reed)
Subject: divide by zero problem in reports.
Message-Id: <5v6nsk$5uq$1@news.rsn.hp.com>


I've come across a problem and I wonder if anyone has a better solution.

I have a report which basically looks like

Computer name     Hours Available   Hours uses    Percent used
@>>>>>>>>>>>>         @#####          @#####         @###.##
$name,$avail,$used,(($used/avail)*100)
 .

Now, if I have 0 hours used, I'm getting the following error...

Illegal division by zero at weekly line 267, <IN> chunk 123.
        main::STDOUT called at weekly line 67

I could use an extra variable and something like

if ($used = 0) {
  $percent = 0
} else {
  $percent = (($used/avail)*100)
}

But I could do without the extra 'if' section. Anyone got
any clever ideas for me please?

Regards
Nigel


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

Date: Wed, 10 Sep 1997 22:42:58 +0200
From: Kvan <kvan@diku.dk>
Subject: Re: divide by zero problem in reports.
Message-Id: <Pine.HPP.3.95.970910223814.12649C-100000@thokk.diku.dk>

On 10 Sep 1997, Nigel Reed wrote:

> Now, if I have 0 hours used, I'm getting the following error...
> 
> Illegal division by zero at weekly line 267, <IN> chunk 123.
>         main::STDOUT called at weekly line 67

If you're getting this error, it's $avail that's zero. If $avail is not
zero, you've swapped the two around in your script.
 
> But I could do without the extra 'if' section. Anyone got
> any clever ideas for me please?

 ... and if $avail *CAN* be zero, why not do something like

$percent = 0;
$percent = (($used/$avail) * 100) unless ($avail == 0);

A bit shorter than your suggestion. I think there may be a better way
involving some logical operations, but I'll leave those (if they exist) to
someone else.

Kvan.

-------Casper Kvan Clausen------ | 'Ah, Warmark, everything that passes
---------<kvan@diku.dk>--------- |  unattempted is impossible.'
'kvan' on pbmserv@eiss.erols.com |   
http://www.diku.dk/students/kvan |        - Lord Mhoram, Son of Variol.      



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

Date: Wed, 10 Sep 1997 15:51:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: divide by zero problem in reports.
Message-Id: <q717v5.4vn.ln@localhost>

Nigel Reed (nigelr@convex.hp.com) wrote:
: I've come across a problem and I wonder if anyone has a better solution.

[ snip ]

: Illegal division by zero at weekly line 267, <IN> chunk 123.
:         main::STDOUT called at weekly line 67

: I could use an extra variable and something like

: if ($used = 0) {
      ^^^^^

eh?

having a zero numerator is OK, you must have meant $avail here?

You want a logical test (==) there, not an assignment.

You should be using the -w switch you know, it issues a complaint
about that line...

See the perlrun man page for info on the -w switch.



:   $percent = 0
: } else {
:   $percent = (($used/avail)*100)
                       ^^^^^

or did you mean $avail here?

You should be using the -w switch you know, it issues three
complaints about the above line...

See the perlrun man page for info on the -w switch.


: }
: But I could do without the extra 'if' section. Anyone got
: any clever ideas for me please?


An exceedingly clever idea is to ask perl to help you debug your
scripts *before* resorting to posting a question to Usenet  ;-)

I thought the auto-FAQ recommended doing that. 

Did you get the auto-FAQ?

Did you read it?

Wanna bang your head against the wall (ignore what it says in there), 
or learn from other people's experience (take heed of what it says)?

See the perlrun man page for info on the -w switch.


   # still an if, just a different kind

   $percent = $avail ? ($used/$avail)*100 : 0; 


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 10 Sep 1997 13:57:03 -0700
From: don@carp.pacdigital.com (Don Marti)
Subject: Re: divide by zero problem in reports.
Message-Id: <5v71iv$eil@carp.pacdigital.com>

In article <5v6nsk$5uq$1@news.rsn.hp.com>,
Nigel Reed <nigelr@convex.hp.com> wrote:

>Now, if I have 0 hours used, I'm getting the following error...
>
>Illegal division by zero at weekly line 267, <IN> chunk 123.
>        main::STDOUT called at weekly line 67
>
>I could use an extra variable and something like
>
>if ($used = 0) {
>  $percent = 0
>} else {
>  $percent = (($used/avail)*100)
>}
>
>But I could do without the extra 'if' section. Anyone got
>any clever ideas for me please?

You could use eval to catch divide by zero:

$percent = (eval {$used/$avail} || 0) * 100;

That saves you typing and scrolling through a couple lines.  But the
"if" makes it easier to see what's going on if you ever have to come
back to the same script again.
-- 
Don Marti                          |    http://www.pacdigital.com 
Pacific Digital Interactive        |
don@carp.pacdigital.com            |


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

Date: 10 Sep 1997 16:56:34 -0400
From: Tom Fawcett <fawcett@nynexst.com.SPAMMERS-OFF-EARTH-NOW>
Subject: Re: divide by zero problem in reports.
Message-Id: <8jg1rc51ml.fsf@nynexst.com.SPAMMERS-OFF-EARTH-NOW>


nigelr@convex.hp.com (Nigel Reed) writes:
> I've come across a problem and I wonder if anyone has a better solution.
>[divide by zero problem]
>
> I could use an extra variable and something like
> 
> if ($used = 0) {
>   $percent = 0
> } else {
>   $percent = (($used/avail)*100)
> }
> 
> But I could do without the extra 'if' section. Anyone got
> any clever ideas for me please?

Use a conditional expression:  ($avail==0 ? 0 : ($used/$avail)*100)



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

Date: Wed, 10 Sep 97 15:22:05 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Finally! Something Perl can't do well!
Message-Id: <3416f39b$6$ofn$mr2ice@speaker.kf8nh.apk.net>

In <3415a30a.0@cfanews.harvard.edu>, on 09/09/97 at 07:27 PM,
   rpete@ascda3.harvard.edu (Pete Ratzlaff) said:
+-----
| I'm trying to read data from a file (a FITS binary table extension, for those
| that care). This data is in the form of short integers. The problem is that
| there are a large number to read ( > 1e6), and Perl's scalars are *much* too
| large for these integers. Reading 2MB worth of file data turns into a 60MB
| Perl process!
+--->8

Read it as a single large string and use unpack() to pull numbers out of it as
needed.

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)           FORZA CREW!
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org



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

Date: 10 Sep 1997 20:14:03 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: h2ph
Message-Id: <5v6v2b$nft@news-central.tiac.net>


In article <01bcbe22$7398f1e0$b5910a9f@aurora.cna.com>,
Aaron <aaron@soltec.net> wrote:
>I have a little question
>
>I am trying to automate an ftp using Perl (and if anyone has any
>information on that that would be appreciated) but when trying to test out
>chat2 I get a problem with sys/socket.h and it asks if I've used h2ph.
>
>Any guidance would be appreciated.

If you're able to use perl5 then get the libnet modules from a CPAN site
(the master site is at ftp.funet.fi under /pub/languages/perl/CPAN or you
can browse to it via http://www.perl.com/ ) and you can do stuff like this
(lifted from the documentation...)

NAME
       Net::FTP - FTP Client class

SYNOPSIS
           use Net::FTP;

           $ftp = Net::FTP->new("some.host.name");
           $ftp->login("anonymous","me@here.there");
           $ftp->cwd("/pub");
           $ftp->get("that.file");
           $ftp->quit;

This is probably a lot easier than trying o interact with a client
designed for human use...

Hope this helps,

Mike


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Wed, 10 Sep 1997 16:02:11 -0400
From: Phil Barone <pbarone@rsa.hisd.harris.com>
Subject: Re: How can I prompt the user?
Message-Id: <3416FCC2.7EBADF72@rsa.hisd.harris.com>


Try this:
 ...
my $name;
print "Enter Name";
chop($name = <>);
 ...

Pascal Lamoureux wrote:

> Is there a way in perl to prompt the user...
> ie. getting info from the stdin.
>
> I tried whit read but I think I'm not using it correctly (I cannot get
> out of the prompt unless I do ^C)
>
> Thanks for the hint,
>
> Pascal





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

Date: Wed, 10 Sep 1997 15:33:13 -0500
From: Robert Campbell <poohba@io.com>
Subject: Is it possible to prompt a user?
Message-Id: <Pine.BSI.3.96.970910142521.28789B-100000@pentagon.io.com>

Is it possible to prompt a user for info with cgi  instead of javascript?




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

Date: Wed, 10 Sep 1997 23:50:28 +0200
From: Loek Gijben <loekje@flatnet.tudelft.nl>
Subject: Need a litlle hand on Netware-Perl: interfacing the server
Message-Id: <34171623.88104FC2@flatnet.tudelft.nl>

Hello,

Im still looking for someone to give me a hint on the internal
server-commands of Netware 3.12 as used with Perl.NLM.

The little doc gives the following example:
> sub SendConsoleBroadcast {  # ($msg [, @list of connections])
>  local($msg) = shift(@_);
>  local($func) = &Symbol'Import("SendConsoleBroadcast");
>  die "$!" if ($func == 0);
>  local($conn) = pack("S*", @_);
>  local($args) = pack("pLp", $msg, scalar(@_), $conn);
>  local($ret) = &Symbol'Call($func, $args);
>  &Symbol'Unimport("SendConsoleBroadcast");
>  $ret = unpack("i", $ret);
>  # return $ret
> }
>
> $i = &SendConsoleBroadcast("this is the message", 2);

Obviously "SendConsoleMessage" is used to call an internal function. Can
anyone point me to a list of all internal functions, please?
I have to find out which users are member of certain groups, and I have
to find out whether they are connected at the moment..

BTW. Netware = 3.12, and Perl is the free version I leeched from CPAN.
But even Netware 4.11 (which has Perl included) has nul-point-nacko info
on this:(

TIA,
Loek Gijben




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

Date: Wed, 10 Sep 1997 21:25:00 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: NEWBIE: Installing Perl on desk top
Message-Id: <3416E5FC.5816@icl.fi>

spalding@netcom.ca wrote:
> 
> Just started into perl and would like to install Perl 5 on my
> computer. I have the following in zip format;
> Pw32a310. Perl for Win32 Alpha Binary
> P1SEa310. Perl Script Alpha Binary
> P1ISa310.  Perl for ISAPI Alpha binary
> Pw32s310. Perl for Win32 Source files
>  Which files should I be using and is there any way to run the scripts
> on my computer without having to use the server, for debugging
> purposes. Please e-mail any suggestions would help

Well, first of all: Do you have a DEC Alpha processor based
system running Windows NT?

If not, get one, or get different binaries (or recompile the
sources for Intel, or get another kit).

If you just want the command line Perl from the kit you have,
install just Pw32a310 (the others are for Microsoft Internet
Information Server [Microsoft's web server] use - supposedly 
the PerlScript version works also as a client-side scripting 
engine with Microsoft Internet Explorer [Microsoft web browser], 
but I have no experience with that).

Depending on what you want to debug you may or may not need 
a server (it also depends on what "server" you mean).

If you mean a web server and you're thinking of debugging
CGI scripts, then you can use CGI.pm and debug from the
command line. See

  http://www-genome.wi.mit.edu/ftp/pub/software/WWW/cgi_docs.htm

for more.

However, since the web server (IIS with Windows NT Server,
PWS with Windows NT Workstation) comes with NT (or you can
get others), why not just install and use it...

Read

  http://www.endcontsw.com/people/evangelo/Perl_for_Win32_FAQ.html

before you start.

Then read

  http://language.perl.com/faq/index.html

and as much of other stuff that you can find via

  http://www.perl.com

See also what's on

  http://www.activestate.com

about the version of Perl you have, and read the docs
that comes with it.

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Wed, 10 Sep 1997 20:28:29 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Perl and Database
Message-Id: <341700f2.7629412@news.wwa.com>

On 10 Sep 1997 15:10:04 GMT, jzhuang@ringer.cs.utsa.edu (Jun Zhuang)
wrote:

>I have try to use some database modules for Perl5. For instance,
>Sprote. But I found Sprite only support simple format such as:
>   name age  ID
>   Joe  25   007
>   Mary 18   009
>which first line has to be the line contain definitions.
>
>But I have some scientific datbase such as:
>
>Record_009	mouse_A		DNA clone
>Date cloned	090197  
>Cloner		Dr. John Smith
>DNA sequence	atgcggggggatcgagtcgggggggggggggggccccctaaaaaaaaaa
>actecccccccccccccctttttttttttgactagggggggggtccccccctttttttttttaa
>Animal Species	Mus Domestic
>Drug tested	AK45
>
>
>Which every first word of the line is the definition.
>
>Is there  any more complicated database module for perl5?

You can shop around the MIT Genome Center FTP Archive-Software
http://www.genome.wi.mit.edu/ftp/pub/software/  I haven't look there
very much, but they might have something to help you.  If you haven't
been there already, you should go to the CPAN near you
http://language.perl.com/CPAN  Also, I am not sure if it will help,
but perhaps just reading sometehing simple like Randal Schwartz's
September 1995 _Unix Review_ article entitled 'Tiny Database'
http://www.stonehenge.com/merlyn/UnixReview/col04.html would be of
use.

HTH

Faust Gertz
Philosopher at Large


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

Date: 10 Sep 1997 22:45:48 GMT
From: lparillo@newshost.li.net (Parillo)
Subject: Re: Perl script question for gurus
Message-Id: <5v77us$gc$1@news01.li.net>


Will you have to do a printf in order to get the leading zeros?
BTW, the perldoc on printf and sprintf is not helpful to non-c 
programmners. Is there a better source (other than deja news?)

lparillo at suffolk dot lib dot ny dot us


Helmut Llamas Stuhne (llamashe@microtec.de) wrote:
: > A quick-n-dirty sketch, you may have to do a little debugging:
: >
: > #!/usr/bin/perl
: >
: > $dir = shift || ".";    # first argument is directory
: > $start = shift || "0";  # second argument is starting number
: >
: > $fnbase = sprintf "%08d", $start;
: > opendir(D, $dir) || die "can't open $dir? $!\n";
: >
: > @files = map { $_ if (-f $_ and $_ !~ /^0.*txt/)} readdir(D);
: > closedir(D);
: >
: > foreach $file (@files) {
: >         rename($file, $fnbase.".txt");
: >         $fnbase++;
: > }

: Only open(D,$dir) you schould change in opendir(D,$dir).Now your script
: is runnig, I have test it.

: regards
:     H.Stuhne



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

Date: Wed, 10 Sep 1997 13:57:07 -0700
From: amit kothari <amit@csd.sgi.com>
To: Julian Cook <siogo@ari.net>
Subject: Re: PERL to restrict URL access
Message-Id: <341709A3.D0EA3D8E@csd.sgi.com>

Julian Cook wrote:
> 
> Gentlemen:
> 
> I started learning PERL a little while ago and my business has taken off
> that I don't have time to devote to learning it as well as I should.
> 
> My question is that I would like to restrict access from certain Host
> Names. Unfortunately after the business took off, I had to move the server
> from my basement to a virtual server, so I don't have access to host.deny
> or .htaccess anymore.
> 
> What I have is an opening page and once the "Continue" button is pressed,
> then have the script to deny access to certain hosts that try to access
> the URL.
> 
> I know that is probably an easy question and my apologies for not
> presenting a more challenging problem but I am SO busy I can barely get
> any sleep and I don't have time to figure this one out.
> 
> Many thanks in advance!
> Julian Cook

try this ~

        $list_access{1} = "some host";
	...
	...
        $remote_host = $ENV{REMOTE_HOST};
        if ($list_access{$remote_host}){
		.....deny access....
        }
        else{
		...aloww access...
        }

regards

amit


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

Date: Wed, 10 Sep 1997 17:35:12 -0400
From: Phil Barone <pbarone@rsa.hisd.harris.com>
Subject: Proper argument processing
Message-Id: <34171290.D4865D2@rsa.hisd.harris.com>


I have a few questions about the proper way to get command line
arguments using Getopt::Std while using strict and diagnostics.

For example:
------------------
#!/usr/local/bin/perl -w

use strict;
use diagnostics;

use Getopt::Std;
getopts('f:');

my $InFile = $opt_f if (defined $opt_f);

print "$Infile\n";
-------------------
Gives me a "requires explicit package name at line 9" message. I have
tried defining the options but haven't found a way to get rid of these
messages other than commenting out use strict and use diagnostic.

Another problem I have is if I do something like:

  my $InFile = $opt_f;

then I am only using $opt_f once, so I get the you might have had a Typo
messages.
How do people handle this situation?



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

Date: Wed, 10 Sep 1997 16:17:10 -0500
From: David Buttrick <buttrick@sportingnews.com>
Subject: Q: Building Perl as shared object?
Message-Id: <34170E56.9CFBCAD1@sportingnews.com>


I have a situation in which our server spawns sometimes as many as 30
Perl programs which might remain idle for hours.

We run an SGI Origin, with IRIX 6.4, and I am interested in building the
PERL binary such that one copy of the interpreter is residnet and shared
among multiple processes or scripts that are using it.

Is this what dynamic loading is, and is done by default, so I dont have
to worry?

Is this possible? Has anyone done it?

Your prompt attention to this matter is appreciated.
--
David Buttrick             tel. (314) 993-7727
WEB Developer           e-mail. buttrick@sportingnews.com
The Sporting News          web. http://www.sportingnews.com
AOL keyword: TSN           aol. tsndmb@aol.com

The Sporting News is a collection of all the sports news and
scores Internet users need. A network of more than 150 writers,
real time chat rooms, fantasy league advice, and over 110 years
of archived sports history make The Sporting News THE SITE for
the serious sports fan.




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

Date: Wed, 10 Sep 1997 13:25:30 -0700
From: Ramesh Nagarajan <ran@sgi.com>
Subject: Re:Split operator
Message-Id: <3417023A.FC976CCD@sgi.com>

Hi,
I am trying to do the following
$array # Contains a large text file (2000 lines with hard returns)

I have to read each and every line into an array say @array. How do I do
that.

At present I am using split operator which splits on characters.
@array = split("", $array).

But the array size becomes tremendously large. Any solution for this
one.
P.S I tried to split on '\n' but the resulting array is all jumbled up.

Any help is greatly appreciated.-- 
                           
-Ramesh


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

Date: Wed, 10 Sep 1997 22:55:29 +0100
From: Rosemary I H Powell <Rosie@dozyrosy.demon.co.uk>
Subject: Saving state with CGI.pm
Message-Id: <2SwdwFARdxF0Ew2U@dozyrosy.demon.co.uk>

Lured by the promise of easily being able to save state across sessions,
I am in the process of converting from using cgi-lib.pl to CGI.pm in my
CGI scripts. BUT - I'm a little confused as I was expecting my life to
be made easier, but so far this doesn't seem to be the case :-(

I have an existing script where form input data is checked and the data 
re-displayed for checking; I presently do this by re-generating the form
with all the previously input data "filled in", and by carrying over
other information via hidden fields on the form, and the user can check
and correct his input before finally submitting...It works nicely but
isn't very beautiful.

Examples in the CGI.pm documentation show:
(a) saving state by saving to and restoring from a file (e.g. a
guestbook):
    $q save->(OUT)  and   
    my $q = new CGI(IN)
- but to do this for carrying TEMPORARY information from one script
invocation to the next, I would STILL have to do the hard bit???
i.e. presumably generate a unique filename for each user, carry the file
name as a hidden field on a form, and delete the file when the user
quits. 

(b) a self referencing URL that preserves state when the script is
reinvoked:
    $myself = $qery->self_url; 
    $the_string = $query->query_string; 
- in the documentation this is discussed in the context of jumping about
in a document via internal anchors, though I assume if this means what
it says, it will carry over the query string from one invocation of the
script to the next. But has this option got the flexibility to do what I
am currently doing?

Am I 
1) misunderstanding what CGI.pm does in these contexts?
2) missing some vital information?
3) or expecting too much of it?
4) errm... :-((  posting in the wrong newsgroup when it should go to the
cgi authoring one? (I didn't really say f*rm or CG*, and NEVER mentioned
HT*L - honest!!)

Any offers of enlightenment or advice on how to proceed would be very
welcome!

Thanks, Rosemary

-------------------------------------------------------------------
| Rosemary I.H.Powell  EMail: Home: rosemary@dozyrosy.demon.co.uk |     
|                             Work: r.i.h.powell@rl.ac.uk         |
|                       http://www.netlink.co.uk/users/dozyrosy/  |
|                       http://www.dozyrosy.demon.co.uk/          | 
-------------------------------------------------------------------


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

Date: 10 Sep 1997 21:30:45 +0200
From: Hrvoje Niksic <hniksic@srce.hr>
Subject: Re: Slogans (Was Re: perl and XEmacs)
Message-Id: <kigk9gpq84a.fsf@jagor.srce.hr>

pudge@pobox.com (Chris Nandor) writes:

> # If you have become part of
> # the Perl thing by months of pain learning the most evil syntax, to the
> # point where you start to believe that you always thought in such a
> # non-linear way, then you're good for Perl.
> 
> # Perl is, to say the least, difficult 
> # to debug if you don't know the complexities and intricacies of the
> # language.  If you're staring at something someone else wrote (or even
> # something that you wrote a few months back), you can easily get
> # confused.  Lisp can even get this way for me -- esp. for huge code.  But 
> # what saves Perl (or *can* save it) is that it can be well-written.
> # Also, since it's interpreted and high-level, lots of ugly stuff is done
> # internally.  There is potential for nice Perl code, though most people
> # don't try.  I don't try too hard myself.  
> 
> If you replace "Perl" with "English," the above sentences still make
> perfect sense.

Or with "Intercal."

-- 
Hrvoje Niksic <hniksic@srce.hr> | Student at FER Zagreb, Croatia
--------------------------------+--------------------------------
Ask not for whom the <CONTROL-G> tolls.


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

Date: Wed, 10 Sep 97 15:25:49 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: What does "regexp *+ operand could be empty" mean?
Message-Id: <3416f45e$7$ofn$mr2ice@speaker.kf8nh.apk.net>

In <5v2d90$oan@agate.berkeley.edu>, on 09/09/97 at 02:45 AM,
   ilya@math.ohio-state.edu (Ilya Zakharevich) said:
+-----
| Note that this (very useful) message is gone with the latest jumbo RE patch. 
+--->8

Is there any particular reason it didn't become a -w warning?

-- 
brandon s. allbery              [Team OS/2][Linux]          bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)           FORZA CREW!
Warpstock '97:  OS/2 for the rest of us!  http://www.warpstock.org



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

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

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