[16199] in Perl-Users-Digest
Perl-Users Digest, Issue: 3611 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 20:14:28 2000
Date: Mon, 10 Jul 2000 17:14:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963274456-v9-i3611@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 10 Jul 2000 Volume: 9 Number: 3611
Today's topics:
Using strict in a module ? <e.bras@hccnet.nl>
Re: Using strict in a module ? (Tad McClellan)
Re: Using strict in a module ? <e.bras@hccnet.nl>
Re: Using strict in a module ? <e.bras@hccnet.nl>
Re: Using strict in a module ? (Keith Calvert Ivey)
Re: Using strict in a module ? (Tad McClellan)
Re: Using strict in a module ? <e.bras@hccnet.nl>
Re: Using strict in a module ? <bwalton@rochester.rr.com>
Re: Using strict in a module ? (Tad McClellan)
Re: Using strict in a module ? <e.bras@hccnet.nl>
Re: Using strict in a module ? <bwalton@rochester.rr.com>
utf-8 and perl 5.6.0... <Joel.Seguillon@uhb.fr>
Variable subroutines <astro@shell.athenet.net>
Re: Variable subroutines <tina@streetmail.com>
Re: Variable subroutines <bwalton@rochester.rr.com>
Re: Variable subroutines <astro@shell.athenet.net>
Re: Variable subroutines <tina@streetmail.com>
Re: Variable subroutines <bwalton@rochester.rr.com>
Re: Variable subroutines <flavell@mail.cern.ch>
Very weird Apache+perl CGI issue ceverett@ceverett.com
Re: Very weird Apache+perl CGI issue (David Efflandt)
Re: Very weird Apache+perl CGI issue ceverett@ceverett.com
Re: Very weird Apache+perl CGI issue newsposter@cthulhu.demon.nl
Re: Very weird Apache+perl CGI issue <randy@theoryx5.uwinnipeg.ca>
Re: Website security (David Efflandt)
Re: Website security (Neil Kandalgaonkar)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 4 Jul 2000 16:42:30 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Using strict in a module ?
Message-Id: <8jst35$3lm$1@enterprise.cistron.net>
How can I use "use strict" in a module, such that that variables are still
know outside the module ?
That is, when I use my in combination with use strict to declare the
variables, the variables aren't know outside the module !
Regards,
Ed Bras
------------------------------
Date: Tue, 4 Jul 2000 10:41:56 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using strict in a module ?
Message-Id: <slrn8m3ttk.enl.tadmc@magna.metronet.com>
On Tue, 4 Jul 2000 16:42:30 +0200, Ed Bras <e.bras@hccnet.nl> wrote:
>How can I use "use strict" in a module, such that that variables are still
>know outside the module ?
use vars qw($foovar);
perldoc vars
>That is, when I use my in combination with use strict to declare the
^^
or use "our" instead of "my" if you have a newish perl.
perldoc -f our
>variables, the variables aren't know outside the module !
That's what my()'d (lexical) variables are _supposed_ to do.
So don't use a lexical variable for that. :-)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 4 Jul 2000 17:43:53 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Re: Using strict in a module ?
Message-Id: <8jt0m8$lvl$1@enterprise.cistron.net>
I was going through the manual and does this mean that I must declare all
variables with use vars (....alll variables ) at top of my program
after the entry "use strict" ?
Regards,
Ed Bras
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8m3ttk.enl.tadmc@magna.metronet.com...
> On Tue, 4 Jul 2000 16:42:30 +0200, Ed Bras <e.bras@hccnet.nl> wrote:
>
> >How can I use "use strict" in a module, such that that variables are
still
> >know outside the module ?
>
>
> use vars qw($foovar);
>
>
> perldoc vars
>
>
> >That is, when I use my in combination with use strict to declare the
> ^^
>
> or use "our" instead of "my" if you have a newish perl.
>
>
> perldoc -f our
>
>
> >variables, the variables aren't know outside the module !
>
>
> That's what my()'d (lexical) variables are _supposed_ to do.
>
> So don't use a lexical variable for that. :-)
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Tue, 4 Jul 2000 17:46:41 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Re: Using strict in a module ?
Message-Id: <8jt0ri$mkd$1@enterprise.cistron.net>
I forgot one more thing:
In this case, that is when using vars, I don't need to export my variables
anymore at the beginning of my module ?
Ed
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8m3ttk.enl.tadmc@magna.metronet.com...
> On Tue, 4 Jul 2000 16:42:30 +0200, Ed Bras <e.bras@hccnet.nl> wrote:
>
> >How can I use "use strict" in a module, such that that variables are
still
> >know outside the module ?
>
>
> use vars qw($foovar);
>
>
> perldoc vars
>
>
> >That is, when I use my in combination with use strict to declare the
> ^^
>
> or use "our" instead of "my" if you have a newish perl.
>
>
> perldoc -f our
>
>
> >variables, the variables aren't know outside the module !
>
>
> That's what my()'d (lexical) variables are _supposed_ to do.
>
> So don't use a lexical variable for that. :-)
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Tue, 04 Jul 2000 16:25:54 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Using strict in a module ?
Message-Id: <39620f1c.59347463@nntp.idsonline.com>
"Ed Bras" <e.bras@hccnet.nl> wrote:
>I was going through the manual and does this mean that I must declare all
>variables with use vars (....alll variables ) at top of my program
>after the entry "use strict" ?
Well, all the variables that you're planning to export (or want
to have accessible from outside by using the package name --
$Module::variable). Other variables can be left as my().
To answer your other question, yes, you still have to export the
variables if you want them to show up in the package where the
module is being used.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
------------------------------
Date: Tue, 4 Jul 2000 12:12:30 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using strict in a module ?
Message-Id: <slrn8m437e.far.tadmc@magna.metronet.com>
On Tue, 4 Jul 2000 17:46:41 +0200, Ed Bras <e.bras@hccnet.nl> wrote:
>In this case, that is when using vars, I don't need to export my variables
>anymore at the beginning of my module ?
No, you don't _need_ to export the variables, you can always
access them by providing the package name:
$MyPackage::my_variable
You may _want_ to export them into the main namespace though.
Then you can just use
$my_variable
[ snip Jeopardy quoted text ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 4 Jul 2000 22:52:09 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Re: Using strict in a module ?
Message-Id: <8jtiou$p7f$1@enterprise.cistron.net>
I am a bit confused now. To resume:
If I like to use "use strict" in my module, I do the following ??? (please
let me know if I am right):
1: Don't export the variables by putting them in the @EXPORT array, just
access them in another module by using the Modulename::$var1.
2: Use "use vars qw($var1 $var2 ..)" to make $var1 and $var2 accessable to
other modules.
3: Declare the variables by making use of "my": my $var1, such that "use
strict" doesn't complain.
Am I correct ??,
Ed
Tad McClellan <tadmc@metronet.com> wrote in message
news:slrn8m437e.far.tadmc@magna.metronet.com...
> On Tue, 4 Jul 2000 17:46:41 +0200, Ed Bras <e.bras@hccnet.nl> wrote:
>
> >In this case, that is when using vars, I don't need to export my
variables
> >anymore at the beginning of my module ?
>
>
> No, you don't _need_ to export the variables, you can always
> access them by providing the package name:
>
> $MyPackage::my_variable
>
>
> You may _want_ to export them into the main namespace though.
>
> Then you can just use
>
> $my_variable
>
>
>
> [ snip Jeopardy quoted text ]
>
>
> --
> Tad McClellan SGML Consulting
> tadmc@metronet.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Tue, 04 Jul 2000 21:24:36 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Using strict in a module ?
Message-Id: <3962565C.9DC4017A@rochester.rr.com>
Ed Bras wrote:
>
> How can I use "use strict" in a module, such that that variables are still
> know outside the module ?
>
> That is, when I use my in combination with use strict to declare the
> variables, the variables aren't know outside the module !
>
> Regards,
> Ed Bras
All you have to do is specify the complete global name of the variable.
For example:
package XX;
use strict;
sub a{
my $a=3;
my $b=4;
$XX::c=$a+$b;
print $XX::c;
}
1;
use strict;
&XX::a;
Without the explicit global variable name $XX::c , use strict would have
generated an error.
--
Bob Walton
------------------------------
Date: Tue, 4 Jul 2000 18:00:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Using strict in a module ?
Message-Id: <slrn8m4njc.fim.tadmc@magna.metronet.com>
[ Please put your comments *following* the quoted text that
you are commenting on.
Please do not quote an entire article. Quote just enough to
establish the context for your comment.
Please do not quote .sigs
Please visit news.announce.newusers
Thank you.
]
On Tue, 4 Jul 2000 22:52:09 +0200, Ed Bras <e.bras@hccnet.nl> wrote:
>I am a bit confused now. To resume:
>
>If I like to use "use strict" in my module, I do the following ??? (please
>let me know if I am right):
>
>1: Don't export the variables by putting them in the @EXPORT array,
Right.
> just
>access them in another module by using the Modulename::$var1.
That is one way of accessing them.
It is "safer" because it does not import things into your
namespace.
Another way of accessing them is to export them into your
namespace. But it is good practice to _ask_ by name (or by
tag) for them to be imported.
So you put them into the @EXPORT_OK array in your module.
In your main program, you can ask for them:
use MyModule qw($somevar somefunc $someothervar);
and then access them without the package name:
$somevar
somefunc( ... )
>2: Use "use vars qw($var1 $var2 ..)" to make $var1 and $var2 accessable to
>other modules.
Right.
For exporting, you want "dynamic variables", which is what "use vars"
(or "our") give you.
Perl has another type of variable, called a "lexical variable".
Lexical variables are *not in any package*, and so cannot
be referenced by prefixing a package name.
See the Perl FAQ, part 7:
"What's the difference between dynamic and lexical (static) scoping?
Between local() and my()?"
>3: Declare the variables by making use of "my": my $var1,
Wrong.
my() gets you the "lexical variables" mentioned above.
Lexical variables are visible _only_ in the current block
(or in the whole file if not in a block).
If you my() variables in one file (your module), you *cannot*
access them from another file (your main program).
So you do not want my() variables for what you are trying to do.
>such that "use
>strict" doesn't complain.
The "use vars" is enough to keep "use strict" happy anyway.
>Am I correct ??,
Almost. Check out the FAQ answer above for further insight.
[ snip Jeopardy quoted text ]
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 5 Jul 2000 10:59:14 +0200
From: "Ed Bras" <e.bras@hccnet.nl>
Subject: Re: Using strict in a module ?
Message-Id: <8jutfa$e3g$1@enterprise.cistron.net>
Bob Walton <bwalton@rochester.rr.com> wrote in message
news:3962565C.9DC4017A@rochester.rr.com...
> Ed Bras wrote:
> >
> > How can I use "use strict" in a module, such that that variables are
still
> > know outside the module ?
> >
> > That is, when I use my in combination with use strict to declare the
> > variables, the variables aren't know outside the module !
> >
> > Regards,
> > Ed Bras
>
> All you have to do is specify the complete global name of the variable.
> For example:
>
> package XX;
> use strict;
> sub a{
> my $a=3;
> my $b=4;
> $XX::c=$a+$b;
> print $XX::c;
> }
> 1;
> use strict;
> &XX::a;
>
> Without the explicit global variable name $XX::c , use strict would have
> generated an error.
> --
> Bob Walton
Thanks Bob,
What about the use of vars ?
Isn't it "better" to use "use vars", as I use many global variables in it ?
And is the resume, concerning the use of use vars, correct that I gave in
the last news article ?
------------------------------
Date: Wed, 05 Jul 2000 19:24:32 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Using strict in a module ?
Message-Id: <39638BCB.7976D998@rochester.rr.com>
Ed Bras wrote:
...
> What about the use of vars ?
> Isn't it "better" to use "use vars", as I use many global variables in it ?
> And is the resume, concerning the use of use vars, correct that I gave in
> the last news article ?
Ed, "use vars" is fine -- just another way to do it. I prefer the
explicit package name method because it clearly points out those places
where one uses a global. Each to his own.
Regarding your second question, I'm not sure to which "resume" you are
making reference. If it is this one (from one of your previous notes),
see my comments:
%%1: Don't export the variables by putting them in the @EXPORT array,
just
%%access them in another module by using the Modulename::$var1.
The access method is $Modulename::var1, not Modulename::$var1.
%%2: Use "use vars qw($var1 $var2 ..)" to make $var1 and $var2
accessable %%to other modules.
That's right -- but note that "use vars" doesn't actually do anything
other than cancel "use strict"'s complaints about those variables. If
you left both "use vars" and "use strict" out, the variables would be
global anyway (and there would be no complaints from "use strict" since
you're not using it). You don't *have* to use strict -- it's just a
good idea if you are developing a significant piece of code.
%%3: Declare the variables by making use of "my": my $var1, such that
"use
%%strict" doesn't complain.
If you do that, the variables *will not* be accessible *at all* from any
other package (and if the "my" is in a block, they will not be
accessible throughout the package they are defined in, either). The
variables declared with "my" are not global; all variables not declared
with "my" are global. Note that if a variable is on the "use vars" list
*and* is declared with "my", it is not global (unless it was used some
prior to the "my" definition, in which case the global retains the value
assigned just prior to the "my").
--
Bob Walton
------------------------------
Date: Mon, 10 Jul 2000 16:04:03 +0200
From: Joel SEGUILLON <Joel.Seguillon@uhb.fr>
Subject: utf-8 and perl 5.6.0...
Message-Id: <3969D7D3.CD6AF221@uhb.fr>
Hi,
I have many problems to translate beetween ISO-Latin1 and utf-8.
I tried to use the tr /UC and tr /CU operator but i had the error :
Malformed UTF-8 character at utf82.pl line 19 for the instruction
tr/\0-\xff//CU;
Furthermore the tr operator seems to be deprecated...
Can someone give me tips and examples ?
Thanks.
--> Joël SEGUILLON <--
------------------------------
Date: Mon, 3 Jul 2000 19:58:42 -0500
From: "John Coke" <astro@shell.athenet.net>
Subject: Variable subroutines
Message-Id: <xFa85.1427$ef3.402702@homer.alpha.net>
I would like to create a variable subroutine. IE:
$subroutine = 'test';
$mysubs[0]->$subroutine('this is a test!');
Would be the same as...
$mysubs[0]->test('this is a test!');
I realize I can do this easily with eval(), but I would like to do it with
references. Any ideas?
Thanks,
John C.
------------------------------
Date: 4 Jul 2000 02:06:44 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Variable subroutines
Message-Id: <8jrgrk$15knk$4@ID-24002.news.cis.dfn.de>
hi,
John Coke <astro@shell.athenet.net> wrote:
> I would like to create a variable subroutine. IE:
> $subroutine = 'test';
> $mysubs[0]->$subroutine('this is a test!');
> Would be the same as...
> $mysubs[0]->test('this is a test!');
> I realize I can do this easily with eval(), but I would like to do it with
> references. Any ideas?
that's a good idea to use refernces instead of eval.
you can do something like
$subroutine = 'test';
$hash{$subroutine} = sub {print @_;};
$hash{$subroutine}->('this is a test!');
tina
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Tue, 04 Jul 2000 03:13:07 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Variable subroutines
Message-Id: <39615686.3BEEE6A@rochester.rr.com>
John Coke wrote:
>
> I would like to create a variable subroutine. IE:
>
> $subroutine = 'test';
> $mysubs[0]->$subroutine('this is a test!');
>
> Would be the same as...
>
> $mysubs[0]->test('this is a test!');
>
> I realize I can do this easily with eval(), but I would like to do it with
> references. Any ideas?
>
> Thanks,
> John C.
Try:
$mysubs[0]=\&mysub1;
$mysubs[1]=\&mysub2;
...
&{$mysubs[0]}('argument1','argument2');
&{$mysubs[1]}('arg1','arg2');
or, for the latter two, as you have it:
$mysubs[0]->('argument1','argument2');
$mysubs[1]->('arg1','arg2');
Is that what you're after?
--
Bob Walton
------------------------------
Date: Mon, 3 Jul 2000 23:42:01 -0500
From: "John Coke" <astro@shell.athenet.net>
Subject: Re: Variable subroutines
Message-Id: <UWd85.1451$ef3.411063@homer.alpha.net>
Nope. The problem is the name of the subroutine is in a variable.
-John
Bob Walton <bwalton@rochester.rr.com> wrote in message
news:39615686.3BEEE6A@rochester.rr.com...
> John Coke wrote:
> >
> > I would like to create a variable subroutine. IE:
> >
> > $subroutine = 'test';
> > $mysubs[0]->$subroutine('this is a test!');
> >
> > Would be the same as...
> >
> > $mysubs[0]->test('this is a test!');
> >
> > I realize I can do this easily with eval(), but I would like to do it
with
> > references. Any ideas?
> >
> > Thanks,
> > John C.
>
> Try:
>
> $mysubs[0]=\&mysub1;
> $mysubs[1]=\&mysub2;
> ...
> &{$mysubs[0]}('argument1','argument2');
> &{$mysubs[1]}('arg1','arg2');
>
> or, for the latter two, as you have it:
>
> $mysubs[0]->('argument1','argument2');
> $mysubs[1]->('arg1','arg2');
>
> Is that what you're after?
> --
> Bob Walton
------------------------------
Date: 4 Jul 2000 05:44:35 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Variable subroutines
Message-Id: <8jrtk3$15knk$7@ID-24002.news.cis.dfn.de>
hi,
John Coke <astro@shell.athenet.net> wrote:
> Nope. The problem is the name of the subroutine is in a variable.
and my solution didn't fit?
what about that?
$sub = 'test';
$subref = \&{$sub};
$subref->('this is a test');
sub test {
print "subroutine: @_";
}
but be careful, that's a kind of symbolic reference.
better use a hash or something in which you
declare the subroutines, to make sure only
the subs are called you want to be called.
by the way, what data is in $mysub[0], i didn't
really understand that...
btw, please do not quote the whole posting and
don't do jeopardy...
regards,
tina
> Bob Walton <bwalton@rochester.rr.com> wrote in message
> news:39615686.3BEEE6A@rochester.rr.com...
>> John Coke wrote:
>> >
>> > I would like to create a variable subroutine. IE:
>> >
>> > $subroutine = 'test';
>> > $mysubs[0]->$subroutine('this is a test!');
>> >
>> > $mysubs[0]->test('this is a test!');
>> >
>> > I realize I can do this easily with eval(), but I would like to do it
> with
>> > references. Any ideas?
>>
>> $mysubs[0]=\&mysub1;
>>
>> $mysubs[0]->('argument1','argument2');
>> [fullquote shortened]
--
http://tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
"The Software required Win98 or better, so I installed Linux."
------------------------------
Date: Tue, 04 Jul 2000 17:16:28 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Variable subroutines
Message-Id: <39621C35.41DA31A0@rochester.rr.com>
John Coke wrote:
>
> Nope. The problem is the name of the subroutine is in a variable.
>
> -John
...
Ah, you want to call a sub whose name is stored in $subroutine. Try:
&$subroutine('arg1','arg2');
or:
$subroutine->('arg1','arg2');
--
Bob Walton
------------------------------
Date: Tue, 4 Jul 2000 19:33:00 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Variable subroutines
Message-Id: <Pine.GHP.4.21.0007041922240.5516-100000@hpplus03.cern.ch>
On Tue, 4 Jul 2000, Bob Walton wrote:
> Ah, you want to call a sub whose name is stored in $subroutine. Try:
>
> &$subroutine('arg1','arg2');
I wouldn't care to be the one who has to clean up the mess afterwards.
The way I look at it is, anyone who has enough expertise to do that
safely would already know how to do it (and would probably decide not
to).
Anyone who needs to ask, it seems to me a public duty to warn them
off. MJD has several instructive rants about dynamic variable names.
This seems to me to be, well, "the same with knobs on".
http://www.plover.com/~mjd/perl/varvarname.html et seq.
have fun
------------------------------
Date: Mon, 10 Jul 2000 07:15:39 GMT
From: ceverett@ceverett.com
Subject: Very weird Apache+perl CGI issue
Message-Id: <8kbt6k$4b0$1@nnrp1.deja.com>
I'm having a problem where @INC is different
according to whether perl is running in CGI
mode or from the command line.
From the command line, we have all the 5.6.0
libs, all hunky dory. In Apache, it wants to
use 5.005.03.
Here is my test program:
-------------------------------------------------------
#!/usr/bin/perl
$inc = join("<br>\n", @INC);
print <<"EOT"
Content-Type: text/html
<html>
<head></head>
<body>
$inc
</body>
</html>
EOT
---------------------------------------------------
here is the output from the command line:
Content-Type: text/html
<html>
<head></head>
<body>
/usr/local/lib/perl5/5.6.0/i586-linux<br>
/usr/local/lib/perl5/5.6.0<br>
/usr/local/lib/perl5/site_perl/5.6.0/i586-linux<br>
/usr/local/lib/perl5/site_perl/5.6.0<br>
/usr/local/lib/perl5/site_perl<br>
</body>
</html>
And this is what the browser shows:
/usr/lib/perl5/5.005/i386-linux
/usr/lib/perl5/5.005
/usr/local/lib/site_perl/i386-linux
/usr/local/lib/site_perl
/usr/lib/perl5
Any useful pointers, or should I go to the P5P list?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 Jul 2000 12:02:49 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Very weird Apache+perl CGI issue
Message-Id: <slrn8mjeqs.us1.efflandt@efflandt.xnet.com>
On Mon, 10 Jul 2000, ceverett@ceverett.com <ceverett@ceverett.com> wrote:
>I'm having a problem where @INC is different
>according to whether perl is running in CGI
>mode or from the command line.
Not hard to understand. Your shell acoount and webserver are on different
boxes. Your home directory is mounted on the webserver, so the server can
get to your public_html, but you may not be able to get to the webserver
from the shell. It looks like the newer box (shell) is compiled
for Pentium (i586) and the server is compiled for i386.
>From the command line, we have all the 5.6.0
>libs, all hunky dory. In Apache, it wants to
>use 5.005.03.
So ask your host to update the Perl version or add any modules you need on
their webserver. Otherwise you could install any script based modules on
your home dir or public_html, but modules that require binary compilation
might not work there.
>Any useful pointers, or should I go to the P5P list?
Why, it is not a Perl issue if versions on different boxes don't match.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Mon, 10 Jul 2000 17:31:25 GMT
From: ceverett@ceverett.com
Subject: Re: Very weird Apache+perl CGI issue
Message-Id: <8kd19e$umt$1@nnrp1.deja.com>
In article <slrn8mjeqs.us1.efflandt@efflandt.xnet.com>,
efflandt@xnet.com wrote:
> On Mon, 10 Jul 2000, ceverett@ceverett.com <ceverett@ceverett.com>
> wrote:
>
>> I'm having a problem where @INC is different
>> according to whether perl is running in CGI
>> mode or from the command line.
>
> Not hard to understand. Your shell acoount and webserver are on
> different boxes. Your home directory is mounted on the webserver,
> so the server can get to your public_html, but you may not be able
> to get to the webserver from the shell. It looks like the newer box
> (shell) is compiled for Pentium (i586) and the server is compiled
> for i386.
>
That's a major, and quite false, assumption on your part. I don't
blame you for making it, since that mistake is quite often made, I'm
sure. But to make myself exquisitely plain:
---> I *definitely* was running my test program on the command line of
the same machine as my web server. <---
So what else could produce the result:
------------------------------------------------------
#!/usr/bin/perl
$inc = join("<br>\n", @INC);
print <<"EOT"
Content-Type: text/html
<html>
<head></head>
<body>
$inc
</body>
</html>
EOT
-----------------------------------------------------
here is the output from the command line:
Content-Type: text/html
<html>
<head></head>
<body>
/usr/local/lib/perl5/5.6.0/i586-linux<br>
/usr/local/lib/perl5/5.6.0<br>
/usr/local/lib/perl5/site_perl/5.6.0/i586-linux<br>
/usr/local/lib/perl5/site_perl/5.6.0<br>
/usr/local/lib/perl5/site_perl<br>
</body>
</html>
And this is what the browser shows:
/usr/lib/perl5/5.005/i386-linux
/usr/lib/perl5/5.005
/usr/local/lib/site_perl/i386-linux
/usr/local/lib/site_perl
/usr/lib/perl5
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 10 Jul 2000 17:50:17 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: Very weird Apache+perl CGI issue
Message-Id: <8kd2cp$61g$1@internal-news.uu.net>
ceverett@ceverett.com wrote:
> ---> I *definitely* was running my test program on the command line of
> the same machine as my web server. <---
What does 'which perl' display, and is that the same as you use in your
scripts?
Erik
------------------------------
Date: 10 Jul 2000 18:00:00 GMT
From: Randy Kobes <randy@theoryx5.uwinnipeg.ca>
Subject: Re: Very weird Apache+perl CGI issue
Message-Id: <8kd2v0$6m$1@canopus.cc.umanitoba.ca>
In comp.lang.perl.misc, ceverett@ceverett.com wrote:
> In article <slrn8mjeqs.us1.efflandt@efflandt.xnet.com>,
> efflandt@xnet.com wrote:
>> On Mon, 10 Jul 2000, ceverett@ceverett.com <ceverett@ceverett.com>
>> wrote:
>>
>>> I'm having a problem where @INC is different
>>> according to whether perl is running in CGI
>>> mode or from the command line.
>>
>> Not hard to understand. Your shell acoount and webserver are on
>> different boxes. Your home directory is mounted on the webserver,
>> so the server can get to your public_html, but you may not be able
>> to get to the webserver from the shell. It looks like the newer box
>> (shell) is compiled for Pentium (i586) and the server is compiled
>> for i386.
>>
> That's a major, and quite false, assumption on your part. I don't
> blame you for making it, since that mistake is quite often made, I'm
> sure. But to make myself exquisitely plain:
> ---> I *definitely* was running my test program on the command line of
> the same machine as my web server. <---
[ ... ]
Is your server running mod_perl? If so, perhaps there's some
directives in the mod_perl server configuration changing
the @INC directories?
best regards,
randy kobes
------------------------------
Date: 3 Jul 2000 16:01:36 GMT
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Website security
Message-Id: <slrn8m1e60.bnv.efflandt@efflandt.xnet.com>
On Mon, 3 Jul 2000 13:19:16 +0100, Bob Hewitt <bob@unit2.com> wrote:
>I'm sorry if I'm going over old ground, or posting this in an unappropriate
>group, but I've been landed with a problem!!!!
>
>I need to set up some form of http_referer file or .htaccess, or a clever
>javascript to refer browsers elsewhere.
HTTP_REFERER is not a required variable and easily faked from a Perl
script. Also since it is not required, I don't know how proxies handle
it. You could check it if it does exist, but you should ignore it if it
doesn't. And since you are referencing .htm pages here instead of Perl
scripts, it seems totally OT for a Perl newsgroup.
See http://www.apache.org/ or the *.www.servers.unix newsgroups for
something you might do with mod_rewrite. Just be aware that some people
may not get into your site at all if you require a non-required variable.
See a javascript newsgroup for other ideas. Just be aware that there are
many versions and it is often disabled for security reasons.
>The idea is to only allow browsers to access a page, lets say
>http://www.myserver.com/index.htm if they come from
>http://www.mymatesserver.com/links.htm but not to allow access from
>http://www.notallowed.com/anypage.htm even if the browser has bookedmarked
>the page from a previous visit.
>
>My server is running Red Hat Linux and Apache, and I have full cgi access to
>the site, although no telnet.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/ http://cgi-help.virtualave.net/
------------------------------
Date: Tue, 04 Jul 2000 02:07:31 GMT
From: neil@brevity.org (Neil Kandalgaonkar)
Subject: Re: Website security
Message-Id: <8jrggb$4dv$1@localhost.localdomain>
In article <396085ab$1@news.jakinternet.co.uk>,
Bob Hewitt <bob@unit2.com> wrote:
>The idea is to only allow browsers to access a page, lets say
>http://www.myserver.com/index.htm if they come from
>http://www.mymatesserver.com/links.htm but not to allow access from
>http://www.notallowed.com/anypage.htm even if the browser has bookedmarked
>the page from a previous visit.
a) This is offtopic.
b) You can't in the general case.
--
Neil Kandalgaonkar <neil@brevity.org>
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3611
**************************************