[7801] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1426 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Dec 6 07:08:12 1997

Date: Sat, 6 Dec 97 04:00:25 -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           Sat, 6 Dec 1997     Volume: 8 Number: 1426

Today's topics:
     Re: $x.xx in PERL <spp@spp.iwaynet.net>
     Re: ... rumours run amok (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: Any opinions/reviews of Perl Resource Kit? <andy_collier@customer-insight.com>
     Re: Communication through pipes with su (Nathan V. Patwardhan)
     Re: Cross-platform way of interacting with user? (John Brownie)
     eval and open: append vs new, i.e. >> vs > (Darwin O.V. Alonso)
     Re: Finding ASCII/ANSI numbers <barnett@houston.Geco-Prakla.slb.com>
     Re: How do I print all but the first variable in an arr <wtansill@erols.com>
     Re: How do I print all but the first variable in an arr (Jeff Fisher)
     HTTP/1.0 500 Server Error (blahblah.cgi is not a valid  (Alan)
     Inserting only the unique elements into an array ... (Narayan Moni)
     need help with concatenation operation <webmaster@aquafan.com>
     Re: need the skinny on my() vs local() (Faust Gertz)
     Re: Odd minus/modulus behavior (Tushar Samant)
     Re: oraperl twod@not.valid
     Re: Perl editor needed <wtansill@erols.com>
     Re: Perl4 is not Y2K (was Re: Forced to use brain-dead  <rootbeer@teleport.com>
     problem with my() and s// <mreimer@vpop.net>
     Re: Q: background process in Perl for a CGI <rootbeer@teleport.com>
     Re: Recommended PERL-book? <tex@collegenet.spam-is-bad.com>
     Re: Seems to be just another  5.004_* bug:-( (Ilya Zakharevich)
     Re: the skinny on my() vs local() -  thanks to all <tchrist@mox.perl.com>
     Re: the skinny on my() vs local() -  thanks to all (Tushar Samant)
     Re: use CGI <rootbeer@teleport.com>
     Re: use CGI (I R A Aggie)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 05 Dec 1997 16:12:56 -0500
From: Stephen P Potter <spp@spp.iwaynet.net>
Subject: Re: $x.xx in PERL
Message-Id: <ydb90tz7auf.fsf@spp.iwaynet.net>

"Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print> writes:
> perrella andrew c wrote in message ...
> > I have writte a script that is used for catalog orders.  It sums
> >the items taken, figures out tax and shipping and then adds them all up.
> >the problem is that I can't seem to truncate the total after 2 decimal
> >places.
> 
> The canonical way to do this* is something like
> 
> $total = int(($total + .005) * 100) / 100;
> 
> * a fancy way of saying "This is how we used to do it in TRS-80 Basic" :D

Actually, there *is* a canonical way in perl.

Perlfaq4 says this:
Does perl have a round function? ...

For rounding to a certain number of digits, sprintf() or printf() is
usually the easiest route. ...

-spp

-- 
Stephen P Potter     |~~~~|                     |~~~~|   spp@colltech.com
Ph: 312-781-1111     |____| C o l l e c t i v e |____|   Team "OH, Yeah!"
Pg: 800-759-8888,    |_______                 _______|   
      571-1869              []  technologies []        jthome.jthome.com/~spp


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

Date: Fri, 05 Dec 97 18:59:48 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: ... rumours run amok
Message-Id: <348895a2$3$ofn$mr2ice@speaker>

In <8c90u0pqqx.fsf@gadget.cscaper.com>, on 12/04/97 at 05:39 PM,
   Randal Schwartz <merlyn@stonehenge.com> said:
+-----
| On IRC-EFNET #perl the other day, we came up with some more precisely
| accurate, but scary phrases:
+--->8

Waitaminute... you guys decided to get away from the trials of the noisegroups
by moving to EFNet IRC?

*boggle*

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)


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

Date: Fri, 05 Dec 1997 14:41:41 -0700
From: Andy Collier <andy_collier@customer-insight.com>
Subject: Re: Any opinions/reviews of Perl Resource Kit?
Message-Id: <34887515.CD06B7EB@customer-insight.com>

brian d foy wrote:
> 
> In article <348768D0.7BB29B30@customer_insight.com>, andy_collier@customer-insight.com wrote:
> 
[snip]
> 
> >What REALLY comes with it?  And is it worth the price/time/trouble?
> 
> have you seen <URL:http://perl.oreilly.com/prk_index.html>?

yes and its not really all that informative - more marketese schlock
than tech content or details.

> worth is a relative measure.  sorta depends on how much you use it.  

Yes, quite true.  I am helping to change a database warehousing project
from csh and awk oever to perl based scripts, and am also engaged in
trying to infiltrate object oriented methods as I do so.  Most folks
here are not that experienced with perl, so I could use all the help I
can get to give them objects and modules (i.e. canned solutions) to code
their scripts with.  Just looking for an evaluation of the quality and
quantity (and helpfulness/utility) of this package IYHO.

Regards,

A.C.


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

Date: 5 Dec 1997 22:24:54 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Communication through pipes with su
Message-Id: <669uvm$ohp@fridge.shore.net>

Jeff Yoak (jeff@yoak.com) wrote:

: 	open(COMMAND, "|su $username -c '$command 2>&1' |");

How does *this* work?  Wouldn't it just be easier to use Net::Telnet?
Or the IPC modules?  Or have I misunderstood your question?

--
Nathan V. Patwardhan
please don't send spam to pres@whitehouse.gov


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

Date: Fri, 05 Dec 1997 14:05:58 +0200
From: john.brownie@pp.inet.fi (John Brownie)
Subject: Re: Cross-platform way of interacting with user?
Message-Id: <john.brownie-ya02408000R0512971405580001@news.inet.fi>

In article <666qes$jir$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com (Tom
Christiansen) wrote:

>    john.brownie@pp.inet.fi (John Brownie) writes:
>:I'm a newcomer to Perl, although with experience of C, awk, etc.  I've got 
>:a successful script working on the Mac, but I need it to work on DOS 
>:and/or Windows (probably both 3.1 & 95).  The major problem is how to 
>:handle interacting with the user.
>
>There's a great deal to be said for using a command line.

An enigmatic comment, Tom.  Do you mean that I should be using a system
such as DOS or Unix which provides a command line interface?  I don't mind
such systems (I started with Unix in 1980), but my audience are Mac,
Windows and DOS people, who are not terribly computer-literate.

Basically, the idea of the program is to extract information from two
database files and produce a report in a readable format.  Obviously, the
location of the input files can be specified as a command line option (or
as a "drag and drop" option on the Mac, although I haven't checked that out
yet).  There is also an option for a translation table, which means looking
for another file, again a possible command line option.  The difficult part
is that, once one of the files is processed, I need the user to tell me
which parts of the other file to process, which implies (to me, at least)
that I need to interact directly with the user.  I do that with a dialog
box in my Mac version.  I can do it with STDIN/STDOUT in DOS, but I need
another dialog routine for Windows, I imagine.  Is there a module out there
for that?

My idea at present is that there would be a separate module which would
handle all this interaction.  I think that I would probably be doing
different versions of it for each platform, but a single solution would be
nicer!  As usual, I don't want to reinvent the wheel, if the right wheel is
available already.

John Brownie


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

Date: 5 Dec 1997 22:21:34 GMT
From: dalonso@u.washington.edu (Darwin O.V. Alonso)
Subject: eval and open: append vs new, i.e. >> vs >
Message-Id: <669upe$j5a$1@nntp6.u.washington.edu>


Under some conditions I want to open a new file for writing,
and under other conditions for appending to an existing file. I.E.:

   open OUT,   "> $newfile"; vs open OUT,   ">> $file";

For conciseness, I'ld like to do it as follows:

  if ( $somecondition ){ $funnel = '>'; }else{$funnel = '>>';}
  open OUT0,   " eval { $funnel } $file0" or die "couldn't open $file";
  open OUT1,   " eval { $funnel } $file1" or die "couldn't open $file";
  open OUT2, ...

However that doesn't seem to work (see example program below). 
I would appreciate advice on how to make this work or alternatives.

Thanks,
Darwin



The following gives "couldn't open t_new at ./openappend line 10."
  
  #!/usr/local/bin/perl -w
  
  $test_newfile = "test_new";
  open TOUTD,   "> $test_newfile" or die "couldn't open  $test_newfile";
  print TOUTD "$test_newfile\n";
  
  $destroy = '>';
  $newfile = "t_new";
  open OUTD,   " eval { $destroy } $newfile" or die "couldn't open $newfile";
  print OUTD "$newfile\n";
  
  $append = '>>';
  $appendfile = "t_append";
  
  system( 'touch', $appendfile );
  open OUTA,   " eval { $append  } $appendfile" or die "couldn't open $appendfile";
  print OUTA "$newfile\n";
  
  close( TOUTD); close( OUTD); close( OUTA);


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

Date: Fri, 05 Dec 1997 15:46:45 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Finding ASCII/ANSI numbers
Message-Id: <34887642.72FD9602@houston.Geco-Prakla.slb.com>

As always, TMTOWTDI..... :-)

This works, but may be slow.....


#!/usr/local/bin/perl -w
#
@list = (65, 66, 67, 68);
$numbers = pack("C*",@list);
print STDOUT "$numbers\n";
foreach $character (split(//,$numbers)) {
        $letters = unpack("C*",$character);
        print STDOUT "$letters\n";
}

__END__

Produces:
ABCD
65
66
67
68



Dave

--
"Security through obscurity is no security at all."
                -comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
* Schlumberger Geco-Prakla   (281) 596-1434 (Office Number)            *
* 1325 S. Dairy Ashford      (281) 596-1807 (Fax)                      *
* Houston, TX 77077                                                    *
------------------------------------------------------------------------





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

Date: Fri, 05 Dec 1997 18:47:37 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <34889299.1AE8@erols.com>

Tom Christiansen wrote:
> 
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, jzp@usa.net writes:
> :I am fairly new to perl and this is the situation I am in. I need to
> :be able to print all but the first variable in a regular array. Do I
> :make sense? Basically I have an array of:
> :@stuff
> :and I want to print $stuff[1] and $stuff[2] and $stuff[3] etc BUT NOT
> :$stuff[0].
> 
> Simply use:
> 
>     print "@stuff[ 1 .. $#stuff ]\n";
> 
> or some less-quoted variation thereon.
> 
> --tom
> --
>         Tom Christiansen        tchrist@jhereg.perl.com
>     The only disadvantage I see is that it would force everyone to get Perl.
>     Horrors.  :-)
>                     --Larry Wall in  <8854@jpl-devvax.JPL.NASA.GOV>

But this does not print a newline after each element in the version of
PERL (on a DOS/Win '95 system) that I use.  Rather, it prints each
element on a single line separated by one space.  The newline prints
after all of the elements.  I'm using version 5.004_02.
-- 

How do I set my laser printer to "stun"?


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

Date: 6 Dec 1997 00:03:21 GMT
From: rzxtlg@dogbert.ies-energy.com (Jeff Fisher)
Subject: Re: How do I print all but the first variable in an array?
Message-Id: <slrn68h5i9.741.rzxtlg@dogbert.ies-energy.com>

[posted and mailed] 

On Fri, 05 Dec 1997 18:47:37 -0500, William B. Tansill, III
     <wtansill@erols.com> said:
> Tom Christiansen wrote:
> > 
> >  [courtesy cc of this posting sent to cited author via email]
> > 
> > In comp.lang.perl.misc, jzp@usa.net writes:
> > :I am fairly new to perl and this is the situation I am in. I need to
> > :be able to print all but the first variable in a regular array. Do I
> > :make sense? Basically I have an array of:
> > :@stuff
> > :and I want to print $stuff[1] and $stuff[2] and $stuff[3] etc BUT NOT
> > :$stuff[0].
> > 
> > Simply use:
> > 
> >     print "@stuff[ 1 .. $#stuff ]\n";
> > 
> > or some less-quoted variation thereon.
> > 
> But this does not print a newline after each element in the version of
> PERL (on a DOS/Win '95 system) that I use.  Rather, it prints each
> element on a single line separated by one space.  The newline prints
> after all of the elements.  I'm using version 5.004_02.
> -- 

Ok, how about
foreach( @stuff[ 1 .. $#stuff]){
	print "$_\n";
}

-- 
Jeff Fisher                       | ...I want to be on the side of the many.
UNIX Sys Admin - IES Industries   | Therefore, I take great pains to explain
http://opus.ies-energy.com/jeff/  | to as many people as possible.
                                  |                      - Johannes Kepler


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

Date: Fri, 05 Dec 1997 23:58:59 GMT
From: arich@u.washington.edu (Alan)
Subject: HTTP/1.0 500 Server Error (blahblah.cgi is not a valid Windows NTapplication.)
Message-Id: <348893dd.27774547@news.u.washington.edu>

I get an 'HTTP/1.0 500 Server Error..' message everytime I attempt to
post to a cgi script.  I'm using Perl 5 for NT.  Is there some
configuration necessary on my NT server's IIS to get it to run cgi
scripts?


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

Date: Sat, 06 Dec 1997 00:23:56 GMT
From: anish@worldnet.att.net (Narayan Moni)
Subject: Inserting only the unique elements into an array ...
Message-Id: <66a5rb$qs7@bgtnsc01.worldnet.att.net>
Keywords: Pass by reference, Array

Hi fellow PERLers

Have a question for you. I am trying to insert an element into an array
I want the element to be inserted ONLY if the element is not already 
in the list. I would prefer if I did not have to search the array
element by element. The code I have looks somewhat like this ( I 
have deleted a bunch of code so as to focus on the questions I have ).

@Values = ("abc", "def");

&ReadValues (\@Values);

sub ReadValues {
    my ($List) = @_;
    $Element = "abc";
    &InsertIntoList ($List, $Element);
}

sub InsertIntoList {
    my ($List) = @_;
    if ( grep ($List, $Element) ) {
        $List->[$#List] = $Element;
    }
}

Now my question to you is 

1/ there a better way to go about this? If there is then I would 
       really like to know about it
2/ In the debugger when I check the value of $#List in the function
       InsertIntoList, it is -1. It seems that if I pass an array by
       reference then it looses all these properties of aan array.
       Is that a valid conclusion?
3/ Can grep be used like above?

Thanks a lot for the info. You could either send me mail at 
anish@worldnet.att.net or post your responses to this newsgroup.

Sincerely,
Anish.


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

Date: 5 Dec 1997 23:38:01 GMT
From: "Aqua Fantasies" <webmaster@aquafan.com>
Subject: need help with concatenation operation
Message-Id: <01bd01d6$40e63620$255583d0@lbowen.vic.com>

Could someone please explain what line 5 does in this little snippet of
code?  It is derived from the Camel book and just doesn't make sense to me.


 
01  open(FILE, "temprefs.txt") or die "Can't open temprefs: $!\n";
02  while ($line = <FILE>)
03  {
04  ($total, $referer) = split(" ", $line);
05  $totals{$referer}  .= $total . " ";
06  }
07  foreach $referer (sort keys %totals) {
08  $finaltotal = 0;
09  @totals = split(" ", $totals{$referer});
10  foreach $total (@totals) {
11  $finaltotal += $total;
12  }
13  print "$finaltotal\t$referer\n";  
14  }
15  close (FILE);

I am trying to teach myself Perl after having been a true-blue C++ believer
and sometimes perl seems quite strange.  Although, I am now totally sold on
Perl for CGI--so much easier and more flexible.

Thanks for the help.

Laurel Bowen
lbowen@vic.com


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

Date: Fri, 05 Dec 1997 23:27:20 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: need the skinny on my() vs local()
Message-Id: <34888a93.3166850@news.wwa.com>

On 4 Dec 1997 19:42:55 GMT, Tom Christiansen <tchrist@mox.perl.com>
wrote:

> [lots of good stuff snipped]
>
>--tom, who can't believe anyone made it this far.

Hey Tom, could your article be made part of the FMTEYEWTK series so
the perplexed could be guided to
http://www.perl.com/CPAN-local/doc/FMTEYEWTK/index.html as well as
http://www.perl.com/CPAN-local/doc/FAQs/FAQ/PerlFAQ.html and
http://www.perl.com/CPAN-local/doc/manual/html/pod/perlsub.html ?


TIA

Faust Gertz
Philosopher at Large


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

Date: 5 Dec 1997 17:44:39 -0600
From: scribble@tekka.wwa.com (Tushar Samant)
Subject: Re: Odd minus/modulus behavior
Message-Id: <66a3l7$k59@tekka.wwa.com>

mcafee@breakout.rs.itd.umich.edu writes:
>> perl -e '$a = "xyz"; print ((-length($a)) % 4)'
>-3

Please file a bug report.



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

Date: 5 Dec 1997 22:01:21 GMT
From: twod@not.valid
Subject: Re: oraperl
Message-Id: <669tjh$fac$1@vnetnews.value.net>

Kuntal Daftary (daftary@_remove_to_send_email_.cisco.com) wrote:
: using sqlplus, i login using the following:
: % sqlplus user/pass@db


Try doing:

$lda = &ora_login('', 'user/pass@db', '') ....

IAP
--
I am using anti-spam measures, please replace 'not.valid' with 'value.net'


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

Date: Fri, 05 Dec 1997 18:31:38 -0500
From: "William B. Tansill, III" <wtansill@erols.com>
Subject: Re: Perl editor needed
Message-Id: <34888EDA.3E09@erols.com>

Bill Guindon wrote:
> 
<snip>

> That's more likely caused by FTPing your files in binary mode.  Make
> sure you use ASCII for ALL CGI files (.pl, .cgi, .pm, etc).
 
Yup.  Binary mode FTP's work great for bianary files.  For text files
the ASCII option will remove/add CR's as appropriate to the direction
your sending the file(s).

-- 

How do I set my laser printer to "stun"?


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

Date: Fri, 5 Dec 1997 13:20:15 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: Perl4 is not Y2K (was Re: Forced to use brain-dead perl 4 -- how do I accomplish task that is simple in perl 5 ?)
Message-Id: <Pine.GSO.3.96.971205131905.29415Q-100000@usertest.teleport.com>

On Fri, 5 Dec 1997, Bart Lateur wrote:

> So what will people think of Perl4 once we get to, say, Perl9?

That's an idea: Make the next version of Perl have a number that's so
large that nobody will want to keep using Perl4.

    Perl98!

Hmmm... On the other hand...

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 05 Dec 1997 15:21:53 -0800
From: Matthew Reimer <mreimer@vpop.net>
Subject: problem with my() and s//
Message-Id: <34888C91.BABA9887@vpop.net>

I'm trying to do variable substitution on a scalar with s//, but
apparently it won't work with my variables. Is this a bug? Anybody have
a workaround?

Matt


#!/usr/local/bin/perl5

my $SOME_VAR = "ABCD";  # take out my and it will work
my $string = 'the variable is $SOME_VAR';

$string =~ s/\$(\w+)/${$1}/g;
print "string: $string\n";

exit;


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

Date: Fri, 5 Dec 1997 13:37:03 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Leo West <lwest@imaginet.fr>
Subject: Re: Q: background process in Perl for a CGI
Message-Id: <Pine.GSO.3.96.971205133540.29415U-100000@usertest.teleport.com>

On Fri, 5 Dec 1997, Leo West wrote:

> I tried several kind of forks (2 forks, killing the first child)
> but the httpd always waits until the parent and children process both
> end.

Tell it that there's nothing to wait for by closing the standard IO
streams. Of course, there's nothing Perl-specific about that; this should
be clearly explained in the FAQ for a newsgroup about CGI. Hope this
helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 05 Dec 1997 13:36:29 -0800
From: Austin Schutz <tex@collegenet.spam-is-bad.com>
Subject: Re: Recommended PERL-book?
Message-Id: <348873DD.37DE@collegenet.spam-is-bad.com>

Christian Bjelle wrote:
> 
> Hello.
>         I want to find a book that describes the basics of PERL, that also
> doesn't get useless after a few days; i.e. it should be useful as a
> reference when the PERL-basics has stuck in my head :)
> I suppose there is some book out there that is to PERL what 'The C
> programming language' by K&R is to C.
> Many thanks in advance. (By the way, this question is most likely
> answered in an faq somewhere isn't it?)

	There's a section on books on www.perl.com. It has a (slightly biased)
section devoted to Perl books.
	Here's my basic take on it:

	You can't go wrong buying any of the O'Reilly perl books. They are the
de-facto standard, and often times when people ask questions the
response will be something like 'didn't you read about that in the Camel
book, p67?'.
	This is not to say there aren't other good perl books out there. I
found the Perl 5 Interactive Course by Jon Orwant very good despite its
being fraught with technical errors. I have yet to find any book that
stacks up to any of the O'Reilly books as overall reference material,
however. Ymmv.

	Austin


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

Date: 5 Dec 1997 22:49:38 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Seems to be just another  5.004_* bug:-(
Message-Id: <66a0e2$593$1@agate.berkeley.edu>

In article <Pine.GSO.3.96.971204141220.4421N-100000@usertest.teleport.com>,
Tom Phoenix  <rootbeer@teleport.com> wrote:
> >      Well, anyway I don't like that this little thing
> > 
> > 	 s/<([^>]+)*>//;
> > 
> >    could hang-up your script now under 5.004_04.
> 
> It's written in a way that can waste a lot of time. That's no different in
> principle than this.
> 
>     for ($n=1; $n < 1e12; $n++) { sleep 1 }

To get the semantic of the above RE, omit the `sleep' part, it is too
gentle to your processor ;-).

Ilya


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

Date: 5 Dec 1997 22:36:53 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: the skinny on my() vs local() -  thanks to all
Message-Id: <669vm5$hcc$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author et alia]
 [he wickedly stealth cc'd me]

In comp.lang.perl.misc, "Dave Kaufman" <davidk@cnct.com> writes:
:1:  my declares new variables and local scopes existing ones.

Your use of scope there is tehnically incorrect.  You might
prefer "affects" or something.

:2.: locally scoped variables stay in scope into nested subroutine calls.

Hm...  There too.  local doesn't determine a scope -- its extent
is through the end of the current scope, however.

Pehraps it's too esoteric a point though.

:So, for my situtaion, where I was moving a bunch of Matt Wright's cookbook
:routines (great book, get it!) into my programs, I would not have wanted to
:change the local's to my's because they were there so that one of his
:routines could call another of his routines and keep scope.

Oh my.  I didn't there was a book.  Of Matt's scripts?  Really?
And they use local all over?  Oh my.

--tom
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


    "A journey of a thousand miles continues with the second step." --Larry Wall


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

Date: 5 Dec 1997 19:00:04 -0600
From: scribble@tekka.wwa.com (Tushar Samant)
Subject: Re: the skinny on my() vs local() -  thanks to all
Message-Id: <66a82k$pst@tekka.wwa.com>

davidk@nospam.cnct.com writes:
>1:  my declares new variables and local scopes existing ones.
>
>2.: locally scoped variables stay in scope into nested subroutine calls.
>My-declared variables cease to exist outside of their home turf code block,
>thus exposing any globals of the same name.

This is not how the word "scope" is used, so I don't know what you mean.
I hope you got it right.

>So, for my situtaion, where I was moving a bunch of Matt Wright's cookbook
>routines (great book, get it!) into my programs, I would not have wanted to
>change the local's to my's because they were there so that one of his
>routines could call another of his routines and keep scope.

Let me put forward an argument:

1. You just heard from a knowledgeable person almost never to use local(). 
2. You have before you programs which have local() all over the place.

Do you want these programs to be exemplary for you? You seem to be going
even further, and PASTING them in your own programs. If you do understand
about my() and local(), the thought of it should make your skin crawl ...  

Actually I even visited this website and looked at an example program.
It was more than local() abuse -- it was a multimedia sensory onslaught.
I experienced searing, elemental terror, followed by excruciating physical
pain. It's for the sake of my suffering body and broken spirit that I beg
you to throw the book away. What you will lose in invested money, you will
gain a hundredfold in the glow that comes from comforting a fellow human.

After that, go to <http://www.stonehenge.com/merlyn/WebTechniques/>.



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

Date: Fri, 5 Dec 1997 13:41:35 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Thomas Paine <paineta@edp.net>
Subject: Re: use CGI
Message-Id: <Pine.GSO.3.96.971205133719.29415V-100000@usertest.teleport.com>

On Fri, 5 Dec 1997, Thomas Paine wrote:

> I have a perl script that was running on a DEC Alpha machine and it had
> the following line. 
> 
> use CGI qw(:standard);
> 
> I am trying to make this script run on a NT web server, but I am not
> having much luck.  Could someone possibly point me in the right
> direction. 

Make sure that the server is plugged in. Make sure that it's turned on. 
Make sure that it's connected to the Internet. Make sure that it's
properly configured. Make sure that it's not running out of disk space or
memory. Make sure that a recent version of Perl is installed. Make sure
that a recent version of the CGI module is properly installed on that
machine. Make sure that your script is using the module as documented. If
those steps don't fix it, you'll probably want to reveal the secret way in
which you're "not having much luck". :-) 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Fri, 05 Dec 1997 17:06:44 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: use CGI
Message-Id: <-0512971706440001@aggie.coaps.fsu.edu>

In article
<Pine.GSO.3.96.971205133719.29415V-100000@usertest.teleport.com>, Tom
Phoenix <rootbeer@teleport.com> wrote:

+ Make sure that the server is plugged in. Make sure that it's turned on. 
+ Make sure that it's connected to the Internet. Make sure that it's
+ properly configured. Make sure that it's not running out of disk space or
+ memory. Make sure that a recent version of Perl is installed. Make sure
+ that a recent version of the CGI module is properly installed on that
+ machine. Make sure that your script is using the module as documented. If
+ those steps don't fix it, you'll probably want to reveal the secret way in
+ which you're "not having much luck". :-) 

[sounds of walking...sounds of slipping...'AAAAAAAAAiiiiieeeee' *thud*ouch*]

Tom, you really need to label your posts dripping with sarcasm better. I
nearly broke my dad-gummed neck on this one.

James - fortunately no beverage was involved, or there'd be monitor/keyboard
        damage, too... ;)

-- 
Consulting Minister for Consultants, DNRC
Support the anti-Spam amendment <url:http://www.cauce.org/>
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/perl/faq/idiots-guide.html>


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

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

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