[12352] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5952 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 10 18:07:21 1999

Date: Thu, 10 Jun 99 15:00:23 -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, 10 Jun 1999     Volume: 8 Number: 5952

Today's topics:
    Re: **ANY HELP APPRECIATED******* <perlguy@technologist.com>
    Re: Apache Authenticate and CGI (brian d foy)
    Re: Binary File Uploading - Part 2 <dfs@thegrid.net>
    Re: block inside print ? <jdporter@min.net>
        CGI and Access Database <trenic@nortelnetworks.com>
        Compiling Perl script w/modules (Rick Frink)
    Re: Creating an external config file. How ? <mhc@Eng.Sun.COM>
        Detecting a File Download Cancel <jbott@compuserve.com>
    Re: Difference of two variables <jdf@pobox.com>
    Re: Difference of two variables (Larry Rosler)
        dimensions of a jpg file <dscapin@harris.com>
        fcntl usage? <bill.williams@cisco.com>
    Re: HELP: Permission Denied retrieving remote URL (DarStec)
    Re: How do I sort files in a dir by last modified time? <aef@pangea.ca>
    Re: how to read excel file ? <bruno@toutatis.demon.co.uk>
        Interpolation Question <ahumphr@c-s-k.de>
    Re: Interpolation Question <uri@sysarch.com>
    Re: invoking a script (not in a subshell) (Andrew Allen)
    Re: Is there a module like URI::Escape for HTML text? (Randal L. Schwartz)
        Is there an MS-DOS perl that will use extended memory? <aperrin@mcmahon.qal.berkeley.edu>
    Re: Is this a bug in Perl? <rootbeer@redcat.com>
        Learning Perl 1st edition still useful? mecran01@homer.louisville.edu
    Re: Learning Perl 1st edition still useful? (Randal L. Schwartz)
    Re: matching function for array? <jdf@pobox.com>
        Oraperl and Oracle Web doug_brough@my-deja.com
    Re: Oraperl and Oracle Web doug_brough@my-deja.com
        Perl and non-constant strings sbeaulieu@my-deja.com
    Re: problem with html pop mail <rrogers@naisp.net>
    Re: quiz for perl professionals <spike1965@worldnet.att.net>
    Re: quiz for perl professionals <uri@sysarch.com>
    Re: Require "No NT commands"  on UNIX (Alastair)
    Re: Require "No NT commands"  on UNIX (Tad McClellan)
    Re: What's the "halting problem"? <jdf@pobox.com>
    Re: What's the "halting problem"? <uri@sysarch.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 10 Jun 1999 15:08:52 -0500
From: Brent Michalski <perlguy@technologist.com>
Subject: Re: **ANY HELP APPRECIATED*******
Message-Id: <37601B54.25EC7A5B@technologist.com>

dmeyers@tisny.com wrote:
> 
> Can anyone suggest where I can find an Engineer with Javascript/C/UNIX
> experience for a contract opportunity with a Fortune 1000 firm in San
> Francisco, Ca?  Please contact dmeyers@tisny.com.  
You could try a Javascript/C/UNIX newsgroup for starters..

>Thank you!
No problem whatsoever...

Brent


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

Date: Thu, 10 Jun 1999 00:07:28 -0400
From: brian@pm.org (brian d foy)
Subject: Re: Apache Authenticate and CGI
Message-Id: <brian-ya02408000R1006990007280001@news.panix.com>

In article <375E7FDE.B0E98099@atrieva.com>, Jerome O'Neil <jeromeo@atrieva.com> posted:

> I have written a module to control Apache style acl and group lists. 
> I'm considering posting it to CPAN, but I don't think it's quite ready
> for that, yet, even though it's useable.  Let me know if you'd like it,
> and I'll send you a copy.

is this different than HTTPD::UserAdmin?

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Monger Hats! <URL:http://www.pm.org/clothing.shtml>


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

Date: Thu, 10 Jun 1999 20:12:24 GMT
From: "Ryan" <dfs@thegrid.net>
Subject: Re: Binary File Uploading - Part 2
Message-Id: <01beb37e$66d467c0$5630a2d1@ryano-ke>



Thanks guys,

Obviously I am new. <G> My comments do not wrap in the code. The mail editor did that.
Thanks for the tips, I will work on it more.
Ryan

Eric The Read <emschwar@rmi.net> wrote in article <xkfd7z4klvs.fsf@valdemar.col.hp.com>...
> "Ryan" <dfs@thegrid.net> writes:
> > #!/usr/local/bin/perl
> 
> No -w.  No "use strict;".  Fix those, and most of your other errors
> should be simple to find.
> 
> > use CGI qw/:standard/;
> 
> This is good.
> 
> > use CGI::Carp qw(fatalsToBrowser);            	#Sends full errors to
> > browser
> 
> Is this what your code really looks like?  Because I found a bunch of
> lines like this, where a comment is continued on a new line without a
> comment marker of its own.  If not, you need to watch out and make sure
> youre newsreader doesn't wrap lines of code indiscriminately.
> 
> <snip>
> 
> > &get_info;					#sub routine call gets information from the form object
> 
> There's no reason you have to do it this way, unless you like that syntax 
> of function calls.  "get_info();" would work just as well.
> 
> > sub get_info{
> > 	$name = $query->param('name');			#name entered on form
> 
> You're using a global CGI object here.  Why not pass it in (or pass in a
> reference to it), and use that?  It makes it much clearer which functions 
> use which program variables.  'perldoc perlsub' for more details.
> 
> > sub error{
> 
> Same here-- why not pass in the variables you're going to use, instead of 
> using globals everywhere?  It's much better style.
> 
> > All of the above works just fine.
> 
> Are you sure?  What happens when you run 'perl -c' on it?
> 
> > sub print_results{
> >      open (NEWPIC,">../submits/$newname") || 		#open existing or create the
> > file and filehandle NEWPIC
> >      die "Unable to create or open file $!";			#or die program and send
> > error to browser
> 
> Again, I can't tell if it's your newsreader or your code, but this
> doesn't compile on my system-- I have to join the multi-line comments
> together on one line.
> 
> >   while ($bytesread=read($newname,$buffer,1024)) {
> 
> perldoc -f read
> 
> Note that read takes as its first argument a filehandle.  Last I checked, 
> $newname is defined as follows:
> 
> > $file_name = $query->param('file_entered'); #file name entered
> > @parts = split(/\\/, $file_name); #split file name path up
> > $newname = $parts[$#parts];			 #gets the last part of parts array
> 
> Which is to say, $newname is a string, not a filehandle.
> 
> >      print NEWPIC $buffer; 
> > }
> >  close(NEWPIC);							#close NEWPIC
> > }
> >
> > Any thoughts anyone? 
> 
> Yes-- write all your perl programs with -w and 'use strict;' until you
> know when not to.
> 
> -=Eric
> 


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

Date: Thu, 10 Jun 1999 18:43:49 GMT
From: John Porter <jdporter@min.net>
Subject: Re: block inside print ?
Message-Id: <7jp112$pmf$1@nnrp1.deja.com>

In article <375fc14e.0@usenet.fccj.cc.fl.us>,
  "Bill Jones" <bill@fccj.org> wrote:
>
> print
>       " Well? ",
> {
>     ((split(/\|/, $vFlag))[7] eq 'x') ? 'do this' : 'do that'
> },
>       "\n";
>
> > NOTE:  The above does cause error -
> > MoreInfoII.cgi: Odd number of elements in hash list at
> > ./MoreInfoII.cgi line 57, <miData> chunk 826.

Did you figure out where that hash reference was coming from?
There's two ways to make a hash reference:
1. take the reference of a hash: \%hash
2. use curlies to make an anonymous hash:  { a => b }

So those curlies aren't doing what you thought they would do.


> I forgot to mention that the HASH Reference ID is
> printing and not what it is pointing to -
> # Odd number of elements in hash list.
> File 'MacOS:Desktop Folder:OddHashReference'; Line 3
>  Well? HASH(0x9fc5490)

That will always be the case.  References are never automatically
dereferenced, in Perl.  If you pass a reference to print(), you
print a reference (stringified, of course).


> I decided I should try to de-reference the implied hash
> using a \'string' slash.

Come on, I know you know better than that.
Backwhack doesn't dereference a reference, it CREATES a reference.


> Then I fiddled with 'stringafication' of the reference.

But you never got the clue that a hash (ref'd or not) is NOT
what you wanted?  You said you wanted a code block!

But what you really wanted, whether you realized it or not,
was an expression.  You wanted to print the result of the
evaluation of an expression.  Expressions can be enclosed in
parentheses (not curlies) in order to prevent the precedence of
things like comma from getting in the way.  So you could have
done this:

print " Well? ",
  (
    ((split(/\|/, $vFlag))[7] eq 'x') ? 'is X' : 'is !X'
  ),
    "\n";

Of course, parens aren't always necessary; but when in doubt,
parenthesize.


> print
>       " Well? ",
> @{[
>   ((split(/\|/, $vFlag))[7] eq 'x') ? 'is X' : 'is !X'
>   # If \'string' used, then generates: Well? SCALAR(0x9fc5178)
> ]},
>       "\n";
>
> which prints:  Well? is X
>
> Which also reminds me that I've used this
> 'interpolation' trick in past scripts,

Except that this is not a case of interpolation, because the
@{[ ]} did not occur inside a string.  The array was passed
directly to print().  Of course, you *could* have interpolated it:

print " Well? @{[
  ((split(/\|/, $vFlag))[7] eq 'x') ? 'is X' : 'is !X'
  # or whatever
]} \n";


> Lesson learned:
>   "Experience is a hard teacher, but you never forget!"

Better hope, then, that what it teaches you is actually correct.

--
John Porter
Put it on a plate, son.  You'll enjoy it more.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 10 Jun 1999 17:24:00 -0400
From: Tom Renic <trenic@nortelnetworks.com>
Subject: CGI and Access Database
Message-Id: <37602CF0.AFC92A51@nortelnetworks.com>

Hi Group,

My knowledge of CGI and perl is fairly limited. I have an Access
Database File that I want hooked up to a form, so that the responses are
added to the database. Is this possible? Can someone show me the way?

Your help will be very much appreciated!

Tom


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

Date: 10 Jun 1999 16:45:39 -0400
From: rfrink@user2.infinet.com (Rick Frink)
Subject: Compiling Perl script w/modules
Message-Id: <7jp85j$2cb@user2.infinet.com>

Hello,

  Using the HP-UX ANSIC compiler and Perl 5.00502, I'm having
trouble compiling a script that accesses any Perl module.  The
compile fails during the linking phase when it cannot resolve
a symbol named "runops", which I do not find in any of the
listed libraries. The compilation also complains about an
invalid option, "b". 

  I'm attaching the output from Perl -V.  I'd appreciate any
suggestions.
Thanks,

Rick

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

# perl -V

Summary of my perl5 (5.0 patchlevel 5 subversion 2) configuration:
  Platform:
    osname=hpux, osvers=10.20, archname=PA-RISC1.1
    uname='hp-ux nmstm1 b.10.20 e 9000800 1412586381 8-user license '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef

  Compiler:
    cc='cc', optimize='-O', gccversion=
    cppflags='-D_HPUX_SOURCE -Aa'
    ccflags ='-D_HPUX_SOURCE -Aa'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=undef, longlongsize=, d_longdbl=define, longdblsize=16
    alignbytes=8, usemymalloc=y, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib/pa1.1 /lib /usr/lib /usr/ccs/lib
    libs=-lnsl_s -lndbm -ldld -lm -lc -lndir -lcrypt
    libc=/lib/libc.sl, so=sl, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_hpux.xs, dlext=sl, d_dlsymun=undef, ccdlflags='-Wl,-E 
    -Wl,-B,deferred '
    cccdlflags='+z', lddlflags='-b -L/usr/local/lib'

Characteristics of this binary (from libperl): 
  Built under hpux
  Compiled at Mar  5 1999 18:54:38
  @INC:
    /opt/perl/lib/5.00502/PA-RISC1.1
    /opt/perl/lib/5.00502
    /opt/perl/lib/site_perl/5.005/PA-RISC1.1
    /opt/perl/lib/site_perl/5.005
    .



























-- 
Rick Frink
UNIX System Engineer
PCSO Consulting, Inc.



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

Date: 10 Jun 1999 12:51:41 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: Creating an external config file. How ?
Message-Id: <8p6lndr25rm.fsf@Eng.Sun.COM>

"Greg Savage" <greg@paradox.net.au> writes:

> I have compilled my perl script and now need to store my configuration
> options in an external text file for ease of modification. I am looking for
> an efficient routine to read in the following pairs, ignoring # comments
> and assign them to variables.
> 
> # This is a comment
> logdir /var/log
> logfile local0
> warning 2
> limit 5
> admin admin@domain.com
> 
> I guess a hash would be a good start but am unsure to the structure.
> 
> 
> Advice would be appreciated.

open CONFIG, "config" or die qq{error: cannot open file "config": $!\n};
my %options = ();
my $line = 0;
while (<CONFIG>) {
   $line++;
   s/\#.*//;                    # delete comments
   next if /^\s*$/;             # ignore blank lines
   unless (/^\s*(\S+)\s+(\S+)\s*$/) {
        die qq{error: line $line: bad format in config file: $_};
   }
   $options{$1} = $2;
}

-mike

(Not speaking for my employer.)


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

Date: Thu, 10 Jun 1999 13:11:48 -0700
From: "James Bott" <jbott@compuserve.com>
Subject: Detecting a File Download Cancel
Message-Id: <OKHGq33s#GA.337@nih2naaf.prod2.compuserve.com>

I'm new to programming in Perl. I am wondering if there is a way to detect
when the user cancels from the download a file dialog called like the
following:

print "Location:$pathto/$scriptname\n\n" ;

# need to detect a cancel here





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

Date: 10 Jun 1999 15:28:16 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: ladlad@my-deja.com
Subject: Re: Difference of two variables
Message-Id: <m3674vonxr.fsf@joshua.panix.com>

ladlad@my-deja.com writes:

> and I would like to get the difference of these two strings

See the documentation for split() to turn those strings into lists,
then see perlfaq4 for determining the difference/intersection of two
arrays. 

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 10 Jun 1999 14:48:23 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Difference of two variables
Message-Id: <MPG.11c9d27f200ff7a3989bb6@nntp.hpl.hp.com>

In article <m3674vonxr.fsf@joshua.panix.com> on 10 Jun 1999 15:28:16 -
0400, Jonathan Feinberg <jdf@pobox.com> says...
> ladlad@my-deja.com writes:
> > and I would like to get the difference of these two strings
> 
> See the documentation for split() to turn those strings into lists,
> then see perlfaq4 for determining the difference/intersection of two
> arrays. 

See my post for why this FAQ doesn't help.  The FAQ 'difference' is 
'symmetric difference', not 'subtraction'.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 10 Jun 1999 15:50:52 -0400
From: Deamon George Scapin <dscapin@harris.com>
Subject: dimensions of a jpg file
Message-Id: <3760171B.825D5A39@harris.com>

I am writing a perl script and need to find a way to get several
dimensions.  I need the dimensions of

1)  An image
2)  The viewer window
3)  The screen size setting.

Are there readily available browser, environmental or other settings I
can query or do I need a module?  Can plain html give me this
information?

Thanks very muchos.

George Scapin
dscapin@maelstrom.cs.fit.edu



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

Date: Thu, 10 Jun 1999 16:20:53 -0400
From: Bill Williams <bill.williams@cisco.com>
Subject: fcntl usage?
Message-Id: <37601E24.3988690A@cisco.com>

what is the proper way of controlling process access to a file using
fcntl?

what I am trying to do (because flock doesn't exist on my particular
unix) is

start a long process,
check for file handle
open a file handle if one doesn't exist,
write the process id to the file handle,
lock it with LOCK_EX
move on
unlock the file

ideally, when cron kicks off this process again if it tries to LOCK_EX

the same file handle again and ssees that the file handle is still
locked, it should barf,
correct?

what I have now that seems not to work is:

open (PID, "$pid_file") || die "can't open $pid_file\n";
fcntl (PID, &LOCK_EX, 0) or die "can't set exclusive lock on
$pid_file\n";
print PID "$pid";

it doesn't complain, the script runs fine, etc. but if I kick off the
same program, it
doesn't die like I would think that it would... am I missing something
obvious here?

I am much more used to flock, not fcntl.

--
Thanks,
_________________________
Bill Williams
ERP Systems Administrator
Cisco Systems
IS - RTP




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

Date: 10 Jun 1999 21:41:51 GMT
From: darstec@aol.com (DarStec)
Subject: Re: HELP: Permission Denied retrieving remote URL
Message-Id: <19990610174151.24729.00001269@ngol05.aol.com>

In article <375b804b.3101269@news.anet-stl.com>, gsoup@yahoo.com (Greg) writes:

>
>I am having problems retrieving a remote URL. I wrote a script using
>LWP::Simple with the LWP and supporting modules copied into a library
>directory.
>	use lib ('/home/username/public_html/cgi-bin/lib');
>	use LWP::Simple;
>	$content = get($url);
>
>I successfully ran the script without errors on my home webpage, but
>it returns a 500 Internal Server error on my free web host on
>virtualave.net with the same module files copied into a library
>directory. Virtualave.net does not allow telnet access, so I can't run
>the script from the command line. I found a newsgroup article which
>mentioned how to catch the error and wrote the folllowing script. 
>

Try this: use lib ('/home/username/public_html/cgi-bin/lib/');  <<---add the
slash
It may be that Virtual Avenue thinks "lib" is a file.  You might find that
putting the script in the cgi-bin directory might work too.

Double check permissions [though all files going to the cgi-bin directory are
automatically set to chmod 755) and don't depend on Automode when using FTP,
explicitly use ASCII mode for transferring.  Virtual Avenue is really finicky
in these matters.


Later,
Darrell Stec                               E-Mail: DarStec@aol.com

Webpage Sorcery
http://webpagesorcery.com
We Put the Magic in Your Webpages




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

Date: Thu, 10 Jun 1999 16:42:23 -0500
From: "AEF" <aef@pangea.ca>
Subject: Re: How do I sort files in a dir by last modified time?
Message-Id: <7jpbo4$v0k$1@pumpkin.pangea.ca>

Thanks:

The good news for me is that i was on  the right track with the stat[9]
and trying to convert mtime to localtime.

I appreciate the info.

Being a newbie , had to do a bit of reading on the assignment operator since
I was not familiar with the "||=" assignment of the

$hash->{$_[0]  ||= (stat $_[0])[9];

Thanks again.

>. Using the orcish
> thingy gives access to the values returned by stat so it can feed
> them into localtime() via the cache hash.
>
> # ----- code ----- #
> #!/usr/bin/perl -w
>
> use strict;
>
> my ( %m );
>
> for ( sort { ( $m{$b} ||= (stat($b))[9] ) <=>
>              ( $m{$a} ||= (stat($a))[9] ) } <*> )
>

>     my ( $day, $mon, $yr );
>     ( $day, $mon, $yr ) = ( localtime $m{$_} )[3..5];
>     print "$_ => d:$day m:", $mon + 1, " y:", 1900 + $yr, "\n";
> }
> # ----- code ----- #
>
> Hope that helps...
>
> dean.
> --
> --
> dean hudson, <deanh@verio.net> Verio Systems Engineering




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

Date: Thu, 10 Jun 1999 22:21:00 +0100
From: Bruno Girin <bruno@toutatis.demon.co.uk>
To: Gopal Kethineni <kkethine@cisco.com>
Subject: Re: how to read excel file ?
Message-Id: <37602C3B.FC955587@toutatis.demon.co.uk>

Gopal Kethineni wrote:

> How do I read MS-Excel file in perl for unix and manipulate the
> data and save it in text format?

What about first asking Excel to export the file as CSV (comma separated
values)? Then you can read it easily. Otherwise, you'll have to
understand Excel's data format, which is not an enjoyable idea.

--
Bruno Girin
Home: bruno@toutatis.demon.co.uk - http://www.toutatis.demon.co.uk
Work: bruno.girin@monis.co.uk - http://www.monis.co.uk





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

Date: Thu, 10 Jun 1999 22:10:02 +0200
From: "Aidan Humphreys" <ahumphr@c-s-k.de>
Subject: Interpolation Question
Message-Id: <7jp61f$498$1@newsread.f.de.uu.net>

Can someone explain to me how I initiate interpolation? Basically I am
retrieving a HTML string with embedded 'syntactical variables' from a
database. I want to then interpolate the variables the program context. To
simulate the data base retrieval I'll assign the sting using a single quoted
here document.


$foo = <<'__ETX';
  <HTML>
  <HEAD>
  <TITLE>$param[0]</TITLE>
  </HEAD>
  <BODY>$param[1]</BODY>
  </HTML>
__ETX

#... ... ...

@param = ("<p>Title", "<p>Body");

eval print $foo;



How do I get the text to print out with the $param[] values interpolated. ?





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

Date: 10 Jun 1999 17:09:58 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Interpolation Question
Message-Id: <x7909r4va1.fsf@home.sysarch.com>

>>>>> "AH" == Aidan Humphreys <ahumphr@c-s-k.de> writes:

  AH> Can someone explain to me how I initiate interpolation? Basically
  AH> I am retrieving a HTML string with embedded 'syntactical
  AH> variables' from a database. I want to then interpolate the
  AH> variables the program context. To simulate the data base retrieval
  AH> I'll assign the sting using a single quoted here document.


  AH> $foo = <<'__ETX';

remove the '' from the here token. where did you see that being used and
why did you do that? the '' makes the whole string look like a single
quoted string which doesn't interpolate. the default (with no quotes on
the token) is to behave like a double quoted string which does interpolate.

  AH>   <HTML>
  AH>   <HEAD>
  AH>   <TITLE>$param[0]</TITLE>
  AH>   </HEAD>
  AH>   <BODY>$param[1]</BODY>
  AH>   </HTML>
  AH> __ETX

  AH> @param = ("<p>Title", "<p>Body");

  AH> eval print $foo;

that won't eval the string and it is the wrong thing to do anyway.

  AH> How do I get the text to print out with the $param[] values
  AH> interpolated. ?

and reverse the order. get the params first and then assign/print the
string. there is no reason to do it your way.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: 10 Jun 1999 21:42:59 GMT
From: ada@fc.hp.com (Andrew Allen)
Subject: Re: invoking a script (not in a subshell)
Message-Id: <7jpbh3$go5$1@fcnews.fc.hp.com>

Mark-Jason Dominus (mjd@op.net) wrote:
: In article <7jmodr$eba$5@fcnews.fc.hp.com>, Andrew Allen <ada@fc.hp.com> wrote:
: >Ain't gonna happen. Since your current shell isn't perl, you can't run
: >perl in your current shell.

: That's what I thought at first, but now I'm not so sure.  What if the
: shell execs the perl program, without forking, and then the perl
: program changes the environment variables and re-execs the shell,
: again without forking?

Inventive, bizarre, almost perl-esque,

  $ exec perl5 -e '$ENV{"HI"}="blah"; exec $ENV{q{SHELL}}'
  $ echo $HI
  blah

and I'll be darned, it works!

: Of course, you'd lose all your shell internal data, like history and
: non-environment variables.  But if this were a script to be run at
: shell startup time, it might work.  Or if you used the `rc' shell,
: which doesn't have non-environment variables and which keeps the
: history in a file.

Good caveats. Definitely "surprising" effects for the casual user.

: I've never heard of anyone actually doing this.  I don't know whether
: it's actually a bad idea, or whether it's one of those things that
: people do all the time in the alternate universe where parasails were
: invented in the 16th Century.

Nearly as bizarre.

Andrew


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

Date: 10 Jun 1999 14:17:07 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Is there a module like URI::Escape for HTML text?
Message-Id: <m1909rycvg.fsf@halfdome.holdit.com>

>>>>> "Mitchell" == Mitchell Morris <mgm@unpkhswm04.bscc.bls.com> writes:

Mitchell> Before I start trying to hack up my own search-n-replace
Mitchell> bit, is there already one of these written?

Besides HTML::Entities in the LWP distribution?

Any more than that is too many. :)

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Thu, 10 Jun 1999 13:44:42 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Is there an MS-DOS perl that will use extended memory?
Message-Id: <376023BA.AB978376@mcmahon.qal.berkeley.edu>

Greetings-

Odd question, I know - I'm trying to recycle an old laptop to do a
particular job that involves its holding a rather large hash in memory.
The laptop has 8Mb of RAM, of which 7 are reported free by DOS, but of
course in good ol' DOS fashion it will only use the low memory area. Has
anyone created a DOS perl binary (v 4 is fine) that can use extended
memory?

Thanks in advance.

--
-------------------------------------------------------------
Andrew J. Perrin - NT/Unix/Access Consulting -  (650)938-4740
aperrin@mcmahon.qal.berkeley.edu (Remove the Junk Mail King)
     http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Thu, 10 Jun 1999 13:48:32 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Is this a bug in Perl?
Message-Id: <Pine.GSO.4.02A.9906101313470.26349-100000@user2.teleport.com>

On Thu, 10 Jun 1999, Derek wrote:

> #!/bin/perl -w
> use strict;
> 
> use POSIX qw(:sys_wait_h :signal_h);
> 
> sub reaper
>   {
>     my $dead_child = wait;
>     print "Reaped $dead_child with status of $?\n";
>   }
> 
> $SIG{CHLD} = \&reaper;
> 
> if( fork ) { exit 0; }

Hmmm... Did you mean to do that? Your parent process just (presumably)
forked a child process and quit. If the child manages to run quickly
enough to finish before the parent can exit, your &reaper will be called.
But if the parent reaches the exit first, no &reaper (but the child will
be reaped by init, of course). 

So, your program is at this point non-deterministic: It may show different
behaviors even on a single system with a single perl binary. Is that what
you wanted, or is that what you're complaining about? :-)

Maybe you wanted to install the handler after forking?

> my @lines = qx(ps);
> die("Dead with $?\n") if( ($? >> 8) != 0 );
> print "Done\n";

But maybe you want the &reaper to capture the exit status from ps. That's
not recommended, since then Perl doesn't get to put it into $? for you. As
a rule, if you're going to be reaping (and collecting the exit status),
you don't want to use qx`` or other ways of starting processes where Perl
is also looking to wait for an exit status.

> On an AIX box with Perl 5.004 I get this:
> 
> > ./reaper.pl
> Reaped 18678 with status of 0
> Dead with -1
> Reaped 25888 with status of 2560

Yup, that looks like your &reaper grabbed the exit status from both ps and
the child process. (The child exited before the parent did, this time.)

> Perl 5.001 on AIX gives:
> 
> > Reaped 49164 with status of 0
> Done

And in this one, I think that the &reaper didn't get the exit status from
ps. I'd guess that that was probably a bug in Perl which went away
sometime before the release of Police Academy 7: Mission to Moscow. You
probably shouldn't use such an old version of Perl as 5.001 anymore.

If you need to have a reaper for some subprocesses, but you also need to
get the status of a command like ps, you'll probably want to fork off the
command "manually". Otherwise, with your program reaping some and Perl
trying to reap others, you'll find only heartache. But hey! that's why we
earn the big bucks, right? :-)

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 10 Jun 1999 18:02:53 GMT
From: mecran01@homer.louisville.edu
Subject: Learning Perl 1st edition still useful?
Message-Id: <7jouk6$on1$1@nnrp1.deja.com>

Learning Perl first edition is on Ebay with no reserve if anyone finds
it at all useful.  It doesn't cover Perl 5, and seems to have less CGI
stuff than the second edition, so buyer beware.  Shipping is 2 bucks
book rate to the US.


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 10 Jun 1999 14:19:58 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Learning Perl 1st edition still useful?
Message-Id: <m14skfycqp.fsf@halfdome.holdit.com>

>>>>> "mecran01" == mecran01  <mecran01@homer.louisville.edu> writes:

mecran01> Learning Perl first edition is on Ebay with no reserve if
mecran01> anyone finds it at all useful.  It doesn't cover Perl 5, and
mecran01> seems to have less CGI stuff than the second edition, so
mecran01> buyer beware.

"less" as in "zero". :)

CGI didn't exist in any real sense when I started writing the Llama.

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 10 Jun 1999 08:59:35 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: OPENLINX <openlinx@openlinx.net>
Subject: Re: matching function for array?
Message-Id: <m3n1y8p5xk.fsf@joshua.panix.com>

OPENLINX <openlinx@openlinx.net> writes:

> is there any way to find out "red" is in the array X?  Or do I have
> to loop thru every elements using a loop control structure like for
> or while?

This is a FAQ, perlfaq4, "How can I tell whether a list or array
contains a certain element?"

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: Thu, 10 Jun 1999 18:01:18 GMT
From: doug_brough@my-deja.com
Subject: Oraperl and Oracle Web
Message-Id: <7jouh7$om8$1@nnrp1.deja.com>

My details:
   Oracle 7.3.4
   Oracle Web Server 4.0.6
   DBD 0.44
   DBI 0.81
   PERL 5.003

The following works fine:

#!/home/orca/rfadba/perl5/bin/perl
print "Content-type: text/html\n\n";
print "<html>\n";
print "<pre>hi mom</pre>\n";
print "</html>\n";

However, if I insert "eval 'use Oraperl; 1' || die $@ if $] >= 5;" as
the 2nd line, I get a blank web page.  The presence of "use Oraperl"
consistently gives me a blank web page.

Any ideas what might be going on?  Thanks in advance!

Doug Brough



Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 10 Jun 1999 19:21:47 GMT
From: doug_brough@my-deja.com
Subject: Re: Oraperl and Oracle Web
Message-Id: <7jp380$qk6$1@nnrp1.deja.com>

Problem solved.  I was finally able to capture the error message.  I
have a library contention problem (problems with my library path).

Thanks,

doug

In article <7jouh7$om8$1@nnrp1.deja.com>,
  doug_brough@my-deja.com wrote:
> My details:
>    Oracle 7.3.4
>    Oracle Web Server 4.0.6
>    DBD 0.44
>    DBI 0.81
>    PERL 5.003
>
> The following works fine:
>
> #!/home/orca/rfadba/perl5/bin/perl
> print "Content-type: text/html\n\n";
> print "<html>\n";
> print "<pre>hi mom</pre>\n";
> print "</html>\n";
>
> However, if I insert "eval 'use Oraperl; 1' || die $@ if $] >= 5;" as
> the 2nd line, I get a blank web page.  The presence of "use Oraperl"
> consistently gives me a blank web page.
>
> Any ideas what might be going on?  Thanks in advance!
>
> Doug Brough
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 10 Jun 1999 18:15:45 GMT
From: sbeaulieu@my-deja.com
Subject: Perl and non-constant strings
Message-Id: <7jovc7$p0l$1@nnrp1.deja.com>

I'm passing a char* from C++ to Perl.  How does Perl handle a constant
string as opposed to a passed char *?  I'm interested into how the
memory management works.

ie.

return "test";

opposed to:

char* test;
return test;


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Thu, 10 Jun 1999 16:07:29 -0400
From: Rob Rogers <rrogers@naisp.net>
Subject: Re: problem with html pop mail
Message-Id: <37601B01.BBF0C5E1@naisp.net>

Andrzej Filip wrote:
> 
> WARNING:
> I have seen at least one ISP which changed its POP server
> to delete all read email (a violation of POP3 specification)

Slightly off topic, but this isn't a violation of POP3 specification.

<CITE=RFC 1939 Section 8 Scaling and Operational Considerations>
One special case of a site policy is that messages may only be
downloaded once from the server, and are deleted after this has
been accomplished.  This could be implemented in POP3 server
software by the following mechanism: "following a POP3 login by a
client which was ended by a QUIT, delete all messages downloaded
during the session with the RETR command".  It is important not to
delete messages in the event of abnormal connection termination
(ie, if no QUIT was received from the client) because the client
may not have successfully received or stored the messages.
Servers implementing a download-and-delete policy may also wish to
disable or limit the optional TOP command, since it could be used
as an alternate mechanism to download entire messages.
</CITE>

I agree that it is a _very_ bad idea, but it is definitely not in
violation of POP3 specification.


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

Date: Thu, 10 Jun 1999 16:19:26 -0400
From: Terry Mealy <spike1965@worldnet.att.net>
Subject: Re: quiz for perl professionals
Message-Id: <37601DCE.D7C3E3AF@worldnet.att.net>

I'm a perl novice!!! I'd say its $#array!  Or that the array has
($#array + 1) elements.  I didn't even have to look in "Learning Perl".

When shall I start?

Kiriakos Georgiou wrote:
> 
> You may not believe it, but so far out of the interviewees that claimed to
> be experienced with perl, none has been able to answer my #1 killer
> question:  "How do you find the length of an array?"
> 
> I figured if the readers of this news group can't get the length of an
> array there isn't much hope.  Anyway, I include a list of questions - if
> you can answer them and you enjoy working with HTML, CGI.pm, DBI (talking
> to sybase), etc., I would like to talk to you. The job is in Washington DC.
> 
> regards,
> Kiriakos
> 
> How do you find the length of an array?
> 
> In the context of regular expressions, what does \S+ stand for ?
> 
> How would you count the number of words in a string?
>   (split it and use scalar context on the array)
> 
> What does 'eval' do?
> 
> Why wouldn't you want to put an eval in a loop?
> 
> How would you get around the problem in the previous question?
> 
> What will    $_ = eval 'sub { print @_; }';   print?
> what does it do?
> what will  &$_(1,2,3);   do?
> 
> What is the difference between 'local' and 'my'?
> 
> How do you pass parameters by value?
> 
> How do you pass parameters by reference?
> 
> Can you describe what the taint mode does?  Can you name of any ways for
> untainting tainted data?


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

Date: 10 Jun 1999 17:03:24 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: quiz for perl professionals
Message-Id: <x7d7z34vkz.fsf@home.sysarch.com>

>>>>> "KG" == Kiriakos Georgiou <kgnews@olympiakos.com> writes:

  KG> How do you find the length of an array?

measure it with a scalar ruler.

  KG> In the context of regular expressions, what does \S+ stand for ?

that would be telling. i am not a regex, i am a free man!!

  KG> How would you count the number of words in a string?
  KG>   (split it and use scalar context on the array)

1, 2, 3, 4 ....

  KG> What does 'eval' do?

the opposite of gud. i wish more perl hackers worked for gud than eval.

  KG> Why wouldn't you want to put an eval in a loop?

because what eval goes around, comes around.

  KG> How would you get around the problem in the previous question?

nail your other foot to the floor.

  KG> What will    $_ = eval 'sub { print @_; }';   print?

who cares. the world will be a cold lifeless rock in 5 billions years. :-(

  KG> what does it do?

what does what do?

  KG> what will  &$_(1,2,3);   do?

do-be-do-be-do! (my condolences to mel torme'e family)

  KG> What is the difference between 'local' and 'my'?

my train is not the local, but the express.

  KG> How do you pass parameters by value?

do not pass parameters, do not collect $200.

  KG> How do you pass parameters by reference?

you don't refer to parameters, instead you imply you have them.

  KG> Can you describe what the taint mode does?  Can you name of any ways for
  KG> untainting tainted data?

always check if your oysters aren't tainted before taking their perls.


well, do i pass? i got a certificate from tekmorons the other day that
claims i am a master perl programmer. it was signed peronally by a laser
printer. i also bait lusers on this group so that makes me a master
baiter perl programmer. i also paid $2 for a certificate from perl
mongers at the last conference and it claims i am a certified perl quiz
hacker. so do i get the job?

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Thu, 10 Jun 1999 20:56:58 GMT
From: alastair@calliope.demon.co.uk (Alastair)
Subject: Re: Require "No NT commands"  on UNIX
Message-Id: <slrn7m0d8p.5i.alastair@calliope.demon.co.uk>

Ashish Kadakia <anonymous@web.remarq.com> wrote:
>I have following setup.
>
>Web Server running on NT

>How I can setup in CGI scripts or Perl Enviornment so that
>it will not go to NT for commands and read UNIX commands as
>I want to try several commands which are on UNIX and not on
>NT.

The easiest way is to install unix and run a unix web server. I'd install Linux
on it (but (just as) free alternatives exist). 

HTH.

-- 

Alastair
work  : alastair@psoft.co.uk
home  : alastair@calliope.demon.co.uk


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

Date: Thu, 10 Jun 1999 12:22:10 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Require "No NT commands"  on UNIX
Message-Id: <inooj7.p06.ln@magna.metronet.com>

Ashish Kadakia (anonymous@web.remarq.com) wrote:

: Web Server running on NT
: CGI Directory is on Unix, as Mapped network drive on NT.


: In CGI script when I call
: open IN, "date|" it reads date command of NT and not unix.


   That is because the _server_ runs the CGI program behalf
   of the user.


: How I can setup in CGI scripts or Perl Enviornment so that
: it will not go to NT for commands and read UNIX commands as
: I want to try several commands which are on UNIX and not on
: NT.


   Run the server on the OS that you want to use.


   ...Or remain a POB, and get you some Perl Power Tools:


        http://language.perl.com/ppt/


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 10 Jun 1999 09:10:22 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: Russ Allbery <rra@stanford.edu>
Subject: Re: What's the "halting problem"?
Message-Id: <m3k8tcp5fl.fsf@joshua.panix.com>

Russ Allbery <rra@stanford.edu> writes:

> Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> writes:
> 
>> the term "halting problem" occurred a couple of times in the thread
>> "Syntax checking a Perl script". What does this term mean? I had a
>> quick grep through perl*.pod but didn't find it there.
> 
> It's something from theoretical computer science, particular
> computability theory.  It's provably impossible to write a program
> that, given another arbitrary program, can tell you whether or not
> that program halts (ie, terminates rather than runs forever).

We owe this result in great part to Kurt Gvdel, about whom there's an
interesting and accessible article in this month's Scientific
American.  The article also features a brief bibliography.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


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

Date: 10 Jun 1999 16:42:42 -0400
From: Uri Guttman <uri@sysarch.com>
Subject: Re: What's the "halting problem"?
Message-Id: <x7g13z4wjh.fsf@home.sysarch.com>

>>>>> "JF" == Jonathan Feinberg <jdf@pobox.com> writes:

  JF> Russ Allbery <rra@stanford.edu> writes:
  >> Philip 'Yes, that's my address' Newton <nospam.newton@gmx.net> writes:
  >> 
  >>> the term "halting problem" occurred a couple of times in the thread
  >>> "Syntax checking a Perl script". What does this term mean? I had a
  >>> quick grep through perl*.pod but didn't find it there.
  >> 
  >> It's something from theoretical computer science, particular
  >> computability theory.  It's provably impossible to write a program
  >> that, given another arbitrary program, can tell you whether or not
  >> that program halts (ie, terminates rather than runs forever).

  JF> We owe this result in great part to Kurt Gvdel, about whom there's an
  JF> interesting and accessible article in this month's Scientific
  JF> American.  The article also features a brief bibliography.

and for a great and creative explanation of it and related problems,
check out the classic book, godel, escher, bach. a must read for anyone
interested in cognition.

uri


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
uri@sysarch.com  ---------------------------  Perl, Internet, UNIX Consulting
Have Perl, Will Travel  -----------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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