[8658] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2275 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 8 13:07:20 1998

Date: Wed, 8 Apr 98 10:00:30 -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           Wed, 8 Apr 1998     Volume: 8 Number: 2275

Today's topics:
    Re: -comparing the values of 2 arrays- <james@cydaps.co.uk.NOSPAM>
    Re: A problem for Perlxs or Perlxstut (Tye McQueen)
        adding passwords accross multiple serveers grindrod@tfn.com
    Re: CGI.pm passing variables into param? ahayes@ingenia.com
        content of file handle <TheSage@uk2.so-net.com>
    Re: fork() and exec() example needed please... <rootbeer@teleport.com>
        HELP .. return true value <venky@clam.com>
    Re: HELP .. return true value <cmargoli@world.northgrum.com>
    Re: Is it just me?  (error/bug? with "my") <cortez@tfn.com>
    Re: Need help with "shared memory" module IPC::Shareabl (Tye McQueen)
    Re: NT: pass STDOUT to a child program? <oesch@bluewin.ch>
    Re: Packing? <merlyn@stonehenge.com>
        Perl scripts not working with Netscape 3.0 on MacIntosh <wmckinn@newbridge.com>
    Re: pidof <rootbeer@teleport.com>
    Re: running `ls $file` on a nt workstation in a search  <um@say.what>
    Re: running `ls $file` on a nt workstation in a search  <WS010@dvvlap.be>
    Re: running `ls $file` on a nt workstation in a search  smitty77@pacbell.net
    Re: serpinski gasket almost-1-liner needs polishing (David A. Black)
    Re: setUID script (Jason Gloudon)
    Re: setUID script <rootbeer@teleport.com>
    Re: setUID script <rootbeer@teleport.com>
    Re: Simple Unix Question,  ( Simple for you maybe ) <dorr@cetrel.lu>
    Re: Simple Unix Question,  ( Simple for you maybe ) (Rob Tanner)
    Re: Simple Unix Question,  ( Simple for you maybe ) <uri@sysarch.com>
    Re: Tail-like functionality (M.J.T. Guy)
    Re: Timeout script <um@say.what>
    Re: Timeout script <rootbeer@teleport.com>
    Re: Tying a blessed hash (was: Re: Tie/bless vs. bless/ (Tye McQueen)
    Re: Urgent: Perl Win32 vs Unix Perl <keithmur@mindspring.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 8 Apr 1998 15:51:49 +0100
From: "James" <james@cydaps.co.uk.NOSPAM>
Subject: Re: -comparing the values of 2 arrays-
Message-Id: <892048549.9165.0.nnrp-04.c2de3f1b@news.demon.co.uk>


Hi!

Thanks for everyone's help with this, it is working perfectly now! Thanks!!


James




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

Date: 8 Apr 1998 10:15:20 -0500
From: tye@fiinix.metronet.com (Tye McQueen)
Subject: Re: A problem for Perlxs or Perlxstut
Message-Id: <6gg4a8$1cn@fiinix.metronet.com>

kfox@pt0204.pto.ford.com (Ken Fox) writes:
[...]
) I think we can both agree that xsubpp and the
) typemaps should be expanded to make more things simple.

What I'd really like right now is something that takes a
C declaration of a struct and turns it into two XS-coded
subroutines:

    set_structname( $packed_struct, { FieldName1=>$value1, [...] } );

    ( $value1, $value2, [...] )= get_structname( $packed_struct,
	[ qw(FieldName1 FieldName2 [...]) ] );

    $hashref= get_structname( $packed_struct );
    $value1= $hashref{FieldName1};

Where the power of typemap determines the code for translating
between Perl's $value1 and C's (structname *)p->FieldName1.

Or, at least, a new XS syntax:

	STRUCT=structname
		char *	FieldOne
		int  	FieldTwo
		char	FieldThree[64]

that produces those routines.  Perhaps as I code a few of these
by hand I'll figure out better how to automate the process.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Wed, 08 Apr 1998 11:06:58 -0600
From: grindrod@tfn.com
Subject: adding passwords accross multiple serveers
Message-Id: <6gg7b1$8gu$1@nnrp1.dejanews.com>

Before I reinvent the wheel, has anyone made a program that can can add a
logon and password to a server and then add it to a specified group of servers
on the same network. I have 10 servers that all need large ranges of logons
added. i.e. 100 new logons for each machine, each servers logons need to be
identicle. I am running SCO Unix perl 5.004. also these systems don't allow
rlogins as root.

Any Ideas or something close let drop me mail @ grindrod@tfn.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 08 Apr 1998 11:10:23 -0600
From: ahayes@ingenia.com
Subject: Re: CGI.pm passing variables into param?
Message-Id: <6gg7hp$8re$1@nnrp1.dejanews.com>

In article <slrn6ilmq1.b65.jgloudon@manitoba.bbn.com>, jgloudon@bbn.com wrote:

> ahayes@ingenia.com <ahayes@ingenia.com> wrote:
> >Hi. I'm trying to get someone elses old script to make use of CGI.pm

> Have you read the documentation within the module ?
> try 'perldoc CGI.pm'. It contains examples like this.

Hi Jason.

Thanks for the suggestion. Believe me, I've read all the docs I can find
(including the documentation within the module) and I'm pretty sure I know
how it should work. I have also converted numerous scripts to CGI.pm and
have not run into this problem before.

Basically, the only difference that I can see is that in the script I'm
currently working on, the "$query->param($qn)" assignment happens within
a for loop with the value of "$qn" changing according to
"$qn = 'query' . $zx;" where "$zx" is the incrementing for loop value.

Have you (or does anyone have) an example similar to what I've described that
works? Could it be a problem with the types of values or the way in which I'm
calling the "param" method?

Anyone care for a look at the code in question?

--
Amos Hayes
ahayes@ingenia.com

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Wed, 08 Apr 1998 16:13:25 -0400
From: Koji Kiyokawa <TheSage@uk2.so-net.com>
Subject: content of file handle
Message-Id: <352BDA65.299B@uk2.so-net.com>

Hello,

Does anyone know if there is a way to print where a file
handle is pointing to? For example, if I had the code:

open(COM,"ps -ef &");

How can I print out "ps -ef &"??
(Apart from storing it in a string first like
$command="ps -ef &";
print $command;

Do I look inside the symbol table, and in that case,
how?

Many thanks!


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

Date: Wed, 8 Apr 1998 08:35:42 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Justin Wills <justin@nectar.com.au>
Subject: Re: fork() and exec() example needed please...
Message-Id: <Pine.GSO.3.96.980408081845.20192F-100000@user2.teleport.com>

On Wed, 8 Apr 1998, Justin Wills wrote:

> never do it like that, what if the fork fails ???
> 
> do something like this

> if($pid=fork())
> {
>     exec($c);
> }
> wait;

Never do it like that; what if the fork fails! :-)  (You didn't check for
a failed fork after all!) 

Fork can fail at any time, since your system may run out of slots in the
process table (or whatever). It's always a good idea to check for the
return value being undef, maybe something like this.

    sub safe_fork {
	# forks and traps fork errors. Returns 0 to child process,
	# child's pid to parent process. May die if fork repeatedly
	# fails.
	my($tries, $pid);
	{		# naked block
	    return $pid if defined $pid = fork;
	    if (++$tries > 5) {
		# fork is always failing...
		die "$tries repeated fork failures: $!";
	    } else {
		sleep 3;
		redo;	# retries the naked block
	    }
	}
    }

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



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

Date: Wed, 08 Apr 1998 11:15:28 -0400
From: Venkatesh <venky@clam.com>
Subject: HELP .. return true value
Message-Id: <352B9490.49C6@clam.com>

hi,

  I have a function compute_method that does some calculation and 
returns a string $computed_list .
This function resides in "x.pl" along with a list of supporting
functions.
When I try to do a 

require "x.pl"  in another file y.pl, I get this error

'x.pl did not return a true value at y.pl line 5' 

Line 5 is the line where the require statement is.

If I tried writing a small calling function within x.pl and call
the same function, it works fine. 

Would appreciate help in fixing the problem

thanks,

venky


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

Date: Wed, 8 Apr 1998 16:32:30 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: HELP .. return true value
Message-Id: <352BA69E.16AB@world.northgrum.com>

Venkatesh wrote:
> 
 
>   I have a function compute_method that does some calculation and
> returns a string $computed_list .
> This function resides in "x.pl" along with a list of supporting
> functions.
> When I try to do a
> 
> require "x.pl"  in another file y.pl, I get this error
> 
> 'x.pl did not return a true value at y.pl line 5'
> 
> Line 5 is the line where the require statement is.

The perlfunc man page says about 'require':

"The file must return TRUE as the last statement to indicate successful
execution of any initialization code, so it's customary to end such a
file with ``1;'' unless you're sure it'll return TRUE otherwise. But
it's better just to put the `` 1;'', in case you add more statements."

So, after the last sub definition in x.pl, type

1;

-- 
Charles G. Margolin                   DSSD Internal Information Services
cmargoli@world.northgrum.com          Northrop Grumman Corp. 0624/23
margolin@acm.org                      Hawthorne, California 90250-3277


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

Date: Wed, 08 Apr 1998 12:40:13 -0400
From: Frank Cortez <cortez@tfn.com>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Is it just me?  (error/bug? with "my")
Message-Id: <352BA86D.29CA@tfn.com>

Tom:

Thanks for your reply.  I kid you NOT-- I checked the args before
the subroutine in question was called; they *were* correct (and
had valid values -- and I'm keen to the notion of lexicals and
scoping-- I was looking *within* said routine's scope), but for
some reason "my" variables declared for them didn't get the
values (and, as you mentioned, it *should* have worked assuming
the correct values were fed in).  This has actually happened on
more than one occasion and in other code (most of which I've
pulled out of books).  I discovered that this problem sometimes
"goes away" if I reboot my machine.

Could this somehow be related to a memory leak issue with a beta
version of Apache I'm running?  I'd assumed that a (potential)
memory leak in Apache wouldn't affect other processes, particularly
since I've been running test programs stand-alone (but then again,
this *IS* Windoze...).

Well, that can remain as a rhetorical question for now (unless
someone else has experienced it and knows of a fix!); I seem to
have everything working again.  I'll speak up if I find
something more substancial and repeatable.

Thanks again for your help.

Tom Phoenix wrote:
> 
> On Tue, 7 Apr 1998, Frank Cortez wrote:
> 
> > Any code that uses variables created using "my" will act as if these
> > variables are undefined.
> 
> my() creates brand-spanking-new variables, so yes, they are undefined
> scalars or empty arrays upon creation. Just as with any other variables.
> Of course, you may set a my variable at the same time you create it, too.
> 
> > I've even tried resetting them myself within subroutines to what they're
> > supposed to be, only to discover that my explicit declarations are
> > *ignored*.
> 
> Naaah. You're just not looking in the right place. For example, are you
> perhaps looking for a my() variable outside of its scope?
> 
> > #> $Loc and $SessId are set before this point (I checked
> > #> at this line before calling the routine!)
> >
> > ShowLoc($SessId, $Loc);
> >
> > # (intermediate code omitted)
> >
> > #> routine definition
> > sub ShowLoc  {
> >
> >     my ($ID, $URL) = @_;
> 
> Okay, $ID is set to the first parameter, $URL is the second.
> 
> >     my %SessionValues, @matches;
> 
> Danger! That makes only one my() variable. Did you forget the parens?
> 
> > #> my $ID and $URL are undefined!
> 
> Maybe, if the caller didn't pass defined values. But, if you passed
> defined values, they will have defined values. I promise! If you can make
> a small program which disproves this, you may have found a bug in (your
> copy of) perl. But that's so big of a bug, I'd be very surprised.
> 
> Hope this helps!
> 
> --
> Tom Phoenix       Perl Training and Hacking       Esperanto
> Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: 8 Apr 1998 09:59:30 -0500
From: tye@fiinix.metronet.com (Tye McQueen)
Subject: Re: Need help with "shared memory" module IPC::Shareable !
Message-Id: <6gg3ci$q81@fiinix.metronet.com>

Benjamin Sugars <bsugars@canoe.ca> writes:
) 
) I have often wondered myself what the proper behaviour of tie modules
) should be.  I mean, in normal Perl you expect a statement like
)     $a = 1;
) to Just Work.  But for a tied $a there's potentially lots of reasons
) why
)     $a = 1;
) might not work.  What is the module to do?


    if(  ! defined( $a= 1 )  ) {
	warn "Couldn't set \$a to 1: $!\n";
    }

That is, the value of the assignment operation is the return value
from the STORE subroutine so assignment to a tied entity can return
C<undef> for failure.  Then you need an "out of band" method for
returning the reason for the failure.  For some modules, $! can be
used.  For Tie::Registry, I use $^E.  For others you may need a
method that returns the reason for the last failure.

But your question got me thinking that this doesn't help when the
module user doesn't bother to check the return value.  Then I
realized that I could write modules that automatically work both
ways:

    sub STORE {
	[...]
	if(  $failed  ) {
	    if(  ! defined(wantarray)  ) {
		croak "Can't assign new value: $reason";
	    }
	    $self->SaveFailure($reason);
	    return undef;
	}
    }

So

    $a= 1;

would croak on failure but:

    if(  ! defined( $a= 1 )  ) {
    }

would not croak.

Cool!
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Wed, 08 Apr 1998 17:39:01 +0200
From: Philippe Oesch <oesch@bluewin.ch>
Subject: Re: NT: pass STDOUT to a child program?
Message-Id: <352B9A15.53605967@bluewin.ch>

sorry no solution but a similar (meanwhile a lot simpler) problem:
how can you pipe the output of a perlscript into another programm off
the commandline? with nt the ">" and "|" operators do not seem to work
appropriate...

Victoria and Hsiwei Yu (Michael) wrote:
> 
> Hi,
> 
> Need to write CGI Perl calling another program, say SAS, on NT, but how can
> I let the child program know the STDOUT?
> 
> On UNIX, I used
> system( .. );
> then the child program automatically inherits STDOUT from parent. So the
> child program writes to web page OK just as the parent Perl can.
> 
> What's the corresponding rule for NT? How to refer to that parent's STDOUT?
> Or
> print "..."; # that place the parent Perl knows, but the child program
> doesn't know???
> 
> Thanks in advance,
> 
> Michael

-- 
Philippe Oesch, Dipl. Ing. ETH
PGP fingerprint:
oesch@bluewin.ch   AE50 1CE7 FE17 CEF6 D000  387E 6BC9 0549 6F29 3ADC


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

Date: 08 Apr 1998 08:54:49 -0700
From: Randal Schwartz <merlyn@stonehenge.com>
To: Gellyfish@btinternet.com
Subject: Re: Packing?
Message-Id: <8cu384b96e.fsf@gadget.cscaper.com>

>>>>> "Jonathan" == Jonathan Stowe <Gellyfish@btinternet.com> writes:

Jonathan> $newip = join "",map sprintf ("%03d",$_), split '\.',$ip;

Jonathan> or any of their increasingly obfuscated brothers and sisters if you
Jonathan> want a unique twelve character filename for each IP number. ;-}

Or, to get it into a more compact interesting form:

	$filename = unpack "H*", pack "C4", split /\./, $ip;

which converts the IP addr into a nice unique 8-char hex string.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)
## legal fund: $20,990.69 collected, $186,159.85 spent; just 146 more days
## before I go to *prison* for 90 days; email fund@stonehenge.com for details

-- 
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: Wed, 08 Apr 1998 11:10:14 -0400
From: William McKinnon <wmckinn@newbridge.com>
Subject: Perl scripts not working with Netscape 3.0 on MacIntosh
Message-Id: <352B9356.22F57A0C@newbridge.com>

Hi there, I've developed some perl scripts that run on a unix machine's
web server, but when the scripts are accessed using Netscape 3.0 on a
MacIntosh the scripts do not work (they work elsewhere).  The scripts do
work with Netscape 2.0 on the Mac  and simple scripts do seem to work
fine.   Any suggestions on what may be causing the problems?

Bill




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

Date: Wed, 8 Apr 1998 09:19:31 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Michele Beltrame <mick@io.com>
Subject: Re: pidof
Message-Id: <Pine.GSO.3.96.980408091342.20192J-100000@user2.teleport.com>

On 8 Apr 1998, Michele Beltrame wrote:

> Is there a Perl function which allows to know the pid of a process matching
> a certain name? Something like the "pidof" unix command.

Nope. But if your system has a pidof command (or another command that
might help, like ps) you could call that from Perl. Hope this helps!

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



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

Date: Wed, 08 Apr 1998 16:07:55 +0100
From: Iqbal <um@say.what>
Subject: Re: running `ls $file` on a nt workstation in a search script problem?
Message-Id: <352B92CB.601D98A7@say.what>

tim pickup wrote:
> 
> I have to implement a standard search script on a nt workstation and
> am
> using  a version of Matts search script. The script runs ok but
> returns no
> hits. The problem is that no files are gathered to search through.
> 
> the relevent bits of code are
> 
> ....
> $basedir = "C:/inetpub/wwwroot/pages/";
> @files = ('*.htm','*/*.htm');
> ....
> 
> sub get_files {
>         chdir($basedir);
>         foreach $file (@files) {
>                 $ls = `ls $file`;
>                 @ls = split(/\s+/,$ls);
>                 foreach $temp_file (@ls) {
>                         print $temp_file;
> #===============this prints out nothing on execution==========
>                                 if (-d $file) {
>                                 $filename = "$file$temp_file";
>                                 if (-T $filename) {
>                                 push(@FILES,$filename);
>                                 }
>                         }
>                         elsif (-T $temp_file) {
>                                 push(@FILES,$temp_file);
>                         }
>                 }
>         }
> }
> 
> the key line is                 $ls = `ls $file`;
> What exactly does this line do. I figure it is saying something like
> get a
> list of all files that are of the type <*/*.htm> for example.
> If so then it isn't getting hold of any files.
> 
> Have tried several variations on the $basedir but i don't think this
> is the
> problem.
> Have run the script fine on other servers. This leads me to believe
> that it
> isn't the code at fault, but rather the implementation of this file
> gathering technique on the nt workstation.
> 
> The perl interpreter is version 5.004.. downloaded from perl.com
> 
> Thanks
> 
> tim

Not sure, but does ls even work on NT, write a quick one liner, or try
it from the command line, but I dont think it gives directory listing. I
could be completely wrong but...

Iqbal


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

Date: 8 Apr 1998 15:23:00 GMT
From: "WS010" <WS010@dvvlap.be>
Subject: Re: running `ls $file` on a nt workstation in a search script problem?
Message-Id: <01bd6303$1a456890$8c7479c1@dvvbeint0ws010>

Tim,
script on a nt workstation? 

> 		$ls = `ls $file`;  
try:                    $ls = `dir $file`; 

but unfortunately, the output is different, you would have
to parse the output differently, so the subsequent split /\s+/
won't work. The opendir call is a fine alternative (perlfunc).

Jos Snellings (Jos.Snellings@1cd4u.com)



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

Date: 8 Apr 1998 08:02:12 -0700
From: smitty77@pacbell.net
Subject: Re: running `ls $file` on a nt workstation in a search script problem?
Message-Id: <6gg3hk$jcn@co-op.newsguy.com>

In article <352b60ce.5413851@news.easynet.co.uk>, tim@interactive1.easynet.co.uk
says...
>
>I have to implement a standard search script on a nt workstation and
>am
>using  a version of Matts search script. The script runs ok but
>returns no
>hits. The problem is that no files are gathered to search through.
>
>the relevent bits of code are
>
>....
>$basedir = "C:/inetpub/wwwroot/pages/";
>@files = ('*.htm','*/*.htm'); 
>....
>
>sub get_files {   
>	chdir($basedir);
>   	foreach $file (@files) {      
>		$ls = `ls $file`;      
>		@ls = split(/\s+/,$ls);
>      		foreach $temp_file (@ls) { 
>			print $temp_file;
>#===============this prints out nothing on execution==========
>        			if (-d $file) {        
>    				$filename = "$file$temp_file";
>            			if (-T $filename) {   
>            			push(@FILES,$filename);
>            			}   
>      			}         
>			elsif (-T $temp_file) {
>            			push(@FILES,$temp_file);  
>       			}     
> 		} 
>  	}
>}
>
>
>the key line is 		$ls = `ls $file`;      
>What exactly does this line do. I figure it is saying something like
>get a
>list of all files that are of the type <*/*.htm> for example.
>If so then it isn't getting hold of any files.

'ls' is a UNIX command to do a directory listing.  Since you're using NT, maybe
you could try
		$dir = `dir $file`;

I would think you'd have to use your native operating system commands when you
backquote or use 'system' or 'exec'.  If I'm wrong, I';m sure someone will
correct me in the nicest possible way.

Dave



>Have tried several variations on the $basedir but i don't think this
>is the
>problem.
>Have run the script fine on other servers. This leads me to believe
>that it
>isn't the code at fault, but rather the implementation of this file
>gathering technique on the nt workstation.
>
>The perl interpreter is version 5.004.. downloaded from perl.com 
>
>Thanks
>
>tim
>
>
>
>


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

Date: Wed,  8 Apr 1998 11:33:53 EDT
From: dblack@saturn.superlink.net (David A. Black)
Subject: Re: serpinski gasket almost-1-liner needs polishing
Message-Id: <6gg5d1$nth$1@earth.superlink.net>

Hello -

root@compstat.wharton.upenn.edu (Jack Siler) writes:

>Inspired by J. Reed's article in TPJ on L-Systems I used substitution
>to produce a Serpinski gasket fractal.  I was unhappy about putting the
>substitutions inside functions but since substitutions return
>number-of-subs instead of the string I couldn't figure out how to put
>the subs in the print line (like I did for the appending) nor how to
>make the functions less clunky.  Comments appreciated.

>$x="*";$y=" ";$s=$x;$reps=16;
>sub D {($t) = @_; $t =~ s/./$&$&/g;$t}
>sub C {($t) = @_; $t =~ s/../(($& eq $y.$y)||($& eq $x.$x))?$y:$x/ge;$t}
>for ($i=1;$i<$reps;$i++) {
>  print ' ' x ($reps-$i),(join ' ',split //,$s=&C($y.&D($s).$y)),"\n"
>}

Well, there's probably a way to get it more streamlined than this,
but here's a one-line-ish version (i.e., not one line, exactly, but
perhaps going in the direction you're looking for):

candle:~/hacking/perl$ perl -e '
> print do{$reps=shift;$s=$x="*";$y=" ";
>         map{" "x($reps-$_),(join " ",split //,
>         $s=&{sub{$_[0]=~s/(.)(.)/($1 eq $2)?$y:$x/ge;$_[0]}}
>         ($y.do{$s=~s/(.)/$1$1/g;$s}.$y)),"\n"}(1..$reps-1);
> }' 16
               * *
              *   *
             * * * *
            *       *
           * *     * *
          *   *   *   *
         * * * * * * * *
        *               *
       * *             * *
      *   *           *   *
     * * * *         * * * *
    *       *       *       *
   * *     * *     * *     * *
  *   *   *   *   *   *   *   *
 * * * * * * * * * * * * * * * *


David Black
dblack@saturn.superlink.net


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

Date: Wed, 08 Apr 1998 15:45:06 GMT
From: jgloudon@manitoba.bbn.com (Jason Gloudon)
Subject: Re: setUID script
Message-Id: <slrn6in6n0.gk4.jgloudon@manitoba.bbn.com>

Bart Lateur <bart.mediamind@tornado.be> wrote:
 .
 .
>Ah. I ment "what am I to do with $< and $>". For instance, what is this
>for? (in a child fork)
>
>	$< = $>;
>
>Is this for the child process to abandon it's privileges, and continue
>running as "nobody"? And what could this possibly be used for?
>
>	($<,$>) = ($>,$<);	 #swap real and effective UID

If you are running a script owned by the original user (that you didn't trust)
you wouldn't want to give it root privileges would you ?

Or if you wanted to access a file with the original user's privileges.

-- 
Jason Gloudon


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

Date: Wed, 8 Apr 1998 08:56:19 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Eugene Sotirescu <eugene@vertical.net>
Subject: Re: setUID script
Message-Id: <Pine.GSO.3.96.980408084855.20192G-100000@user2.teleport.com>

On Tue, 7 Apr 1998, Eugene Sotirescu wrote:

> ##flock operation param
> $LOCK_EX = 2;

You should really get this from a module; there's no certainty that this
value will be 2 on J. Random Unix.

> &ReadParse(*form_data);

This is a good place for a module, too.

> $text = $form_data{'text'};
> print "User input is: $text\n";  #just to check what's going on
> 
> ##untaint user input to please Perl
> ##any pattern match will untaint the variable, but it is hoped
> ##the pattern match is going to be something intelligent that would
> ##filter out dangerous characters
> $text = $1 if ( $text =~ /^([\w.]+)$/ );

Note that, if the pattern failed, $text is still set (and tainted, in a
set-id or -T script). Perl's taint checks are useful, but you can still do
a few unsafe things with tainted data. Better, IMHO, is something like
this:

    ($text) = $text =~ /(whatever)/;

Now, $text is either a match or undef, and it's easy to check for undef.

Hope this helps!

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



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

Date: Wed, 8 Apr 1998 09:06:22 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Bart Lateur <bart.mediamind@tornado.be>
Subject: Re: setUID script
Message-Id: <Pine.GSO.3.96.980408085900.20192H-100000@user2.teleport.com>

On Wed, 8 Apr 1998, Bart Lateur wrote:

> Are you saying that I'm too paranoid? 

There is no such thing as "too paranoid". :-)  (And some of what I say
below may not apply on your system, so don't trust me, either! :-)

> what is this for? (in a child fork) 
> 
> 	$< = $>;

Sets the uid to be the euid. That is, if your script is being run by
barney, but it's set-uid to fred, now it should be acting as if fred
started it directly, mostly.

> Is this for the child process to abandon it's privileges, and continue
> running as "nobody"? 

You could do that kind of thing. You should know, though, that on some
systems, "nobody" is not allowed to change uid, even when set-uid to
root(!). Also, if I'm intending to give up privs, I check the magical
variables after the assignment, to see that the change "stuck".

> And what could this possibly be used for?
> 
> 	($<,$>) = ($>,$<);	 #swap real and effective UID

Temporarily assume the user's id, for creating files (say). Then you may
change back later.

Hope this helps!

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



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

Date: Wed, 08 Apr 1998 15:08:21 +0200
From: Denis DORR <dorr@cetrel.lu>
Subject: Re: Simple Unix Question,  ( Simple for you maybe )
Message-Id: <352B76C5.507E8359@cetrel.lu>



Tad McClellan wrote:

> ...


Nice shot.

That's the kind of answer I like.



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

Date: Wed, 08 Apr 1998 08:19:03 -0700
From: rtanner@linfield.edu (Rob Tanner)
Subject: Re: Simple Unix Question,  ( Simple for you maybe )
Message-Id: <rtanner-0804980819030001@wildflower.linfield.edu>

In article <kfreg6.gl.ln@localhost>, tadmc@flash.net (Tad McClellan) wrote:

> Namsuk Kim (a-namsuk@microsoft.com) wrote:
> : Try @variable = `ls -l`
> 
> : I think this is what you meant.
> 
> 
> Why do you think that?
> 
> 
> : Tad McClellan wrote in message ...
> : >UNIXstuff (unixstuff@aol.com) wrote:
> : >
> : >: From with a perl script.
> : >: I want to run the UNIX command ls -l
> : >: and have the info/string stored in a variable.
>                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> 
> : >   $my_variable = `ls -l`;
> 
> That looks like a string stored in a variable to me.
> 

`ls -l` is back-ticked.  That means perl should execute the command "ls
-l", the output of which is multiple lines and so is a list.

The sequence $my_variable = `ls -l` will yield the count of returned lines
in the variable $my_variable.

The sequence @my_variable = `ls -l` will yield the output the the "ls"
command in the array @my_variable.

As you can see, there is a major difference there.

      _ _ _ _           _    _ _ _ _ _    
     /\_\_\_\_\        /\_\ /\_\_\_\_\_\  
    /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
   /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
  /\/_/_/_/_/ /\_\  /\/_/    /\/_/             
 /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
 \/_/  \/_/  \/_/_/_/_/     \/_/              sounds profound)

 Rob Tanner
 Manager of Systems and Communications
 Linfield College, McMinnville, OR
 (503) 434-2558 <rtanner@linfield.edu> _____________________________________________________________________


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

Date: 08 Apr 1998 12:40:53 -0400
From: Uri Guttman <uri@sysarch.com>
To: rtanner@linfield.edu (Rob Tanner)
Subject: Re: Simple Unix Question,  ( Simple for you maybe )
Message-Id: <x7k990jmga.fsf@sysarch.com>

>>>>> "RT" == Rob Tanner <rtanner@linfield.edu> writes:

  >> : > $my_variable = `ls -l`;
  >> 
  >> That looks like a string stored in a variable to me.
  >> 

  RT> `ls -l` is back-ticked.  That means perl should execute the
  RT> command "ls -l", the output of which is multiple lines and so is a
  RT> list.

no it is the output of ls -l. the list part is determined by the
context. backticks does nothing to the output of its command.

  RT> The sequence $my_variable = `ls -l` will yield the count of
  RT> returned lines in the variable $my_variable.

where did you get this false information? camel2 says the correct thing
on page 52. you always get the full output of backticks. in a list
context a split is done (preserving the newlines) and one list of lines
is returned.

  RT> The sequence @my_variable = `ls -l` will yield the output the the
  RT> "ls" command in the array @my_variable.

  RT> As you can see, there is a major difference there.

wrongo my little buddy. the only difference is the line split to the list.


uri, who has been lurking out there!


-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----  8 Years of Perl Experience, Available Immediately
uri@sysarch.com  ---------  Resume and Perl Example at http://www.sysarch.com
Use the Best Search Engine on the Net  --------  http://www.northernlight.com


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

Date: 8 Apr 1998 15:19:57 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Tail-like functionality
Message-Id: <6gg4it$5u5$1@lyra.csx.cam.ac.uk>

In article <6gg1eg$201$1@info.uah.edu>, Greg Bacon <gbacon@cs.uah.edu> wrote:
>perlfaq5.pod:=head2 How do I do a C<tail -f> in perl?
>
>Read (at least) section five of the fine Perl FAQ.

That may be a good thing to do for other reasons, but it has no bearing
on the question asked.    The problems raised by "tail -f" are
quite different from and more complicated than those of a simple "tail".

Just use the technique Andrew Langmead suggests.


Mike Guy


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

Date: Wed, 08 Apr 1998 16:16:08 +0100
From: Iqbal <um@say.what>
Subject: Re: Timeout script
Message-Id: <352B94B8.C8C68449@say.what>

Philippe de Rochambeau wrote:
> 
> I am currently looking for a way to log off somebody from a restricted-access
> server after a few minutes. For instance, once the user has typed in his user
> id and password, a Perl script should let him browse through the website's
> pages for a total of 3 minutes, after which the script should disconnect him.
> 
> Any suggestions on how to write such a timeout script?
> 
> I guess I should spawn some sort of process which would automatically
> disconnect the user after a short while. However, I am not sure how to write a
> Perl script that spawns such a process.
> 
> Philippe de Rochambeau
> 
> P.S. I plan to run this script with MacPerl first, then on a Unix machine.

Well one way would be to create a frame site, when he enters his
user/pass they goto another frame, which just reloads after 3 mins. This
is probably, in fact i know its not a nice way of doing it, but its
cheap and nasty.

Iqbal


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

Date: Wed, 8 Apr 1998 09:13:12 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Philippe de Rochambeau <pr1@club-internet.fr>
Subject: Re: Timeout script
Message-Id: <Pine.GSO.3.96.980408090739.20192I-100000@user2.teleport.com>

On Wed, 8 Apr 1998, Philippe de Rochambeau wrote:

> I am currently looking for a way to log off somebody from a
> restricted-access server after a few minutes.

Typically, I'd do this by having a "watchdog" program running at low
priority. When it sees that fred has overstayed his welcome, it would
notify the server (or whatever). Of course, there's nothing Perl-specific
about this; it could be written in any language. If you need help knowing
how to interface this program to a particular server, check that server's
docs or newsgroups. Hope this helps! 

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



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

Date: 8 Apr 1998 11:23:44 -0500
From: tye@fiinix.metronet.com (Tye McQueen)
Subject: Re: Tying a blessed hash (was: Re: Tie/bless vs. bless/tie and segmentation fault)
Message-Id: <6gg8ag$gf1@fiinix.metronet.com>

lehman@visi.com (Todd Lehman) writes:
) 
) Well I'll be a monkey's uncle.  It -is- possible after all to tie a blessed
) hash with a single-class implementation.  And the solution is fast and clean
) -- and no crashing perl either.  :-)
[...]
) new() creates a dummy hash which is never really used.  TIEHASH() creates
) the real guts for the object -- the hash which contains "public" data (the
) stuff you get at by overloading the hash indexing syntax) and "private" data
) (the stuff that only the object itself is supposed to see).
[...]
) Has this all been done before a million times?  I've had a few looks around
) and maybe I just don't know the right keywords for searches...

Eventually this needs to end up in perlbot.pod or something similar.
I did something similar but "backward" in one respect to your approach:
my new() creates a real object while TIEHASH() creates a dummy that
just gives you easier access to the real object.

One person wrote me that they tried something similar but it
stopped working in Perl5.004_5x or Perl5.004_6x.

So I suspect that a lot of this has been going on.

I've also been kicking around in the back of my mind that
something similar to what you did would be useful for writing
large OO projects in Perl.  Specifically, acces your object-local
data (aka members) the "standard" way via C<$self->{MEMBER_NAME}>
but have the %$self internal hash tied to a package that turns
"MEMBER_NAME" into "Package::MEMBER_NAME" but with support for
member inheritance via @ISA.  (I hope Abigail is reading this.)

I don't have a need for it and I would need to seriously study
the nuances of @ISA inheritance of methods before I tried to start
writing it.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Wed, 08 Apr 1998 11:16:07 -0500
From: "Keith G. Murphy" <keithmur@mindspring.com>
Subject: Re: Urgent: Perl Win32 vs Unix Perl
Message-Id: <352BA2C6.92A0D7BC@mindspring.com>

Let's turn the question around.  What web server are they running on
Unix?  Because, if it's Apache, that has FrontPage extensions available,
and they appear to work fine (in fact, the registration WebBot works
under Apache, not under IIS).  Maybe you could just do the whole thing
on the Unix machine!

J. Probert wrote:
> 
> Hello all,
> 
> I have a situation in which I need to make a decision urgently, and
> any guidance will be much appreciated.
> 
> I am setting up a commercial website using Frontpage extensions, and
> Perl for the cgi's. Everything is set up and running beautifully on my
> personal Win95 pc, with Perl for Win32 and Isapi installed. My version
> is
> version 5.003_07, build 313.
> 
> The service provider who quoted on the hosting of this site is busy
> preparing their side for the upload, and have informed me that all the
> Perl scripts will be placed on their Unix machine, the rest of the
> Frontpage stuff will be on an NT machine.
> Their reason is that Perl Win32 is "buggy, and more than capable of
> causing NT to crash, and Perl is more stable on Unix", and they are
> not prepared to put their other clients hosted on that NT machine at
> risk.
> 
> Now I know that Perl was born on Unix, and logic says it probably is
> more stable on it, but the scripts I intend running are
> straightforward pattern-matching searchscripts, and any machine with a
> fast processor and lots of RAM should cope easily.
> 
> Separating the cgi's from frontpage is going to cause me extra
> trouble, the HTML ACTION tags all have to be changed, the scripts all
> need the #!path to perl added to the first line etc., and all the
> paths to files that the scripts are to open and read from etc. need to
> change.
> 
> So, to get to my question(s):
> 
> How bad is Perl on NT, is the service provider being reasonable -- or
> should I insist they run Perl on NT just for me - on a seperate server
> if they have to. They knew right from the start of my enquiry with
> them that I wanted Frontpage and Perl -- they never once indicated
> that the two were "incompatible".
> 
> Perhaps someone from ActiveWare can comment on this "incompatibility".
> And maybe someone knows some more implications of separating Frontpage
> and Perl CGI, just so I can get some idea of what I'm in for.
> 
> My apologies  for taking so long to get to the point, and my thanks
> for your time and comment.
> 
> P.S. The site (not up yet) will be at
> http://www.sabtin.co.za
> 
> Justin Probert [South Africa]


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

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

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