[22935] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5155 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jun 30 11:06:03 2003

Date: Mon, 30 Jun 2003 08:05:14 -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           Mon, 30 Jun 2003     Volume: 10 Number: 5155

Today's topics:
    Re: Fast CGI Vs Java Application Servers <Kyler@news.Lairds.org>
    Re: Fast CGI Vs Java Application Servers <wojciech@n0spam-kocjan.org>
    Re: Getting the total size of files matching a pattern? (Tad McClellan)
    Re: Hide source, compiling, whatever! <simon.andrews@bbsrc.ac.uk>
    Re: How do you sort a 2D array with column headers? (Greg Bacon)
    Re: How to create a file <me@privacy.net>
    Re: How to pass global variables between files (Tad McClellan)
    Re: How to pass global variables between files <nobull@mail.com>
        How to test a hash of arrays for defined/not defined (Steve)
    Re: How to test a hash of arrays for defined/not define <kalinabears@hdc.com.au>
    Re: How to test a hash of arrays for defined/not define (Tad McClellan)
        Is there a good free/not so expensive Perl IDE for Linu <gblydenburgh@nospam.com>
    Re: Is there a good free/not so expensive Perl IDE for  <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: Is there a good free/not so expensive Perl IDE for  (Tad McClellan)
    Re: Is there a good free/not so expensive Perl IDE for  <arc_of_descent@gmx.net>
    Re: Is there a good free/not so expensive Perl IDE for  <abigail@abigail.nl>
    Re: Is there a good free/not so expensive Perl IDE for  <gblydenburgh@nospam.com>
    Re: Is there a good free/not so expensive Perl IDE for  (Greg Bacon)
    Re: Is there a good free/not so expensive Perl IDE for  <kkeller-spammmm@wombat.san-francisco.ca.us>
        loading a module dependant on the OS <user@host.com>
    Re: loading a module dependant on the OS <nobull@mail.com>
    Re: loading a module dependant on the OS <arc_of_descent@gmx.net>
    Re: loading a module dependant on the OS <noreply@gunnar.cc>
    Re: loading a module dependant on the OS <user@host.com>
    Re: loading a module dependant on the OS <user@host.com>
        Messing with UID's and GID's (Dave Ardrey)
    Re: Messing with UID's and GID's (Greg Bacon)
    Re: Newbie problem with open <abuse@sgrail.org>
    Re: Sending the "down" key via Expect <minceme@start.no>
    Re: Speed of file vrs dbase access <abigail@abigail.nl>
    Re: Storable module for Activestate 5.6.1?? (Kenjis Kaan)
        storing variables using system (dipu bhaskar)
    Re: storing variables using system <ian@WINDOZEdigiserv.net>
    Re: storing variables using system <tony_curtis32@yahoo.com>
    Re: String matching not working <eric-amick@comcast.net>
    Re: String matching not working <s_grazzini@hotmail.com>
    Re: String matching not working <nobull@mail.com>
    Re: Using filehandle many times (Tad McClellan)
    Re: Using filehandle many times <thens@nospam.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 30 Jun 2003 11:42:31 GMT
From: Kyler Laird <Kyler@news.Lairds.org>
Subject: Re: Fast CGI Vs Java Application Servers
Message-Id: <nrv3t-q2a.ln1@news.lairds.com>

Irmen de Jong <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> writes:

>A (fast)CGI program compared to the actual Java program may not be
>much of a difference, depending on the program of course. What is
>a *huge* difference is that the Java app is running inside an
>*application server*. A (J2EE) Application Server provides a
>rich environment on which to base your scalable enterprise applications:

Outstanding points.  For trivial applications, CGI is fine, but beyond
that we get into the need for this infrastructure.  Creating it from
scratch (or bundling it into each application) is a pain and demands
ongoing maintenance.  It's great for "tinkerers" but doesn't make
sense for someone wanting to concentrate on building applications.

A Python solution for all of this is Zope.

--kyler


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

Date: Mon, 30 Jun 2003 15:34:15 +0200
From: Wojciech Kocjan <wojciech@n0spam-kocjan.org>
Subject: Re: Fast CGI Vs Java Application Servers
Message-Id: <bdpe9q$rt0$1@nemesis.news.tpi.pl>

Kyler Laird wrote:
> Irmen de Jong <irmen@-NOSPAM-REMOVETHIS-xs4all.nl> writes:
> 
> 
>>A (fast)CGI program compared to the actual Java program may not be
>>much of a difference, depending on the program of course. What is
>>a *huge* difference is that the Java app is running inside an
>>*application server*. A (J2EE) Application Server provides a
>>rich environment on which to base your scalable enterprise applications:
> 
> 
> Outstanding points.  For trivial applications, CGI is fine, but beyond
> that we get into the need for this infrastructure.  Creating it from
> scratch (or bundling it into each application) is a pain and demands
> ongoing maintenance.  It's great for "tinkerers" but doesn't make
> sense for someone wanting to concentrate on building applications.

That depends. Many companies want to write their own base modules, so 
that they can be extended to meet their needs. This is very time 
consuming, but the upside is that you know the code perfectly and are 
able to fix bugs/enhance the code very fast.

> A Python solution for all of this is Zope.

And a Tcl solution is AOLserver and OpenACS :-)

-- 
WK



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

Date: Mon, 30 Jun 2003 06:41:33 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Getting the total size of files matching a pattern?
Message-Id: <slrnbg08fd.2u8.tadmc@magna.augustmail.com>

Math55 <magelord@t-online.de> wrote:

> is there a goor mothod to get the total size of special files
> in a directory? for example all *.gz and *.html file in /var/log or


   perl -e '$i += -s for @ARGV; print "$i\n"' /var/log/*.html /var/log/*.gz

or 

   perl -e '$i += -s for </var/log/*.html /var/log/*.gz>; print "$i\n"'


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Jun 2003 12:22:05 +0100
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: Re: Hide source, compiling, whatever!
Message-Id: <3F001D5D.3060900@bbsrc.ac.uk>



Mike wrote:

>>The PAR module (available from CPAN) does the
>>same thing and is free.
>  
> I really think that this will work, I appreciate the tip! It won't be
> perfect, but probably close enough.

The PAR module won't help you at all.  PAR is a packaging mechanism 
which bundles your Perl code (+modules and optionally a Perl 
interpreter) into a single file, which is easy to distribute.  When the 
file is run it decompresses the code and runs it.  The code is right 
there in a temp file for all the world to see. (I seem to remember that 
if you even open the .exe in a text editor, the code is there in plain 
text).

Also, you don't want to use a PAR exe as a CGI script as there would be 
a large overhead on every execution whilst the code was decompressed.

If this is just a CGI script then why not host it yourself somewhere and 
let your customer point their forms at it?   That way you retain full 
control over your code.

HTH

Simon.




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

Date: Mon, 30 Jun 2003 14:39:54 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: How do you sort a 2D array with column headers?
Message-Id: <vg0itq8h40r616@corp.supernews.com>

In article <2bevfvsti9fbk1u6s0cvb1n4gf9r8s0lqk@4ax.com>,
     <Dennis@NoSpam.com> wrote:

: Thanks Greg for the really great Perl code and explanations on how it
: works. [...]

Glad to help.

Greg


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

Date: Mon, 30 Jun 2003 23:10:31 +1200
From: "Tintin" <me@privacy.net>
Subject: Re: How to create a file
Message-Id: <bdp5o6$ums04$1@ID-172104.news.dfncis.de>


"Bernt Levinsson" <levin.spambox@telia.com> wrote in message
news:2r9ufv84uqeieotvfqtah3mo2c40r6cauo@4ax.com...
> This I've learned:
> open(OUTFILE, ">output.txt");
>
> But, if the file doesn't exists, how can get the file handle to write
> to a new file?

Prove that it doesn't




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

Date: Mon, 30 Jun 2003 07:28:34 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to pass global variables between files
Message-Id: <slrnbg0b7i.2u8.tadmc@magna.augustmail.com>

Monday <monday94301@yahoo.com> wrote:

> I want to call a subroutine and have it access the
> global variables in the caller program, 


Why do you want to call a subroutine and have it access the
global variables in the caller program?

That will open you up to action-at-a-distance bugs.

Why not pass the variables as subroutine arguments instead?


> How do I do this since there is no 'include' type of statement in
> Perl?


What leads you to believe that there is no "include type" of
statement in Perl?

(a rhetorical question, since you do not need an "include"
 mechanism to get What You Want.
)


> index.cgi
>=========
> #!c:/perl/bin/perl.exe


   require '/path/to/called.cgi'; # so perl will know where sub callNow() is


> our $globalVar = "Chicago";
> callNow();
> return 1;
> 
> called.cgi
>==========
> callNow() {
>     print "global variable is $globalVar";


   print "global variable is $main::globalVar";


> }


   1;  # make 'require' happy



See also:

   "Coping with Scoping":

      http://perl.plover.com/FAQs/Namespaces.html


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 30 Jun 2003 13:17:56 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to pass global variables between files
Message-Id: <u9r85bdaiz.fsf@wcl-l.bham.ac.uk>

monday94301@yahoo.com (Monday) writes:

> Hello, I am new to Perl. I want to do something simple but seem to be
> unable to do this. I want to call a subroutine and have it access the
> global variables in the caller program, similar to below where
> index.cgi is the calling program and called.cgi is the called program.
> How do I do this since there is no 'include' type of statement in
> Perl? 

I don't know, since you must be living in a paralell universe.  In my
universe Perl has require, use and do.

> index.cgi
> =========
> #!c:/perl/bin/perl.exe
> our $globalVar = "Chicago";
> callNow();
> return 1;
> 
> called.cgi
> ==========
> callNow() {
>     print "global variable is $globalVar";
> }

It is confusing to use the file suffix ".cgi" for something that is
not a CGI script.

If you use a Perl4-style library then you can just do it.

Perl4-style libraries are simply required and don't contain a package
directive thus they are compiled in the same namespace a the file that
required them.  Perl4-style libraries should not be required by
Perl5-style modules unless you really understand what you are doing.
In fact, I would go so far as to say, you sould not write Perl4-style
libraries unless you really understand why you are doing it.

Conventionally a Perl4-style library has .pl extension but it doesn't
actually matter.

Perl5-style modules can export package scoped symbols (including
variables) into the namespace of the package that use()s them.  Also
calling programs can directly manipulatate a module's package scoped
symbols using a qualified name.  This is the opposite of what you
asked but probably achieves the effect you are looking for better than
what you thought you wanted to do.

You can learn about Perl5 modules in "perldoc perlmod".

If you really want to access variables in the callers package
namespace then use symbolic references and the caller subroutine.  It
is very rare that this is the right thing to do.  Symbolic preferences
are documented in "perldoc perlref".  The caller function is
documented in "perldoc -f caller".

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


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

Date: 30 Jun 2003 05:20:32 -0700
From: ineverlookatthis@yahoo.com (Steve)
Subject: How to test a hash of arrays for defined/not defined
Message-Id: <f0d57f86.0306300420.403e83e7@posting.google.com>

Dear All

I have a problem which I have reduced to the extreme case below.
I am populating a hash of arrays from a form (several scrolling
lists).
It may be completely undefined - nothing chosen from any list. I test
each for this as below.

But an undefined hash fails with the message "Can't use an undefined
value as an ARRAY reference".

Any thoughts ?

Thanks

Steve

#!D:/Perl/bin/Perl.exe -w

use strict;

my (%myparams, $chosen);

#$myparams{item}[0]='boo';  # with this line in, runs as expected
                            # without it crashes where I would hope 
                            # $chosen to be set to zero

$chosen = (@{$myparams{item}} || 0);  # want to set to number of items
selected

print "  chose: $chosen";


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

Date: Mon, 30 Jun 2003 23:03:22 +1000
From: "Sisyphus" <kalinabears@hdc.com.au>
Subject: Re: How to test a hash of arrays for defined/not defined
Message-Id: <3f00364e$0$22144@echo-01.iinet.net.au>


"Steve" <ineverlookatthis@yahoo.com> wrote in message
news:f0d57f86.0306300420.403e83e7@posting.google.com...
> Dear All
>
> I have a problem which I have reduced to the extreme case below.
> I am populating a hash of arrays from a form (several scrolling
> lists).
> It may be completely undefined - nothing chosen from any list. I test
> each for this as below.
>
> But an undefined hash fails with the message "Can't use an undefined
> value as an ARRAY reference".
>
> Any thoughts ?
>
> Thanks
>
> Steve
>
> #!D:/Perl/bin/Perl.exe -w
>
> use strict;
>
> my (%myparams, $chosen);
>
> #$myparams{item}[0]='boo';  # with this line in, runs as expected
>                             # without it crashes where I would hope
>                             # $chosen to be set to zero
>
> $chosen = (@{$myparams{item}} || 0);  # want to set to number of items
> selected
>
> print "  chose: $chosen";

I think you want:
$chosen = (defined(@{$myparams{item}}) || 0);

or perhaps you want:
$chosen = (@{$myparams{item}}[0] || 0);

You can, if you like, delete the outside '()'s as they are not necessary.

Hth.

Cheers,
Rob




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

Date: Mon, 30 Jun 2003 08:11:56 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to test a hash of arrays for defined/not defined
Message-Id: <slrnbg0dos.31u.tadmc@magna.augustmail.com>

Steve <ineverlookatthis@yahoo.com> wrote:

> But an undefined hash fails with the message "Can't use an undefined
> value as an ARRAY reference".


> $chosen = (@{$myparams{item}} || 0);  # want to set to number of items
> selected


   $chosen = defined $myparams{item} ? @{$myparams{item}} : 0;


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Jun 2003 08:22:58 -0400
From: Gary Blydenburgh <gblydenburgh@nospam.com>
Subject: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <5sa0gvgrnopfc0gkc28h0j8nl91hrjgs0b@4ax.com>




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

Date: Mon, 30 Jun 2003 12:26:43 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <Xns93AA928785C4Delhber1lidotechnet@62.89.127.66>

Gary Blydenburgh wrote:


> Subject: Is there a good free/not so expensive Perl IDE for Linux


Yes. xterm.


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Mon, 30 Jun 2003 08:06:40 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <slrnbg0df0.31u.tadmc@magna.augustmail.com>

Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> Gary Blydenburgh wrote:
> 
> 
>> Subject: Is there a good free/not so expensive Perl IDE for Linux
> 
> 
> Yes. xterm.


Three xterms.

One for the editor, one for executing the program, one for
"checking stuff" such as the docs or the contents of files.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Jun 2003 19:03:08 +0530
From: Rohan Romanus Almeida <arc_of_descent@gmx.net>
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <20030630190308.6e11b0fb.arc_of_descent@gmx.net>


tadmc@augustmail.com (Tad McClellan) thus wrote:
> Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> > Gary Blydenburgh wrote:
> > 
> > 
> >> Subject: Is there a good free/not so expensive Perl IDE for Linux
> > 
> > 
> > Yes. xterm.
> 
> 
> Three xterms.
> 
> One for the editor, one for executing the program, one for
> "checking stuff" such as the docs or the contents of files.
> 

I use 'konsole'. Or 'screen(1)'.

--
arc_of_descent



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

Date: 30 Jun 2003 14:02:35 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <slrnbg0gnr.el.abigail@alexandra.abigail.nl>

Tad McClellan (tadmc@augustmail.com) wrote on MMMDXC September MCMXCIII
in <URL:news:slrnbg0df0.31u.tadmc@magna.augustmail.com>:
##  Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
## > Gary Blydenburgh wrote:
## > 
## > 
## >> Subject: Is there a good free/not so expensive Perl IDE for Linux
## > 
## > 
## > Yes. xterm.
##  
##  
##  Three xterms.
##  
##  One for the editor, one for executing the program, one for
##  "checking stuff" such as the docs or the contents of files.


Two. Running the program can be done from within the editor
with an appropriate macro. ;-)


    2 store-macro
      save-file
      shell-command &cat "perl " $cfilname
   ~endm

   bind-key execute-macro-2 ^A-r


Abigail
-- 
perl -wlne '}{print$.' file  # Count the number of lines.


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

Date: Mon, 30 Jun 2003 10:38:36 -0400
From: Gary Blydenburgh <gblydenburgh@nospam.com>
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <aqi0gv4dt07d8tt45ecav6d7jjespbo443@4ax.com>

OK...  How about any similar to Komodo.


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

Date: Mon, 30 Jun 2003 14:42:41 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <vg0j3194i0of36@corp.supernews.com>

In article <slrnbg0gnr.el.abigail@alexandra.abigail.nl>,
    Abigail  <abigail@abigail.nl> wrote:

: Tad McClellan (tadmc@augustmail.com) wrote on MMMDXC September MCMXCIII
: in <URL:news:slrnbg0df0.31u.tadmc@magna.augustmail.com>:
:
: ##  Three xterms.
: ##  
: ##  One for the editor, one for executing the program, one for
: ##  "checking stuff" such as the docs or the contents of files.
: 
: Two. Running the program can be done from within the editor
: with an appropriate macro. ;-)

One.  Reading docs and other files can be done from within the
editor. :-)

    <esc>:!man perl

Greg
-- 
I can see it now: some 70-year-old guy . . . gets it onto the highway.
Vroom, vroom. He floors it. He blacks out. This makes about as much sense
as J. Howard Marshall marrying Anna Nicole Smith, with similar effects.
    -- Gary North


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

Date: Mon, 30 Jun 2003 07:57:00 -0700
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <s3jpdb.6us.ln@goaway.wombat.san-francisco.ca.us>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In article <vg0j3194i0of36@corp.supernews.com>, Greg Bacon wrote:
> 
>: Tad McClellan (tadmc@augustmail.com) wrote on MMMDXC September MCMXCIII
>: in <URL:news:slrnbg0df0.31u.tadmc@magna.augustmail.com>:
>:
>: ##  Three xterms.
>: ##  
>: ##  One for the editor, one for executing the program, one for
>: ##  "checking stuff" such as the docs or the contents of files.
>: 
> One.  Reading docs and other files can be done from within the
> editor. :-)

I'm with Tad--my memory is too short to remember what I read when
I get back to my source code.  :)

- --keith

- -- 
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
alt.os.linux.slackware FAQ:  http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iEYEARECAAYFAj8AT7sACgkQhVcNCxZ5ID+FKgCgibyL+0Z/7efJuZvvGK9DlWVz
zw4AniSa8k6yQ11oQZSnZlzCwdeCh0fL
=Q1av
-----END PGP SIGNATURE-----


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

Date: Mon, 30 Jun 2003 11:03:45 GMT
From: <user@host.com>
Subject: loading a module dependant on the OS
Message-Id: <lOULa.6743$g4.133637@news1.nokia.com>

I have a Perl script which runs under Windows and uses the module
Win32::Process, I now have a need to run this on Linux.

I can do produce two scripts on for each platform, which would be a pain to
maintane.

My question being how can I have a script on Linus that has

use Win32::Process;

since this module does not exist I get a compilation error. I thought I
could use the $^O variable but my little knowledge fails to supply the
answer.

I assume this is a common problem so will have an answer. If you can point
me in the direction of a README or HOW_TO document I would be greatful.

Richard.







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

Date: 30 Jun 2003 13:24:11 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: loading a module dependant on the OS
Message-Id: <u9n0fzda8k.fsf@wcl-l.bham.ac.uk>

<user@host.com> writes:

> use Win32::Process;
> 
> since this module does not exist I get a compilation error. I thought I
> could use the $^O variable but my little knowledge fails to supply the
> answer.

Since you have a question about use please read at least the first
paragraph of:

perldoc -f use

Write the "use" out long-hand and then apply the knowledge already
have.  That should supply the answer.

Surely this should be in the FAQ!

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


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

Date: Mon, 30 Jun 2003 19:11:41 +0530
From: Rohan Romanus Almeida <arc_of_descent@gmx.net>
Subject: Re: loading a module dependant on the OS
Message-Id: <20030630191141.13e802bd.arc_of_descent@gmx.net>


<user@host.com> thus wrote:
> use Win32::Process;
> 
> since this module does not exist I get a compilation error. I thought I
> could use the $^O variable but my little knowledge fails to supply the
> answer.
> 

You can do an "eval" before the use.

Look at this example:
<code>
$useReadKey = 0;
eval q/use Term::ReadKey/;
if (!$@) {
	# Term-ReadKey module is installed
	$useReadKey = 1;
}
</code>

--
arc_of_descent



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

Date: Mon, 30 Jun 2003 16:20:23 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: loading a module dependant on the OS
Message-Id: <bdph9k$tpcot$1@ID-184292.news.dfncis.de>

user@host.com wrote:
> 
> use Win32::Process;
> 
> since this module does not exist I get a compilation error. I
> thought I could use the $^O variable

You can:

     BEGIN { require Win32::Process if $^O eq 'MSWin32' }

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Mon, 30 Jun 2003 14:33:05 GMT
From: <user@host.com>
Subject: Re: loading a module dependant on the OS
Message-Id: <BSXLa.6767$g4.134094@news1.nokia.com>

Thanks for the solution :-) I forgot all about eval.

Richard.


"Rohan Romanus Almeida" <arc_of_descent@gmx.net> wrote in message
news:20030630191141.13e802bd.arc_of_descent@gmx.net...
>
> <user@host.com> thus wrote:
> > use Win32::Process;
> >
> > since this module does not exist I get a compilation error. I thought I
> > could use the $^O variable but my little knowledge fails to supply the
> > answer.
> >
>
> You can do an "eval" before the use.
>
> Look at this example:
> <code>
> $useReadKey = 0;
> eval q/use Term::ReadKey/;
> if (!$@) {
> # Term-ReadKey module is installed
> $useReadKey = 1;
> }
> </code>
>
> --
> arc_of_descent
>




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

Date: Mon, 30 Jun 2003 14:34:11 GMT
From: <user@host.com>
Subject: Re: loading a module dependant on the OS
Message-Id: <DTXLa.6768$g4.133759@news1.nokia.com>

Oh wow that was so easy, thanks.

I'll go read the camel book again.

Richard.

"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:bdph9k$tpcot$1@ID-184292.news.dfncis.de...
> user@host.com wrote:
> >
> > use Win32::Process;
> >
> > since this module does not exist I get a compilation error. I
> > thought I could use the $^O variable
>
> You can:
>
>      BEGIN { require Win32::Process if $^O eq 'MSWin32' }
>
> / Gunnar
>
> --
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
>




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

Date: 30 Jun 2003 07:06:45 -0700
From: dew814@aol.com (Dave Ardrey)
Subject: Messing with UID's and GID's
Message-Id: <20de6cd6.0306300606.597f9dd9@posting.google.com>

I am trying to write a program that will write to a log file every
time it is called.  However, I don't want everyone to have write
access to the log file, so I made the log file have the same owner as
the script and set the permissions on the script to 6755 (setting the
uid and gid bits).

The problem is that when the permissions are set and I'm running as a
different user, it doesn't like doing system calls(gives me an error).
 So I set the effective uid and gid to be the real uid and gid until I
need them to be different but now when I try and do a system call I
get this error:

Insecure $ENV{PATH} while running with -T switch at /dev/fd/3 line
102.


Any ideas what can be done about this?  I know it's probably just as
much of a UNIX question than a perl one.  I hope that's ok.

Thanks for your help.


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

Date: Mon, 30 Jun 2003 14:52:26 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Messing with UID's and GID's
Message-Id: <vg0jlam2q04o97@corp.supernews.com>

In article <20de6cd6.0306300606.597f9dd9@posting.google.com>,
    Dave Ardrey <dew814@aol.com> wrote:

: [...]
: 
: The problem is that when the permissions are set and I'm running as a
: different user, it doesn't like doing system calls(gives me an error).
: So I set the effective uid and gid to be the real uid and gid until I
: need them to be different but now when I try and do a system call I
: get this error:
: 
: Insecure $ENV{PATH} while running with -T switch at /dev/fd/3 line
: 102.

Right.  When perl sees that it's running setuid, it goes into taint
mode.  See the perlsec manpage for the full details.

The quick fix is to follow this advice from the perlrun manpage:

    $ENV{PATH}  = '/bin:/usr/bin';    # or whatever you need
    $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
    delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};

I *strongly* encourage you to read the perlsec manpage if you're
planning to write and run setuid Perl programs.

: Any ideas what can be done about this?  I know it's probably just as
: much of a UNIX question than a perl one.  I hope that's ok.

Why not follow the syslog model, i.e., have another program listen
at some rendezvous point such as a named pipe or socket (either Unix
or network domain) for log entries?  That way, you don't have to bother
with setuid games: the logging process would run as the owner of the
log file.

Greg
-- 
WARNING:  Do NOT calculate Pi in binary.  It is conjectured that this number
is normal, meaning that it contains ALL finite bit strings. [...] Some of
the files on my PC are intensely personal, and I for one don't want you
snooping through a copy of them.      -- Keith F. Lynch in comp.risks


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

Date: Mon, 30 Jun 2003 14:50:53 GMT
From: derek / nul <abuse@sgrail.org>
Subject: Re: Newbie problem with open
Message-Id: <7bj0gv44huhc2teaohurep432otbdpprs2@4ax.com>

On Mon, 30 Jun 2003 06:42:29 +0000 (UTC), efflandt@xnet.com (David Efflandt)
wrote:

>On Mon, 30 Jun 2003 05:44:37 GMT, derek / nul <abuse@sgrail.org> wrote:
>> Have been through perldoc -f open and trying to do:-
>>  open(FH, "<:utf8", "file")
>> 
>> My code looks like:-
>> 
>> #win32 Activestate 5.8.0
>> 
>> use strict;
>> use warnings;
>> use Encode qw/encode decode/;
>> my $dash9=   "c:/program files/microsoft games/train
>> simulator/trains/trainset/dash9/dash9.eng";
>> 
>> open (DASH9, "<:utf16", "$dash9"),   or die "Cannot open $dash9 for read :$!";
>> 
>> 
>> I get the error:-
>> 
>> perlio: unknown layer "utf16".
>> 
>> What am I doing wrong?
>
>According to 'perldoc Encode' under Encoding via PerlIO it looks like you 
>should be using something like [was there some reason for the extra comma 
>after your open()]:
>
>open (DASH9, "<:encoding(utf16)", "$dash9")
>    or die "Cannot open $dash9 for read :$!";

David,

that was it, many thanks

Someone else suggested I invite perlio to do it for me, I had no idea what that
was, I think I do now.


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

Date: Mon, 30 Jun 2003 13:53:45 +0000 (UTC)
From: Vlad Tepes <minceme@start.no>
Subject: Re: Sending the "down" key via Expect
Message-Id: <bdpfd9$ktt$1@troll.powertech.no>

Nick Leeson <nickleeson78@yahoo.com> wrote:

> Hi,
> I am using an expect script to interact with lynx running on a remote
> server.I am trying to figure out how to send the direction keys
> ...left(->), right(<-),up and down keys....I know i need to send their
> equivalent ASCII values..but what would they be?
> Please let me know...

If you have trouble with the escapes for the arrow buttons, you could
start lynx with vi-keys:

    lynx -vikeys

and use h,j,k,l instead of left, down, up and right.

-- 
Vlad


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

Date: 30 Jun 2003 11:31:04 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Speed of file vrs dbase access
Message-Id: <slrnbg07ro.el.abigail@alexandra.abigail.nl>

fatted (fatted@yahoo.com) wrote on MMMDXC September MCMXCIII in
<URL:news:4eb7646d.0306300038.2be15c80@posting.google.com>:
}}  A request for some data is processed by my perl script. The data is
}}  currently stored in plain text files on a linux system. Each file's
}}  data contains less than 600 characters. The data from 3 files will be
}}  required (read into the script) per request. I now have the
}}  opportunity, to place the data in a MySQL table. A database handle
}}  (using the DBI module) is already opened to the database where this
}}  new table would be stored.(MySQL database and data files are stored on
}}  machine where perl script is run).
}}  
}}  Would database access be quicker or slower than direct file access to
}}  the current linux files?


First of all, that's not a Perl question. Second, it depends. It depends
on how the data is stored, and how you make requests. Reading a single
file from disk might even be faster than doing a single request to the
database, if that data still needs to be fetched from disk. But if you
need to do a linear search over all the different files, while the database
can make use of an index, the latter is much faster than the former.
If you know which file you need, but you have a gazillion files, it will
take relatively long for the OS to even find the file.

The only way to know for sure is it do some extensive testing, under
production circumstances.



Abigail
-- 
$_ = "\nrekcaH lreP rehtona tsuJ"; my $chop; $chop = sub {print chop; $chop};
$chop -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()
-> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> () -> ()


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

Date: 30 Jun 2003 06:58:02 -0700
From: tivolinewbie@canada.com (Kenjis Kaan)
Subject: Re: Storable module for Activestate 5.6.1??
Message-Id: <6a8ba9f8.0306300558.4ccab08b@posting.google.com>

"Sisyphus" <kalinabears@hdc.com.au> wrote in message news:<3effe8ec$0$22124@echo-01.iinet.net.au>...
> "Kenjis Kaan" <tivolinewbie@canada.com> wrote in message
> news:6a8ba9f8.0306292303.5259f69b@posting.google.com...
> > I am running Activestate Perl 5.6.1 and wanted to install the Storable
> > module.  HOwever, from PPM, I tried to install and it replied.
> > "Error installing package 'Storable': Could not locate a PPD file for
> > package Storable"
> >
> > I really think the package already exists for Activestate, but can't
> > seem to install it nor able to find the ppd for it.  Anybody know?
> 
> ActiveState certainly have this package. There is apparently some problem
> with the functionality of your ppm installation. (I think there is a number
> of possible causes for receiving this error.)
> Does 'ppm search Storable' report that it exists ?

ppm search Storable returns blank.  So I guess you are right there is
a problem with ppm, maybe its the version (2.1.5).  It got installed
as part of my perl 5.6.1 installation.  Would it be possible to update
just ppm by itself without touching the perl installation?


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

Date: 30 Jun 2003 07:31:04 -0700
From: bhdipu@yahoo.com (dipu bhaskar)
Subject: storing variables using system
Message-Id: <17c3ed23.0306300631.65a8b690@posting.google.com>

hi

  i am doing a unix operation in perl using the "system" command,and i
want this to be stored into a variable,hence this variable should be
accessed by perl


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

Date: Mon, 30 Jun 2003 14:35:32 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: storing variables using system
Message-Id: <4li0gvgfuohj34v1uucf4rr5qlt5b60gk1@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Whilst lounging around on 30 Jun 2003 07:31:04 -0700,
bhdipu@yahoo.com (dipu bhaskar) amazingly managed to produce the
following with their Etch-A-Sketch:

> hi
> 
>   i am doing a unix operation in perl using the "system"
> command,and i want this to be stored into a variable,hence this
> variable should be accessed by perl


   perldoc -f system



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPwBKsmfqtj251CDhEQIURwCffhYFKVKtVOLAPJewvhUORnwp+wUAoONF
5BRCGNPpsTP+t5i2keG40OrY
=c4C8
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Programming, Web design, development & hosting.


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

Date: Mon, 30 Jun 2003 09:36:59 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: storing variables using system
Message-Id: <87y8zjvdh0.fsf@limey.hpcc.uh.edu>

>> On 30 Jun 2003 07:31:04 -0700,
>> bhdipu@yahoo.com (dipu bhaskar) said:

> hi i am doing a unix operation in perl using the
> "system" command,and i want this to be stored into a
                              ^^^^
> variable,hence this variable should be accessed by perl

What is "this"?  The question has a number of answers,
depending on what you actually mean.  Give a simple
example of the command, and what you're trying to capture
from it.

hth
t


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

Date: Mon, 30 Jun 2003 06:21:42 -0400
From: Eric Amick <eric-amick@comcast.net>
Subject: Re: String matching not working
Message-Id: <pd30gvgaoptslqkf6pii4410cmqb49brbh@4ax.com>

On 30 Jun 2003 02:56:51 -0700, davidmcguinness@dublin.ie (Dave from
Dublin) wrote:

>Hi,
>
>I am quite new to Perl.  I have several sets of data and within each
>individual file news stories are seperated using ========.
>
>My goal is to recreate each file without this divider.  Eventually I
>will look to iterate through the whole directory but for now I just
>want to print all lines but the divider into a new file for one file
>(1.ref)

>#!/usr/bin/perl
>
>open(FILEREAD, "< 1.ref");
>open(FILEWRITE, "> 1a.ref");

Always check if open() has succeeded.  Always.

>while (<FILEREAD>){
>        chop ( $line );

Where did $line get a value?  And chomp is safer.

>                 if ($line !=~ /====/ ){

The operator you want is !~

>        print FILEWRITE;
>        }
>        else{
>        print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";
>        }
>}
>close FILEWRITE;
>close FILEREAD;

-- 
Eric Amick
Columbia, MD


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

Date: Mon, 30 Jun 2003 10:27:57 GMT
From: Steve Grazzini <s_grazzini@hotmail.com>
Subject: Re: String matching not working
Message-Id: <NgULa.30705$Kg7.23212@nwrdny01.gnilink.net>

Dave from Dublin <davidmcguinness@dublin.ie> writes:
> 
> But it's not working, all lines are being printed.
>
> while (<FILEREAD>){
>    chop ( $line );
>    if ($line !=~ /====/ ){
>         print FILEWRITE;
>    }

Well, for starters you never put anything in $line.
Turning on 'warnings' would help (it will tell you 
whenever you use an uninitialized variable).

And then the "doesn't match" operator is mispelled.

You should also prefer chomp() to chop(), but I don't 
think you want either in this case:

  while (<FILEREAD>) {
      print FILEWRITE unless /====/;
  }

HTH
-- 
Steve


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

Date: 30 Jun 2003 12:59:49 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: String matching not working
Message-Id: <u9vfundbd6.fsf@wcl-l.bham.ac.uk>

davidmcguinness@dublin.ie (Dave from Dublin) writes:
> 
> I am quite new to Perl.

> #!/usr/bin/perl

You should always enable strictures and warnings.

The cause of your problem is a trival typo that would have caused Perl
to emit a warning if you had allowed it to do so.

It is insluting to ask a human to do the work of a machine.

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


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

Date: Mon, 30 Jun 2003 07:21:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Using filehandle many times
Message-Id: <slrnbg0aql.2u8.tadmc@magna.augustmail.com>

ABC <cdcer@hongkong.com> wrote:

> print on closed filehandle main::DST at tempQGen line 71, <SRC> chunk
> 28.
> 
> I understand the meaning of this error message, 
  ^^^^^^^^^^^^

That seems suspect for two reasons:

   1) it is not an error message at all, it is a warning.


> but I want to know how
> to solve it?


   2) you would have been asking about the part of the code that
      was supposed to open() the DST filehandle.


All of the messages that perl might issue are documented in
perldiag.pod, you should look up messages there as a first step
in troubleshooting:

-------------------------------
=item print() on closed filehandle %s

(W closed) The filehandle you're printing on got itself closed sometime
before now.  Check your control flow.
-------------------------------


How come you are not asking us questions about the control flow
in your program?  :-)


> How could I open and close this filehandle many times inside a
> for-loop? 


Using open(), or using close() and open().


> Or how could I clear the filehandle?


What would "clear"ing a filehandle mean?

If you mean "close" then you would call close(), but that is not
going to solve your problem, since the filehandle in question *is*
closed already.


Show code if you want help with code.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 30 Jun 2003 18:38:28 +0530
From: Thens <thens@nospam.com>
Subject: Re: Using filehandle many times
Message-Id: <20030630183828.7f15e1c1.thens@nospam.com>

On 29 Jun 2003 23:43:42 -0700
cdcer@hongkong.com (ABC) wrote:

>print on closed filehandle main::DST at tempQGen line 71, <SRC> chunk
>28.
>
>I understand the meaning of this error message, but I want to know how
>to solve it?

  In such cases, 'use diagnostics' might help you with what exactly you
need to do.

>How could I open and close this filehandle many times inside a
>for-loop? Or how could I clear the filehandle?


  This is a FAQ and is covered in the perl documentation.

perldoc -q "filehandle local"

Regards,
Thens.


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

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


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