[22743] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4964 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 9 14:07:57 2003

Date: Fri, 9 May 2003 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 9 May 2003     Volume: 10 Number: 4964

Today's topics:
        "use_pty" does not work for SSH2 (Quackie)
        alarm and readline <spambox@centrum.cz>
    Re: Bloody Java Proselytisers!!! <denshimeiru-sapmctacher@durchnull.ath.cx>
    Re: Bloody Java Proselytisers!!! <cwilbur@mithril.chromatico.net>
    Re: Bloody Java Proselytisers!!! <goedicke@goedsole.com>
    Re: Bloody Java Proselytisers!!! <tassilo.parseval@rwth-aachen.de>
    Re: Bloody Java Proselytisers!!! <p.lord@russet.org.uk>
    Re: Bloody Java Proselytisers!!! <p.lord@russet.org.uk>
    Re: Bloody Java Proselytisers!!! <cwilbur@mithril.chromatico.net>
    Re: Bloody Java Proselytisers!!! <cwilbur@mithril.chromatico.net>
        dont match this pattern <user@someserver123abc.com>
    Re: How do you create a biniary file in Perl. <tassilo.parseval@rwth-aachen.de>
    Re: How many groups have a regex? <tassilo.parseval@rwth-aachen.de>
    Re: How many groups have a regex? <auch-ich-m@g-kein-spam.com>
    Re: How many groups have a regex? <nobull@mail.com>
        Insecure $ENV{PATH} error under mod_perl (Michael Pohl)
    Re: Logic(al nightmare!) <usenet@dwall.fastmail.fm>
    Re: Newbie - packing Perl application for distribution <simon.andrews@bbsrc.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 9 May 2003 06:19:19 -0700
From: minh_quoc@yahoo.com (Quackie)
Subject: "use_pty" does not work for SSH2
Message-Id: <39787a94.0305090519.218ca19a@posting.google.com>

I have a Perl script on Windows 2000 that uses the Net::SSH::W32Perl
package to login to the SSH server on Solaris 8 and execute commands
remotely.
Everything works fine.  I can login to the system and execute basic
commands such as "ls", "pwd" ...  However, for commands such as "su"
and "passwd", it does not work at all.  I found out that the reason it
does not work because for security reason, these commands require an
allocation of ptty before runs the commands.
I read from the docs and see that in the docs there is an option
called "use_pty" which is exactly what I wanted.  If set this
"use_pty" to 1, the ptty supposed to be allocated before a command is
executed.  However, when I set this "use_pty" to 1, it still does not
work. I, then, search the source code of the Net::SSH::Perl package
for this option and found that this feature is only implemented on
SSH1 but not in SSH2 unless you request a shell ($ssh->shell)

The code to allocate a ptty is something similiar to this:

        my $r_packet = $channel->request_start('pty-req', 0);
        my($term) = $ENV{TERM} =~ /(\w+)/;
        $r_packet->put_str($term);
        $r_packet->put_int32(0) for 1..4;
        $r_packet->put_str("");
        $r_packet->send;

Under the cmd function in SSH2.pm (sub cmd), you don't see this code
is used. I tried to modify the source code and put these lines into
sub cmd before it sends the commands, but I got no success of doing
it.  It cause the server and client to hang.

Here is the part of the code I modify:

sub cmd {
    my $ssh = shift;
    my($cmd, $stdin) = @_;
    my $cmgr = $ssh->channel_mgr;
    my $channel = $ssh->_session_channel;
    $channel->open;

    $channel->register_handler(SSH2_MSG_CHANNEL_OPEN_CONFIRMATION, sub
{
        my($channel, $packet) = @_;

        # these r the lines I added
        my $r_packet = $channel->request_start('pty-req', 0);
        my($term) = $ENV{TERM} =~ /(\w+)/;
        $r_packet->put_str($term);
        $r_packet->put_int32(0) for 1..4;
        $r_packet->put_str("");
        $r_packet->send;
        # end of modify cmd        

        $channel->{ssh}->debug("Sending command: $cmd");
        my $r_packet = $channel->request_start("exec", 0);
        $r_packet->put_str($cmd);
        $r_packet->send;
        .
        .

Anyone here success executing these commands "su" and "passwd"
remotely?  Is something i am missing?
If this is a bug in Net::SSH::Perl, then any Perl expert here can hack
into the source code and fix the "use_pty" feature?

Thanks


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

Date: 9 May 2003 17:44:22 GMT
From: Jiri <spambox@centrum.cz>
Subject: alarm and readline
Message-Id: <b9gpdm$iprvo$1@ID-134981.news.dfncis.de>

Hello,
I've recently upgraded Perl to 5.8.0.  To be honest, I don't know what 
version of Perl I was using before, but it was about 2/3 years old.

After the installation, I've noticed some unusual problems with vicq (a 
Perl ICQ client---on of the reasons I use it is https proxy support, it 
is quite configurable and (most important of all) runs on console).  I was 
able to send messages, but they seemed to arrive only when I pressed enter.

I think I've figured out what is wrong, but wasn't able to fix it.  They 
set alarm to show messages that arrive, but the alarm function doesn't seem 
to work when readline is used.  It must have worked with the previous 
version of Perl---I didn't have any problems.  

Any ideas?  Is there any other way of setting alarm which would interrupt 
the readline function from Term::ReadLine or Term::ReadLine:Gnu?

I don't have much time to rewrite the whole vicq client to use threads.

Many thanks in advance.

-- 
Jiri


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

Date: 9 May 2003 13:09:36 GMT
From: Rudolf Polzer <denshimeiru-sapmctacher@durchnull.ath.cx>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <slrnbbna60.nmu.denshimeiru-sapmctacher@message-id.durchnull.ath.cx>

Scripsit ille »Xavier Noria« <fxn@hashref.com>:
> In article <slrnbbmchf.nc8.denshimeiru-sapmctacher@message-id.durchnull.ath.cx>, Rudolf Polzer wrote:
> 
> : There is no such thing as a best language. There aren't even better and
> : worse languages. There are just DIFFERENT languages. There are cases in
> : which one language seems to be better than another one (Java provides
> : platform-independent character encoding and GUI handling, Perl allows
> : doing much without writing much BUT IS SLOWER
> 
> Slower? Than Java? I don't think that's true in general, for a convenient
> definition of general. I think perl is damn fast at most things. 

As soon as you can use Perl's integrated features (REs for example), Perl
wins. As soon as you do ANY larger amount of I/O, Perl wins.

For a simple backtracking algorithm (I think I should do the comparison
again with a more known problem, perhaps "n queens"), I found out that
Java is 30% slower than C or C++ (equally fast), Free Pascal was 40%
slower, GNU Pascal was 20% slower (so Java positioned itself between
the "compiled" languages). With the same problem, Perl lost by factor
200 to C. I hadn't known Ruby at that time.

But - such a simple computation can easily be done in C, so Inline::C
in Perl or Ruby's C interface (which is far easier to use and understand
than Perl's - that's why I named Inline::C and not XS) would be one's
choice then.

I'll redo the comparison with the n queens problem, even including
languages like Prolog - and will post the results. It might be
interesting.

I'll then also try to put in debugging output and compare again, so that
I/O performance becomes visible.


-- 
Noe, das Leerzeichen bedeutet, dass genau an dieser Stelle das Denken
aussetzt oder so.
                       [Rosie Schuler in t-online.talk.allgemein über's Plenken]


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

Date: Fri, 09 May 2003 14:58:13 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <87smromanu.fsf@mithril.chromatico.net>

Rudolf Polzer <denshimeiru-sapmctacher@durchnull.ath.cx> writes:

> I can understand anyone disliking Perl. But until now I haven't
> found out what's so good about Java. It's like a stripped-down C++
> together with a relatively big class library providing support for
> GUIs for example. So why should one use Java instead of C++ if he
> doesn't need Java's big class library? Or: if he can make use of
> C++'s templates to make his code more generic?

It's easier to find a dozen mediocre programmers than a single
top-notch programmer, and the language and culture of Java make it
possible to coordinate those 12 mediocre programmers so that they can
get the project done.  At the same time, it lessens the amount of
damage a mediocre programmer can do, and allows managers to treat
programmers like interchangeable parts without significant damage to
the project.  You're still better off with good programmers than with
mediocre ones, but you can get the job done with mediocre programmers,
which is not the case for a lot of other languages.  It also has a lot
of glossy-magazine PR behind it, which helps the suits a great deal.

And if what you use every day at work is Java, and you have the sort
of education that's depressingly common -- i.e., you have a degree in
the field, but you've never used any other language for more than two
weeks; or you have no formal computer science education and picked up
Java for Dummies because you thought there was money in it -- then
you're not going to bother learning C++ for the sake of the project,
and even if you did, the requirement for explicit memory management
would probably baffle you, coming from a garbage-collected language.

Charlton



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

Date: Fri, 09 May 2003 15:25:30 GMT
From: William Goedicke <goedicke@goedsole.com>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <m3u1c4uopq.fsf@mail.goedsole.com>

Dear Charlton - 

Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

> It's easier to find a dozen mediocre programmers than a single
> top-notch programmer

Truer words were never spoken.

> the language and culture of Java make it possible to coordinate
> those 12 mediocre programmers so that they can get the project done.

Of course, projects can be completed with mediocre programmers in any
language.  What characteristic does java have that makes it better at
this than other languages?

> At the same time, it lessens the amount of damage a mediocre
> programmer can do, and allows managers to treat programmers like
> interchangeable parts without significant damage to the project.

How?

> you can get the job done with mediocre programmers, which is not the
> case for a lot of other languages.

Please name one and explain why.

     Yours -      Billy

============================================================
     William Goedicke     goedicke@goedsole.com            
                          http://www.goedsole.com:8080      
============================================================

          Lest we forget:

You're wasting your time talking to Billy about
current pop culture..

		- Ted Silva


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

Date: 9 May 2003 16:16:15 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <b9gk8f$6fr$1@nets3.rz.RWTH-Aachen.DE>

Also sprach William Goedicke:

> Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

>> the language and culture of Java make it possible to coordinate
>> those 12 mediocre programmers so that they can get the project done.
> 
> Of course, projects can be completed with mediocre programmers in any
> language.  What characteristic does java have that makes it better at
> this than other languages?

One thing that I think could justify the above statement is the fact
that Java offers only a limited number of ways and shortcuts to do a
particular task. It's no coincidence that creating JAPHs and golf are
two things that have evolved for Perl and not for Java (at least not
that I know, otherwise I stand corrected).

>> At the same time, it lessens the amount of damage a mediocre
>> programmer can do, and allows managers to treat programmers like
>> interchangeable parts without significant damage to the project.
> 
> How?

One example: Have a look at t/test_bases.t in the Regexp::Common
distribution. It's a typical Abigailism. I surely wouldn't want to
maintain line 1 throughout 5 of this file.

>> you can get the job done with mediocre programmers, which is not the
>> case for a lot of other languages.
> 
> Please name one and explain why.

Perl would be one. But not the only language which this applies to. I
think that languages with a really vast of concepts and features
qualify. So LISP might be another example. The more ways a language
provides to solve a particular task, the more likely the solutions
produced by different programs will differ. 

Mark Jason Dominus has not long ago created two weekly quizzes (a
beginner's one and an advanced one): Each week there was a quizz to be
solved in Perl. The solutions differed drastically. See
<http://perl.plover.com/qotw/> for an archive of the mailing-list. The
quizzes are currently on rest because MJD is busy, though.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 09 May 2003 17:32:03 +0100
From: Phillip Lord <p.lord@russet.org.uk>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <vfsmrokrng.fsf@rpc71.cs.man.ac.uk>


>>>>> "Charlton" == Charlton Wilbur <cwilbur@mithril.chromatico.net> writes:

  Charlton> And if what you use every day at work is Java, and you
  Charlton> have the sort of education that's depressingly common --
  Charlton> i.e., you have a degree in the field, but you've never
  Charlton> used any other language for more than two weeks; 

Well I didn't have that sort of education, at least not in
programming. 

  Charlton> or you have no formal computer science education and
  Charlton> picked up Java for Dummies because you thought there was
  Charlton> money in it

but I did have this sort of education, although I don't think it was
java for dummies I used. 

  Charlton> -- then you're not going to bother learning C++ for the
  Charlton> sake of the project, and even if you did, the requirement
  Charlton> for explicit memory management would probably baffle you,
  Charlton> coming from a garbage-collected language.

Actually no. It would irritate me. Having written in code in quite a
few different languages, most of them (java, lisp, perl) with GC of
differing qualities, I have to say that its a positively good thing. 

I find myself continually confused by people who seem to think that
coping with explicit memory management is a badge of honour, or is a
sign of a good programmer. I can cope with it, if I am forced to. But
I'd much rather not.

Maybe its because I'm really not a programmer. I just need to get
something done with a computer, and this requires that I write
relatively large code bases, so I do.


Phil


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

Date: 09 May 2003 17:52:54 +0100
From: Phillip Lord <p.lord@russet.org.uk>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <vfn0hwkqop.fsf@rpc71.cs.man.ac.uk>

>>>>> "Dodger" == Dodger  <dodger@dodger.org> writes:

  Dodger> Well, the parts I thought were funny were that he seemed to
  Dodger> be taking the approach that Java was far superior because
  Dodger> it's Object-oriented (okay, okay, Perl is technically not OO
  Dodger> but it pretends well enough like it is to make the detail
  Dodger> irrelevant in coding practice, if not in overhead),


Java's object orientation is nicer than perls, although even its not
perfect. Type's are good as well, although I realise that some people
do not like them. I really miss them in a non typed language. 


  Dodger> because Java is (his words) good at parsing strings, because
  Dodger> Java has lots of classes available, and because Java is
  Dodger> fastest to develop in.

Java is fast to develop in. Its not good at parsing strings. Perl is
very good at text processing, as this is what it was designed for. 


  Dodger> Oh, yeah -- and he said that Perl's 'method of dealing with
  Dodger> strings is weird.' 

It depends which side of the fence you are coming from. Perls variable
interpolation always strikes as odd, although other languages do it as
well. 


  Dodger> Took me a bit to figure out what he was talking about there
  Dodger> (especially since Java doesn't natively deal with strings at
  Dodger> all, just bytearrays). 

What can you mean by this I wonder? Perhaps you are referring to C?
Java has lots of support for Strings. 



  Dodger> Also, there are best languages for specific applications --
  Dodger> or, rather, there are definite NOT-GOOD languages for some
  Dodger> things. If anyone insists on disagreeing, I invite them to
  Dodger> write a closure in Java. B^)

Why would you invite some one to do such a thing? Closures are not
supported by Java. And frankly, who cares? Ask them to fulfil a
specific task. You might use closures in perl, or lisp. In java you
would use a different construct, such as an object. 

I know its hard to believe but the relative lack of language features
in Java, compared to perl is one of its advantages in my eyes. I've
written a reasonable amount of perl in my life, and am relatively
comfortable with it now, but I still find it hard to read others code,
as there are so many different programming idioms around. 

Phil


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

Date: Fri, 09 May 2003 17:28:13 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <87k7d0m40c.fsf@mithril.chromatico.net>

William Goedicke <goedicke@goedsole.com> writes:

> > the language and culture of Java make it possible to coordinate
> > those 12 mediocre programmers so that they can get the project done.
> 
> Of course, projects can be completed with mediocre programmers in any
> language.  What characteristic does java have that makes it better at
> this than other languages?

Bondage and discipline syntax: there's often only one way to do it,
and the language enforces its predominant design paradigm.

A dominant approach to design: I have yet to encounter a Java
programmer who has not at least heard of Model-View-Controller.

An enormous standard library: this, combined with the bondage and
discipline syntax, means that frequently it's an order of magnitude
easier to use something previously built than to rebuild from the
ground up.

Consistent support from Sun, and consultants who support Sun have the
same design philosophy.

> > At the same time, it lessens the amount of damage a mediocre
> > programmer can do, and allows managers to treat programmers like
> > interchangeable parts without significant damage to the project.
> 
> How?

Object orientation, corporate mindset, and mindshare, principally.

> > you can get the job done with mediocre programmers, which is not the
> > case for a lot of other languages.
> 
> Please name one and explain why.

Perl.  Because there's more than one way to do it, you need to have a
project manager with an extremely firm hand to keep the project
under control and maintainable.  Also because there's more than one
way to do it, the right way to do it is often not clear to the
mediocre programmer.  (If there are multiple right ways, this isn't a
problem; in a case where some ways are better than others, it is a
huge problem.)  You can use Perl to program in many different idioms;
the project manager must pick an idiom and find a way to enforce that
his team uses it, or support costs increase because the maintainers
must understand *all* the idioms that Perl supports.

While Perl has a tremendous library in CPAN, it's not often clear,
especially to mediocre programmers, that using a module is the right
thing to do.  Consider how many programmers -- even ones who should
know better -- roll their own CGI code rather than using CGI.pm or
CGI::Lite.pm.  And while Perl support is quite good, it's not
monolithic, and there are a diversity of views and approaches
contained in it.

This is not to say that Java is a better language than Perl in some
absolute judgment, by any means; given an appropriate number of good
programmers, I'd go with Perl without a second thought, and I use Perl
a great deal more than I use Java.  But if I were a manager who had to
run a large project, given the ubiquity of mediocre programmers, I'd
almost certainly go with Java, for the reasons I've outlined above.

I could probably do the same thing with a number of other languages.
My point was not to argue language advocacy, but to point out the
reasons that Java is so popular.  It doesn't give the good programmer
anything that he can't find in Perl or C++ *spit* or C or Ruby or
Python, but it does have real benefits for mediocre programmers.

Charlton



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

Date: Fri, 09 May 2003 17:58:13 GMT
From: Charlton Wilbur <cwilbur@mithril.chromatico.net>
Subject: Re: Bloody Java Proselytisers!!!
Message-Id: <87addwm2by.fsf@mithril.chromatico.net>

"Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de> writes:

> One example: Have a look at t/test_bases.t in the Regexp::Common
> distribution. It's a typical Abigailism. I surely wouldn't want to
> maintain line 1 throughout 5 of this file.

And Abigail is a perfect example.  He does absolutely brilliant things
with Perl, but it takes another good programmer to grasp what he's
done, and a programmer of his level to maintain it appropriately.  

If I had a team of Abigails I'd have no problem solving the world in
Perl.

Charlton



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

Date: Fri, 09 May 2003 13:43:22 -0400
From: stinkbomb <user@someserver123abc.com>
Subject: dont match this pattern
Message-Id: <3EBBE8BA.DD2C52C4@someserver123abc.com>

I'm able to !match a single character, but what about a longer string?

/[^x]/ in 
$str =~ s/[^x]/something/g;
will match a string that's not x.
I cant seem to do that with a string. 

I want to be able to incorporate this into a more complex regex
like:

$str =~ s/(match this)(exclude this)(match this)/something/;


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

Date: 9 May 2003 15:19:22 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: How do you create a biniary file in Perl.
Message-Id: <b9ggtq$32f$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Anno Siegel:

> Tassilo v. Parseval <tassilo.parseval@post.rwth-aachen.de> wrote in comp.lang.perl.misc:
>      
>>     seek F, SEEK_SET, 20;           # jump to 20th byte
>>     seek F, SEEK_CUR, 20;           # 20 bytes ahead from the current pos
>>     seek F, SEEK_END, -20;          # 20 bytes before EOF
> 
> You have the second and third parameter of seek swapped.

Oups, I have! Good catch, Anno. I should be more careful with quoting
from memory.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: 9 May 2003 15:23:52 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: How many groups have a regex?
Message-Id: <b9gh68$394$1@nets3.rz.RWTH-Aachen.DE>

Also sprach André Malo:

> * i5513 wrote:
> 
>> Hi again, I need a copy of $1..$last after a $var =~ /$er/ is done.
>>
>> Is there any var that says how many groups are there at last
>> expression evaluate?
> 
> Just count the opening parentheses in $er, which aren't followed by a
> question mark.

And which aren't preceeded by an uneven number of backslashes.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Fri, 9 May 2003 17:51:34 +0200
From: =?ISO-8859-1?Q?Andr=E9?= Malo <auch-ich-m@g-kein-spam.com>
Subject: Re: How many groups have a regex?
Message-Id: <j49h2fwkn561ndparker@news.perlig.de>

* Tassilo v. Parseval wrote:

> Also sprach Andr=E9 Malo:
>
>> * i5513 wrote:
>>
>>> Hi again, I need a copy of $1..$last after a $var =3D~ /$er/ is done.
>>>
>>> Is there any var that says how many groups are there at last
>>> expression evaluate?
>>
>> Just count the opening parentheses in $er, which aren't followed by a
>> question mark.
>
> And which aren't preceeded by an uneven number of backslashes.

ehm... yes.
I convinced, Anno's solution is much better anyway ;-)

nd
--=20
If God intended people to be naked, they would be born that way.
  -- Oscar Wilde


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

Date: 09 May 2003 17:21:27 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How many groups have a regex?
Message-Id: <u93cjow0oo.fsf@wcl-l.bham.ac.uk>

i5513@hotmail.com (i5513) writes:

> Hi again, I need a copy of $1..$last after a $var =~ /$er/ is done.

Why must it be done after?  Why not just do it at the same time?
 
> Is there any var that says how many groups are there at last expression evaluate?

scalar(@+) or scalar(@-)

> $var =~ /$er/;
> # $n_groups = n_match_parents ($er) 
> map { $groups{$_} = ${$_}} 0 .. $n_groups;

You mean 1 not 0. $0 is something totally unrelated.

Why is %groups a hash?  An array is a more natural data-type.

See FAQ: "What's wrong with using grep or map in a void context?"

Also if you must use symbolic references enable them only in the
smallest applicable scope.

for ( 1 .. @+ ) {
   no strict 'refs'; 
   $groups{$_} = ${$_};
}

Better still just do:

my @groups = $var =~ /$er/;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 9 May 2003 10:29:50 -0700
From: google@newtopia.com (Michael Pohl)
Subject: Insecure $ENV{PATH} error under mod_perl
Message-Id: <da4ea47.0305090929.36be0da1@posting.google.com>

I'm apparently misinterpreting something from perldoc perlsec.  Under
mod_perl, with PerlTaintCheck On server-wide, the following code in a
use()'d module:

$ENV{PATH} = '';
$rc = `/usr/local/ghostscript/bin/gs -dNODISPLAY -sNOPAUSE $code_file
-c quit`;

throws the following error:

[Fri May  9 12:58:52 2003] [error] Insecure $ENV{PATH} while running
with -T switch at /home/michaelp/dev/cp/cgi-bin/eps.pm line 2077.

I also have PATH set in my Apache conf:

PerlSetEnv PATH "/bin:/usr/bin:/usr/local/bin"
PerlPassEnv PATH

Input appreciated.

thanks,

michael


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

Date: Fri, 09 May 2003 16:39:36 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Logic(al nightmare!)
Message-Id: <Xns937680C8F2693dkwwashere@216.168.3.30>

Brad Walton <sammie@greatergreen.com> wrote:

> I solved the problem. Was tough for me, and just in case anyone
> else comes across this issue I will post how I solved it.
> 
> The premise: You have 3 arrays (one in a file) and need to either
> replace information, or write new information, to the file
> (depending on whether it exists already). @discpl represents the
> changes 'keys' to the other arrays. This method requires Tie::File
> module: 
> 
> sub file_stats_left {
>  tie @DB, 'Tie::File', $dormantstatdb or "cannot open
>  $dormantstatdb: $! 
> \n";

I think you mean 

tie @DB, 'Tie::File', $dormantstatdb 
    	or die "cannot open $dormantstatdb: $!\n";

You won't get a syntax error with what you wrote, but as Tad 
McClellen pointed out, it probably isn't what you mean.


>  for (@DB) {
>   ($type,$name,@rest) = split /\t/, $_;
>   foreach $discpl (@discpl) {
>    if ($discpl eq $name) {
>     foreach $oldsession (@oldsession) {
>      if ($oldsession =~ /$name/) {
>       $_ = $oldsession;
>      }
>     }
>    $added{$discpl} = 1;
>   }
>  }
> }

Where do @oldsession, @discpl, and %added come from?  Are they global 
variables?  If so, should they be?  Why?


>  foreach $discpl (@discpl) {
>   if (!$added{$discpl}) {
>    foreach $oldsession (@oldsession) {
>     if ($oldsession =~ /$discpl/) {
>      push @DB, $oldsession;
>     }
>   }
>  }
> }
> 
>  untie @DB;
>}
> 
> Hope that helps someone,

Even without doing anything about the global variables floating 
around, the code can be shorter and clearer by using 'next' and a few 
statement modifiers:


sub file_stats_left {
    my @DB;
    tie @DB, 'Tie::File', $dormantstatdb 
        or die "cannot open $dormantstatdb: $!\n";
    for my $db (@DB) {
        my $name = (split /\t/, $db)[1];
        foreach my $discpl (@discpl) {
            next unless $discpl eq $name;
            foreach my $oldsession (@oldsession) {
                $db = $oldsession if $oldsession =~ /$name/;
            }
            $added{$discpl} = 1;
        }
    }

    foreach my $discpl (@discpl) {
        next if $added{$discpl};
        foreach my $oldsession (@oldsession) {
            push @DB, $oldsession if $oldsession =~ /$discpl/;
        }
    }

    untie @DB;
}


Please notice that I added 'my' in several places as well, so as to 
confine the scope of a variable to the loop where it's used.

It seems you're not using the strict and warnings pragmas.  For your 
own sanity and convenience, you should be.  

This is the most important piece of advice you've been given (not 
just by me).

Enabling strict and warnings will help you produce safer, cleaner, 
and less buggy code.  It may still be buggy in many ways, but strict 
and warnings will catch some things for you;  let perl help you as 
much as it can.  

If nothing else, declaring variables with my() (a requirement if you 
use strict) will make your program run faster, although it's more 
important that it be correct than fast.

-- 
David Wall


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

Date: Fri, 09 May 2003 16:48:17 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Newbie - packing Perl application for distribution
Message-Id: <3EBBCDC1.805@bbsrc.ac.uk>


Chris Trueman wrote:
> I have a couple of Perl utilities that I'd like to distribute to 
> colleagues.  I can expect them to download and install a binary 
> distribution of Perl but having them install the modules that my code 
> depends on is probably too much.
> 
> Is there a simple way to package my code + that required modules that will 
> make it easy for them to install the utilities?

Yep.  Take a look at the PAR module.  They don't even need perl 
installed if you use the pp utility.

http://search.cpan.org/author/AUTRIJUS/PAR-0.67/

HTH

Simon.



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

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


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