[6925] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 550 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 31 20:07:19 1997

Date: Sat, 31 May 97 17:00:19 -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           Sat, 31 May 1997     Volume: 8 Number: 550

Today's topics:
     Re: Can you Modify a Record "in-Line?" (Abigail)
     Re: chsh script <rootbeer@teleport.com>
     Re: Code Snippet Wanted <chuckr@ptw.com>
     Re: environmental variables <rootbeer@teleport.com>
     Re: Execute normal code & delayed code at the same time <rootbeer@teleport.com>
     Re: form input feilds problems (Andrew M. Langmead)
     Re: form input feilds problems <chuckr@ptw.com>
     Re: FrontPage97 & PERL, Help! <rootbeer@teleport.com>
     Re: Help! Scoping problems with use strict turned on :- <rootbeer@teleport.com>
     Re: Help: Accessing Package from variable <rootbeer@teleport.com>
     Re: How do I pass HTTP_REFERER parameter in LWP:UserAge (Abigail)
     Re: More PERL questions <rootbeer@teleport.com>
     Re: Perl Memory Error When using '0' all others work? <rootbeer@teleport.com>
     Re: Second perl book (Chris Nandor)
     Re: Second perl book (Tad McClellan)
     Re: Server side includes to run Perl scripts from web p <scott@moriah.com>
     Re: Tutorial Needed <jbucks@procci.com>
     Re: Who will win?  Borland or Microsoft or Programmers? <PRAXIM@prodigy.net>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sat, 31 May 1997 22:00:06 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Can you Modify a Record "in-Line?"
Message-Id: <EB2Fs6.163@nonexistent.com>

On 31 May 1997 01:11:37 GMT, Jason Fish - SunEducation
(jason@thereef.west.sun.com) wrote in comp.lang.perl.misc
<URL: news:5mnts9$l0p@newsworthy.West.Sun.COM>:
++ I want to read a record in, and if it matches a specific check:
++ 
++ 	1.  replace the entire record with a new one - does the replacement
++ 	    string need to be the same length? What about if the replacement
++ 	    string is longer or shorter, can I get perl to truncate/pad
++ 	    respectively?

You can truncate the file (perldoc -f truncate). You cannot truncate
lines; files are not line based, it's just a stream of characters.

++ 	2.  replace a portion of the string - the FIRST n chars/words/bytes,
++ 	    or the LAST n chars/words/bytes, or some number of bytes right 
++ 	    from in the MIDDLE of the record.
++ 
++ If a line doesn't match, it is not affected and simply output.
++ 
++ I want to do this WITHOUT TEMP FILES, in-line, so to speak.  So I assume
++ I'd open the
++ file for reading and writing.  But once I've read in a record, how do I
++ tell perl to 
++ write it back out to the exact same spot it came from, with or without
++ changes intact?

perldoc -f seek.

Note that if your replacement is longer, you need to read in what's
coming next first, or else you will overwrite the other lines. If your
replacement is shorter, be sure to read/write what's going to follow,
and to trunctate the file, or you'll be stuck with unwanted
characters.

You also might want to look at the -i switch.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: Sat, 31 May 1997 15:27:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Brandon W. Metcalf" <brandon@physics.utexas.edu>
Subject: Re: chsh script
Message-Id: <Pine.GSO.3.96.970531151712.18874D-100000@kelly.teleport.com>

On Fri, 30 May 1997, Brandon W. Metcalf wrote:

> Here is a script that I wrote to allow NIS users to change their shell. 

Didn't your NIS come with a chsh utility? Okay...

> Is there a better way to edit-in-place the passwd.yp file with having to
> split the pertinent line into different variables - it seems like a
> waste to have to declare so many variables just for editing purposes. 

It's not too inefficient, and how much load can a chsh program put on your
system anyway? But you could improve things by using my variables.

> is there anything about this script that is a security risk? 

> # need to add in checking for a valid shell

Besides that? :-)  Okay, to be fair, I don't think that that can cause you
any security troubles. But you'll still have users who change their shell
to /bin/cash and beg you to fix it. At a minimum, use -x to see that they
have execute perms for the supposed shell, but it would be even better to
use /etc/shells to get the real list. (That way, when you add a new shell,
you won't have to fix your script, an added bonus.)

But you don't lock the passwd file before you edit it, which could cause
great grief if two people are using your script at the same time. Check
out flock, and you'll be safer.

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/





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

Date: Sat, 31 May 1997 15:22:28 -0700
From: Chuck <chuckr@ptw.com>
To: Jim McCullars <jim@info.uah.edu>
Subject: Re: Code Snippet Wanted
Message-Id: <3390A4A3.5FE864FC@ptw.com>

Hello Jim,

If you have all these files saved locally on your hard drive, you try
something I've used before to do a similar find/replace hunt.

I've used Ultra Edit to edit almost all of my files now that I have
found out how powerful it is. http://www.idmcomp.com/

To search for the <IMG tag's in many files, start Ultra Edit with no
page loaded. If it does start with a new page, choose File / close to
get rid of the blank page.

Then click "Search" and choose "Replace in Files" then enter the first
image tag you want to remove.
Such as "<img src="uah_bar.gif">" and replace that with "<img
src="/images/uah_bar.gif">"

Then click the browse button, and select the place on your hard drive
that you have all these files stored. Check mark any of the options that
you feel might be good, and press Replace All. It happily replaces every
instance for you. After you fix that one, proceed to the next...

Hope this helps,
Chuck



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

Date: Sat, 31 May 1997 15:50:46 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Peter Sakalaukus <sakalauk@coam.usm.edu>
Subject: Re: environmental variables
Message-Id: <Pine.GSO.3.96.970531154609.18874G-100000@kelly.teleport.com>

On Wed, 28 May 1997, Peter Sakalaukus wrote:

> Newsgroups: comp.lang.perl

If your news administrator still carries comp.lang.perl, please encourage
him or her to check out the frequent posting about bogus newsgroup names
in news.announce.newgroups. You'll be doing yourself and many others a
favor to use comp.lang.perl.misc (and other valid Perl newsgroups)
instead.

    news:news.announce.newgroups

> Subject: environmental variables

You mean environment variables.

> For instance, the variable $MODAS_HOME is a base variable and $DOMAIN is
> defined as: DOMAIN = $MODAS_HOME/DOMAIN/user_input, (the = is not in the
> file).

> When the value of DOMAIN is printed out I get: 
> $MODAS_HOME/DOMAIN/user_input instead of the value of $MODAS_HOME
> followed by /DOMAIN/user_input.
> 
> Any ideas on how to force Perl to do variable interpolation of
> $MODAS_HOME without my having to parse the string and extracting the
> value? 

Somebody has to parse the string. :-)  Maybe you want something like this,
which modifies some $variable so that its references to $FOO are replaced
by $ENV{FOO}.

    $variable =~ s/$(\w+)/$ENV{$1}/g;

If you have many such variables to process, you can do this in a loop, of
course. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 16:16:05 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Joluco <joluco@gsyc.inf.uc3m.es>
Subject: Re: Execute normal code & delayed code at the same time?
Message-Id: <Pine.GSO.3.96.970531161221.18874I-100000@kelly.teleport.com>

On Wed, 28 May 1997, Joluco wrote:

Newsgroups: comp.lang.perl

If your news administrator still carries comp.lang.perl, please encourage
him or her to check out the frequent posting about bogus newsgroup names
in news.announce.newgroups. You'll be doing yourself and many others a
favor to use comp.lang.perl.misc (and other valid Perl newsgroups)
instead.

    news:news.announce.newgroups

> Somebody knows how to manage a Perl script to execute code after a time
> while executing the normal code secuence? That is, I want my script to
> wait for executing an action (e.g a subroutine) but not sleep, so it can
> continue and perform his normal running with the delayed action at the
> same time.

Do you mean that you want to continue normal execution, but you want your
script to periodically check to see whether the time has come to do
something else? That's easy to do, in most cases, by regularly calling a
routine that checks the clock and does the action if needed. 

Or do you want to fork off a second process to do something after an
interval? That's not too hard either.

Or do you want to use something like cron or at to run something at
another time whether your script is running or not?

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 22:00:10 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: form input feilds problems
Message-Id: <EB2FsB.Lqt@world.std.com>

TRG Custom Graphics <customdesign@nstate.net> writes:

>Hi.. I know this is simi-cgi.. not perl.. but.. sort of.. ok, here's the
>deal.. I am somewhat lost here. it's a problem that no one can seem to
>figure out.  in form input type scripts. Either message boards,  email
>forms, guest books, and in chat forums.  People can take the input areas
>in HTML and change the name values of input $in{'whatever'}  and even
>though it's not in the script.. every $in later down will be affected..
>for instance..  

Is the problem that the user can alter the input from what you expect
based on the form that you expect they have come from? 

Can you just validate your input, before going on processing?

Thinks like:

%valid_fields = map {$_, 1} qw(name pass_word home_page city email);


# check for fields other than the ones I expect.
for $key (keys %in) {
  unless $valid_fields{$key} {
    print_error_page("Invalid field: $key");
    exit;
  }
}

# check that all required fields are present.
for $key (keys %valid_fields) {
   unless (defined $in{$key}) {
     print_error_page("Missing required field: $key");
     exit;
   }
}

# check that all the data jibes with information the user previously
# gave. %user_data is populated from some data stored on the server
# from running a previous process. 
# (Stored when they ran accessed a prevous web page.)

@saved{pass_word, home_page, city, email} = @{$user_data{$in{name})};

for $key( keys %valid_fields) {
   if($saved{$key} ne $in{$key}) {
     print_error_page("Somethings wrong: before you said $key was " .
                       "$saved{$key}, now you say its $in{$key}");
     exit;
   }
}

>Hmmm.. just a thought.. I wonder if anyone knows what to do.. Too bad
>this isn't C.. I'd have it by now.. :O    

Then write your CGI programs in C. Nobody is stopping you.
-- 
Andrew Langmead


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

Date: Sat, 31 May 1997 15:03:45 -0700
From: Chuck <chuckr@ptw.com>
To: customdesign@nstate.net
Subject: Re: form input feilds problems
Message-Id: <3390A041.30A5EC87@ptw.com>


--------------32D48867ED67E13BC26E9BC7
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

 Hello Tim,

In my opinion, the hole you speak of  is opened when the user want's to
create chaos by installing the HTML document on his computer, or even
his own his web site. Then modify your HTML so he can change the input
variables. I would see this as a security issue since the user can
attempt to have your CGI / PERL... whatever script send him your
passwords.

It's easy to do, most of the time, all that is required is to copy the
HTML document that submits the information to your server, and modify it
so he then can submit what ever he want's into which ever input field
you provide. And even request information that you would not otherwise
allow him to see.

I am attaching a snippet that should patch the hole by testing where the
input information is being sent from. You will need to edit the
"@referers" line to match your server. That should be all the
modifications required. This snippet will need to be cut and pasted into
your script(s) and then should fix your leak. It is in three sections,
the user defined variable (@referers), the test, and the output (should
the test find true). Please copy each carefully.

As far as limiting the input fields, you can test to see if data is
provided in each field. And if no information is supplied, return a
warning message, asking for the person to press Back on their browser
and supply you with the information.

A good example of a program that checks for security hazzards is
Formmail from Matt's Script Archive. You may be able to borrow from
cetain ideas that the script uses.
http://www.worldwidemart.com/scripts/formmail.shtml

Chuck Reed
chuckr@ptw.com

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# COPY THIS SECTION TO THE USER DEFINED VARIABLES OR TOP OF YOUR SCRIPT.

# _ _ _ _ _ _ _ _ _ _ _ _ cut below this line _ _ _ _ _ _ _ _ _ _ _ _ _
_ _

# The following line specifies which URL(s) allows CGI access.
# Enter your domain name in the single quotes:
@referers = ('foo.com','www.foo.com');

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# COPY THE FOLLOWING SECTION INTO THE MAIN BODY OF YOUR CGI SCRIPT
# _ _ _ _ _ _ _ _ _ _ _ _ cut below this line _ _ _ _ _ _ _ _ _ _ _ _ _
_ _

# Test environment for allowable URL access.
if ($ENV{'HTTP_REFERER'}) {
   foreach $referer (@referers) {
      if ($ENV{'HTTP_REFERER'} =~ /$referer/i) {
         $check_referer = '1';
       last;
         }
      }
   }
   else {
      $check_referer = '1';
   }

   if ($check_referer != 1) {
      &error('bad_referer');
   }

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# #
# COPY THE FOLLOWING SECTION TO THE BOTTOM OF YOUR SCRIPT
# _ _ _ _ _ _ _ _ _ _ _ _ cut below this line _ _ _ _ _ _ _ _ _ _ _ _ _
_ _

# Display error message if the Environment doesn't match @referers
sub error {
   ($error,@error_fields) = @_;

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

   if ($error eq 'bad_referer') {
#
# Start HTML warning message
#
     print "
 <HTML> <HEAD> <TITLE>
   Bad Referrer - Access Denied
 </TITLE> </HEAD>

 <BODY> <CENTER> <H1>Bad Referrer - Access Denied</H1> </CENTER>

   The form that is trying to use the <B>Security Check Program</B>
   resides at: <FONT COLOR=\"red\">$ENV{'HTTP_REFERER'}</FONT>,
   which is not allowed to access this cgi script. Please remove
   the offending script.<P>

   Sorry!

 </BODY></HTML>\n";
   }
   exit(0);

}

--------------32D48867ED67E13BC26E9BC7
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<HTML>
<HEAD>
<!-- selection start -->
<!-- selection end -->
</HEAD>
<TT>&nbsp;Hello Tim,</TT><TT></TT>

<P><TT>In my opinion, the hole you speak of&nbsp; is opened when the user
want's to create chaos by installing the HTML document on his computer,
or even his own his web site. Then modify your HTML so he can change the
input variables. I would see this as a security issue since the user can
attempt to have your CGI / PERL... whatever script send him your passwords.</TT><TT></TT>

<P><TT>It's easy to do, most of the time, all that is required is to copy
the HTML document that submits the information to your server, and modify
it so he then can submit what ever he want's into which ever input field
you provide. And even request information that you would not otherwise
allow him to see.</TT><TT></TT>

<P><TT>I am attaching a snippet that should patch the hole by testing where
the input information is being sent from. You will need to edit the "@referers"
line to match your server. That should be all the modifications required.
This snippet will need to be cut and pasted into your script(s) and then
should fix your leak. It is in three sections, the user defined variable
(@referers), the test, and the output (should the test find true). Please
copy each carefully.</TT><TT></TT>

<P><TT>As far as limiting the input fields, you can test to see if data
is provided in each field. And if no information is supplied, return a
warning message, asking for the person to press Back on their browser and
supply you with the information.</TT><TT></TT>

<P><TT>A good example of a program that checks for security hazzards is
Formmail from Matt's Script Archive. You may be able to borrow from cetain
ideas that the script uses.</TT>
<BR><TT><A HREF="http://www.worldwidemart.com/scripts/formmail.shtml">http://www.worldwidemart.com/scripts/formmail.shtml</A></TT><TT></TT>

<P><TT>Chuck Reed</TT>
<BR><TT>chuckr@ptw.com</TT><TT></TT>

<P><TT># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # #</TT>
<BR><TT># COPY THIS SECTION TO THE USER DEFINED VARIABLES OR TOP OF YOUR
SCRIPT.</TT>
<BR><TT># _ _ _ _ _ _ _ _ _ _ _ _ cut below this line _ _ _ _ _ _ _ _ _
_ _ _ _ _ _</TT><TT></TT>

<P><TT># The following line specifies which URL(s) allows CGI access.</TT>
<BR><TT># Enter your domain name in the single quotes:</TT>
<BR><TT>@referers = ('foo.com','www.foo.com');</TT>
<BR><TT></TT>
<BR><TT></TT><TT></TT>

<P><TT># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # #</TT>
<BR><TT># COPY THE FOLLOWING SECTION INTO THE MAIN BODY OF YOUR CGI SCRIPT</TT>
<BR><TT># _ _ _ _ _ _ _ _ _ _ _ _ cut below this line _ _ _ _ _ _ _ _ _
_ _ _ _ _ _</TT><TT></TT>

<P><TT># Test environment for allowable URL access.</TT>
<BR><TT>if ($ENV{'HTTP_REFERER'}) {</TT>
<BR><TT>&nbsp;&nbsp; foreach $referer (@referers) {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ($ENV{'HTTP_REFERER'} =~ /$referer/i)
{</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $check_referer
= '1';</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; last;</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp; else {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; $check_referer = '1';</TT>
<BR><TT>&nbsp;&nbsp; }</TT><TT></TT>

<P><TT>&nbsp;&nbsp; if ($check_referer != 1) {</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &amp;error('bad_referer');</TT>
<BR><TT>&nbsp;&nbsp; }</TT>
<BR><TT></TT>
<BR><TT></TT><TT></TT>

<P><TT># # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # # #</TT>
<BR><TT># COPY THE FOLLOWING SECTION TO THE BOTTOM OF YOUR SCRIPT</TT>
<BR><TT># _ _ _ _ _ _ _ _ _ _ _ _ cut below this line _ _ _ _ _ _ _ _ _
_ _ _ _ _ _</TT><TT></TT>

<P><TT># Display error message if the Environment doesn't match @referers</TT>
<BR><TT>sub error {</TT>
<BR><TT>&nbsp;&nbsp; ($error,@error_fields) = @_;</TT><TT></TT>

<P><TT>&nbsp;&nbsp; print "Content-type: text/html\n\n";</TT><TT></TT>

<P><TT>&nbsp;&nbsp; if ($error eq 'bad_referer') {</TT>
<BR><TT>#</TT>
<BR><TT># Start HTML warning message</TT>
<BR><TT>#</TT>
<BR><TT>&nbsp;&nbsp;&nbsp;&nbsp; print "</TT>
<BR><TT>&nbsp;&lt;HTML> &lt;HEAD> &lt;TITLE></TT>
<BR><TT>&nbsp;&nbsp; Bad Referrer - Access Denied</TT>
<BR><TT>&nbsp;&lt;/TITLE> &lt;/HEAD></TT><TT></TT>

<P><TT>&nbsp;&lt;BODY> &lt;CENTER> &lt;H1>Bad Referrer - Access Denied&lt;/H1>
&lt;/CENTER></TT><TT></TT>

<P><TT>&nbsp;&nbsp; The form that is trying to use the &lt;B>Security Check
Program&lt;/B></TT>
<BR><TT>&nbsp;&nbsp; resides at: &lt;FONT COLOR=\"red\">$ENV{'HTTP_REFERER'}&lt;/FONT>,</TT>
<BR><TT>&nbsp;&nbsp; which is not allowed to access this cgi script. Please
remove</TT>
<BR><TT>&nbsp;&nbsp; the offending script.&lt;P></TT>
<BR><TT>&nbsp;</TT>
<BR><TT>&nbsp;&nbsp; Sorry!</TT><TT></TT>

<P><TT>&nbsp;&lt;/BODY>&lt;/HTML>\n";</TT>
<BR><TT>&nbsp;&nbsp; }</TT>
<BR><TT>&nbsp;&nbsp; exit(0);</TT><TT></TT>

<P><TT>}</TT></HTML>

--------------32D48867ED67E13BC26E9BC7--



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

Date: Sat, 31 May 1997 16:33:24 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: dkranste@vpsiinc.com
Subject: Re: FrontPage97 & PERL, Help!
Message-Id: <Pine.GSO.3.96.970531162749.18874K-100000@kelly.teleport.com>

On Sat, 31 May 1997 dkranste@vpsiinc.com wrote:

> I am a beginner Perl "programmer" and just bought FrontPage97
> and I have no idea how to go about previewing a CGI script
> with FP97 before uploading to my ISP's webserver.  

I don't know either. If it's not adequately covered in the documentation
that came with your new purchase, I hope you saved your receipt. :-) 

If you have a Perl script that's written to use CGI.pm, I can tell you how
to try that out without a server. Just run your program from the command
line, and CGI.pm will let you run it interactively. You don't need
FrontPage at all.

If you have more questions about FrontPage, please do not post them here,
though. This newsgroup is about Perl, so non-Perl questions really aren't
welcome here. Thanks!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 16:27:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stephen Riehm <sr@pc-plus.de>
Subject: Re: Help! Scoping problems with use strict turned on :-(
Message-Id: <Pine.GSO.3.96.970531161724.18874J-100000@kelly.teleport.com>

On Sat, 31 May 1997, Stephen Riehm wrote:

> I tried using @main::array to get at the array which was defined in the
> main file, using "my" - but it still comes up empty. 

That's because @main::array is the @array in the main symbol table, and my
variables are never in a symbol table. They're only accessable by name by
code contained lexically within their scope. In short, if the code is in
another file, it's not going to be able to access the my variable by name. 

> Dose anyone know how I can continue to work with strict turned on, and
> yet still bandy these variables around without having to do
> summersaults?

Sure; just pass a reference to the variable when you call your code in the
other file. Of course, the other sub has to know to expect that
parameter.

    use strict;
    my(@array);
    &some_pkg_routine(\@array);	# Uses the passed ref

If you can't use a parameter (which you really should use, but okay) you
can use a global either for the array or the ref.

    use strict;
    my(@array);
    use vars qw($global_ref);
    $global_ref = \@array;
    &some_pkg_routine;		# Uses the global ref

Or, you could even write the library routine to have its own variable.
This is a valid way to pass information to a library routine, although
it's not recommended except for global settings. (Even there, I'd write an
interface routine.)

    use strict;
    my(@array);
    $Mypack::array_ref = \@array
    &some_pkg_routine;		# Uses its own array ref

See perlref(1) for more details about references. Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 15:45:16 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eric Brown <ericb@mathworks.com>
Subject: Re: Help: Accessing Package from variable
Message-Id: <Pine.GSO.3.96.970531153910.18874F-100000@kelly.teleport.com>

On 30 May 1997, Eric Brown wrote:

> In the following code I would like to access "@registry" in the package
> specified in $type (i.e. if $type eq "Piece" it would access 
> "@Piece::registry").

You could use a soft reference.

    @{ $type . '::registry' }

If you do this, you may need to tell the compiler C<no strict refs> in
that block.

> Eric Brown        |ericb@mathworks.com | I will consider Deep Blue
> Tools Engineer    |(508)-647-7352      | intelligent when it tells us it
> The Mathworks Inc |www.mathworks.com   | would rather go see a sunset.
>                                             A caller on "The Connection"

    print "I'd rather see a sunset.   :-)\n";

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 22:16:04 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: How do I pass HTTP_REFERER parameter in LWP:UserAgent ?
Message-Id: <EB2GIt.2KF@nonexistent.com>

On 31 May 1997 13:46:16 GMT, Walter Klomp (walter@swiftech.com.sg) wrote in
comp.lang.perl.misc
<URL: news:01bc6dc9$42a69a00$7bec2aca@walter.swiftech.com.sg>:
++ Hi,
++ 
++ I am trying to auto-submit (POST) some information to a form on a server
++ which actually checks on the HTTP_REFERER parameter (which browsers usually
++ send). Is there any way I can submit this information in my request as well
++ ?
++ 
++ Any answers are very welcome. Also please e-mail it directly to me as
++ sometimes my news-program doesn't work that well...

I would say so! Your news program is seriously broken, it is posting
CGI questions in a Perl group. You really have to get a newsreader
that posts CGI questions to a CGI group.



Abigail
-- 
perl5.004 -wMMath::BigInt -e'$=new Math::BigInt+qq;$$783$[$%9889$47$|88768$596577669$%$5$3364$[$$$|838747$[8889739$%$|$673$%$98$76777$=56;;$=$]*(q.25..($=@))=>do{print+chr$%$;$/=$}while$!=$'


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

Date: Sat, 31 May 1997 16:47:21 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Doyle Tracy <doyle@teleport.com>
Subject: Re: More PERL questions
Message-Id: <Pine.GSO.3.96.970531163611.18874M-100000@kelly.teleport.com>

On Sat, 31 May 1997, Doyle Tracy wrote:

> 1. What are the expression evaluation rules for PERL?  What are the
> operator precedences?  Is left to right or right to left the direction
> among operators of equal precedence? 

These questions are all covered in the online documentation. If you can't
find what you want there, then please ask again. 

>    Also, I am looking for an EBNF representation for these rules. 

I don't think there is one. (I'm not sure EBNF is powerful enough to
express all of those concepts.) 

> 2. Does PERL permit an unconditional branch into the block of statements
> executed under control of a conditional? 

This should be in the docs. 

> 3. What types are permitted for the control expression of a case
> statement? 

> 4. How does PERL react when an unspecified choice is evaluated for the
> expression controlling a case statement? 

:-) 

> 5. Does PERL permit unconditional branching into or out of the body of
> an iteration?

This should be in the docs. 

> 6. What is the value of the ICV (Iteration Control Variable) after the
> completion of an iteration? 

This should be in the docs. 

> 7. When is the final expression evaluated in a fixed-count iteration? 

This should be in the docs. 

> 8. Does PERL permit in ICV to be of a real type? 

:-) 

> 9. Does PERL permit an iteration to have multiple exit tests? 

This should be in the docs. 

> 10. Does PERL permit modification of the ICV in the body of a
> fixed-count iteration? 

This should be in the docs. 

> 11. When is the index of an array checked against its domain type? 

> 12. When is the domain of an array bound to the array? 

> 13. What types are permitted for the domain of an array? 
 
> 14. What types are permitted for the range of an array? 

:-) 

> 15. Is array assignment permitted?  How are arrays with different
> domains and the same cardinality handled? 

This should be in the docs. 

> 16. Is ordering defined in arrays?  If so, how? 

This should be in the docs. 

> 17. Is there a maximum length enforced on strings?  Is it user
> definable? 

This should be in the docs. 

> 18. If PERL has varient records, is the discriminant selection enforced? 
> Is assinment permitted to components not currently activated by the
> discriminant? 

This should be in the docs. 

> I've looked high and low for a book to find these answers in but I can
> only find books on programming PERL, not the specifics of the language.

High and low? Did you try the manpages? Also, there's a good book called
"Programming Perl" which is a reference to the specifics of the language. 

> In addition to these specific questions, I'm also looking for a little
> history on the language such as what platform was is designed for? 

Unix, and unix-type systems, although it's been ported to many, many
others.

> And any other info on the language that would be helpful in presenting
> it to a college class of computer science majors. 

Taking a class on Perl would be a good step. If you'd be interested in a
three-day lab course on learning Perl that will be held in mid-June in
Portland, Oregon, I could help you to get more information. That should
get you started. Good luck! 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 16:02:04 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Geoffrey Hebert <soccer@microserve.net>
Subject: Re: Perl Memory Error When using '0' all others work?
Message-Id: <Pine.GSO.3.96.970531155258.18874H-100000@kelly.teleport.com>

On Thu, 29 May 1997, Geoffrey Hebert wrote:

> When I have a value of  0 I get the memory error message below.
> 
> libc base conversion file _times_power.c line 74:  binary exponent 4 :
> Insufficient or invalid memory

That's a bug, no doubt about it. If you can reproduce it with the most
recent Perl (version 5.004), you should run perlbug to report it to the
Perl developers so that it can be fixed. 

> I am merging two files on a field that contains numbers and alpha.
> When I get all numbers I add 1000000 to it so that 3 comes before
> 1000.  

Well, that's one way to do it. You could also use leading spaces, which
wouldn't change your numeric value, since '      3' sorts before 
'   1000'. Unless there's some inefficiency I don't see, this should be
pretty efficient, since now your sort won't have to convert to strings.

    $sort_key = sprintf '%7s', $sort_key if $sort_key =~ /^\d+$/;

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Sat, 31 May 1997 19:14:40 -0400
From: pudge@pobox.com (Chris Nandor)
Subject: Re: Second perl book
Message-Id: <pudge-ya02408000R3105971914400001@news.idt.net>

In article <19970531181221347500@rhrz-ts3-p1.rhrz.uni-bonn.de>,
uzs90z@uni-bonn.de (Michael Schuerig) wrote:

#I only casually use perl and without Programming Perl next to me I'm
#virtually lost. Although by now I know that there's always more than one
#way to do it in perl I'm looking for a description of good perl
#programming style. Somebody's gotta know, I gather, as there a people
#around who do write exceptionally clean (even readable) perl code. Has
#anyone of them written a book or is there some place on the web where I
#ought to look?

Well, try just using the perlstyle man page for starters.  That's a good start.

Look on http://www.perl.com/perl/ for the man pages and for a list of books
(aloing with reviews of many of them).

--
Chris Nandor                 pudge@pobox.com                 http://pudge.net/
%PGPKey=('B76E72AD',[1024,'08 24 09 0B CE 73 CA 10  1F F7 7F 13 81 80 B6 B6'])
#=============================================================================
    That means I'll have to use $ans to suppress newlines now.  
    Life is ridiculous. 
        --Larry Wall in Configure from the perl distribution
#=============================================================================


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

Date: Sat, 31 May 1997 18:03:19 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Second perl book
Message-Id: <nnaqm5.5k3.ln@localhost>

Michael Schuerig (uzs90z@uni-bonn.de) wrote:

: I only casually use perl and without Programming Perl next to me I'm
: virtually lost. Although by now I know that there's always more than one
: way to do it in perl I'm looking for a description of good perl
: programming style. Somebody's gotta know, I gather, as there a people
: around who do write exceptionally clean (even readable) perl code. Has
: anyone of them written a book or is there some place on the web where I
: ought to look?


You mean like is described in the *perlstyle man page* that
is included with the perl distribution?


--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming
    tadmc@flash.net


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

Date: Sat, 31 May 1997 16:28:52 -0700
From: Scott Crumpton <scott@moriah.com>
To: Matthew Burnham <danew@enterprise.net>
Subject: Re: Server side includes to run Perl scripts from web pages
Message-Id: <3390B434.4F69@moriah.com>

Matthew Burnham wrote:

> >I am trying to execute a Perl script to generate a counter on my web page
> >using the following comment tag in the webpage itself.
> >
> ><!--#exec cgi="http://cep.lse.ac.uk/fm-cgi-bin/counter.pl"-->
> This should be a server path not a url, but I'm not sure whether it
> should be a full path or a virtual path (from the webserver root).

On our system it looks like this.

<!--#exec cgi="/cgi-bin/my_counter.cgi" -->


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

Date: Sat, 31 May 1997 17:26:02 -0600
From: "James T. Bucks" <jbucks@procci.com>
Subject: Re: Tutorial Needed
Message-Id: <3390B38A.411C@procci.com>

Andy Birkett wrote:
> 
> Are there any good Perl tutorials on the net.  If so could someone
> please point me in the right directions.
> 
> Thanks
> --
> Andy Birkett


Check out http://www.randysoft.com

HtH

Jim

-- 
+--------------------------------------+--------------------------------+
|Jim Bucks                             |Phone: +1 (970) 330-3279 
Office|
|Professional Computer Consulting, Inc.|       +1 (970) 350-3332  Pager
|
|1924 44th Avenue Court                |       +1 (303) 266-7176  Pager
|
|Greeley, Colorado  80634       (USA)  |Email: jbucks@procci.com       
|
+--------------------------------------+--------------------------------+
|                        WWW: http://www.procci.com                    
|
+-----------------------------------------------------------------------+


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

Date: 31 May 1997 18:23:23 GMT
From: "Max Rondon" <PRAXIM@prodigy.net>
Subject: Re: Who will win?  Borland or Microsoft or Programmers?
Message-Id: <01bc6def$8a84c6a0$56deedcc@patrickr>

 [ALL SNIPPED]

I've been a somewhat loyal Delphi user for about 4 months now, and the only
thing that bugs me about it is the closed-mindedness of both sides of the
MS-Borland battle. Neither side is willing to even TRY the other product.
While this may be difficult with VB, Borland has a demo of Delphi 2 right
on their www site! It does everything the full version does except compile
EXE files.

  I've used BOTH VB and Delphi, and actually have grown attached to VB. But
Delphi is more productive, allows for easier distribution (the pro edition
comes with InstallShield, while VB has the CrApplication Setup Wizzer), and
so far all of my Delphi projects have taken less time and turned out better
than my VB projects. Just my $2,000. (.02 is too small)



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

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

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