[7245] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 870 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 15 01:08:03 1997

Date: Thu, 14 Aug 97 22:00:28 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 14 Aug 1997     Volume: 8 Number: 870

Today's topics:
     Re: a perl4 question (Tad McClellan)
     Re: about -e and getting filenames (Tad McClellan)
     Re: Can't match numeric text in m// <mchase@ix.netcom.com>
     Re: Converting an Array to a Hash <rtietjen@kale.connix.com>
     Re: converting from hex (Scott Houck)
     Re: Cookies and PERL <petri.backstrom@icl.fi>
     Re: Fork error in open() <rootbeer@teleport.com>
     Re: General Oraperl Help <mchase@ix.netcom.com>
     Re: Generic script in Perl (Tad McClellan)
     Re: Generic script in Perl <bholzman@mail.earthlink.net>
     Re: HELP WITH INSTALLING PERL5 ON WINDOWS 95 (Danny Aldham)
     Re: HELP: Search and replace question (Greg Bacon)
     Re: How to execute remote Perl script from Perl? <petri.backstrom@icl.fi>
     Re: how to set shell variable from perl? <rootbeer@teleport.com>
     Re: how to set shell variable from perl? (Tad McClellan)
     Re: how to set shell variable from perl? <bholzman@mail.earthlink.net>
     Re: localizing $^A causes core dump <rootbeer@teleport.com>
     makewhatis for Solaris (Trey Valenta)
     Re: NT with Enterprise Serv. 3.0 Perl Problems (Danny Aldham)
     Re: Overriding Functions in Modules, i.e. File::Find ls <rootbeer@teleport.com>
     Re: perform operations on files withing directory tree <rootbeer@teleport.com>
     Re: Puting pattern in a variable (Tad McClellan)
     Re: Q: IPC between Perl and C <rootbeer@teleport.com>
     Re: Read from growing file - eof problem <petri.backstrom@icl.fi>
     Removing elements in the middle of arrays? <yuzow@sec.sel.sony.com>
     Re: Removing elements in the middle of arrays? <rootbeer@teleport.com>
     Re: Removing elements in the middle of arrays? <bholzman@mail.earthlink.net>
     Re: Seeking object enlightenment (Scott Houck)
     Re: Simple question on s/// operator in expressions (Charles DeRykus)
     Using passwd command inside a perl script (Brian Wiren)
     Re: Why doesn't sort take a reference any more? (Charles DeRykus)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 14 Aug 1997 22:05:06 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: a perl4 question
Message-Id: <21h0t5.l2m.ln@localhost>

Daryl Williams (daryl.williams@tivoli.com) wrote:
: does anyone know how to do something like the following
: in perl4:

: What I need to do is have an array that looks like this conceptually:

: firstkey, item1, item2, item3
: secondkey, item1, item2, item3
: thirdkey, item1, item2, item3

: What I want to do is index into the array by the *key and then
: iterate thru the item*'s assigning or printing the item* values.
: I'm not sure how to do that.

: My first attempt looked something like this:

: @itemarray1 = (0,0,0);
: @itemarray2 = (0,0,0);

: %bigarray = (
:    'firtskey', @itemarray1,
:    'secondkey', @itemarray2
: );

: Obviously not correct syntax but you get the idea.


The poor man's hash of arrays  ;-)

---------------
%bigarray = ( 'firstkey',  '1:10:100:',
              'secondkey', '2:20:200:');

foreach $key (keys %bigarray) {
   foreach $val (split /:/, $bigarray{$key}) {
      print "$key => $val\n";
   }
   print "\n";
}
---------------


Of course, the problem with that is you have to find a field separator
that is guaranteed to never appear in a field...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 14 Aug 1997 21:30:30 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: about -e and getting filenames
Message-Id: <60f0t5.2ul.ln@localhost>

Bob Fawcett (bfawcett@myriad.com) wrote:
: Kenneth Kin Lum wrote:

: > Is there a way to do
: >   if (-e "*.txt") { ... }
: > ?  That is, must "-e" take an exact filename but can't take
: > a wildcard?
: >
: > Also, is there a way not to fork a process but just do in PERL to do
: >   foreach $file (`ls *.txt`) { ... }
: >
: > This is because forking a process on my ISP's server is
: > really slow.
: >
: > Could you please also CC to me when respond.  Thanks.

:  Take a look at this little bit of code that reads files from the
                       ^^^^^^^^^^^^^^^^^^

Or even a littler bit of code ;-)


: current directory and deletes the ones that start with "LQ-", end with
: ".syb" and are older than 1 day:

:     opendir THISDIR, ".";
:     @allfiles= readdir THISDIR;
:     closedir THIDIR;

:     foreach $allfiles(@allfiles){
:         if (($allfiles=~/^(LQ-).*(.syb)/) && (-M $allfiles > 1)){
:          unlink $allfiles;
:         }
:     }


    # no need for that @allfiles array...

    opendir THISDIR, "." || die "could not open the current directory";
    foreach $allfiles(readdir THISDIR){
        if (($allfiles=~/^(LQ-).*(.syb)/) && (-M $allfiles > 1)){
         unlink $allfiles;
        }
    }
    closedir THIDIR;


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 14 Aug 1997 18:50:55 -0700
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: Can't match numeric text in m//
Message-Id: <5t0hs9$bi0@dfw-ixnews4.ix.netcom.com>

Neither string is being converted to number form, the problem is that '.'
and '+' have special meaning when used in a regular expression (see
perlre.pod).

The easiest way to avoid the problem is to 'quote' the non-alphanumeric
characters in $num with \Q as shown below.

>    print $text =~   /$num/   ? "match\n" : "no match\n";
     print $text =~ /\Q$num\E/ ? "match\n" : "no match\n";

--
Mac :})   mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
-----END GEEK CODE BLOCK------

Brett Denner wrote in article <33EB9398.B0064851@lmtas.lmco.com>...

>I'm trying to perform a pattern match on a text string containing an
>exponential-format number like this:
>
>    $text = "num = 1.0E+01";
>
>I would like to see if this text actually contains an exact exponential
>number, like "1.0E+01".  Here's my code:
>
>    $text = "num = 1.0E+01";
>
>    $num = "1.0E+01";
>
>    print $text =~ /$num/ ? "match\n" : "no match\n";
>
>When I run this code, it prints out "no match";  I suspect that the $num
>variable is being converted to its double-precision representation in
the
>pattern match before the pattern match is attempted, but I'm not sure.
Or,
>the "." and "+" in the $num variable may be causing problems.
>
>Is there a way to force a scalar to retain its text representation of a
>number, even though it looks like a double-precision number?





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

Date: 14 Aug 1997 22:07:58 -0400
From: Richard Tietjen <rtietjen@kale.connix.com>
Subject: Re: Converting an Array to a Hash
Message-Id: <87d8ngxkox.fsf@kale.connix.com>



Bill Baker <baker@hpspk7jp.spk.hp.com> writes:
 
> 
> I have been trying to find an elegant (read that as 'terse') way to 
> take an array and save it as a hash where the even numbered entries in the 
> array are the keys for the (entry offset + 1) entries.  The array is
> guaranteed to contain an even number of entries.  It seems like such a
> utilitarian function that I am surprised that I haven't found the answer
> after searching through Programming Perl 2nd Edition, Perl Man Pages and
> usenet.  I am sure this will end up being a {hitting forehead with palm}
> "Why didn't I think of that!" kind of answer.
> 

I think the answer you're looking for in terms both of efficacy and
concision is simply:

  %hash = @list;

where @list = (k => v, k1 => v, ...);

Recall that  => is the moral equivalent of a comma.

Try it.


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

Date: Fri, 15 Aug 1997 01:53:03 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: converting from hex
Message-Id: <33f3b4cd.4497847@news1.radix.net>

Darrell Johnson <" darrell_johnson"@nmisq2.miss.nt.com> wrote:

>unpack is more efficient :)
>
>#start of code
>sub tohex ($) {
>    my $input = shift;
>#start of relevant code
>    @ret= map{hex} unpack "a1a2a2a2", $input;
>    shift @ret;
>#end of relevant code
>    return @ret;
>};
>
>@rgb=tohex($ARGV[0]);
>print "Red  : @rgb[0]\n";
>print "Green: @rgb[1]\n";
>print "Blue : @rgb[2]\n";
>#end of code

An excellent refinement!  However, I was SHOCKED :-) to notice your
*inefficient* use of "a1" to unpack something that was never going to
be used!  Use "x" instead!  Then you don't have to shift @ret, and you
won't even *need* @ret!  And while we're at it, who needs my $input?
(Literally, not figuratively :-)

sub tohex ($) {
   return map{hex} unpack "xa2a2a2", shift;
}



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

Date: Mon, 11 Aug 1997 09:01:12 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Cookies and PERL
Message-Id: <33EEAAA8.352E@icl.fi>

Joshua Marotti wrote:
> 
> Does anyone have a list of all of the internet variables that perl uses...
> including environmental hash variables...
> for example $ENV{'USER_ADDR'} = the current users address...

Perl doesn't know anything about "internet variables".

However, it can read any and all environment variables that
your web server happens to set (including those it sets 
based on data sent to it by the [HTTP] client).

Now, to find out what it is that your web server sets, you
need to consult the documentation of your web server.

In addition, if you need to know browser specific variables
that your web server sets, then consult the docs of that 
particular browser.

If these aren't documented, then consult the appropriate
newsgroup for the web server or browser.

See also the CGI specification at:

   http://www.ast.cam.ac.uk/~drtr/cgi-spec.html

It'll list all the "standardized" CGI variables, that
all web servers supporting CGI should handle in
a similar fashion (which usually is, but may not always 
be the case).

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Thu, 14 Aug 1997 19:47:55 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ken Ficara <ficara@acm.org>
Subject: Re: Fork error in open()
Message-Id: <Pine.GSO.3.96.970814192813.18525G-100000@julie.teleport.com>

On Thu, 14 Aug 1997, Ken Ficara wrote:

> I have this code running using perl 5.003 under Solaris 2.4. The
> intent is to execute a command once for each machine listed in
> @servers on a filehandle named for the server (making it possible to
> wait on each and identify errors if any occur).
> 
> 	foreach $server (@servers)
> 	{
> 	      $cmd = 'rcp foo $server: foo';
>               open ("$server", '-|') || exec ($cmd);
> 	}

It looks as if you're using a piped open where you want to use fork. 
(Piped open forks a process, too, but it has a limited tolerance for
difficulties, I believe.) Your machine can run a certain maximum number of
processes at any one time. When forking more than N times in quick
succession, for some value of N, you should expect to run out of processes
and need to pause and retry. I recommend using a value of N=1. :-)

Hope this helps!

	use POSIX;			# To get error numbers

	foreach $server (@servers) {
	    $cmd = 'rcp foo $server: foo';
FORK:	    {
		if (!defined($pid = fork)) {
		    # fork failure
		    die "Unexpected fork error: $!"
			unless $! == EAGAIN;
		    sleep 1;
		    redo FORK;
		} elsif ($pid == 0) {
		    # Child process
		    exec $cmd
			or die "Can't exec '$cmd': $!";
		} else {
		    # Parent process (no action needed)
		}
	    }
	}

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 14 Aug 1997 20:11:55 -0700
From: "Michael A. Chase" <mchase@ix.netcom.com>
Subject: Re: General Oraperl Help
Message-Id: <5t0hsb$bi0@dfw-ixnews4.ix.netcom.com>

Look in http://www.perl.com/CPAN/authors/id/TIMB/ for DBD and DBI.  The
DBD-Oracle includes the oraperl interface.

--
Mac :})   mchase@ix.netcom.com
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS/CC/E/IT/O d s+:+ a+ C++$ ULUHSC*++$ P++$ L+(++) E- W++ N++ o? K-? w+
O M- V- PS+@ PE Y+ PGP+ t+ 5++ X R tv b+++(++++) DI++(+++) D? G e++ h---
r+++ y+
------END GEEK CODE BLOCK------

Scott Kelley wrote in article <33EF8251.E2FB3CFF@axe.humboldt.edu>...

>I'm trying to trak down general help pages/resources for Oraperl.





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

Date: Thu, 14 Aug 1997 21:56:12 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Generic script in Perl
Message-Id: <cgg0t5.n1m.ln@localhost>

Marcantonio Fabra (fabra@ax.apc.org) wrote:

: I have a file called arq.htm. My script reads this file, make some procedures on
: it and write all the records to a file called arq.html.
: Here's the script:

: #!/usr/local/bin/perl

You are missing a -w switch there...


: #
: # change.pl
:  
: open(inpfile,"<arq.htm");
: open(outfile,">arq.html");

You should check the return values from open().

It might not have opened anything...

You should use upper case filehandle names, else you will need to
rework all your scripts when Perl v.{now} + 1 comes out with a keyword
that matches your filehandle.


: while ($temp=<impfile>)

You should check that with defined(), or you may exit the loop
*before* you get to the end of the file.


: {
:   <procedimentos>
:   print outfile "$temp";

You don't need those double quotes.


: }
: close impfile;
: close outfile;

: My question is:

: How can I change this script in order to do this operations in all the htm files
: of my directory ?

------------------------
#!/usr/bin/perl -w

opendir(DIR, '.') || die "could not open current directory  $!";

foreach $htm (grep /\.htm$/, readdir(DIR)) {

   open(IN, $htm) || die "could not open '$htm'  $!";
   open(OUT, ">${htm}l") || die "could not open '${htm}l'  $!";

   while (defined($temp = <IN>)) {
      $temp = ucfirst($temp);
      print OUT $temp;
   }

   close(IN);
   close(OUT);
}

closedir(DIR);
------------------------


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Fri, 15 Aug 1997 00:04:09 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Marcantonio Fabra <fabra@ax.apc.org>
Subject: Re: Generic script in Perl
Message-Id: <33F3D539.29D3A21B@mail.earthlink.net>

> #!/usr/local/bin/perl
> #
> # change.pl
> 
> open(inpfile,"<arq.htm");
> open(outfile,">arq.html");
> 
> while ($temp=<impfile>)
> {
>   <procedimentos>
>   print outfile "$temp";
> }
> close impfile;
> close outfile;
> 
> My question is:
> 
> How can I change this script in order to do this operations in all the htm files
> of my directory ?
> 
>                 Marcantonio Fabra

You basically have two options-- have the shell determine which files to
process (by, for instance, calling "change.pl *.htm", or have perl
determine which files to process, perhaps by giving it a directory name,
and having the perl script do a readdir and sucking up the file names
which match, say, /\.htm$/

I would lean towards the first option, but that could just be personal
preference.  Here's how to do it:

foreach $infile (@ARGV) {	# @ARGV will contain every filename
  open(inpfile,"<$infile");	# the shell sends us.
  open(outfile,">${infile}l");
 
  while ($temp=<impfile>)
  {
    <procedimentos>
    print outfile "$temp";
  }
  close impfile;
  close outfile;
}

Here's the second option; let's make the directory hard-coded.

$my_dir = '/some/path/';

opendir(DIR, $my_dir) || die "Couldn't opendir $my_dir: $!";
@files = grep {/\.htm$/} readdir DIR;

foreach $infile (@files) {
 ...				# from here on out, it's the same...

Just a suggestion-- you might want to take a look at perl's -i
command-line switch...

Hope this helps!
Benjamin Holzman


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

Date: 14 Aug 1997 21:16:58 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: HELP WITH INSTALLING PERL5 ON WINDOWS 95
Message-Id: <5t0l7q$nnt$1@lennon.postino.com>

Ed Wilson (hbact647@csun1.csun.edu) wrote:
: I downloaded the perl5 interpreter from the perl web site, but can't
: seem to get in working.  Can anyone help with the basic install
: procedures?  What to watch out for, tricks... anything would help.

Building perl5 from scratch is a chore. You might want to go to 
www.activeware.com and get Pw32i307.exe and run it. It will
extract & install. But if you should be interested in rolling
your own perl, get the gcc dev kit from www.cygnus.com , the
new patch program from prep.ai.mit.edu , the required patches
from www.tiac.net/users/cgf , and a good nights sleep before
your start. :-) 

--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
I don't need to hide my e-mail address, I broke my sendmail.


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

Date: 15 Aug 1997 02:05:28 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
To: carpente@earth.execpc.com (Vinit Carpenter)
Subject: Re: HELP: Search and replace question
Message-Id: <5t0dh8$f9h$1@info.uah.edu>

[Posted and mailed]

In article <5sv5kj$qhc$1@earth.execpc.com>,
	carpente@earth.execpc.com (Vinit Carpenter) writes:
: Hi there. I've got a quick question about searching and replacing in
: Perl. Here's what I want my script to do. Go thru a file and find every
: occurance of a particular word. If it finds that word, I want it to
: delete that line and replace it with another word that I specify.

% perl -pi.bak -e '$_ = "Intranet\n" if /internet/i' file.html

Hope this helps,
Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Mon, 11 Aug 1997 08:48:35 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: How to execute remote Perl script from Perl?
Message-Id: <33EEA7B3.73D1@icl.fi>

David Estornell wrote:
> 
> Is it possible to execute a remote Perl script from Perl? I would like
> to 'capture' the output from the remote Perl script and have it appear
> in-line with the output of the parent script.
> 
> For example, say the URL for remote.pl is
> http://abcdefg.net/cgi-bin/remote.pl. 

[snip]

Look at the libwww (LWP) modules that either come with
your Perl distribution, or if not, get them from:

   http://www.perl.com/CPAN/

I'd also like to suggest that you get to know services
such as

   http://www.dejanews.com
   http://altavista.digital.com

as they'll help you locate answers to frequently asked
questions more guickly (than posting in a newsgroup,
waiting for days, possibly weeks, for an answer that
may never appear).

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Thu, 14 Aug 1997 20:05:40 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Tom <ii@fairhope.com>
Subject: Re: how to set shell variable from perl?
Message-Id: <Pine.GSO.3.96.970814200506.18525O-100000@julie.teleport.com>

On 15 Aug 1997, Tom wrote:

> The following command works fine from the csh, but in perl it seems to
> be ignored. 
> 
> `setenv MYDIR "$HOME/foo" `

This FAQ entry may shed some light on the problem. Hope this helps!

    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/perlfaq8/
          I_changed_directory_modified_m.html

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 14 Aug 1997 21:14:02 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: how to set shell variable from perl?
Message-Id: <a1e0t5.8pl.ln@localhost>

Tom (ii@fairhope.com) wrote:
: The following command works fine from the csh, but in perl it seems to
: be ignored. 

: `setenv MYDIR "$HOME/foo" `

: Any suggestion?


I would suggest reading the Perl FAQ, part 8.


"I {changed directory, modified my environment} in a perl script.  
 How come the change disappeared when I exited the script?  
 How do I get my changes to be visible?"


I guess you missed it somehow when you checked the FAQ before posting.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 14 Aug 1997 23:49:51 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: ii@fairhope.com
Subject: Re: how to set shell variable from perl?
Message-Id: <33F3D1DF.BDE5E954@mail.earthlink.net>

Tom wrote:
> 
> The following command works fine from the csh, but in perl it seems to
> be ignored.
> 
> `setenv MYDIR "$HOME/foo" `
> 
> Any suggestion?
> 
> Tom
Exactly how do you mean it's getting ignored?  I'm sure it is taking
full effect, but only in between the backticks, as they implicitly fork
a shell and wait for it to die.  You probably want to do something like: 
$ENV{'MYDIR'} = "$ENV{'HOME'}/foo";

This will be in effect for all subsequent system calls.

Hope this helps!
Benjamin Holzman


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

Date: Thu, 14 Aug 1997 20:00:14 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Ian Duplisse <duplisse@rentwks1.golden.csc.com>
Subject: Re: localizing $^A causes core dump
Message-Id: <Pine.GSO.3.96.970814195928.18525L-100000@julie.teleport.com>

On Thu, 14 Aug 1997, Ian Duplisse wrote:

> With Perl 5.002, localizing $^A in a subroutine and returning it causes
> a SEGV. 

If you can duplicate this in 5.004, please file a bug report by using the
perlbug utility. Thanks! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: 14 Aug 1997 23:38:18 GMT
From: trey@zipcon.net (Trey Valenta)
Subject: makewhatis for Solaris
Message-Id: <871601931.453586@ran.zipcon.net>
Keywords: solaris makewhatis catman perl

I would like to fix the windex file on my SunOS5.5.1 system so that the
man pages for perl modules and other non Sun items get parsed properly
and inserted into the windex. I searched DejaNews and found that some
people had written some various perl scripts to replace sun's makewhatis
script but the only script I could get my hands on didn't work right.
(I won't waste any more bandwidth on this and assume that if you don't
have/know of this problem, you don't have anything already written).

Does anyone have anything current I can get? I'd be most appreciative. I
found refs to this many times on comp.lang.tcl, but I don't care to use
a Tcl script if I don't have to and can get one in perl or awk.

thanks!
Trey
--
Trey Valenta	trey@zipcon.net	 Seattle, WA



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

Date: 14 Aug 1997 21:10:35 -0700
From: danny@lennon.postino.com (Danny Aldham)
Subject: Re: NT with Enterprise Serv. 3.0 Perl Problems
Message-Id: <5t0krr$nj3$1@lennon.postino.com>

rhaman@reveregroup.com wrote:
: Currently I am working on an NT 4.0 box with
: Netscape Enterprise Server 3.0 as the Web Server.  As far as I can
: tell I
: have Ent. Srv. configured correctly but none of my PERL scripts will
: work.
: I've tried them with both .pl and .cgi extensions I even created a
: file

You need to enable script mapping by editing the registry HKEY_LOCAL_MACHINE
\System\CurrentControSet\Services\W3SVC\Parameters\ScriptMap , Add Value
with Value name .pl with data type REG_SZ , and in the String Editor box
type   full\path\to\your\perl.exe %s  
Stop & restart WWW service and you should be OK.
 
--
Danny Aldham           SCO Ace , MCSE , JAPH , DAD
I don't need to hide my e-mail address, I broke my sendmail.


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

Date: Thu, 14 Aug 1997 19:21:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Stuart Poulin <stuart@becool.cdac.com>
Subject: Re: Overriding Functions in Modules, i.e. File::Find lstat
Message-Id: <Pine.GSO.3.96.970814185511.18525F-100000@julie.teleport.com>

On Thu, 14 Aug 1997, Stuart Poulin wrote:

> How do I go about overriding a function in a module?
> For example: I want File::Find to use 'stat' instead of 'lstat'

I'm not sure why you want it, but assuming that it's a Good Thing :-) 
here's a pretty good way to make it happen: Make your own copy of
File::Find, and add an option in the form of a global package variable
called (say) $File::Find::use_stat. Fix the code to notice whether that
variable is set, and to use stat instead of lstat when it is. Then, when
you have it all debugged and documented, if you think anyone else might
also find that feature useful, send a patch to the Perl developers and ask
what they think. It might become a part of a future release of Perl. Have
fun with it! 

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 14 Aug 1997 19:58:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: chasmo@zapt.com
Subject: Re: perform operations on files withing directory tree
Message-Id: <Pine.GSO.3.96.970814195823.18525K-100000@julie.teleport.com>

On Thu, 14 Aug 1997, Chasmo wrote:

> I'm fairly new to Perl and still trying to figure out how to execute
> operations on all files within a selected directory tree. 

Check out File::Find. Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 14 Aug 1997 21:25:18 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Puting pattern in a variable
Message-Id: <eme0t5.rsl.ln@localhost>

Eric Bohlman (ebohlman@netcom.com) wrote:
: Bob Wilkinson (b.wilkinson@pindar.co.uk) wrote:

: : Try something like

: : my $regex = join("|",@List);

: This is potentially unsafe if the regexes in @List are more complicated 
: than simple keywords.  Something like

: my $regex = '('.join(")|(",@List).')';

: would ensure that there are no unintentional precedence problems.


There are even some more ways for it to not match what might be expected:

With:

   @List = qw(one oneHundred two three);
   $_ = 'oneHundred';

It will match the 'one' part.


So...

my $regex = join '|', sort {$b cmp $a} @List; # match the longest one please


;-)


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 14 Aug 1997 20:03:08 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Joachim Wunder <Joachim.Wunder@LRZ-Muenchen.DE>
Subject: Re: Q: IPC between Perl and C
Message-Id: <Pine.GSO.3.96.970814200245.18525N-100000@julie.teleport.com>

On Fri, 15 Aug 1997, Joachim Wunder wrote:

> I am trying to figure out how to do InterProcessCommunication (IPC)
> between a C program and a Perl 5 program. 

Does the perlipc(1) manpage help you any? Good luck!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Mon, 11 Aug 1997 09:07:16 +0300
From: Petri Backstrom <petri.backstrom@icl.fi>
Subject: Re: Read from growing file - eof problem
Message-Id: <33EEAC14.770D@icl.fi>

howard@wdsec.com wrote:
> 
> I'm using the
> while <FILE>
> loop to parse data from a growing file.
> At the end of the while loop I sleep and then reset with
> seek
> and start the while <FILE> loop again.
> 
> Unfortunately sometimes I read in the last line
> AS it's growing so I get an incomplete line.
> Is there any way around this?
> Somehow detect the invalid line and reset to read in
> the last line again?

Read it twice and compare:

Before you do a read, use tell() to remember the place,
then read & save, then seek() again to the place you
remember, read again, compare.

regards,
 ...petri.backstrom@icl.fi
    ICL Data Oy
    Finland


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

Date: Thu, 14 Aug 1997 19:25:01 -0700
From: Yuzo Watanabe <yuzow@sec.sel.sony.com>
Subject: Removing elements in the middle of arrays?
Message-Id: <33F3BDFD.13857E0E@sec.sel.sony.com>

Perl novice seeks enlightenment.

	I'm just starting up with perl, and I stumbled onto something and
wanted to know if there was _any_ easier way to do it.

	Essentially, I want to delete a record from an array that's not
associative (or else I'd use the handy-dandy delete() function).  Is
there any better way to do it than:

1.  Parse array until you find the offending data.
2.  Keep track by incrememnting a counter.
3.  Splice all the entries before the bad element into a new array, and
then merge all the elements after the bad one also onto the new array.
4.  Get rid of the old array that had the bad element.

	This is pretty much what has to be done in C, and that's why you use
linked lists when you had to do things like delete or add elements in
the middle.  Is there an easy way to do this in PERL?  Should I be using
another data structure that I don't know about?

	BTW, does the camel book go over any of the other data structures like
Hash tables and such?  

Yw  
-- 

========================================================================
[Yuzo Watanabe(yuzow@sec.sel.sony.com)  http://www.andrew.cmu.edu/~yw26]
[----------------------------------------------------------------------]
[ "Looking into Microsoft and seeing vast conspiracies to rob us of    ]
[  our individual freedoms diminishes the credibility of those of us   ]
[  who have legitimate, reasonable gripes with some areas of Microsoft ]
[  policy. "                                                           ]
[                                                                      ]
[                                              - Jason Shankel (Maxis) ]
========================================================================


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

Date: Thu, 14 Aug 1997 20:07:44 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Yuzo Watanabe <yuzow@sec.sel.sony.com>
Subject: Re: Removing elements in the middle of arrays?
Message-Id: <Pine.GSO.3.96.970814200647.18525P-100000@julie.teleport.com>

On Thu, 14 Aug 1997, Yuzo Watanabe wrote:

> Subject: Removing elements in the middle of arrays?

> Is there any better way to do it than:
> 
> 1.  Parse array until you find the offending data.
> 2.  Keep track by incrememnting a counter.
> 3.  Splice all the entries before the bad element into a new array, and
> then merge all the elements after the bad one also onto the new array.
> 4.  Get rid of the old array that had the bad element.

Maybe you want grep, documented in the perlfunc(1) manpage. Hope this
helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 14 Aug 1997 23:39:12 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Yuzo Watanabe <yuzow@sec.sel.sony.com>
Subject: Re: Removing elements in the middle of arrays?
Message-Id: <33F3CF60.C3ABB9E4@mail.earthlink.net>

[posted & mailed]
Yuzo Watanabe wrote:
> 
> Perl novice seeks enlightenment.
> 
>         I'm just starting up with perl, and I stumbled onto something and
> wanted to know if there was _any_ easier way to do it.
In perl, there usually is... :-)
> 
>         Essentially, I want to delete a record from an array that's not
> associative (or else I'd use the handy-dandy delete() function).  Is

You want the splice() function-- it will do what you want, and much,
much more.  Here's how you could have found this out for yourself:

1. search for "array" in the perlfunc manpage.  The first match is:

Functions for real @ARRAYs 
     pop, push, shift, splice, unshift 

2. read the documentation for each of these functions.  Here's what
you'd find:

splice ARRAY,OFFSET,LENGTH,LIST 

splice ARRAY,OFFSET,LENGTH 

splice ARRAY,OFFSET 
     Removes the elements designated by OFFSET and LENGTH from an array,
and replaces them with the elements of LIST, if any. Returns the
elements removed from the array. The array grows or shrinks as
necessary. If LENGTH is omitted, removes everything from OFFSET onward.

>         BTW, does the camel book go over any of the other data structures like
> Hash tables and such?
Yup!
> 
> Yw
> --
Hope this helps!

Benjamin Holzman


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

Date: Fri, 15 Aug 1997 04:00:38 GMT
From: scott@radix.net (Scott Houck)
Subject: Re: Seeking object enlightenment
Message-Id: <33f4d3ad.12401882@news1.radix.net>

Randal Schwartz <merlyn@stonehenge.com> wrote:
>
>	bless $something, "Some::Random::Package";
>
>"blesses" it into the package Some::Random::Package, so that:
>
>	$something->foo("bar");
>
>will start by looking for the subroutine called
>Some::Random::Package::foo, passing it $something and "bar" as
>parameters.

Perhaps part of the obscurity (What?  Perl obscure?) lies in the
choice of the word "bless" to do this.  Is this an OOP term?  I never
heard of it before.  But you all act like this is the most natural
association in the world!  :-)


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

Date: Fri, 15 Aug 1997 00:29:54 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Simple question on s/// operator in expressions
Message-Id: <EExIpu.D4q@bcstec.ca.boeing.com>

In article <33F31FB0.FC124FC@oberbrunner.com>,
Gary Oberbrunner  <garyo@oberbrunner.com> wrote:
 > Sorry for a question that's so simple I should be able to figure it out, but
 > I can't for the life of me.
 > 
 > I often want to do a substitution on a string and use the result 'in-line',
 > without having to create a new variable just to hold the result (or modify the
 > original string).  The only way I have found is to substitute into another
 > variable with this hack:
 > 
 >   $foo = "my string\n";
 >   $tempfoo = $foo;
 >   $tempfoo =~ s/my/my new/;
 >   print $newfoo;
 > 
 > when all I really want is something like this:
 > 
 >   $foo = "my string\n";
 >   print s/my/my new/ ($foo);   # Syntax error, s/// is not a unary operator.
 > 
 > There must be some clever perl way to do this kind of thing.  I'm using
 > perl5.004, if it makes any difference...
 > 
 > Thanks for any advice you might have;
 > 

At the risk of earning time in obfuscation hell :) 

   print do { $foo =~ s/my/my new/; $foo};


HTH,
--
Charles DeRykus
ced@carios2.ca.you_know_the_drill.boeing.com


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

Date: 15 Aug 1997 03:40:04 GMT
From: bwiren@bs.wa.gov.au (Brian Wiren)
Subject: Using passwd command inside a perl script
Message-Id: <5t0j2k$rap$2@marri.bs.wa.gov.au>


Hi

I am trying to use the UNIX /usr/bin/passwd command within a script.

I am setting up a system to allow people to administer their POP Email 
accounts.

I have tried to open passwd as a file handle then print the info to the pipe - 
but alas no worky.

Any help would be appreciated.

Regards Brian




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

Date: Fri, 15 Aug 1997 00:05:24 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Why doesn't sort take a reference any more?
Message-Id: <EExHL1.Bnn@bcstec.ca.boeing.com>

In article <33f318e9.526978643@news.rev.net>,
Bernard Cosell <bernie@rev.net> wrote:
 > On Perl 5.003 on Linux, I have a routine that has a really complicated
 > set of sorting criteria, and so what I tried to do is:
 >     my $compsub;   # I also tried local $compsub
 >     if (lots of tests)
 >     {  $compsub = sub {first sort criteria} ; }
 >     elsif (lots of tests)
 >     {  $compsub = sub {second sort criteria} ; }
 >       ...
 >     sort $compsub (keys %hash) { ...}
 > 
 > I'd been struggling a bit to try to understand what this error meant:
 > 
 >    not a GLOB reference at ./call_logs.pl line 96.
 > 
 > which didn't seem to make much sense.  But upon looking at the
 > perlfunc man page, I discovered an interesting change from Camel 2.
 > Camel 2 says "SUBNAME may be a scalar variable name (unsubscripted) in
 > which case the value provides the name of (or a reference to) the
 > actual subroutine to use"  That has been -removed- from perlfunc.
 > 
 > So it appears that my problem is that i'm trying to do something that
 > is no longer supported, but I'm left with wondering WHY it was
 > removed.  It would seem that the original functionality would be handy
 > for a situation like the above and I don't see a really an as-clean
 > way to do it.  Thanks!!
 > 

What timing :). Just stumbled into this problem today ...and then stumbled 
into a workaround: 

sort {&$compsub} ... 



HTH,
--
Charles DeRykus
ced@carios2.ca.knock-it-off.boeing.com


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V8 Issue 870
*************************************

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