[20020] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2215 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 27 06:05:51 2001

Date: Tue, 27 Nov 2001 03:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1006859110-v10-i2215@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Nov 2001     Volume: 10 Number: 2215

Today's topics:
        ANNOUNCE: Champaign-Urbana Perl Mongers meeting Tue Nov (Daniel S. Lewart)
    Re: Confused about timing map vs sub (Rafael Garcia-Suarez)
        Curses + ANSI? <dont@send.spam>
    Re: Curses + ANSI? (Chris Fedde)
    Re: File position of of every word in a file (Rob van Strien)
    Re: How to trap calls to undefined procedures at compil (Peter Terpstra)
        I need helps for Perl/Nt and Db2 <stefano.monteverde@tin.it>
        Intersectioning arrays <jonni@ifm.liu.nospam.se>
    Re: make subset of the search result <fly_no_spam@china.org>
    Re: Math Library Module Question <SSEA@SSEAweb.com>
        Mod perl with "local $/" (Richard Curtis)
    Re: Mod perl with "local $/" <bernard.el-hagin@lido-tech.net>
        New problem.. <mds@wam.umd.edu>
    Re: New problem.. <jonni@ifm.liu.nospam.se>
    Re: New problem.. <bernard.el-hagin@lido-tech.net>
    Re: Newbie Help... <admin@asarian-host.net>
    Re: Newbie Help... (HoboSong)
    Re: Newbie Help... <chrisw_63@hotmail.com>
    Re: no autovivication for subs (Rafael Garcia-Suarez)
    Re: Perl CGI scripts with read access contain passwords (David Efflandt)
    Re: Perl CGI scripts with read access contain passwords (Owain McGuire)
        Perl script - display log file in browser (bigpig)
        Perl/TK with DBI <david.mohorn@home.com>
    Re: Problem with XML::DOM (Matt Sergeant)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 27 Nov 2001 06:22:16 GMT
From: d-lewart@uiuc.edu (Daniel S. Lewart)
Subject: ANNOUNCE: Champaign-Urbana Perl Mongers meeting Tue Nov 27
Message-Id: <siGM7.494$Nz1.8877@vixen.cso.uiuc.edu>

By popular demand, our November meeting will be:
	Tue Nov 27 18:00 CST 2001
	Papa Del's
	206 E Green St
	Champaign, IL

Bring your Perl questions, scripts, anecdotes, etc.
We will be in the non-smoking area.

Happy Thanksgiving!
Daniel Lewart
http://cmi.pm.org/


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

Date: 27 Nov 2001 08:23:33 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Confused about timing map vs sub
Message-Id: <slrna06jdq.sff.rgarciasuarez@rafael.kazibao.net>

Aaron Sherman wrote in comp.lang.perl.misc:
} I've written the uniq function over and over. It looks like this:
} 
}   sub uniq {
}     my @r;
}     my %x;
}     foreach my $e (@_) {
}       push @r, $e unless $x{$e}++;
}     }
}     return @r;
}   }
} 
} In one case, I did not need to preserve order, but cared about keeping
} the original floating-point representation (without converting to/from
} string), so I wrote:
} 
}   values %{{map {("$_",$_)} @mylist}}
} 
} To be sure that this was more efficient, I ran some timing tests, and
} was STUNNED! It turns out that this is less efficient on a 50,000
} element list of (already unique) items BY A FACTOR OF MORE THAN 6!
} 
} I'm not certain how this could be. Does anyone have an understanding
} of what could be going on? The temporary array, and temporary hash are
} the same size in both cases. It seems to me that they should be the
} same running time, except that one can be more easily inlined by hand
} (which is what I was doing).

I think that the map slows it down, because it makes perl do a lot of
internal stack operations to construct the anonymous hash. Look at the
output of B::Terse to see the inner workings :

$ perl -MO=Terse,exec -e '@a=(1..50_000);@a=values %{{map {("$_",$_)}@a}}'
[... cut a bit of output ...]
LISTOP (0x80fc938) mapstart
LOGOP (0x80fc980) mapwhile [8]
MAPWHILE => {
    OP (0x8183b98) null [174]
    OP (0x8183b78) pushmark
    SVOP (0x80fcb50) gvsv  GV (0x80f023c) *_
    LISTOP (0x819da38) stringify [6]
    SVOP (0x819d9a8) gvsv  GV (0x80f023c) *_
    LISTOP (0x819d9e8) list
    LISTOP (0x8183bd0) scope
    goto LOGOP (0x80fc980)
}
LISTOP (0x80fc9c8) anonhash
[...]

That is, perl constructs 50000 times a 2-element list!
Probably far less efficient than using slices directly.

} Even stranger!
} 
}   @tmp{@mylist}=@mylist;@result=values %tmp;
} 
} is a hair FASTER than the subroutine version.... Now I'm really
} confused!

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Mon, 26 Nov 2001 21:08:40 -0800
From: xris <dont@send.spam>
Subject: Curses + ANSI?
Message-Id: <pan.2001.11.26.21.08.40.695157.6304@send.spam>

I recently got readdicted to one of the best muds out there
(sneezy.stanford.edu:7900)...  but when I started shopping around for
clients, I realized that none of them seem to support both a separate
command area (like tintin's #split option) and ANSI moveto controls.  Not
their fault, just seems to be that it's too hard to do both at once.
Anyway, since I couldn't find what I wanted to do in any available
clients, I decided to write my own.  Curses rock.  I love the instant
control they give me over the screen (I tried Term::Screen but couldn't
figure out how to make it scroll)..   However, I can't seem to get it to
display control characters as-is, without converting them to the ^X type
notation, which is a big hindrance when I want/need to support ANSI
colors.

Has anyone out there ever been able to get this to work?  You'd think
there would be a flag to turn of this feature for those of us who really
do want to transmit our OWN control characters to the terminal...

Any help will be much appreciated

-Chris



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

Date: Tue, 27 Nov 2001 06:56:45 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Curses + ANSI?
Message-Id: <NOGM7.537$Fbh.239857152@news.frii.net>

In article <pan.2001.11.26.21.08.40.695157.6304@send.spam>,
xris  <dont@send.spam> wrote:
>I recently got readdicted to one of the best muds out there
>(sneezy.stanford.edu:7900)...  but when I started shopping around for
>clients, I realized that none of them seem to support both a separate
>command area (like tintin's #split option) and ANSI moveto controls.  Not
>their fault, just seems to be that it's too hard to do both at once.
>Anyway, since I couldn't find what I wanted to do in any available
>clients, I decided to write my own.  Curses rock.  I love the instant
>control they give me over the screen (I tried Term::Screen but couldn't
>figure out how to make it scroll)..   However, I can't seem to get it to
>display control characters as-is, without converting them to the ^X type
>notation, which is a big hindrance when I want/need to support ANSI
>colors.
>

It's too bad that curses and termcap out lasted Hazeltine, Televideo
and the Volker-Craig 404. It would be more obvious why curses is
the way it is if all the myriad of terminal types still existed.
As it is now ANSI sequences are just about a universal language
for this kind of thing.

If you want to "pass" escape sequences to the display you'll
need to intercept and tokenize them as if they were commands
then make the right API call to update the display. 
-- 
    This space intentionally left blank


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

Date: Tue, 27 Nov 2001 10:19:44 GMT
From: strien@inl.nl (Rob van Strien)
Subject: Re: File position of of every word in a file
Message-Id: <3c036710.10953203@news.leidenuniv.nl>

On Mon, 26 Nov 2001 21:11:46 +1100, "Andrew Hamm"
<ahamm@programmer.net> wrote:

>Rob van Strien wrote in message <3c020c98.8334750@news.leidenuniv.nl>...
>>Thanks to all of you who helped me with this problem.
>>This is my solution (apart from the discussion of what
>>a 'word' might be, which isn't solved yet in my case).
>>
>Ain't that the way with English? I thought there was a module on CPAN which
>did a damn fine job of intuiting english words, but I couldn't find it the
>other day. Pity. Anyways, you just gotta do what correctly handles 99.99% of
>your data. The other 0.01% is pathalogical sick English. I pray that your
>data isn't complete English ;-)

It's even worse, it is all in Dutch from the year 1500 and later. And
a lot of Mb's too! But we'll get there someday.

>
>>         $match = $&;
>>
>This is a bad habit to get into. If you use $`  $&  or  $' then you are
>imposing a performance penalty on yourself. I haven't got the time to
>explain but it's in the Programming Perl book, which you have bought, right?
>For the pattern you have shown, you'd be better off to use $1 instead - it
>represents the stuff inside the first ( ) pair and it doesn't come with a
>cost.

Thanks, I changed the script. Although performance isn't a real issue
with this code. I use it to built an index in the nightly hours.

-Rob
>
>--
>Space Corps Directive #723
>Terraformers are expressly forbidden from recreating Swindon.
>    -- Red Dwarf
>
>
>



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

Date: Tue, 27 Nov 2001 09:50:05 GMT
From: terpstra@REMOVEPLEASEsmr.nl (Peter Terpstra)
Subject: Re: How to trap calls to undefined procedures at compile time
Message-Id: <91666C6E3terpstrasmrnl@24.132.26.253>


cp@onsitetech.com (Curtis Poe) wrote in
<9ttum3$jog@dispatch.concentric.net>: 

>I know of no way to accomplish that and frankly, I don't think it's
>possible.  With ease of access to symbol tables, AUTOLOAD, and
>generating code on the fly, it would be impossible for Perl to know at
>compile time if, in fact, a given function exists.
>
>The best I could suggest is to write some code that walks your symbol
>tables and looks for coderefs, but then you're going to wind up with
>problems trying to parse all of the different ways Perl can call
>functions and methods.  What follows is five different ways to call the
>same function (and some of these can break, depending on the how the
>program is structured): 
>
>my $q = new CGI;
>my $q = CGI::->new;
>my $q = CGI->new;
>my $q = CGI->new();
>my $q = &CGI::new;
>
>--
>Cheers,
>Curtis Poe
>Senior Programmer
>ONSITE! Technology
>www.onsitetech.com
>503.233.1418
>"Peter Terpstra" <terpstra@REMOVEPLEASEsmr.nl> wrote in message
>news:91659E6E7terpstrasmrnl@24.132.26.253...
>>
>> Well,
>>
>> the subject says it all.
>> I'm working on a large program, written in perl. The program has a lot
>> of modules.
>> When I do a syntax check in a module, which calls an undefined
>> procedure, the
>> syntax checker still says that the syntax is "OK".
>>
>> I tried stuff like "use strict", but that does not seem to help.
>> I know about the dynaloader, but this module only traps errors at
>> runtime. 
>>
>> Without an appropriate compile time check, I would need to have a
>> test, which checks exhaustively all possible execution branches. This
>> is not 
>very
>> practical.
>> Is there a better solution?
>>
>> Peter Terpstra
>>
>>
>
>
>

Thanks Curtis,

I think this lack of verification is a serious flaw in the language
design. It's a pity and makes Perl less suitable for large projects.

Or do the Perl-language designers think that this is a feature and not a
design flaw :) 

Peter


 


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

Date: Tue, 27 Nov 2001 10:01:36 GMT
From: "Stefano Monteverde" <stefano.monteverde@tin.it>
Subject: I need helps for Perl/Nt and Db2
Message-Id: <4wJM7.21691$4M2.578550@news2.tin.it>

Hello: first, excuse me for my english (...and italian too)
I am experienced on mainframe but beginner with PERL and i need to read data
on Db2 on MVS-OS/390.
Does anyone ever try to do the same i do?
I have installed Nt 4.0, sp 6, IIS 4.0, ActivePerl 5.6.1, PPm 3.0!
I now that is necessary to use the DBI... probably with special interface,
but what?
Can someone tell me what can i do? (before to change job)

thanks.




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

Date: Tue, 27 Nov 2001 08:47:24 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Intersectioning arrays
Message-Id: <9tvgcg$oc6$1@news.island.liu.se>

Is there a way to make arrays intersect?

Like this (doen't work like I want).

my @array1=("elem1","elem2","elem3");
my @array2=("newelem1",\$array1[1]);
my $scalar=\$array[2];

Now changing $$scalar or ${$array2[1]} will change @array1.

But is there a way to make it more transparent, like making $scalar and
$array2[1] pointing directly to the elements in @array1?
I tried to fool around with typeglobs but I can't make it work. Is it
possible?

no strict;
$sc1="kkk";
*sc2=*sc1;
$sc2="lll";
print $sc1;

Will work for scalars, but without the possibility to use scoping.
--
/jN




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

Date: Tue, 27 Nov 2001 05:35:12 GMT
From: qiang <fly_no_spam@china.org>
Subject: Re: make subset of the search result
Message-Id: <kCFM7.35479$T67.11040885@news4.rdc1.on.home.com>

Logan Shaw wrote:

[snip]
> The other approach is to do the whole query all at once and store the
> extra results somewhere.  Storing them in a temporary file is not a
> half bad idea, although you end up having to parse the temporary file
> every time.  In some cases, that won't actually speed anything up.  You
> could write a daemon to store temporary search results (and maybe even
> to do the search for you) and allow your CGI (etc.) to retrieve them
> through some sort of inter-process communication.  Again, only in some
> cases would that be a good idea.
> 
>   - Logan

wow, A lot of  helpful information... thanks Logan
hmm, above approach sounds need lots HD space..or maybe i can delete the 
tmp file using a cron job.  but i am insterested in it.   
apart from this , i am thinking using search indexer .here is a sketch. 
please feel free to give me advice. 
1. index and save all text of file and each text has the corresponding file 
names which contains the text under it.
2. during the search, get the  files list which match user keyword from 
index file ,then search the files and return result.. detail i will follow 
logan's idea.


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

Date: Tue, 27 Nov 2001 06:45:40 GMT
From: "Basil Skordinski" <SSEA@SSEAweb.com>
Subject: Re: Math Library Module Question
Message-Id: <oEGM7.8377$WC1.991377@newsread2.prod.itd.earthlink.net>

uri,

Here's the code that I'm working with.  And below it is a sample of the
output.  You'll be able to see the numbers that I'm working with in the
output.  To me, it seems as though "Math::BigFloat" works best when the
numeric strings are in scientific notation format.
-----

#! /usr/bin/perl -w
use diagnostics;
use strict;
use Math::BigFoot;
my $List5 = "tmpSYBm"; my $List3 = "tmpA";
open(Ch3, "<$List3") or die "\nCannot open List 3.\n";
open(Ch5, "<$List5") or die "\nCannot open List 5.\n";
while($main::cdpch3 = <Ch3>, $main::cdpch5 = <Ch5>){
  chop($main::cdpch3); chop($main::cdpch5);
  $main::delta = Math::BigFloat -> new( "0.0E+00" );
  if($main::cdpch3 =~ /([+-]?[0-9]*\.?[0-9]*)(e?)([+-]?[0-9]*)$/){
    if($2 eq "e"){$main::dp31 = join '', $1, 'E', $3;}
    if($2 eq ""){$main::dp31 = join '', $1, 'E+00';}
    print 'Numeric String Interpretation of $dp31: *', "$main::dp31", '*',
"\n";}
    $main::dp3 = Math::BigFloat -> new( $main::dp31 );
    print 'Math::BigFloat Interpretation of $dp31: *', "$main::dp3", '*',
"\n";

 if($main::cdpch5 =~ /([+-]?[0-9]*\.?[0-9]*)(e?)([+-]?[0-9]*)$/){
    if($2 eq "e"){$main::dp51 = join '', $1, 'E', $3;}
    if($2 eq ""){$main::dp51 = join '', $1, 'E+00';}
    print 'Numeric String Interpretation of $dp51: *', "$main::dp51", '*',
"\n";}
    $main::dp5 = Math::BigFloat -> new( $main::dp51 );
    print 'Math::BigFloat Interpretation of $dp51: *', "$main::dp5", '*',
"\n";

    $main::delta = $main::dp3 -> fsub( $main::dp5 );
    print "$main::dp3     $main::dp5     $main::delta\n";

  print "\n-----\n\n";}
close(Ch3) or print "\n\nProcess could not close List 3.\n\n";
close(Ch5) or print "\n\nProcess could not close List 5.\n\n";

------------------------------------------------------------
A sample of output data looks like this:
------------------------------------------------------------

Numeric String Interpretation of $dp31: *0.0018987940000000001E+00*
Math::BigFloat Interpretation of $dp31: *.0018987940000000001*
Numeric String Interpretation of $dp51: *0.0018987940000000000893842778E+00*
Math::BigFloat Interpretation of $dp51: *.0018987940000000000893842778*
Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm line 80,
<Ch5> chunk 1 (#1)

(W) An undefined value was used as if it were already defined.
It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign an initial value to your variables.

Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm line 79,
<Ch5> chunk 1 (#1)

 .0018987940000000001     .0018987940000000000893842778     +106157222E-28

-----

Numeric String Interpretation of $dp31: *0.0011321949999999999E+00*
Math::BigFloat Interpretation of $dp31: *.0011321949999999999
Numeric String Interpretation of $dp51: *0.0011321949999999999028621467E+00*
Math::BigFloat Interpretation of $dp51: *.0011321949999999999028621467*
Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm line 80,
<Ch5> chunk 2 (#1)

(W) An undefined value was used as if it were already defined.
It was interpreted as a "" or a 0, but maybe it was a mistake.
To suppress this warning assign an initial value to your variables.

Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm line 79,
<Ch5> chunk 2 (#1)

 .0011321949999999999     .0011321949999999999028621467     -28621467E-28

-----





"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7u1vi82c8.fsf@home.sysarch.com...
> >>>>> "BS" == Basil Skordinski <SSEA@SSEAweb.com> writes:
>
>
>   BS> "Use of uninitialized value at /usr/perl5/5.00503/Math/BigFloat.pm
>   BS> line 80."
>
>   BS> In the code fragment that I use I assign a number string to the
variable
>   BS> $dp51 elsewhere in my program and then try to convert it to a big
float in
>   BS> the following manner:
>
>   BS> use Math::BigFloat;
>   BS> $dp5 = Math::BigFloat->("$dp51");
>                               ^     ^
> don't need quotes there
>
>   BS> I've looked at line 80 in BigFloat.pm and it seems to me that $6
>   BS> within the scope of its regular expression is undefined.  However,
>   BS> I could be wrong.  Can anyone shed some light on my problem?
>
> could you post the number you tried? and make sure it is demarked so we
> can see all the characters.
>
> uri
>
> --
> Uri Guttman  ------  uri@stemsystems.com  --------
http://www.stemsystems.com
> -- Stem is an Open Source Network Development Toolkit and Application
Suite -
> ----- Stem and Perl Development, Systems Architecture, Design and
Coding ----
> Search or Offer Perl Jobs  ----------------------------
http://jobs.perl.org
>




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

Date: 27 Nov 2001 01:24:00 -0800
From: ck102399@stmail.staffs.ac.uk (Richard Curtis)
Subject: Mod perl with "local $/"
Message-Id: <34dfa845.0111270124.6e3980ec@posting.google.com>

Hi.  I have a program which needs to slurp data from a filehandle and
encode the data to base 64.  I use the following code to ensure that
windows newline characters dont mess this up.

binmode F; local $/ = undef; 
$encoded = encode_base64(<F>);
close F;

The question I have, is does this local version of $/ only affect this
scope ?
I am aware that any functions I call for example within this function,
will inherit the undefined version of $/, but will this not affect the
value of $/ for other instances of the program running ?

If multiple users hit the server at the same time, and someone happens
to be executing this code, am I correct in assuming that the version
of $/ used by other users sessions will be the correct global version
and not the local one defined in the above code ?

Any input welcomed
Richard Curtis


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

Date: 27 Nov 2001 09:38:13 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: Mod perl with "local $/"
Message-Id: <slrna06qle.qsr.bernard.el-hagin@gdndev25.lido-tech>

On 27 Nov 2001 01:24:00 -0800, Richard Curtis <ck102399@stmail.staffs.ac.uk>
wrote:
> Hi.  I have a program which needs to slurp data from a filehandle and
> encode the data to base 64.  I use the following code to ensure that
> windows newline characters dont mess this up.
> 
> binmode F; local $/ = undef; 
> $encoded = encode_base64(<F>);
> close F;
> 
> The question I have, is does this local version of $/ only affect this
> scope ?
> I am aware that any functions I call for example within this function,
> will inherit the undefined version of $/, but will this not affect the
> value of $/ for other instances of the program running ?
> 
> If multiple users hit the server at the same time, and someone happens
> to be executing this code, am I correct in assuming that the version
> of $/ used by other users sessions will be the correct global version
> and not the local one defined in the above code ?


It's easy to test this. For example:

 ------------------------------
#!/usr/bin/perl -w
use strict;

aaa();
print "[$/]";

sub aaa{
  local $/ = 'bla';
  
  print "In aaa \$/ = [$/]\n";
  bbb();
}

sub bbb{
  print "In bbb \$/ = [$/]\n";
}
 ------------------------------


As you see the global value of $/ is untouched by the subs,
which is actually the point of using local in the first place.


Cheers,
Bernard


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

Date: Tue, 27 Nov 2001 00:08:39 -0500
From: "Mike Schmitt" <mds@wam.umd.edu>
Subject: New problem..
Message-Id: <9tv77l$e6q$1@hecate.umd.edu>

I've just written a rather large PERL program which I feel could be used as
a viable tool for anyone with Windows and AIM.  My only problem is, most
non-powerusers don't have PERL on their systems, nor do they have any idea
or concept of what PERL is.  Is there a way of "compiling", per se, my perl
script into a file which is standalone-enough to be run by just any user of
Windows?  For instance, MS Quick Basic has a "compiler" which I guess just
rolls a version of the Basic interpreter together with the code, and all
into a standalone EXE; is there a way of doing this with PERL?
Thanks.
~Mike




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

Date: Tue, 27 Nov 2001 08:15:15 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.nospam.se>
Subject: Re: New problem..
Message-Id: <9tveg8$nuj$1@news.island.liu.se>

"Mike Schmitt" <mds@wam.umd.edu> wrote in message
news:9tv77l$e6q$1@hecate.umd.edu...
<SNIP>
| or concept of what PERL is.  Is there a way of "compiling", per se, my
perl
| script into a file which is standalone-enough to be run by just any user
of
| Windows?  For instance, MS Quick Basic has a "compiler" which I guess just
<SNIP>

www.perl2exe.com

/jN




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

Date: 27 Nov 2001 07:31:21 GMT
From: Bernard El-Hagin <bernard.el-hagin@lido-tech.net>
Subject: Re: New problem..
Message-Id: <slrna06j7j.qsr.bernard.el-hagin@gdndev25.lido-tech>

On Tue, 27 Nov 2001 00:08:39 -0500, Mike Schmitt <mds@wam.umd.edu> wrote:
> I've just written a rather large PERL program which I feel could be used as
> a viable tool for anyone with Windows and AIM.  My only problem is, most
> non-powerusers don't have PERL on their systems, nor do they have any idea
> or concept of what PERL is.  Is there a way of "compiling", per se, my perl
> script into a file which is standalone-enough to be run by just any user of
> Windows?  For instance, MS Quick Basic has a "compiler" which I guess just
> rolls a version of the Basic interpreter together with the code, and all
> into a standalone EXE; is there a way of doing this with PERL?


This is in the FAQ. Part 3, by the way.


Cheers,
Bernard


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

Date: Tue, 27 Nov 2001 07:09:15 GMT
From: "Mark" <admin@asarian-host.net>
Subject: Re: Newbie Help...
Message-Id: <v_GM7.50027$YD.4444920@news2.aus1.giganews.com>

"Chris White" <chrisw_63@hotmail.com> wrote in message
news:cv160uknnk6nj48lqkil5n5gp6i10t4htd@4ax.com...

> Okay, yes, I'm a newbie to Perl and CGI. But I've had several years of
> programming in other languages and I have a Perl book (IOW, I can follow
> instructions!)

>

> Internal Server Error The server encountered an internal error or
> misconfiguration and was unable to complete your request.

> #!/usr/local/bin/perl
> # hello.pl -- my first perl script!
> print "Content-type: text/html\n\n";
> print <<"EOF";
> <HTML> <HEAD>
> <TITLE>Hello, world!</TITLE>
> </HEAD> <BODY>
> <H1>This don't work!</H1>
> </BODY> </HTML>
> EOF


As Wyzelli has already pointed out, you need to make sure there is a newline
char after the HERE doc.

P.S. In cases like this, it is very useful to check the error_log.

Depending on your platform, of course, it may reside somewhere in the
neighborhood of:

/usr/local/www/vhosts/your-site/logs/error_log

If therein you find something like:

[Tue Nov 27 06:14:57 2001] [error] ... Can't find string terminator "EOF"
anywhere before EOF at test.pl line ...

Then you know what to do. :)

- Mark




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

Date: 27 Nov 2001 00:42:33 -0800
From: chrisvano@yahoo.com (HoboSong)
Subject: Re: Newbie Help...
Message-Id: <4fbb9396.0111270042.66f697e5@posting.google.com>

Chris White <chrisw_63@hotmail.com> wrote in message news:<cv160uknnk6nj48lqkil5n5gp6i10t4htd@4ax.com>...

> 
> #!/usr/local/bin/perl 
> # hello.pl -- my first perl script! 

use CGI;  ## </~~ Try adding "use CGI;"

> print "Content-type: text/html\n\n";
> print <<"EOF";
> <HTML> <HEAD>
> <TITLE>Hello, world!</TITLE>
> </HEAD> <BODY>
> <H1>This don't work!</H1>
> </BODY> </HTML>
> EOF


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

Date: Tue, 27 Nov 2001 10:50:12 GMT
From: Chris White <chrisw_63@hotmail.com>
Subject: Re: Newbie Help...
Message-Id: <gnr60u8sc3hs698gg35h73fa5gqv77h2lc@4ax.com>

On Tue, 27 Nov 2001 13:23:41 +0930, "Wyzelli" <wyzelli@yahoo.com>
wrote:

>> #!/usr/local/bin/perl
>> # hello.pl -- my first perl script!
>> print "Content-type: text/html\n\n";
>> print <<"EOF";
>> <HTML> <HEAD>
>> <TITLE>Hello, world!</TITLE>
>> </HEAD> <BODY>
>> <H1>This don't work!</H1>
>> </BODY> </HTML>
>> EOF
>>
>> Thats it.  It doesn't run!  I know the server sees it, because the

>Are you certain there is a return after the end of the here-doc?

Rats!  And thank you very much.  It seemed like there was a return
after the EOF in my editor, but it must strip it off when saving.  I
added a comment line at the end to make SURE it would put the return
there, and viola!

Thanks again!

Chris W.



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

Date: 27 Nov 2001 10:16:50 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: no autovivication for subs
Message-Id: <slrna06q29.7ul.rgarciasuarez@rafael.kazibao.net>

Joe Schaefer wrote in comp.lang.perl.misc:
} Why don't the return values of perl subs autovivify?
} 
}   % perl -wle ' sub f {$_} print f() -> [0] '
}   Can't use an undefined value as an ARRAY reference at -e line 1.

This behavior is correct : you're basically doing "undef->[0]".

} It doesn't even work for lvalued subs:
} 
}   % perl -wle ' sub f:lvalue {$_} print f() -> [0] '
}   Can't use an undefined value as an ARRAY reference at -e line 1.

Hm, this looks like a bug. As $_ is undefined, it should spring into
existence, as documented in perlref. Can you report it via perlbug?

} Can this feature be exploited in perl6 to control autovivication?

Perhaps it's not too late for perl 5.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
perl -sleprint -- -_='Just another Perl hacker,'


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

Date: Tue, 27 Nov 2001 06:26:29 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Perl CGI scripts with read access contain passwords to database
Message-Id: <slrna06cgk.ad0.efflandt@typhoon.xnet.com>

On Mon, 26 Nov 2001, Owain McGuire <owain@nospam.demon.co.uk> wrote:
> I am using an ISP that runs Apache under the user nobody.  In order
> for Apache to be able to read and execute my Perl CGI scripts it needs
> global read and exec access (only global read for the modules I
> think).  The problem is that one of my modules contains the userid and
> password to my Mysql database and hence anyone who has access to the
> ISP's  filesystem can mess my database up.
> 
> How do I prevent this?

Find an ISP that runs apache suexec option or separate cgiwrap so you can 
run CGI with 700 permission and access 600 data files.

I was going to suggest suidperl or an suid C wrapper which could limit
direct access to the data, but someone might still be able to manipulate
the script through their own CGI (if not the shell).  But you could thwart
with that by requiring a password, which would be entered as regular text,
but would be compared with a crypted password (in the script or elsewhere)
before the script would do anything.

For a webshell.cgi that can execute arbitrary shell commands, I use both a
crypted password entered from a confusing form, and compare REMOTE_ADDR
against my static IP.  Hm, maybe I should crypt my IP too.

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Tue, 27 Nov 2001 10:24:34 GMT
From: owain@nospam.demon.co.uk (Owain McGuire)
Subject: Re: Perl CGI scripts with read access contain passwords to database
Message-Id: <3c0368ba.88734132@news.demon.co.uk>

On Mon, 26 Nov 2001 16:59:36 -0500, "Mina Naguib"
<spam@thecouch.homeip.net> wrote:

>
>"Owain McGuire" <owain@nospam.demon.co.uk> wrote in message
>news:3c029aa1.35973356@news.demon.co.uk...
>> I am using an ISP that runs Apache under the user nobody.  In order
>> for Apache to be able to read and execute my Perl CGI scripts it needs
>> global read and exec access (only global read for the modules I
>> think).  The problem is that one of my modules contains the userid and
>> password to my Mysql database and hence anyone who has access to the
>> ISP's  filesystem can mess my database up.
>
>#1 Make sure you pick a trustworthy web hosting provider

It's really the other users to the filesystem that worry me.

>#2 Make sure that if someone steals the username/pass for the database and
>log on, it will allow them to do minimal to zero changes (maybe permissions
>to only do SELECT queries). This is a restriction that's implemented on the
>database side

Not really possible since need to insert, delete, update rows during
the course of running the application.

>#3 Not really a great idea, but use security through obscurity. Try to
>obfiscuate your password to an extent that a casual sysadmin will not be
>able to figure it out. Think of a neat way to do 2-way enc/dec/ryption and
>store the password in the encrypted form, to be encrypted dynamically at
>runtime.

Not possible to hide the key.  Stops casual cribs


>#4 See if you can compile the script or delegate the password setting to a
>compiled piece. Note that statically declared strings in source code are
>often seen as plaintext inside a compiled binary executable, so you might
>want to use this option in conjunction with option #3


I connect to the db using DBI which as far as I am aware is
interpreted.  Could I call a compiled prog which in tern calls a Perl
function and still handle all of the handles $dbh etc.


>
>That's all I can think of. Hopefully someone will provide better ideas.
>

Thanks for the ideas.

>>
>> How do I prevent this?
>>
>> O.
>> ------------------
>> Owain McGuire owain@nospam.ofrm.demon.co.uk (Minus the nospam.)
>
>

------------------
Owain McGuire owain@nospam.ofrm.demon.co.uk (Minus the nospam.)


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

Date: 27 Nov 2001 01:23:00 -0800
From: eguttridge@buildonline.com (bigpig)
Subject: Perl script - display log file in browser
Message-Id: <b09860cc.0111270123.471738a3@posting.google.com>

Hi,

I am looking for some example code to reside in /cgi-bin which will
display a UNIX log file (eg. /var/adm/messages) in a browser. All
example code is appreciated.


Thank you.


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

Date: Tue, 27 Nov 2001 05:44:15 GMT
From: "David Mohorn" <david.mohorn@home.com>
Subject: Perl/TK with DBI
Message-Id: <PKFM7.19369$V46.4551430@news1.rdc1.va.home.com>

I need to rewrite an Unix AIX perl application of mine that makes extensive
use of DBI to talk to a SQL Server.  Does anyone have any examples of how
they might use Perl/Tk with DBI?  The result from the query will need to be
put into a listbox or scrollable text box.

Any help would be appreciated...

david.mohorn@home.com





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

Date: 27 Nov 2001 01:44:11 -0800
From: msergeant@star.net.uk (Matt Sergeant)
Subject: Re: Problem with XML::DOM
Message-Id: <eb3031b9.0111270144.7c239fe8@posting.google.com>

M Pritchard <noemail@---stealthmode---.com> wrote in message news:<MPG.166c0cba42b2212798978d@news1.server.wcom.com>...
> Hello
> 
> I've been using ActivePerl on a Windows NT machine and I've just started 
> playing with the XML::DOM package.  I seem to be having a strange problem 
> with the createProcessingInstruction function.
> 
> This:
> 
>     $element = $doc->createProcessingInstruction(
>                   "xml", "version=\"1.0\" encoding=\"UTF-8\"");
> 
> Throws this exception:
> 
>     XML::DOM::DOMException(Code=5, Name=INVALID_CHARACTER_ERR,           
>                 Message=bad ProcessingInstruction Target [xml])
> 
> But changing "xml" to something else, like 
> 
>     $element = $doc->createProcessingInstruction(
>                   "xyz", "version=\"1.0\" encoding=\"UTF-8\"");
> 
> Seems to work fine, except for the resulting XML has the wrong processing 
> instruction.
> 
> Am I doing something dumb?

The XML declaration (the <?xml version="1.0"?> bit) isn't a processing
instruction, and processing instructions beginning with <?xml are
illegal in XML. So the DOM throws you an error. The XML declaration is
supposed to be created by the DOM serialisation, and you should be
able to specify the version and so on at DOM creation time, though I
don't know the DOM API off the top of my head.


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 2215
***************************************


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