[11390] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4990 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 16:17:36 1999

Date: Fri, 26 Feb 99 13:07:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Feb 1999     Volume: 8 Number: 4990

Today's topics:
        open fails with "Not enough space"? <bruce.w.mohler@saic.com>
    Re: open fails with "Not enough space"? (Tad McClellan)
        open(TEMP, "text.txt"); does not work on NT (Duplication Discounters, Inc.)
    Re: open(TEMP, "text.txt"); does not work on NT <sbh@mch10.sbs.de>
    Re: open(TEMP, "text.txt"); does not work on NT (Alastair)
    Re: open(TEMP, "text.txt"); does not work on NT (Clay Irving)
    Re: open(TEMP, "text.txt"); does not work on NT <gavin@optus.net.au.dontspam.myass>
        outputting the day? <nospam-seallama@mailcity.com>
    Re: outputting the day? <Tony.Curtis+usenet@vcpc.univie.ac.at>
        parsing <dkh@home.com>
        parsing <seugenio@man.amis.com>
    Re: parsing <stevenhenderson@prodigy.net>
    Re: parsing <tchrist@mox.perl.com>
    Re: parsing <ebohlman@netcom.com>
        Passing data during runtime.... <wfunk@dev.tivoli.com>
    Re: Passing data during runtime.... <jdf@pobox.com>
        Passing of Parameter from one script to another <scijr@nus.edu.sg>
    Re: Passing of Parameter from one script to another <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Passing two arrays to a subroutine gibsonc@aztec.asu.edu
    Re: Passing two arrays to a subroutine <paladin@uvic.ca>
    Re: Passing two arrays to a subroutine (Greg Bacon)
    Re: Passing two arrays to a subroutine <tchrist@mox.perl.com>
    Re: Passing two arrays to a subroutine (Tad McClellan)
    Re: Passing two arrays to a subroutine massimobalestra@my-dejanews.com
        password PWS <ddufour@royaume.com>
    Re: password PWS (Abigail)
        pb with Cwd::getcwd() ! [perl 5.005_02 / Cygwin32 B.20. (Sibastien Barri)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 24 Feb 1999 15:00:04 -0800
From: Bruce Mohler <bruce.w.mohler@saic.com>
Subject: open fails with "Not enough space"?
Message-Id: <36D48474.7BF69900@saic.com>

Can anyone help me understand why the following code snippet is failing?

       $df = "/usr/bin/df";
       $fs = "/usr/local";

       ...

       open DFOUTPUT, "$df $fs |" or die...

The error message out of die() is

       Couldn't execute df command /usr/bin/df: Not enough space at ...

I'm creating test files on a server and don't want to exceed a
certain percent full of the file system.  Is there a better way to
do this?

The environment: Perl 5.005_02 running on HP-UX 10.20.

Thanks, in advance!

Bruce

--
Bruce W. Mohler                619-458-2675 (voice)
SAIC/ITS/Server Support        619-535-7806 (fax)
Sr UNIX system administrator   888-781-5697 (pager)
                               mailto:bruce.w.mohler@saic.com
Of course my password is the same as my pet's name.
My dog's name is Q47pY!3, but I change it every 90 days.




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

Date: Wed, 24 Feb 1999 18:43:40 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: open fails with "Not enough space"?
Message-Id: <cr22b7.nmc.ln@magna.metronet.com>

Bruce Mohler (bruce.w.mohler@saic.com) wrote:
: Can anyone help me understand why the following code snippet is failing?

:        $df = "/usr/bin/df";
:        $fs = "/usr/local";
:        ...
:        open DFOUTPUT, "$df $fs |" or die...

: The error message out of die() is
                    ^^^^^^^^^^^^

   So you say.

   If you had given us your real code we could tell for ourselves.

   It would make a difference in suggesting what the problem
   might be.


:        Couldn't execute df command /usr/bin/df: Not enough space at ...


   Since that error message is not listed in perldiag.pod, I don't
   expect that it is coming from Perl.

   If you are really getting text from the die() there, about
   the only thing that could cause it is fork() failing.

   Are you pushing the number of processes limit?


   See the Perl FAQ, part 8:

      "Why doesn't open() return an error when a pipe open fails?"


   Another thing to try would be to dump the output to a file,
   instead of to a piped filehandle, and see what happens:

      system("$df $fs >/tmp/df.dump") && die "system() failed  $!";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 22 Feb 1999 16:45:55 -0800
From: brett@77dupes.com (Duplication Discounters, Inc.)
Subject: open(TEMP, "text.txt"); does not work on NT
Message-Id: <TQmA2.133$Ff.40348@WReNphoon4>

The following code works perfectly from the command prompt:

open (TEMP, "text.txt");
@name = <TEMP>;
close TEMP;
print @name;

It will print the file perfectly,
BUT
when I access this code from a broswer it will not open the file. The code
runs, but the open command returns no value at all. I am running NT with SP3
and IIS 4.0.

Is this a NTFS problem? ANY help will be appreciated!

--Brett
brett@77dupes.com



**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****


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

Date: Tue, 23 Feb 1999 13:48:28 +0100
From: Seidl Bernhard <sbh@mch10.sbs.de>
Subject: Re: open(TEMP, "text.txt"); does not work on NT
Message-Id: <36D2A39C.81ABDB0@mch10.sbs.de>

you are using a file name relative to the current directory. please remember the
environment of a cgi-script. probabliy you will get another restult, if you are unsing
a absolute path ("C://temp//text.txt" or so.) Next problem is: usually
IIS4-CGI-Scripts are running as IUSR_<hostname> user. pls check the user rights of the
path and the file.

"Duplication Discounters, Inc." wrote:

> The following code works perfectly from the command prompt:
>
> open (TEMP, "text.txt");
> @name = <TEMP>;
> close TEMP;
> print @name;
>
> It will print the file perfectly,
> BUT
> when I access this code from a broswer it will not open the file. The code
> runs, but the open command returns no value at all. I am running NT with SP3
> and IIS 4.0.
>
> Is this a NTFS problem? ANY help will be appreciated!
>
> --Brett
> brett@77dupes.com
>
> **** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ****



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

Date: Tue, 23 Feb 1999 01:24:34 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: open(TEMP, "text.txt"); does not work on NT
Message-Id: <slrn7d40tb.9p.alastair@calliope.demon.co.uk>

Duplication Discounters, Inc. <brett@77dupes.com> wrote:
>The following code works perfectly from the command prompt:
>
>open (TEMP, "text.txt");

Why not check your open succeeded?

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: 22 Feb 1999 21:32:24 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: open(TEMP, "text.txt"); does not work on NT
Message-Id: <slrn7d44pn.8k7.clay@panix.com>

On Mon, 22 Feb 1999 16:45:55 -0800, Duplication Discounters, Inc. 

<brett@77dupes.com> wrote:
>The following code works perfectly from the command prompt:
>
>open (TEMP, "text.txt");
>@name = <TEMP>;
>close TEMP;
>print @name;
>
>It will print the file perfectly,
>BUT
>when I access this code from a broswer it will not open the file. The code
>runs, but the open command returns no value at all. I am running NT with SP3
>and IIS 4.0.

I see several problems:

- Perl programs don't run in a browser -- They run on the server.

- If your program runs from the command line, you must not have a Perl 
  problem.

- Did your open succeed? You did test it. Remember, a Web server most 
  likely runs your program with a `nobody' userid.

- Print what? Where is the MIME header?

>Is this a NTFS problem? ANY help will be appreciated!

You need to take a look at:

    Idiot's Guide to Solving Perl/CGI Problems 
    http://language.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html

-- 
Clay Irving <clay@panix.com>
Don't join the book burners. Don't think you are going to conceal thoughts
by concealing evidence that they ever existed. 
- Dwight David Eisenhower 



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

Date: Tue, 23 Feb 1999 04:16:45 GMT
From: "Gavin Cato" <gavin@optus.net.au.dontspam.myass>
Subject: Re: open(TEMP, "text.txt"); does not work on NT
Message-Id: <NYpA2.7$qp1.413574@news0.optus.net.au>

Opening from a browser??

I hope you mean you are accessing it via CGI

try checking the outcome of the file open process.

open (FILE, "file.txt") or die "I couldn't open file.txt : $! \n";
print $_;
close FILE;

--

--
Gavin Cato - Optus Network Engineer - gavin@optus.net.au

gawk; talk; date; wine; grep; touch; unzip; touch; gasp; finger; gasp;
mount; \
 fsck; more; yes; gasp; umount; make clean; make mrproper; sleep


Duplication Discounters, Inc. <brett@77dupes.com> wrote in message
news:TQmA2.133$Ff.40348@WReNphoon4...
>The following code works perfectly from the command prompt:
>
>open (TEMP, "text.txt");
>@name = <TEMP>;
>close TEMP;
>print @name;
>
>It will print the file perfectly,
>BUT
>when I access this code from a broswer it will not open the file. The code
>runs, but the open command returns no value at all. I am running NT with
SP3
>and IIS 4.0.
>
>Is this a NTFS problem? ANY help will be appreciated!
>
>--Brett
>brett@77dupes.com
>
>
>
>**** Posted from RemarQ - http://www.remarq.com - Discussions Start Here
(tm) ****




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

Date: Thu, 25 Feb 1999 23:44:33 -0800
From: dan <nospam-seallama@mailcity.com>
Subject: outputting the day?
Message-Id: <36D650E1.E093C570@mailcity.com>

is there a way to output what day it is? i used localtime(time) to get
the date, month, and year, but i cant get the actual day. any pointers?
thanks




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

Date: 26 Feb 1999 12:00:28 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: outputting the day?
Message-Id: <83ogmhfn03.fsf@vcpc.univie.ac.at>

Re: outputting the day?, dan
<nospam-seallama@mailcity.com> said:

dan> is there a way to output what day it is? i used
dan> localtime(time) to get the date, month, and
dan> year, but i cant get the actual day. any
dan> pointers?

localtime() in an array context will give you the
day as well, q.v.

Also perldoc POSIX ==> strftime.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Mon, 22 Feb 1999 16:09:05 GMT
From: "donna k. hodges" <dkh@home.com>
Subject: parsing
Message-Id: <BifA2.6592$po.2945@c01read02.service.talkway.com>

how does parsing in PERL compare/differ from parsing in ksh (i.e., use
of sed, awk, nawk, etc.)?
--
Posted via Talkway - http://www.talkway.com
Surf Usenet at home, on the road, and by email -- always at Talkway.



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

Date: 25 Feb 1999 08:27:30 GMT
From: "Sheila  Eugenio" <seugenio@man.amis.com>
Subject: parsing
Message-Id: <01be6098$6b7b97f0$2bbe10ac@amipnet>

I am planning to read a tab file consisting of about 200 lines where each
line appears exactly like the one below:

01854-005-FTA.01                LAT87533.1  R-NVAL_BXSV-BOXSTOCK     
1291.0PS09-OCT-1998 13:08:18           314-OCT-1998 00:00:00FINISHNOPRCD  

How can I parse it so that when I write it to a new file, it will appear:

01854-005-FTA.01   LAT87533.1  R-NVAL_BXS 	V-BOXSTOCK     1291	PS  
09-OCT-1998  3  14-OCT-1998    FINISH		NOPRCD 

I want to insert some spaces, trim some decimal places and delete the hours
format. Thanks for all the help.



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

Date: Mon, 22 Feb 1999 08:23:32 -0600
From: "Steven T. Henderson" <stevenhenderson@prodigy.net>
Subject: Re: parsing
Message-Id: <gYfA2.59341$641.158975@news.san.rr.com>

very similar and all regex stuff *should* be the same.

donna k. hodges wrote in message ...
>how does parsing in PERL compare/differ from parsing in ksh (i.e., use
>of sed, awk, nawk, etc.)?
>--
>Posted via Talkway - http://www.talkway.com
>Surf Usenet at home, on the road, and by email -- always at Talkway.
>




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

Date: 22 Feb 1999 09:57:47 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: parsing
Message-Id: <36d18c8b@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    "Steven T. Henderson" <stevenhenderson@prodigy.net> writes:
:>how does parsing in PERL compare/differ from parsing in ksh (i.e., use
:>of sed, awk, nawk, etc.)?
:very similar and all regex stuff *should* be the same.

Oh no.  Not at all.  The shell tools do not have the power of 
perl's so-called regexes, and aren't integrated, either.

And I think you're using "parse" in a non-technical way, correct?
We have yacc and bison for parsing, not sed and awk.

--tom
-- 
    /* now make a new head in the exact same spot */
            --Larry Wall in cons.c from the perl source code


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

Date: Thu, 25 Feb 1999 08:50:59 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: parsing
Message-Id: <ebohlmanF7pCKz.DK2@netcom.com>

Sheila  Eugenio <seugenio@man.amis.com> wrote:
: I am planning to read a tab file consisting of about 200 lines where each
: line appears exactly like the one below:

: 01854-005-FTA.01                LAT87533.1  R-NVAL_BXSV-BOXSTOCK     
: 1291.0PS09-OCT-1998 13:08:18           314-OCT-1998 00:00:00FINISHNOPRCD  

: How can I parse it so that when I write it to a new file, it will appear:

: 01854-005-FTA.01   LAT87533.1  R-NVAL_BXS 	V-BOXSTOCK     1291	PS  
: 09-OCT-1998  3  14-OCT-1998    FINISH		NOPRCD 

: I want to insert some spaces, trim some decimal places and delete the hours
: format. Thanks for all the help.

Your data looks like it's in fixed-length record format, so the best way 
to split it up into fields is probably to use unpack(), more information 
on which can be obtained from the perlfunc (man page | HTML document | 
POD file).  I say "probably" because you *could* do it with a bunch of 
calls to substr(), but I find this less robust and maintainable (because 
you have to specify both start position and length for each field, 
manually adding them up as you go).

Once you've got your fields into variables, you simply do the 
transformations and then use print or (more likely) printf to output in 
your new format.



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

Date: Thu, 25 Feb 1999 19:54:27 -0600
From: "Wade T. Funk" <wfunk@dev.tivoli.com>
Subject: Passing data during runtime....
Message-Id: <36D5FED3.EF9735AA@dev.tivoli.com>

I have a script that runs as a large while loop.  While in the loop
I give commands to run other procedures in other files.  I am trying
to take a CGI approach to present a GUI for this.  My question is,
how do I pass data to this backgrounded script and get the results
from the other procedures' output?

If anyone can tell me how to use 'perldoc' I would also be much
appreciative.  I'm new to this stuff.

Thanks,

Wade



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

Date: 26 Feb 1999 10:58:04 -0500
From: Jonathan Feinberg <jdf@pobox.com>
To: "Wade T. Funk" <wfunk@dev.tivoli.com>
Subject: Re: Passing data during runtime....
Message-Id: <m3k8x5rwc3.fsf@joshua.panix.com>

"Wade T. Funk" <wfunk@dev.tivoli.com> writes:

> If anyone can tell me how to use 'perldoc' I would also be much
> appreciative.

You open a command prompt and type "perldoc foo" or 
"perldoc -f foofunc" or "perldoc -q searchstring".

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Tue, 23 Feb 1999 17:30:51 +0800
From: Jeremy <scijr@nus.edu.sg>
Subject: Passing of Parameter from one script to another
Message-Id: <36D2755F.468753A8@nus.edu.sg>

hi can anyone help ? I want to pass a value chosen from a popup-menu in
script A and passed it to script B to be displayed on screen. Is it
possible in CGI.pm ?

this may sound trivial but i'm really a newbie in perl. thanks !



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

Date: 23 Feb 1999 10:40:19 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Passing of Parameter from one script to another
Message-Id: <83n225sbjw.fsf@vcpc.univie.ac.at>

Re: Passing of Parameter from one script to another,
Jeremy <scijr@nus.edu.sg> said:

Jeremy> hi can anyone help ? I want to pass a value
Jeremy> chosen from a popup-menu in script A and
Jeremy> passed it to script B to be displayed on
Jeremy> screen. Is it possible in CGI.pm ?

Depends on what you mean by "passed".  Do you want
to invoke B as an external child process in A?  Or
is B to be invoked remotely through another CGI
"link"?

I assume you mean the latter, in which case see

    perldoc LWP
    perldoc URI::URL
    perldoc HTTP::Request

For the former case, see perldoc perlipc.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Wed, 24 Feb 1999 21:56:47 GMT
From: gibsonc@aztec.asu.edu
Subject: Passing two arrays to a subroutine
Message-Id: <7b1sir$ca0$1@nnrp1.dejanews.com>

What is the correct way of passing two arrays as parameters?

For example,


#****************************************************************************
sub GetEnums {
#****************************************************************************
#
# Description:

  local($structureName, $hFile, $nStr, $i, @tokens, %strcts) = @_ ;

I always seem to have trouble with the second array, or hash, it appears
empty, when it isn't.  Hope I didn't miss it in the Perl documentation...

Thanks for your time,
Craig

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 24 Feb 1999 14:36:01 -0800
From: Draco Paladin <paladin@uvic.ca>
To: gibsonc@aztec.asu.edu
Subject: Re: Passing two arrays to a subroutine
Message-Id: <Pine.A41.4.05.9902241429490.18132-100000@unix4.UVic.CA>

On Wed, 24 Feb 1999 gibsonc@aztec.asu.edu wrote:
[cc'd to poster]

> What is the correct way of passing two arrays as parameters?

[example snipped]

> I always seem to have trouble with the second array, or hash, it appears
> empty, when it isn't.  Hope I didn't miss it in the Perl documentation...

Perl, when passing parameters into or out of sub's, collapses all
parameters into one array (@_ inside the sub).

You can get away with passing in one array if it is the last thing passed
in eg.

&ExampleSub($scalar1, $scalar2, @array1);

sub ExampleSub {
	my ($var1, $var2, @arr1) = @_;
	# do stuff here
}

But this will only work with one array.  To pass more than one array or
hash you must pass in  references to the arrays or hashes.

Read
perldoc perlsub
perldoc perlref
for more information.

HTH

---------------------------------------------
Mother is the name for GOD on the lips and
hearts of all children.  - Eric Draven



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

Date: 24 Feb 1999 22:49:10 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Passing two arrays to a subroutine
Message-Id: <7b1vl6$hcq$3@info.uah.edu>

In article <7b1sir$ca0$1@nnrp1.dejanews.com>,
	gibsonc@aztec.asu.edu writes:
: What is the correct way of passing two arrays as parameters?

Please read the perlsub manpage, paying careful attention when you
reach the "Pass by Reference" section.

Greg
-- 
Democracy: Two wolves and a sheep voting on what's for dinner.


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

Date: 24 Feb 1999 19:00:43 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Passing two arrays to a subroutine
Message-Id: <36d4aecb@csnews>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, gibsonc@aztec.asu.edu writes:
:What is the correct way of passing two arrays as parameters?

Somehow you appear to have missed the proper answer when you studiously
searched the standard Perl documentation on your very own system.  It was
there waiting for you.  It's pretty obvious. I can't understand how you
missed it.

% man perlsub

    ...

       Pass by Reference

       If you want to pass more than one array or hash into a
       function--or return them from it--and have them maintain their
       integrity, then you're going to have to use an explicit pass-by-
       reference.  Before you do that, you need to understand references
       as detailed in the perlref manpage.  This section may not make
       much sense to you otherwise.

       Here are a few simple examples.  First, let's pass in several
       arrays to a function and have it pop all of then, return a new
       list of all their former last elements:

           @tailings = popmany ( \@a, \@b, \@c, \@d );

           sub popmany {
               my $aref;
               my @retlist = ();
               foreach $aref ( @_ ) {
                   push @retlist, pop @$aref;
               }
               return @retlist;
           }

       Here's how you might write a function that returns a list of keys
       occurring in all the hashes passed to it:

           @common = inter( \%foo, \%bar, \%joe );
           sub inter {
               my ($k, $href, %seen); # locals
               foreach $href (@_) {
                   while ( $k = each %$href ) {
                       $seen{$k}++;
                   }
               }
               return grep { $seen{$_} == @_ } keys %seen;
           }

       So far, we're using just the normal list return mechanism.  What
       happens if you want to pass or return a hash?  Well, if you're
       using only one of them, or you don't mind them concatenating, then
       the normal calling convention is ok, although a little expensive.

       Where people get into trouble is here:

           (@a, @b) = func(@c, @d);
       or
           (%a, %b) = func(%c, %d);

       That syntax simply won't work.  It sets just @a or %a and clears
       the @b or %b.  Plus the function didn't get passed into two
       separate arrays or hashes: it got one long list in @_, as always.

       If you can arrange for everyone to deal with this through
       references, it's cleaner code, although not so nice to look at.
       Here's a function that takes two array references as arguments,
       returning the two array elements in order of how many elements
       they have in them:

           ($aref, $bref) = func(\@c, \@d);
           print "@$aref has more than @$bref\n";
           sub func {
               my ($cref, $dref) = @_;
               if (@$cref > @$dref) {
                   return ($cref, $dref);
               } else {
                   return ($dref, $cref);
               }
           }

       It turns out that you can actually do this also:

           (*a, *b) = func(\@c, \@d);
           print "@a has more than @b\n";
           sub func {
               local (*c, *d) = @_;
               if (@c > @d) {
                   return (\@c, \@d);
               } else {
                   return (\@d, \@c);
               }
           }

       Here we're using the typeglobs to do symbol table aliasing.  It's
       a tad subtle, though, and also won't work if you're using my()
       variables, because only globals (well, and local()s) are in the
       symbol table.

       If you're passing around filehandles, you could usually just use
       the bare typeglob, like *STDOUT, but typeglobs references would be
       better because they'll still work properly under use strict
       'refs'.  For example:

           splutter(\*STDOUT);
           sub splutter {
               my $fh = shift;
               print $fh "her um well a hmmm\n";
           }

           $rec = get_rec(\*STDIN);
           sub get_rec {
               my $fh = shift;
               return scalar <$fh>;
           }

       Another way to do this is using *HANDLE{IO}, see the perlref
       manpage for usage and caveats.

       If you're planning on generating new filehandles, you could do
       this:

           sub openit {
               my $name = shift;
               local *FH;
               return open (FH, $path) ? *FH : undef;
           }

       Although that will actually produce a small memory leak.  See the
       bottom of the open() entry in the perlfunc manpage for a somewhat
       cleaner way using the IO::Handle package.

    ...

% man perlfaq7

NAME
    perlfaq7 - Perl Language Issues ($Revision: 1.24 $, $Date:
    1999/01/08 05:32:11 $)

DESCRIPTION

 ...

  How can I pass/return a {Function, FileHandle, Array, 
      Hash, Method, Regexp}?

    With the exception of regexps, you need to pass references to
    these objects. See the section on "Pass by Reference" in the
    perlsub manpage for this particular question, and the perlref
    manpage for information on references.

    Passing Variables and Functions
        Regular variables and functions are quite easy: just pass
        in a reference to an existing or anonymous variable or
        function:

            func( \$some_scalar );

            func( \@some_array  );
            func( [ 1 .. 10 ]   );

            func( \%some_hash   );
            func( { this => 10, that => 20 }   );

            func( \&some_func   );
            func( sub { $_[0] ** $_[1] }   );

    Passing Filehandles
        To pass filehandles to subroutines, use the `*FH' or
        `\*FH' notations. These are "typeglobs" - see the section
        on "Typeglobs and Filehandles" in the perldata manpage
        and especially the section on "Pass by Reference" in the
        perlsub manpage for more information.

        Here's an excerpt:

        If you're passing around filehandles, you could usually
        just use the bare typeglob, like *STDOUT, but typeglobs
        references would be better because they'll still work
        properly under `use strict 'refs''. For example:

            splutter(\*STDOUT);
            sub splutter {
                my $fh = shift;
                print $fh "her um well a hmmm\n";
            }

            $rec = get_rec(\*STDIN);
            sub get_rec {
                my $fh = shift;
                return scalar <$fh>;
            }

        If you're planning on generating new filehandles, you
        could do this:

            sub openit {
                my $name = shift;
                local *FH;
                return open (FH, $path) ? *FH : undef;
            }
            $fh = openit('< /etc/motd');
            print <$fh>;

    Passing Regexps
        To pass regexps around, you'll need to either use one of
        the highly experimental regular expression modules from
        CPAN (Nick Ing-Simmons's Regexp or Ilya Zakharevich's
        Devel::Regexp), pass around strings and use an exception-
        trapping eval, or else be very, very clever. Here's an
        example of how to pass in a string to be regexp compared:

            sub compare($$) {
                my ($val1, $regexp) = @_;
                my $retval = eval { $val =~ /$regexp/ };
                die if $@;
                return $retval;
            }

            $match = compare("old McDonald", q/d.*D/);

        Make sure you never say something like this:

            return eval "\$val =~ /$regexp/";   # WRONG

        or someone can sneak shell escapes into the regexp due to
        the double interpolation of the eval and the double-
        quoted string. For example:

            $pattern_of_evil = 'danger ${ system("rm -rf * &") } danger';

            eval "\$string =~ /$pattern_of_evil/";

        Those preferring to be very, very clever might see the
        O'Reilly book, *Mastering Regular Expressions*, by
        Jeffrey Friedl. Page 273's Build_MatchMany_Function() is
        particularly interesting. A complete citation of this
        book is given in the perlfaq2 manpage.

    Passing Methods
        To pass an object method into a subroutine, you can do
        this:

            call_a_lot(10, $some_obj, "methname")
            sub call_a_lot {
                my ($count, $widget, $trick) = @_;
                for (my $i = 0; $i < $count; $i++) {
                    $widget->$trick();
                }
            }

        Or you can use a closure to bundle up the object and its
        method call and arguments:

            my $whatnot =  sub { $some_obj->obfuscate(@args) };
            func($whatnot);
            sub func {
                my $code = shift;
                &$code();
            }

        You could also investigate the can() method in the
        UNIVERSAL class (part of the standard perl distribution).

    ...


-- 
    /* now make a new head in the exact same spot */
            --Larry Wall in cons.c from the perl source code


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

Date: Wed, 24 Feb 1999 17:51:15 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Passing two arrays to a subroutine
Message-Id: <3pv1b7.oic.ln@magna.metronet.com>

gibsonc@aztec.asu.edu wrote:
: What is the correct way of passing two arrays as parameters?


   Don't pass two arrays.

   Pass two references to arrays instead.

   See the perlref.pod man page.


: I always seem to have trouble with the second array, or hash, it appears
: empty, when it isn't.  Hope I didn't miss it in the Perl documentation...


   Quite astonishing that you managed to miss it in the docs.

   I would think that one of the first places folks would look
   when having a problem with a subroutine is the perlsub.pod
   doc, entitled "Perl subroutines".

   The second paragraph there describes the problem you are
   having and how to fix it...


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Thu, 25 Feb 1999 11:54:52 GMT
From: massimobalestra@my-dejanews.com
Subject: Re: Passing two arrays to a subroutine
Message-Id: <7b3dma$k88$1@nnrp1.dejanews.com>

  Greg Bacon <gbacon@cs.uah.edu> wrote:
> In article <7b1sir$ca0$1@nnrp1.dejanews.com>,
> 	gibsonc@aztec.asu.edu writes:
> : What is the correct way of passing two arrays as parameters?

As usual there is more than one way to do it:
The first (better) is to pass the references

The second can be collapse the two arrays into two strings comma (or another
character) separated, pass the two stings normally to the array and then use
the "split" function to come back to an array.

It is ugly and inefficient but it works.

 Massimo Balestra
 System Engineer
 Torino Italy

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 26 Feb 1999 00:06:59 -0500
From: Daniel Dufour <ddufour@royaume.com>
Subject: password PWS
Message-Id: <36D62BF3.6F02F245@royaume.com>

Hi

I have personnal web server on Win98 computer.

I have a PERL section of my website that is personnel, I want to add a
password to keep others out.

How I do this? It's easy with NT but I don't know with Win98

Thank
Daniel





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

Date: 26 Feb 1999 07:54:25 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: password PWS
Message-Id: <7b5jvh$88c$2@client2.news.psi.net>

Daniel Dufour (ddufour@royaume.com) wrote on MMV September MCMXCIII in
<URL:news:36D62BF3.6F02F245@royaume.com>:
^^ Hi
^^ 
^^ I have personnal web server on Win98 computer.
^^ 
^^ I have a PERL section of my website that is personnel, I want to add a
^^ password to keep others out.
^^ 
^^ How I do this? It's easy with NT but I don't know with Win98


That's not a Perl question. Go to rec.pets.camels, say you have a CAMEL
section of your website that is "personnel" (you've people working for 
you on that section?) and want to add a password to keep others out.




Abigail
-- 
perl  -e '$_ = q *4a75737420616e6f74686572205065726c204861636b65720a*;
          for ($*=******;$**=******;$**=******) {$**=*******s*..*qq}
          print chr 0x$& and q
          qq}*excess********}'


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

Date: Fri, 26 Feb 1999 01:19:44 GMT
From: Sebastien.Barre@utc.fr (Sibastien Barri)
Subject: pb with Cwd::getcwd() ! [perl 5.005_02 / Cygwin32 B.20.1]
Message-Id: <36d9f665.6589134@news.club-internet.fr>

(crossposted to the cygwin32 mailing list also)

I'm trying to build/install Perl 5.005_02 for Cygwin32 B20.1
(NT4.0/SP4), and it fails while installing the HTML-pod pages.

After some investigation in the installperl script, I found that the
Cwd::getcwd() (= get pathname of current working directory) was
responsible :

Use ::Cwd;
print getcwd();

=> 
readdir(./..): No such file or directory at yo.pl line 2

If I try to use using cwd() (= same as getcwd but is
implemented using the most natural and safe form for the current
architecture) instead of getcwd();

Use ::Cwd;
print cwd();

=>
/d/devel/gnuwin32/root/tmp/perl5.005_02

which seems OK, although /d/devel/gnuwin32/root is mounted to /, hence
it should better returns /tmp/perl5.005_02.

The problem is, getcwd() seems to be used in many other files in the
distribution, therefore I'd like to fix/understand it in a more general
way before starting to replace all instance of getcwd() with cwd().

Thanks a lot.
-- 
Sebastien Barre : http://www.hds.utc.fr/~barre/


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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