[13208] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 618 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 23 02:07:20 1999

Date: Sun, 22 Aug 1999 23:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 22 Aug 1999     Volume: 9 Number: 618

Today's topics:
    Re: $$var[xxx] vs ${var}[xxx] <mpersico@erols.com>
    Re: $$var[xxx] vs ${var}[xxx] (elephant)
    Re: Bizarre inconsistency (Martien Verbruggen)
        Help for the newbie <tallen@allentechconsult.com>
    Re: How to do "or" in IF test? (Jim)
    Re: most efficient method to communicate over sockets <bshow@my-deja.com>
        parent/child communication and odbc <kangas@anlon.com>
    Re: parent/child communication and odbc <ahands@sprynet.com>
    Re: Perl executablles (elephant)
    Re: Perl executablles <carvdawg@patriot.net>
    Re: Recursing through directory headache (Sean McAfee)
        Redex and Efficiency <joeyandsherry@mindspring.com>
    Re: Setting User ID in perl script (Martien Verbruggen)
        single quote regular expression but allow back referenc (Bill Moseley)
    Re: system() under Win32 <john@dlugosz.com>
    Re: system() under Win32 <john@dlugosz.com>
    Re: system() (Martien Verbruggen)
    Re: The logic of curly braces <jongl@proaxis.com>
    Re: what does eq do on lists? <john@dlugosz.com>
    Re: What does gmtime[3,4,5] do? <john@dlugosz.com>
    Re: Why use Perl when we've got Python?! (Abigail)
    Re: Why use Python when we've got Perl? (Cameron Laird)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Sun, 22 Aug 1999 23:41:57 -0400
From: "Matthew O. Persico" <mpersico@erols.com>
Subject: Re: $$var[xxx] vs ${var}[xxx]
Message-Id: <37C0C305.BC2B730A@erols.com>



Irwin Feuerstein wrote:
> 
> These curly braces are confusing to me. Let's go back to the
> beginning.
> 
> First, is $var the same as ${var}? Is there a rationale for using one
> over the other?

Yes, the are the same. The {} are optional when it is clear what the
variable is, not so when not clear. Meaning:

$foo = 6; # no need for braces

print "${foo}pack of beer\n"; # w/o braces, variable is $foopack.

In short, always use them and you'll never have to wonder if your should.

> On page 41 of Programming Perl, there is "how ${verb}able". Why is it
> coded like that? Is "{$verb}able" the same as "${verb}able"? There
> must be a difference, no?

Assume that $verb = 'runable':

"{$verb}able" == "{run}able";

"${verb}able" == "runable";

Get it?

-- 
Matthew O. Persico
    
You'll have to pry my Emacs from my cold dead oversized
   control-pressing left pinky finger. -- Randal L. Schwartz


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

Date: Mon, 23 Aug 1999 14:04:56 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: $$var[xxx] vs ${var}[xxx]
Message-Id: <MPG.122b7371ffc6a4b2989c71@news-server>

Matthew O. Persico writes ..
>Irwin Feuerstein wrote:
>> On page 41 of Programming Perl, there is "how ${verb}able". Why is it
>> coded like that? Is "{$verb}able" the same as "${verb}able"? There
>> must be a difference, no?
>
>Assume that $verb = 'runable':
>
>"{$verb}able" == "{run}able";
>
>"${verb}able" == "runable";
>
>Get it?

I hope Irwin doesn't ever see your post .. it can only create more 
confusion

a) assuming C<$verb = 'runable';> then

  print "{$verb}able\n";
  print "${verb}able\n";

would output

{runable}able
runableable

b) however .. even with the above assumption - the fact that you used 
the numeric equality operator (==) will mean that both comparisons

  "{$verb}able" == "{run}able";
  "${verb}able" == "runable";

would still be true .. but so would

  "${verb}able" == "nothing in particular";

the only things that Matthew's code does show is that using the '-w' 
switch really is not a joke - and that code should always be tested 
before being posted to this newsgroup .. incorrect answers are worse 
than no answer at all

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 23 Aug 1999 03:02:43 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Bizarre inconsistency
Message-Id: <nR2w3.4015$pN3.8231@nsw.nnrp.telstra.net>

In article <7pq1gv$3i$1@nnrp1.deja.com>,
	perfectbeat@my-deja.com writes:
> The following will not work:
> 
> open (NR_NEW_RELEASES, ">./Html/new_releases/
> nr$old_date_fields[0]\.html")
> 
> where
> 
> local(@old_date_fields) = split(/\|/
> ,$previous_date);

And of course, you don't know why it doesn't work, because you aren't
asking for the reason, right?

# no need to escape the . Besides, why do you escape one ., but not
# the other?
my $fn = "./Html/new_releases/nr$old_date_fields[0].html";
open(NR_NEW_RELEASES, ">$fn") || die "Cannot open $fn for write: $!";

Maybe this will give you some info on what is going wrong, and why.
Maybe one of the directories you are trying to access doesn't exist.
Maybe you program is running in a different place than you think it
is, and maybe you should use absolute rather than relative paths. Who
knows?

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | What's another word for Thesaurus?
NSW, Australia                      | 


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

Date: Mon, 23 Aug 1999 01:40:54 -0400
From: "Tim Allen" <tallen@allentechconsult.com>
Subject: Help for the newbie
Message-Id: <7pqmt7$ncj$1@bgtnsc02.worldnet.att.net>

Is there a tutorial somewhere that can show me how to manipulate an sql
database with a perl program?

thanks

tim

--
----------------------------------------------------------------
Tim Allen
tallen@allentechconsult.com




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

Date: Sun, 22 Aug 1999 23:32:04 -0500
From: jkrogerDONCHA_SPAM_ME@earthlink.net (Jim)
Subject: Re: How to do "or" in IF test?
Message-Id: <jkrogerDONCHA_SPAM_ME-2208992332050001@ip101.princeton.nj.pub-ip.psi.net>

Thanks very kindly, Per, Allan, and Jimmy!

Jim



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

Date: Mon, 23 Aug 1999 03:32:11 GMT
From: Bob Showalter <bshow@my-deja.com>
Subject: Re: most efficient method to communicate over sockets
Message-Id: <7pqfbr$95k$1@nnrp1.deja.com>

If you use pack/unpack, be sure to use "n" or "N" to get "network"
order, as different machines have different byte orderings.

In article <iOJv3.13233$s%1.51798875@rmnws01.ce.mediaone.net>,
  "Chuck Hirstius" <chirstius@mediaone.net> wrote:
> I'm coding up a program to do remote admin of many NT boxes, it
basically
> runs as a service, hooks onto a port and listens for a remote login,
it then
> allows you to get a report of drives capacity, memory usage, and
various
> other tidbits.  I would also like to add the abilty to start and stop
> services, or run certain applications.  So here's my question, many
of the
> remote machines are on a satellite connection and transmission speed
is
> slower then a 28.8 modem, what is the most effiecient way to send
"commands"
> to these machines over a socket connection?  Currently I'm using
plain text
> stuff like "get memory" and parsing it out on the other end, this is
fine
> for testing, and over a local lan spped is no problem, but for
security and
> bandwidth issues I feel I need to look into another way to do this.
One
> thought I had was pack() - ing the data, or using numeric messages,
like
> SNMP traps, anyone done anything like this? or have any suggestions?
Please
> reply by email whether or not you post a reply to the NG  Thank you!!
>
> Chuck
>
> chirstius@mediaone.net
>
>


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


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

Date: Sun, 22 Aug 1999 21:26:46 -0500
From: Kangas <kangas@anlon.com>
Subject: parent/child communication and odbc
Message-Id: <37C0B166.D930E610@anlon.com>


--------------C05D15ED141DAEAEEA528D6E
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Parent/Child realtions::
I have been trying to use pipes and have a pipe working but for only one
connection. I want to have one script act as a server which starts a
pipe, then a lot of child processes try to open this pipe to the server
but I am having synchronization problems and sleep() isn't helping. I
started originally with Win32::Process but it was suggested to me to use
pipes but since I couldn't get that to work properly I went back to
Win32::Process.

I would try to use the Win32::Mutex, Event, or Semaphore but I can't
find any examples to go by and the documentation that I can find doesn't
tell me much. Anyone have some example of these in action??

Here is the two main parts of the parent and child that i want
communicating.

########################################

The main.pl has any number of ftp servers in an array and creates the
ftp.pl process to check their availability.

foreach(@results) {
   @data = split(/\*---\*/, $_);
    # rename $data[XXX] var to $ip and such was here.
       Win32::Process::Create($ProcessObj,
                              "D:\\Perl\\bin\\Perl.exe",
                              "Perl ftp.pl $ip $user $pass $port",
                               0,
                               NORMAL_PRIORITY_CLASS,
                              ".") || die &ReportError;
}



The ftp.pl will test the ftp server and put the server welcome text in a
flat file right now but i want to eliminate as much file I/O as
possible. It just seems to me that perl would have more to offer than
this but I do not know how to do it is all.

use Win32::Internet;
$I = new Win32::Internet();

$I->FTP($FTP, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]) || ($dead=1);
print "$ARGV[0] not available.\n" if $dead;
exit if $dead;

$result = $FTP->GetResponse();
# put into a file here and then die and later the parent will read it.

########################################


ODBC:
I have many scripts that use Win32::ODBC but would like to have the
first script open a connection to the database and then all following
scripts use this connection rather than having to create a new
connection for each script that needs access. This may be a bigger
question of holding objects, variables, arrays and associative arrays in
memory.  So, i guess my question is "Is it possible to hold variables
and objects in memory for another process to use?".

Any and all help would be greatly appreciated.

--
Michael Kangas
kangas@anlon.com


--------------C05D15ED141DAEAEEA528D6E
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<b>Parent/Child realtions::</b>
<br>I have been trying to use pipes and have a pipe working but for only
one connection. I want to have one script act as a server which starts
a pipe, then a lot of child processes try to open this pipe to the server
but I am having synchronization problems and sleep() isn't helping. I started
originally with Win32::Process but it was suggested to me to use pipes
but since I couldn't get that to work properly I went back to Win32::Process.
<p>I would try to use the Win32::Mutex, Event, or Semaphore but I can't
find any examples to go by and the documentation that I can find doesn't
tell me much. Anyone have some example of these in action??
<p>Here is the two main parts of the parent and child that i want communicating.
<p>########################################
<p>The main.pl has any number of ftp servers in an array and creates the
ftp.pl process to check their availability.
<p>foreach(@results) {
<br>&nbsp;&nbsp; @data = split(/\*---\*/, $_);
<br>&nbsp;&nbsp;&nbsp; # rename $data[XXX] var to $ip and such was here.
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Win32::Process::Create($ProcessObj,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"D:\\Perl\\bin\\Perl.exe",
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
"Perl ftp.pl $ip $user $pass $port",
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
0,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
NORMAL_PRIORITY_CLASS,
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
".") || die &amp;ReportError;
<br>}
<br>&nbsp;
<br>&nbsp;
<p>The ftp.pl will test the ftp server and put the server welcome text
in a flat file right now but i want to eliminate as much file I/O as possible.
It just seems to me that perl would have more to offer than this but I
do not know how to do it is all.
<p>use Win32::Internet;
<br>$I = new Win32::Internet();
<p>$I->FTP($FTP, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]) || ($dead=1);
<br>print "$ARGV[0] not available.\n" if $dead;
<br>exit if $dead;
<p>$result = $FTP->GetResponse();
<br># put into a file here and then die and later the parent will read
it.
<p>########################################
<br>&nbsp;
<p><b>ODBC:</b>
<br>I have many scripts that use Win32::ODBC but would like to have the
first script open a connection to the database and then all following scripts
use this connection rather than having to create a new connection for each
script that needs access. This may be a bigger question of holding objects,
variables, arrays and associative arrays in memory.&nbsp; So, i guess my
question is "Is it possible to hold variables and objects in memory for
another process to use?".
<p>Any and all help would be greatly appreciated.
<p>--
<br>Michael Kangas
<br>kangas@anlon.com
<br>&nbsp;</html>

--------------C05D15ED141DAEAEEA528D6E--



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

Date: Mon, 23 Aug 1999 01:46:24 -0400
From: Adrian Hands <ahands@sprynet.com>
To: Kangas <kangas@anlon.com>
Subject: Re: parent/child communication and odbc
Message-Id: <37C0E030.115474A5@sprynet.com>

It sounds to me like you want a bunch of child processes to each hit a
different ftp server and send the results back to the parent, right ?
I've never used perl on ms-win, but on on unix I think what I'd do is
have the parent call fork() instead of launching a bunch of new
perl.exe's to run a seperate script.

This works on linux, I don't know about windows:

#!/usr/bin/perl -w

use strict;
use LWP;
use IO::Pipe;

# Here's the documents I want to get:
my @ftp_urls =
    ('ftp://anonymous:foo@ftp.cdrom.com/README',
     'ftp://anonymous:foo@ftp.ncsu.edu/welcome.msg',
     );

# List of pipes:
my @kids = ();

# Spawn children to get the documents:
for my $url (@ftp_urls) {

    my $pipe = new IO::Pipe();

    my $pid = fork();
    if($pid == 0) {
	&child_logic($url, $pipe);
	exit;
    } else {
	$pipe->reader();
	push @kids, $pipe;
    }
}

# Now get the data from the children one at a time:
my $kidno = 0;
for my $pipe (@kids) {
    $kidno++;
    print "$$ Checking $kidno...\n";
    while(my $line = <$pipe>) {
	print "kid $kidno said: $line";
    }
    $pipe = undef;
}


#################
sub child_logic {
#################
    my($url, $pipe) = @_;

    $pipe->writer();

    my $ua = new LWP::UserAgent;
    my $document = "$url\n";
    my $res = $ua->request(HTTP::Request->new(GET => $url));
    if ($res->is_success) {
	$document .= $res->content();
    } else {
	$document .= "Not available\n";
	$document .= sprintf("Message: %s\n", $res->message());
    }
    
    print $pipe $document;
}



Kangas wrote:
> 
> Parent/Child realtions::
> I have been trying to use pipes and have a pipe working but for only
> one connection. I want to have one script act as a server which starts
> a pipe, then a lot of child processes try to open this pipe to the
> server but I am having synchronization problems and sleep() isn't
> helping. I started originally with Win32::Process but it was suggested
> to me to use pipes but since I couldn't get that to work properly I
> went back to Win32::Process.
> 
> I would try to use the Win32::Mutex, Event, or Semaphore but I can't
> find any examples to go by and the documentation that I can find
> doesn't tell me much. Anyone have some example of these in action??
> 
> Here is the two main parts of the parent and child that i want
> communicating.
> 
> ########################################
> 
> The main.pl has any number of ftp servers in an array and creates the
> ftp.pl process to check their availability.
> 
> foreach(@results) {
>    @data = split(/\*---\*/, $_);
>     # rename $data[XXX] var to $ip and such was here.
>        Win32::Process::Create($ProcessObj,
>                               "D:\\Perl\\bin\\Perl.exe",
>                               "Perl ftp.pl $ip $user $pass $port",
>                                0,
>                                NORMAL_PRIORITY_CLASS,
>                               ".") || die &ReportError;
> }
> 
> 
> 
> The ftp.pl will test the ftp server and put the server welcome text in
> a flat file right now but i want to eliminate as much file I/O as
> possible. It just seems to me that perl would have more to offer than
> this but I do not know how to do it is all.
> 
> use Win32::Internet;
> $I = new Win32::Internet();
> 
> $I->FTP($FTP, $ARGV[0], $ARGV[1], $ARGV[2], $ARGV[3]) || ($dead=1);
> print "$ARGV[0] not available.\n" if $dead;
> exit if $dead;
> 
> $result = $FTP->GetResponse();
> # put into a file here and then die and later the parent will read it.
> 
> ########################################
> 
> 
> ODBC:
> I have many scripts that use Win32::ODBC but would like to have the
> first script open a connection to the database and then all following
> scripts use this connection rather than having to create a new
> connection for each script that needs access. This may be a bigger
> question of holding objects, variables, arrays and associative arrays
> in memory.  So, i guess my question is "Is it possible to hold
> variables and objects in memory for another process to use?".
> 
> Any and all help would be greatly appreciated.
> 
> --
> Michael Kangas
> kangas@anlon.com
>


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

Date: Mon, 23 Aug 1999 12:11:06 +1000
From: elephant@squirrelgroup.com (elephant)
Subject: Re: Perl executablles
Message-Id: <MPG.122b58c6e442f692989c70@news-server>

Derek writes ..
>Does anyone know if there is a product out there that will do what I need. I 
>have looked at active perl but though they have this PerlEx product that is no
>what I need at all.

I don't have it so can't recommend it .. but ActiveState have something 
called PerlApp which is part of the PDK - more information available 
from their website

lines longer that 80 chars after attribution was added have been rudely 
truncated

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Sun, 22 Aug 1999 23:06:54 -0400
From: "Harlan Carvey, CISSP" <carvdawg@patriot.net>
Subject: Re: Perl executablles
Message-Id: <37C0BACE.5D8264AC@patriot.net>

> Does anyone know if there is a product out there that will do what I need. I
> have looked at active perl but though they have this PerlEx product that is not
> what I need at all.

Derek,

http://www.perl2exe.com

This product is far superior to PerlApp...





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

Date: Mon, 23 Aug 1999 04:58:09 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Recursing through directory headache
Message-Id: <Bx4w3.2798$J72.556228@news.itd.umich.edu>

In article <7pli2e$gue$1@charm.magnus.acs.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Sean McAfee
><mcafee@waits.facilities.med.umich.edu>],
>who wrote in article <lwqv3.2627$J72.536834@news.itd.umich.edu>:
>> >Well, it is me who wrote a significant part of the code you discuss.
>> >And there is a lot of reason why not.

>> Okay, I give up.  Why not?
>> I tested the code I posted, and it appeared to work as advertised.

>Effectively, you are iterating through a hash, while changing the
>hash.  See
>  perldoc -f each
>on hints.

I don't see how.  Each time File::Find scans a directory, it slurps the
entire contents into an array at once:

sub finddir {
	# ...
    # Get the list of files in the current directory.
    opendir(DIR,'.') || (warn("Can't open $dir: $!\n"), $bydepth || return);
    my(@filenames) = readdir(DIR);
    closedir(DIR);
	# ...
}

(I did check this code before posting my original reply.)

Once the file's name is in that @filenames array, File::Find has nothing
more to do with it, beyond passing it to the user-defined subroutine.

Renaming directories would clearly be a Bad Thing, but the original poster
wanted to rename only .txt and .csv files (most likely not directories),
and my solution explicitly renamed only ordinary files.

>[Note that I got this idea only after reading your initial reply.  I
> was using my pfind script (based on File::Find) for years (mostly on
> HPFS) without any glitch.  Probably the renames I was doing were very
> "local" (say, a change of an extension), and were not changing the
> ordering.]

Once a directory has been slurped into a lexical Perl array, what does it
matter how the directory's structure changes on disk afterwards, as long as
its subdirectories are still available under the same names as before?

I'm no OS expert, so I'll admit this might be possible, although it's hard
for me to see how.  In that case, a more defensive strategy would be to
cache all of the renames and execute them all at once afterwards:

----------------------------------------------------------------------
use File::Find;

my @rename;

sub cache_rename {
	return unless -f && $File::Find::name =~ /(.*)\.(txt|csv)$/;
	my $new_file = $1 . uc($2);
	push @rename, [ $File::Find::name, $new_file ];
}

find \&cache_rename, '/dir/to/start/';

rename $_->[0], $_->[1] or warn "Can't rename $_->[0]: $!\n" for @rename;
----------------------------------------------------------------------

Is that better?

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: Sun, 22 Aug 1999 22:12:44 -0400
From: <joeyandsherry@mindspring.com>
Subject: Redex and Efficiency
Message-Id: <7pqaqq$aeu$1@nntp1.atl.mindspring.net>

Hello,

Thanks in advance...

 I've recently discovered regex and am now able to identify with: "..oh my
god, it's full of stars."

 ...anyway.

If I wanted to make a script that would search for a zip code in a very
large db, which would be the most efficient:

1.
$zip='12345';
($a, $b, $c, $d, $e)= split(//, $zip);
if ($find=~/$a$b($c$d$e)/){
$xyz="yes";}

OR

2.
$zip='12345';
if ($find="$zip"){
$xyz="yes";}


Thanks alot!

Joey
-The Race is to the Driven, not the Swift.





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

Date: Mon, 23 Aug 1999 06:01:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Setting User ID in perl script
Message-Id: <ys5w3.5236$pN3.12181@nsw.nnrp.telstra.net>

[this is the second post of yours I see today. The first one was sent three
times, and this one twice. Please try to post once only.]

In article <7pjjcd$mfc$1@nnrp1.deja.com>,
	poocus@my-deja.com writes:
> I have a piece of perl script that makes a system call, however it won't

Judging by your other post you are not talking about a system call,
but about the system() builtin.

> run the code being called because the user id of the web browser has no
> permissions, does anybody know how to set the following:
> Real User ID
> Effective User ID
> Real group ID
> Effective Group ID

# perldoc perlvar
/ look for uid

# perldoc perlsec

But you really do not want to do it. I seriously doubt that you will be
able to do it, since you need root priveleges. And unless you really
know what you are doing, you shouldn't mess with this. Just make sure
that the user which your webbie thingie runs as can execute whatever
you need to execute. If your sysadmin judges it too dangerous to do
that, then you probably should try to run it.

> Ps I running the perl via an oracle perl cartridge, does this make any
> difference to the way I use the 'system' command?

Huh? what's an oracle perl cartridge? Never mind. I don't need to
know.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Never hire a poor lawyer. Never buy
Commercial Dynamics Pty. Ltd.       | from a rich salesperson.
NSW, Australia                      | 


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

Date: Sun, 22 Aug 1999 22:44:27 -0700
From: moseley@best.com (Bill Moseley)
Subject: single quote regular expression but allow back references
Message-Id: <MPG.122a7f893ff1e84a9896cf@nntp1.ba.best.com>

Let's see if I can embarrass my self again by missing some obvious 
point.

I'm reading in regular expressions from a file and I want to limit their 
'scope'.  I want to allow use of meta characters and back referencing 
with $1, $2, .etc, but I don't want to allow interpolation to other 
variables within my script.

This is a search and replace program where the patters are stored in a 
file.  So in other words, I'd like to provide the full use of the perl 
regular expressions, yet keep them isolated from the programs internal 
variables.  (Although it might be nice to be able to provide access to 
%ENV, for example, but that's offering too much.)

In an earlier post I asked about using the single quote as the pattern 
separator to prevent variable interpolation.  What I didn't realize is 
that would also not allow back referencing.

So my (perhaps obvious) question this time is how to allow the use of 
the back referencing features, yet not allow variable interpolation in 
the patterns.

All I can think of is to backslash all '$' and '@' symbols (unless the 
'$' is at the very end of the pattern).


Thanks,

-- 
Bill Moseley mailto:moseley@best.com


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

Date: Sun, 22 Aug 1999 22:07:23 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: system() under Win32
Message-Id: <2120F7F6660C2C46.E49DCFD8CA5BDAB3.A5D20B5DEADE47DE@lp.airnews.net>


Bob Walton <bwalton@rochester.rr.com> wrote in message
news:37BB595A.BA6E77DE@rochester.rr.com...
> John, you can't really blame this one on Perl, but rather on Microsoft's
> braindead command interpreter (you are, I assume, using Win32 given the
nature
> of the command quoting you are attempting, even though you neglected to
mention
> what your OS is).

First of all, you don't have to assume what OS I'm using because the
"Subject" line says "system() under Win32".

Second, the documentation states that it =won't= involve the Shell in this
case.  Because there are no shell metacharacters in the string, it will
parse off the first word and exec the function directly.  What it forgets to
do is strip the quotes from this "word" first, so the file is not found.

Poking through the Perl program source code, it's a bit more convoluted than
documented, but it does indeed try to run the program directly first, and
then tries the shell if that doesn't work.

I submit that the Win32 build strip off surrounding quotes in this case, and
make sure that quotes produce a "word" that may contain spaces rather than
just doing a split ' ' on the string.

--John






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

Date: Sun, 22 Aug 1999 22:16:33 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: system() under Win32
Message-Id: <1F73A9FDA84EBDE8.6AC040D9435E11E4.56F7F92A78687418@lp.airnews.net>


elephant <elephant@squirrelgroup.com> wrote in message
news:MPG.12261f3aab98ccdf989c4e@news-server...
> I'm sorry John - but I don't believe you *8^) .. show us the code - I
> can't imagine anything that would do this with an *.exe file

Hmm, a two-line test program doesn't show the problem.
My real program though, failed when quotes were around the EXE file name.
Removing the quotes fixed it, so it wasn't a problem with the string itself.
Parsing the quotes part into another variable and using the list form of
system fixed it, so again it can't be a problem with the string itself.

I wonder if it's a problem with ActiveState build 517 that's fixed in 518?

--John





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

Date: Mon, 23 Aug 1999 05:56:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: system()
Message-Id: <Sn5w3.5216$pN3.12181@nsw.nnrp.telstra.net>

In article <7pjkh6$nbs$1@nnrp1.deja.com>,
	poocus@my-deja.com writes:
> I have a script that calls an external executable, but the line :
>     system ("<full path and filename>");
> is not invoking the executable, what am I doing wrong?

1) You posted the same thing three times. Wrong.
2) You don't show us _real_ code. Wrong.
3) You fail to explain what 'is not invoking the executable' means
   exactly. What does perl complain about? Did it say something like:
   'Can't exec foo: reason here'? Wrong.
4) You fail to check the return status of system(). Wrong.
5) You fail to mention the operating system and the environment
   (command line, CGI, other interface). Wrong.

You probably also forget to use the -w flag, and strict. But without
seeing any actual code, that's very hard to say.

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Sun, 22 Aug 1999 22:06:01 -0700
From: "John Doe" <jongl@proaxis.com>
Subject: Re: The logic of curly braces
Message-Id: <rs1lmntj5u290@corp.supernews.com>

The difference is that "{$verb}able" will print "{stuff}able" and
"${verb}able" will print "stuffable" if $verb = "stuff".

The reason is because to perl "{" is just another character until "$" is
found.  If "{" comes right after some variable flag, like "$", "@", "%", and
such which let's perl know what type of variable you want, it becomes a
marker letting perl know whatever is between "{" and "}" is the name of the
variable you are referring to.  This lets you write stuff like "${verb}able"
and perl will know if you mean $verb is the variable you want and not
$verbable.  It also lets you do things like ${$pointer}, where $pointer can
be some string pointing to some other variable... then we get into hashes or
associative arrays.

But before that, here are some examples of what I'm talking about...

$apple = "red";
$orange = "orange";
$pare = "green";

$one = "apple";
$two = "orange";
$three = "pare";

print "${${one}}"; # is same as ${$one} = ${$one} = ${apple} = $apple = red
print "${$one}"; # is same as ${apple} = $apple = red
print "${one}"; # is same as ${one} = $one = apple

confused?


Irwin Feuerstein <websites@erols.com> wrote in message
news:37c00d98.137169422@news.erols.com...
> These curly braces are confusing to me. Let's go back to the
> beginning.
>
> First, is $var the same as ${var}? Is there a rationale for using one
> over the other?
>
> On page 41 of Programming Perl, there is "how ${verb}able". Why is it
> coded like that? Is "{$verb}able" the same as "${verb}able"? There
> must be a difference, yes?
>
> Irwin




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

Date: Sun, 22 Aug 1999 21:59:58 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: what does eq do on lists?
Message-Id: <FD51CED35FA9FB22.098285A9347FA342.F734505E99F32509@lp.airnews.net>


Abigail <abigail@delanet.com> wrote in message
news:slrn7rpsdg.ath.abigail@alexandra.delanet.com...
> Now, if you know that $" isn't a substring in any of the strings you
> are comparing, you can take use of the fact that a slice in string
> context acts like an array, and compare them as:
>
>    "@a[0..3]" eq "@b"
>
> Of course, if you don't know whether $" can be contained, you end up with
> writing a loop.


As it turns out, the data I'm working with are lines read from a file, so
they all end in \n and never contain a \n, so the string interpolation trick
would work fine.  But I ended up writing a loop, cringing at the
inefficiency of catenating it all together just to test it.

--John




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

Date: Sun, 22 Aug 1999 22:03:19 -0500
From: "John M. Dlugosz" <john@dlugosz.com>
Subject: Re: What does gmtime[3,4,5] do?
Message-Id: <9BF47044BAC5BCD8.631D3B98B8B12FFB.8B1D336D7B3A52CC@lp.airnews.net>


Abigail <abigail@delanet.com> wrote in message
news:slrn7rv7sp.c9p.abigail@alexandra.delanet.com...
> It takes [3, 4, 5] and passes that as an argument to gmtime. And [3, 4, 5]
> in numerical context is a valid number; hence some (but bogus) result
> from gmtime, and no warnings.

Thank's for the enlightenment.

--John





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

Date: 22 Aug 1999 23:54:48 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <slrn7s1l29.jkg.abigail@alexandra.delanet.com>

Ilya Zakharevich (ilya@math.ohio-state.edu) wrote on MMCLXXXII September
MCMXCIII in <URL:news:7ppqph$ju4$1@charm.magnus.acs.ohio-state.edu>:
__ [A complimentary Cc of this posting was sent to Abigail
__ <abigail@delanet.com>],
__ who wrote in article <slrn7rv9bc.c9p.abigail@alexandra.delanet.com>:
__ > What of course really sucks in Perl is that you cannot easily do operator
__ > overloading, unless you resort to 'use overload'. Which of course, doesn't
__ > have overload magic for assignment or indexing.
__ 
__ Of course, you did not do
__ 
__    perldoc overload
__ 
__ for loooooooooooooong time.


   $ man overload
   ....
             However, it does not overload the Perl
   assignment operator. This would go against Camel hair.
   ....
   23/Jan/1999             perl 5.005, patch 03
   ....
   $ date
   Mon Aug 23 00:52:53 EDT 1999
   $

I believe perl 5.005_03 is the most recent version of Perl.


__ > Oh, and don't even think of creating an overloaded operator with lazy
__ > evaluation/short circuiting. Or to overload an operator such that it
__ > takes a regex as argument.
__ 
__ Aha, and you do not read p5p either...


I'm not interested in discussion forums that turn into moderated ones
just because someone has the technical means, and not the concensus.



Abigail
-- 
perl -MLWP::UserAgent -MHTML::TreeBuilder -MHTML::FormatText -wle'print +(
HTML::FormatText -> new -> format (HTML::TreeBuilder -> new -> parse (
LWP::UserAgent -> new -> request (HTTP::Request -> new ("GET",
"http://work.ucsd.edu:5141/cgi-bin/http_webster?isindex=perl")) -> content))
=~ /(.*\))[-\s]+Addition/s) [0]'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 23 Aug 1999 03:27:19 GMT
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: Why use Python when we've got Perl?
Message-Id: <FAA0A36A71C86317.F8AACF1ACF4646E5.12D37B0704A76E00@lp.airnews.net>


In article <37b634a2@cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:
			.
			.
			.
>Think back to the 80s and early 90s.  The change, if it really happened,
>came with the upty-gazillion CGI script kiddies who couldn't program
>2+2, yet who wanted *us* to write *them* these persistent, encrypted,
>crossplatform, multiscreen shopping carts for e-commerce, complete with
>dynamically-generated animated vanity counters, each and every time 
>they stepped up to the feeder.
			.
			.
			.
And e-mail address validation; don't forget that.
No, wait, I mean, the *eight* things no one ever
expects from the Spanish Inquisition are ...
-- 

Cameron Laird           http://starbase.neosoft.com/~claird/home.html
claird@NeoSoft.com      +1 281 996 8546 FAX


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
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" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. 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" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 618
*************************************


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