[7844] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1469 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 14 05:07:33 1997

Date: Sun, 14 Dec 97 02:00:29 -0800
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, 14 Dec 1997     Volume: 8 Number: 1469

Today's topics:
     @a = m// bug in 5.004_04? (David M. Jones)
     Re: A sort list problem ... (brian d foy)
     Re: A sort list problem ... <rjk@coos.dartmouth.edu>
     Another Sort problem, this time with numbers (Tiwason)
     Re: Another Sort problem, this time with numbers (John Moreno)
     Re: Another Sort problem, this time with numbers <mcohen@netaxs.com>
     Re: Are locals automatically initialized ? <rjk@coos.dartmouth.edu>
     delete files in perl <kelly_horst@hotmail.com>
     Re: delete files in perl (Tushar Samant)
     Re: getting list of directories, returned as an array <rjk@coos.dartmouth.edu>
     Re: is there anyway around this ssi problem with "query <kgraham@alpha.furman.edu>
     Re: need to know what browser the client is using <Curmudgeon@mbcf.org>
     Re: newbie: compact an array (Abigail)
     Re: Part of a line <Curmudgeon@mbcf.org>
     Re: perl program very slow <dformosa@st.nepean.uws.edu.au>
     prevent download of images psyclone@twd.net
     Problem: My mailbot dropping lines (Grey Cloak)
     Re: Restricting CGI Programs to Perl. (Jake Burns)
     Re: Shoving an array into a glob? or fixing IO::ScalarA (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Useful posts from Nathan Stanford (Massimo Ferrario)
     Re: what does qq() do? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Re: Which language pays most 17457 -- C++ vs. Java? <gschwarz@netup.cl>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 13 Dec 1997 21:35:12 -0500
From: dmjones@theory.lcs.mit.edu (David M. Jones)
Subject: @a = m// bug in 5.004_04?
Message-Id: <s3p90toejof.fsf@sandpiper.lcs.mit.edu>

This script

    #!/usr/local/bin/perl
    
    print "This is perl v$]\n";
    
    if (@a = "a" =~ /b/) {
        print "TRUE\n";
    } else {
        print "FALSE\n";
    }
    
    print "\$#a = $#a\n";

produces the following

    This is perl v5.00404
    TRUE
    $#a = 0

According to Devel::Peek, @a is set to ("") rather than (), as I would
expect, and as an old version of perl4 does.  Is this a known bug, or
am I the only person daft enough to evaluate a match in list context
without putting any backreferences in the pattern?

On a related matter, can anyone explain why s/// doesn't return an
array of matched subpatterns in list context?  I need to save all the
substrings produced by a match without knowing the pattern in advance,
and between m//'s misbehaviour above and s///'s refusal to cooperate
with list context, I'm not enjoying the experience.  :-)

David M. Jones               "If you must do this damn silly thing,
dmjones@theory.lcs.mit.edu    don't do it this damn silly way."


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

Date: Sat, 13 Dec 1997 21:01:40 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: A sort list problem ...
Message-Id: <66ve96$7nk@bgtnsc02.worldnet.att.net>

In article <66ppbu$dft@news2.snet.net>, "Kilrogg2_GS"
<kilrogg2@mindless.com> wrote:

> Here is my problem, i want to reorder a list of word in the
> alphabetical order.
> I tried the script below but it doesn't work at all !
> 
> @list = ('HeLlo','how','arE','yOU','Today');
> @list = sort @list;
> 
> Instead it gives the result : ('HeLlo','Today','arE','how','yOU')

does this mean that you want it done without regard to case?  you could
do something like

   @new_list = sort { lc($a) cmp lc($b) } @list;

for more details on providing your own sort routine to the sort
function, check the Llama book [1].

[1]
Learning Perl
Randal Schwartz and Tom Christiansen
<URL:http://www.oreilly.com>

-- 
brian d foy                                 <http://computerdog.com>
#!/usr/bin/perl
$_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
$pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm


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

Date: Sat, 13 Dec 1997 21:18:54 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Kilrogg2_GS <kilrogg2@mindless.com>
Subject: Re: A sort list problem ...
Message-Id: <3493420E.2885358C@coos.dartmouth.edu>

[posted and e-mailed]

Kilrogg2_GS wrote:
> 
> Here is my problem, i want to reorder a list of word in the
> alphabetical order.
> I tried the script below but it doesn't work at all !
> 
> @list = ('HeLlo','how','arE','yOU','Today');
> @list = sort @list;
> 
> Instead it gives the result : ('HeLlo','Today','arE','how','yOU')
> 
> Does anybody have an idea of what to do here ?

Your script works fine for what you told it to do.  :-)

The default sort function sorts elements in the standard string comparison
order, which means that uppercase letters come before lowercase letters.
What you want to do is a case insensitive sort, which you could do like this:

@list = ('HeLlo','how','arE','yOU','Today');
@list = sort {lc($a) cmp lc($b)} @list;

Chipmunk


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

Date: 14 Dec 1997 06:15:54 GMT
From: tiwason@aol.com (Tiwason)
Subject: Another Sort problem, this time with numbers
Message-Id: <19971214061501.BAA23773@ladder02.news.aol.com>

If i have a bunch of numbers to sort say
5,7,2,1,21,4,11,32

is there anyway to get around them sorting like

1,11,2,21,32,4,5,7

other than having 1/every number then sorting or adding zeros on to the
front...??

Thanks

Tim


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

Date: Sun, 14 Dec 1997 01:50:11 -0500
From: phenix@interpath.com (John Moreno)
Subject: Re: Another Sort problem, this time with numbers
Message-Id: <1d18977.1gv4ht9s9uum0N@roxboro-180.interpath.net>

fTiwason <tiwason@aol.com> wrote:

> If i have a bunch of numbers to sort say
> 5,7,2,1,21,4,11,32
> 
> is there anyway to get around them sorting like
> 
> 1,11,2,21,32,4,5,7

You know, I started to reply to this with a informative answer with a
bit of sample code, then I realized that it's in the manual, not even in
the faq but in the damn manual under the description of sort.  If you've
learned how to use sort then you know how to do this.  I'm not too
familiar with sort and thought you had probably tried the obvious and it
didn't work because perl was treating the elements as strings and they
just needed to be coerced into integers using int, but no that's not the
cause, you haven't read the manual on how to use sort at all.  Look at
the manual and THEN you'll know how to do it.  Hint: it's so
pathetically easy that you'll feel stupid for not knowing how to do it.

-- 
John Moreno


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

Date: Sun, 14 Dec 1997 03:31:33 -0500
From: Martin Cohen <mcohen@netaxs.com>
Subject: Re: Another Sort problem, this time with numbers
Message-Id: <34939965.2A20@netaxs.com>

John Moreno wrote:
> 
> fTiwason <tiwason@aol.com> wrote:
> 
> > If i have a bunch of numbers to sort say
> > 5,7,2,1,21,4,11,32
> >
> > is there anyway to get around them sorting like
> >
> > 1,11,2,21,32,4,5,7
> 
> You know, I started to reply to this with a informative answer with a
> bit of sample code, then I realized that it's in the manual, not even in
> the faq but in the damn manual under the description of sort.  If you've
> learned how to use sort then you know how to do this.  I'm not too
> familiar with sort and thought you had probably tried the obvious and it
> didn't work because perl was treating the elements as strings and they
> just needed to be coerced into integers using int, but no that's not the
> cause, you haven't read the manual on how to use sort at all.  Look at
> the manual and THEN you'll know how to do it.  Hint: it's so
> pathetically easy that you'll feel stupid for not knowing how to do it.
> 
> --
> John Moreno

Seems like a pretty rough answer.  If you sort numerically you get
 1,2,4,5,7,11,21,32 not 1,11,2,21,32,4,5,7
So I guess you have to sort using cmp, but that may not work if the
strings are different lengths.  Please show the code you were going to
post.
-- 
Martin Cohen, 900 Valley Rd #D203, Melrose Park, PA 19027-3228,
mcohen@acm.org


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

Date: Sat, 13 Dec 1997 21:22:58 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: Kilrogg2_GS <kilrogg2@mindless.com>
Subject: Re: Are locals automatically initialized ?
Message-Id: <34934302.9858162F@coos.dartmouth.edu>

[posted and e-mailed]

Kilrogg2_GS wrote:
> 
> Hi !
> 
> I wonder if parmeters declared "local"
> in a function are initialized to a default
> value by the compiler ?
> 
> sub foo { local($var); }

Why not write a bit of code to find out?

sub foo {
  local($var);
  print "\$var is ", (defined($var) ? "defined" : "undefined"), "\n";
}

&foo;


Chipmunk


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

Date: Sat, 13 Dec 1997 19:51:34 -0700
From: Kelly Horstmann <kelly_horst@hotmail.com>
Subject: delete files in perl
Message-Id: <349349B6.2787E4C1@hotmail.com>

I want to write a perl program to delete a specific kind of file, (for
example *.o
 file)in the current directory (say, /usr/bin/perl) and also delete all
the *.o
files in all the subdirectories (eg. /usr/bin/perl/dir1,
/usr/bin/perl/dir2, /usr/perl/dir3 
etc). I have been working on that for couple hours, and I just don't
know how to call perl
to search all the *.o files in all the subdirectories. Just let me know,
if you can
code up this problem.




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

Date: 13 Dec 1997 23:13:42 -0600
From: scribble@tekka.wwa.com (Tushar Samant)
Subject: Re: delete files in perl
Message-Id: <66vpu6$do2@tekka.wwa.com>

kelly_horst@hotmail.com writes:
>I want to write a perl program to delete a specific kind of file, (for
>example *.o file)in the current directory (say, /usr/bin/perl) and also
>delete all the *.o files in all the subdirectories (eg. /usr/bin/perl/dir1,
>/usr/bin/perl/dir2, /usr/perl/dir3  etc). I have been working on that
>for couple hours, and I just don't know how to call perl to search all
>the *.o files in all the subdirectories. Just let me know, if you can
>code up this problem. 

I can't, but Tom Phoenix most definitely can. Have you looked at the
followups to your earlier identical post?



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

Date: Sat, 13 Dec 1997 20:59:57 -0500
From: Chipmunk <rjk@coos.dartmouth.edu>
To: "Joshua J. Kugler" <jkugler@inreach.com>
Subject: Re: getting list of directories, returned as an array
Message-Id: <34933D9C.45A8B54C@coos.dartmouth.edu>

[posted and e-mailed]

Joshua J. Kugler wrote:
> 
> This works:
> 
> find(\&get_dir_list, '.');
> 
> sub get_dir_list {push(@dirlist, $File::Find::name) if -d;}
> 
> And well.  I like it, and probably will use it.

In this one, you're passing a reference to a subroutine to find.


> This doesn't work:
> 
> find({push(@dirlist, $File::Find::name) if -d;}, '.');
> 
> It gives me:
> 
> syntax error at \utah\test.bat line 7, near ") if"
> Execution of \utah\test.bat aborted due to compilation errors.

In this one, you're executing a block of code and passing the result
to find.

Try this instead:

find(sub {push(@dirlist, $File::Find::name) if -d;}, '.');

which passes a reference to an anonymous subroutine to find.

Look at man perlref for more details.

Chipmunk


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

Date: Sun, 14 Dec 1997 00:25:38 -0500
From: Kevin Graham <kgraham@alpha.furman.edu>
To: 283492834 <4823@283423>
Subject: Re: is there anyway around this ssi problem with "query_Strin
Message-Id: <Pine.OSF.3.96.971214002059.19911E-100000@alpha.furman.edu>



> i have an ssi
> <!--#exec cmd="/home/user/go/html/cgi-bin/perl.pl?miscinfo"-->
> 
> if i use QUERY_STRING in the perl script, the query after the ? is
> ignored. 

Your problem is really simple.. First off, you'd need to use #exec
cgi=.. #exec cmd is intended for shell-level commands, and isn't
intended for CGI's. Unfortunately, even still, a SSI will not pass
QUERY_STRING information (or PATH_INFO, for that matter).

There are two ways to get around this, neither being very elegant. The
first is to examine the calling doc and use that data, the other is (in
the case of Apache) to use the XSSI commands which will allow you to
define env variables which would be passed to the CGI..

hope this helps.
 ..kg..



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

Date: Sat, 13 Dec 1997 22:40:01 -0800
From: Curmudgeon <Curmudgeon@mbcf.org>
To: Ricky <ric@megsinet.net>
Subject: Re: need to know what browser the client is using
Message-Id: <34937F41.EB665C68@mbcf.org>

I hate to post about another language here, but why don't you just for
the browser type using JavaScript?  Going to a CGI prog will just slow
the users down and we all know they hate that.

I'm not real good at JavaScript so I'll let you play around with it, but
I do know there is a function called 'navigator.appName' which will
return just that, the browser name.


Here's some JavaScript that I have tested with Netscape 4.03 and IE 3.02

	var browser = navigator.appName;
	if (browser == "Microsoft Internet Explorer") {
	    alert("Browser type is IE" )
	}
	else if (browser == "Netscape") {
	    alert("Browser type is Netscape")
	    var myText = "Netscape"
	}
	else {
	    alert("Browser type is " +browser)
	}


I have not had a chance to write and test any perl programs for this
purpose, but just printing the USER_AGENT gave me the folowing results:

Netscape:

	HTTP_USER_AGENT: Mozilla/4.03 [en] (WinNT; U)

But for IE it was:

	HTTP_USER_AGENT: Mozilla/2.0 (compatible; MSIE 3.02; Update a; Windows
NT) via NetCache version 3.1.1d-Solaris 


Hope this helps solve your problem.

/Curmudgeon


Ricky wrote:
> 
> hey all!  ok, i'm another one of those perl newbies y'all are probably
> sick of but i'm kinda stuck so here's my question.
> 
> there's this page i have.  i rigged it with javascript to open another
> little window on top of it when it loads (onLoad=littlewindow( ) ), but,
> it's a problem with AOL users.  it works fine with netscape and IE, but
> totally screws up on AOL.  so, instead of making a regular <a
> href="blah.html">link</a>, i made this one --->  <a
> href="/cgi-bin/blah.pl">link</a> where blah.pl is a perl script that
> checks the client browser and returns the javascripted page for netscape
> and IE users, or an alternative page for AOL users.  here's my problem.
> i have no idea what "name" for AOL would be in the environment
> variable.  shoot, i don't even know the name for netscape or IE.  how
> can i check for them if i don't know what to check for?  i thought
> netscape's would be Mozilla, but it returns true for IE also, which is
> fine but it also returns true for AOL, which is not fine.  in a
> nutshell, i need to know what name is used for AOL, IE, and Netscape
> that is stored in the HTTP_USER_AGENT environment variable, so i can
> differentiate between the browsers thereby getting the desired result.
> i didn't think i'd need to provide the script, but if you would like to
> see it i'll post it later upon request.  if anyone can help me with
> this, i'd appreciate it immensely.  thanks to all gurus in advance and
> may ye have the happiest of holiday seasons.
> 
> ricky


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

Date: 14 Dec 1997 07:58:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: newbie: compact an array
Message-Id: <slrn6974gs.50c.abigail@betelgeuse.wayne.fnx.com>

Tad McClellan (tadmc@metronet.com) wrote on 1565 September 1993 in
<URL: news:vq7u66.jo.ln@localhost>:
++ Xah (xah@best.com) wrote:
++ : Suppose @a is an array of integers. I want to compact @a, so that elements
++ : that are 0 get deleted. How can I do this without declaring another array @b
++ : such as:
++ 
++ : # compact array
++ : $j=0;
++ : foreach $i (@a) {if ($i) {@b[$j] = $i; $j++;};};
++ 
++ 
++ This does not "declare another array", 
++ though it does (temporarily) build another list:
++ 
++    @a = grep $_ != 0, @a;

This one doesn't use a temporary list, and just one splice:

        for ($i = $j = 0; $j < @a; $i ++ if $a [$i] = $a [$j ++]) {}
        splice @a, $i;


Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Sun, 14 Dec 1997 00:36:36 -0800
From: Curmudgeon <Curmudgeon@mbcf.org>
To: rdeleonx@hotmail.com
Subject: Re: Part of a line
Message-Id: <34939A94.C40261E9@mbcf.org>

Well I suppose it really depends on what you really want to do here.  If
all you looking for is a quick-and-dirty solution then it probably
easiest to use regexes (for more info on regexes type 'man perlre' or go
to http://www.perl.com) like so

	($result) = $line =~ /(Archivo:.*)Guia:/;

But if you really wanted to do something useful with that particular
info (and possibly the others someday) and make your program a little
more robust I would suggest using arrays and hashes like so:

	@Lines = split /<br>/, $line;
	foreach $element (@lines) 
	{
	    ($name, $value) = split /:/, $a;
	    $hash{$name} = $value;
	}

This will give you the ability to reference any of the data later in
your program by just using the following syntax:

	$hash{'Archivo'}; # Where "Archivo" could be any name stored in
			  # the hash

NOTE: Using hashes can cause some confusion if you are not careful and
realize what the outcome could be.  If you read in a new value for one
of the previously defined named pairs the previously defined value will
be over-written.

Hope this helps solve your problem.

/Curmudgeon

rdeleonx@hotmail.com wrote:
> 
> Hi. I was wondering, how do you read a part of a line in a text file?  For
> example, I need to read a line like this:
> 
> <br>Copia:<br>Archivo: EXPAC1-USR<br>Guia: AMENA <br>Version: 03<br>
> 
> What I need to do is read everything between, and including, "Archivo:"
> and the next "<br>" and store it in a scalar.
> 
> Any help would be really appreciated.
> 
> - Rodrigo
> 
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 14 Dec 1997 07:56:53 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: perl program very slow
Message-Id: <882086211.206022@cabal>

In <3.0.3.32.19971212234321.006da7d8@mail.virgin.net> waqar.hafiz@virgin.net (Waqar Hafiz) writes:

>Perl 5.004.003 OS Solaris 2.5.1 HW Sun Ultra 1.
>I've the following program which even for 2 hosts
>is taking between 10-20 secs. Is there any way to
>speed it up?

>use Net::Ping;

>foreach $host (@hosts) {
>	if (pingecho $host) {
>		if (`rsh $host "ps -ax | grep alr"`) {

My bet that most of the time is being taken up doing net access  I dout
there is any perl stuff you can do to speed it up.  My advice would be to
make the script demand driven,  only genrateing the HTML when you need it,
if that is possable.




--
Please excuse my spelling as I suffer from agraphia see the url in my header. 
Never trust a country with more peaple then sheep. I do not reply to mungged 
Support NoCeM http://www.cm.org/                   addresses.  
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Sat, 13 Dec 1997 23:32:22 -0600
From: psyclone@twd.net
Subject: prevent download of images
Message-Id: <882076770.704643078@dejanews.com>

Just a thought. Is it possible to check the HTTP_REFERER variable and use
'expires' and 'pragma: no-cache' headers in a script to block browsers
from saving and image on a web site (either in cache or storing to disk)?
I've played with this a bit (about an hour or so), and it seems that the
browser (Netscape 3.03, in my case) still stores the image in memory
cache. My thoughts were to check the calling page/script via HTTP_REFERER
(which isn't set when the URL to the image is typed in manually) to
prevent the browser from being able to load it outside of an html page
set in the script. Setting 'expires 0' and 'pragma: no-cache' should
force the browser to reload the image on either a "view" or "save"
command, right? How (if possible) would someone stop a browser from
storing an image in memory cache? The script still works fine for
preventing other sites from calling the image. Any comments/ideas are
welcome.

Thanks,

Allen

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: 14 Dec 97 08:13:22 GMT
From: greycloak@greycloak.access.one.net (Grey Cloak)
Subject: Problem: My mailbot dropping lines
Message-Id: <slrn696os2.nc.greycloak@greycloak.access.one.net>

I trying to create a mailbot. Since I lost my old one during an upgrade. 
Not having the address toget it, I decided to write my own. I am hitting
a little snag.

When sending the file requested, it drops lines. Here's the script.

-------------cut---------------
#!/bin/perl -w
#-----------------------------------
# Created December 1997
#
# History:  I had another mailbot script that was lost with a
#           upgrade. Forgetting where I had secured the perl script
#           caused me to write my own version.
#------------------------------------

$sendmail="/usr/sbin/sendmail -oi -t";
$xheaders="X-Mailer: Grey Cloak's Mailbot v0.1\n";
$WhoOwnMe="grycloak\@greycloak.access.one.net";

#--- It should not be nessary to change below

$ETo = "To: $WhoOwnMe";
$ESubject = "Subject: Error Report From GCMailbot\n";


open (OUT, "|$sendmail");

#---- Read the piped email


unless ($ARGV[0]) {
    print OUT "$ETo\n";
    print OUT "$From:\n";
    print OUT "$ESubject";
    print OUT "Invalid file name or file name not given\n";
    print OUT "usage in /etc/aliases: \n\n";
    print OUT "mailaliases: |/path/gcmailbot.pl /path/filename";
    print OUT "\n\n\nCheck /etc/aliases (or ~/.procmailrc) for correct file\n";
    exit 1;
}

$File = $ARGV[0];

open (IN, "-");
while (<IN>) {
    $_ = <IN>;

    #--- Get the From feild, then Convert it to out To:
    if ($_ =~ /From:/) {
	$To = "To: " . substr($_,6);

	    #--- Open the requested file and send it
	close (IN);
	open (SFILE, "$File"); 

	
	print OUT "$To";
	print OUT "$xheaders";
        
	while (<SFILE>) {
	    $_ =  <SFILE>;
	    
	    print OUT "$_";

	}

	print OUT "\n";

        close (SENDFILE);

	print OUT  << 'FOOTER';

-----                    
This file was sent to you via a automated email bot.  No actual human has 
processed this request. This file is sent to the From: feild in a email
sent to the email address of this server. 

LEGAL: These docs are served without any warranty what-so-ever.
       You use any information or instruction in these documents at
       at your own risk. This server nor the Author are responciable
       for any damage that may result from the use of these instructions,
       codes, or scripts.

FOOTER

print OUT "To email an human, send mail to $WhoOwnMe\n\n\n";
print OUT "The file was sent to you via GCMailbot.pl created by Grey Cloak in /
 1997\n\n";


        close (OUT);

	exit 0;
    }
}

$ETo = "To: $WhoOwnMe";
$ESubject = "Subject: Error Report From GCMailbot";
print OUT "$ETo\n";
print OUT "$From\n";
print OUT "$ESubject";

print OUT "Email address error From: (?)";
close IN;

exit 1;

-------------end---------------




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

Date: Sat, 13 Dec 1997 22:41:13 -0600
From: jake@blacksun.net (Jake Burns)
Subject: Re: Restricting CGI Programs to Perl.
Message-Id: <882073999.623116293@dejanews.com>

In article <881956713.1442709506@dejanews.com>,
  djr@newcoast.com wrote:
>
> Hello,
>
> 1. Is their an easy way to have a web server restrict CGI programs to
> Perl in an UNIX environment (Solaris 2.6 running SWS 1.0)?  2. Is
> there a way to restrict Perl to what it can spawn, such as only
> sendmail, etc?  Any information on how to accomplish this is
> greatly appreciated.
>

Add a group and put all users in that group.  Make sure whoever your web
server runs as is *not* in the group.

Lets assume you name this group 'users':

# for a in `find / -print`; do chmod o-x $a; done
# chmod a+x `which perl` `which sendmail`
# chgrp -R users /bin /usr/bin /usr/local/bin /opt

an idea, anyway.

--
Jake Burns
jake@blacksun.net

> Thanks
>     - Dan
>
> -------------------==== Posted via Deja News ====-----------------------
>       http://www.dejanews.com/     Search, Read, Post to Usenet

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Sat, 13 Dec 97 12:16:12 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Shoving an array into a glob? or fixing IO::ScalarArray
Message-Id: <3492c8ca$5$ofn$mr2ice@speaker>

In <Pine.GSO.3.96.971212120839.29438H-100000@user2.teleport.com>, on 12/12/97
at 12:14 PM,
   Tom Phoenix <rootbeer@teleport.com> said:
+-----
| On Thu, 11 Dec 1997 schwern@rt1.net wrote:
| > I recently found it necessary to use the data on an array as a filehandle
| > (a module routine only accepted IO::Handle type filehandles and I had
| > data which I had piped and processed into an array that I wanted to pass
| > into it.)  
| Are you saying that you had data which you wanted to print on a filehandle?
+--->8

Only if you posit a temporary file or a pipe and fork().  What he's asking for
(ignoring the confusion as to the meaning of "print" :-) is:

    package IOArray;
    use 5.004;

    use strict;
    use diagnostics;
    use Carp;

    # condensed for newsreader convenience....
    sub TIEHANDLE { my $class = shift; bless([@_], $class); }
    sub PRINT { croak("IOArray is read-only"); }
    *PRINTF = *PRINT;
    sub READLINE { my $this = shift; shift(@$this); }
    sub READ { croak("Can't do arbitrary reads from IOArray"); }
    *GETC = *READ;

    1;

which is used as:

    #!/usr/bin/perl -w
    use strict;
    use diagnostics;

    use IOArray;

    use vars qw(*TEST);
    # bind the script's arguments as an IOArray
    tie(*TEST, 'IOArray', @ARGV);

    while (<TEST>)
    {
        print "The next line is: $_\n";
    }

(and works fine here, so maybe I've managed to escape the dreaded typo bug for
a change :-)

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)


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

Date: Fri, 12 Dec 1997 06:55:06 GMT
From: ferrario@protec.it (Massimo Ferrario)
Subject: Useful posts from Nathan Stanford
Message-Id: <348fc079.5378123@news.protec.it>

Hey man , would you please stop answering questions in the newsgroup with 

> If you haven't figured it out or gotten an answer email me
>
>--
>Nathan Stanford       The Perl N.uT.
>nathan_stanford@cabp.com - Work
>nathan@cyberservices.com - Home
>

I think you could E-mail such messages, don't you?



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

Date: Sat, 13 Dec 97 12:43:02 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: what does qq() do?
Message-Id: <3492c95c$6$ofn$mr2ice@speaker>

In <ebohlmanEL3y77.3Dn@netcom.com>, on 12/13/97 at 03:11 AM,
   Eric Bohlman <ebohlman@netcom.com> said:
+-----
| obviously won't cut it.  You *might* write
| perl -e "print \"hello, world!\n\""
+--->8

perl -e "print ""hello, world\n"""

Which is, if anything, worse than backwhacking everything in sight.

-- 
use 5.004;sub AUTOLOAD{print$_{$_.++$x{$_}}}sub new{my%x;%_=map{++$a%2?$_.++$x{
$_}:$_}split(//,pack('N*',unpack('w*',unpack('u*','M@H*HP\'2"@\C`88+SE/!EA(F!'.
"A'6\$LZV0+(3;C9QRA9NAPG2&D\\G(88:KL=A0\n4AN.5W\"\"&\\[W>;H>3S>0\@A\\N\@PB\$`")
)));bless{}}$b=(new main);map{$b->_}split(//,' Brandon S. Allbery KF8NH') # :-)


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

Date: Sat, 13 Dec 1997 03:01:05 -0400
From: Guillermo Schwarz <gschwarz@netup.cl>
Subject: Re: Which language pays most 17457 -- C++ vs. Java?
Message-Id: <34923264.75B5@netup.cl>

Miguel Carrasquer Vidal wrote:
> 
> On Fri, 12 Dec 1997 11:31:58 -0800 (PST), Mix
> <mixmaster@remail.obscura.com> wrote:
> 
> >Unfortunately, my college taught languages that were "scientifically"
> >correct but useless practically.
> >FORTRAN is dead and has started to stink
> >because of its poor and incomprehensible grammar, and its emphasis on
> >poor programming style. It was good for the punch card epoch but not
> >for the client-server world.
Because it has no sockets?
> >Eiffel is a good language for people who are just starting to learn
> >programming, but is not a good choice for non-novices.
Because you can't build a WebBrowser with it?
> >ADA has always been the DOD's pet language which has never been accepted
> >outside the military-industrial complex.
> >Smalltalk hardly deserves a mention.
Have you ever seen a program written in Smalltalk?
> >As a sad result of all that, the jobs for these languages are almost
> >nonexistent and the salaries are not that great. I will have to accept
> >that I need to forget them in order to make decent money.
> >That leaves me with the only alternative -- C++ or Java. 
Forgot VisualBasic, which I suppose is the only language you
really know by the way you "mention" other real languages.
> >Both languages
> >have been hugely successful DESPITE their design flaws.
You should have said they have been hugely marketed DESPITE
their huge design flaws.
For a language to be succesful, 6 things must happen:
1. Actual programs must be written in it.
2. Lots of libraries must be written for it.
3. Most computer architectures must have a compatible version of it.
4. Source code must be easily understable (by good coders).
5. Lots of programmers must know the language in deep.
6. The syntax must be simple. The semantics must be well defined.

C is ok with 1, 2 and 3, but not with 4, 5 and 6.
Smalltalk is ok with 1, 2, 3, 4, 5 and 6.
Take a look at Squeak.

Note that speed is not a language issue but a compiler issue.


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

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

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