[8492] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2109 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Mar 16 13:17:05 1998

Date: Mon, 16 Mar 98 10:00:32 -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           Mon, 16 Mar 1998     Volume: 8 Number: 2109

Today's topics:
    Re: beginner troubles <camerond@mail.uca.edu>
    Re: Delete Files via Unlink on NT?? Help! <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
    Re: Delete Files via Unlink on NT?? Help! scott@softbase.com
        exact match (Farid Hamjavar)
    Re: file age <aet@aryth.webplanets.com>
    Re: File::Copy <uri@sysarch.com>
        fwd: Redirect to another url <wongkl@singnet.com.sg>
    Re: globbing vs. opendir / readdir (I R A Aggie)
        help me with cgi posting using perl <techsoft@abcpages.com>
    Re: help me with cgi posting using perl scott@softbase.com
        how to use unix  system command in perl (Lalit Jairath)
        Input <edgar@pce.net>
    Re: Integration with the Perl I/O system (Tom Grydeland)
    Re: Is there a "Newsgroup" for Newbies to Perl? <stackhou@elk.cray.com>
    Re: Is there a "Newsgroup" for Newbies to Perl? <barnett@houston.Geco-Prakla.slb.com>
    Re: Is there any way to evaluate a string as a variable schwern@starmedia.net
    Re: ls -l to an array and pull 3 columns on data schwern@starmedia.net
    Re: New Error Message - @INC <barnett@houston.Geco-Prakla.slb.com>
    Re: New Error Message - @INC schwern@starmedia.net
        passwd in perl <pinky@mail.usmo.com>
    Re: passwd in perl (Will Morse)
    Re: Perl 5 installation <camerond@mail.uca.edu>
    Re: Perl and Windows NT question (Richard Bellavance)
        Perl Win32 on NT with MS FP PWS (NCSA 1.3 port) <nospam@beezlebub.com>
    Re: Problem with x in s///x (Tom Grydeland)
    Re: proces killer (Joonas Timo Taavetti Kekoni)
    Re: Querying number of entries from multiple lines <uri@sysarch.com>
    Re: Reference syntax help (Tom Grydeland)
    Re: Reference to a part of a hash? <jgoerzen@southwind.net>
    Re: removing everything between < and > <j.marshall@dial.pipex.com>
    Re: Socket IO, non echoed? <aet@aryth.webplanets.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 16 Mar 1998 11:21:52 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: El Penguino <penguin@tiac.net>
Subject: Re: beginner troubles
Message-Id: <350D5FB0.5EDFFC49@mail.uca.edu>

[cc'd to ep]

Go here: http://hjs.geol.uib.no/Perl/index6.html-ssi

and follow the instructions. Can't miss.

(your note just showed up here. Hope it's not too late.)

Cameron
camerond@mail.uca.edu

El Penguino wrote:
> 
> I'm trying to learn CGI w/Perl on my own. I downloaded the Perl 5
> interpreter (on my Win95 PC) but looking at all these readme
> instructions I'm totally lost. Would someone be willing to call me on
> the phone and talk me through this mess. Please reply then I'll reply
> with my phone number. Thanks.


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

Date: Mon, 16 Mar 1998 07:26:45 -0800
From: "Creede Lambard" <$_=qq!fearless\@NOSPAMio.com!;y/A-Z//d;print>
Subject: Re: Delete Files via Unlink on NT?? Help!
Message-Id: <6ejg8a$bsd@bgtnsc03.worldnet.att.net>

Here's one of the problems:

> {
> unlink("c:\inetpub\wwwroot\upload\deleteme.txt");
> }


You need to backwhack your backwhacks, Jack. :D

The code is perfectly proper provided that particular file exists, except
that you have to have double-backslashes in a double-quoted string. (Try
this one-liner and see what happens:

perl -e "print \"c:\inetpub\wwwroot\upload\deleteme.txt\n\";"

Whatever you see is what's being passed to unlink(). It's probably not what
you expected. :D (By the way, your Perl should understand frontwhacks just
like it does in Unix, and using them would make things much easier.)

I would also put a die statement in there just in case you don't have
permission to delete the file:

$myFile = "C:/inetpub/wwwroot/upload/deleteme.txt";
unlink($myFile) or die "Can't delete $myFile: $!";

Hope this helps.

--- Creede Lambard
Minister of Irregular Expressions
Programming Republic of Perl







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

Date: 16 Mar 1998 17:55:41 GMT
From: scott@softbase.com
Subject: Re: Delete Files via Unlink on NT?? Help!
Message-Id: <6ejp2t$et1$1@scully.new-era.net>

Mark Polakow (mark@imp.net) wrote:
> I have been informed about UNLINK and RMDIR but I have no idea how to =
> use them and what it needs.
> COuld someone PLEASE, PLEASE, send me some =
> code and how to use it that will delete a file/directory, I would be so =
> appreciative!

Your basic unlink example:
	open(D, ">deleteme.txt")|| die "$!";
	print D "Delete me\nDelete me\nDelete me\n";
	close(D);
	system("dir deleteme.txt");
	unlink("deleteme.txt");
	system("dir deleteme.txt");

Produces this output on NT (with unnecessary lines deleted):

 3/16/98  11:57              33  deleteme.txt
 The system cannot find the file specified.  "G:\scott\deleteme.txt"

> I have ignorantly tried to use this code and failed...

The main thing you seem to be ignorant of is file permissions.  A CGI
program runs as a nobody with no permission to do much of anything. Are
you sure that you are allowed to delete this file? NT, in particular
with Internet Information Server, is a morass of poorly documented and
almost totally and universally not understood file permissions. Before
switching to Apache, I had to give everyone total permission on all the
IIS directories to get anything to work.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: 16 Mar 1998 10:21:23 -0700
From: hamjavar@unm.edu (Farid Hamjavar)
Subject: exact match
Message-Id: <6ejn2j$31d6@mirac.unm.edu>


Greetings,

I use the following to know if ARGV[1]
is all digit characters. I tried several
other variations but they did not work.
How can I compare  $item  against
something like    /^[0-9].*[0-9]$/  and
know that it's all digits?
Saying it in other words, I don't
want to accomplish this by "negative comparison",
meaning that here (below) I know it's not all
digits because it's not all alpha characters.


Thanks,
Farid
#
#
$item =  $ARGV[1];
#
$[=1;#start index from 1, not zero.
if ($item !~  /[a-zA-Z]/ )
   {
    $item =~ s/^0*//;
    print "$item";
   }
#
#
#


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

Date: 15 Mar 1998 23:41:30 GMT
From: Andy Tompkins <aet@aryth.webplanets.com>
Subject: Re: file age
Message-Id: <6ehova$td$1@aginor.webplanets.com>

In comp.lang.perl.modules Haaino Beljaars <Beljaars@fys.ruu.nl> wrote:
> Hi,

> I have a simple problem. I am currently running a system with multiple
> users, the user 'guest' has a disk quota of 10 MB. All files of 'guest'
> must be deleted after 10 days but the files of the other persons must be
> left alone. How do I do that?

> --
> Greetings from Haaino Beljaars

> --------------------------------------------------
> E-Mail:         Beljaars@fys.ruu.nl              -
> Home Page:      HTTP://www.fys.ruu.nl/~beljaars/ -
> File not found. Should I fake it? (Y/N)          -
> Beware of programmers who carry screwdrivers.    -
> --------------------------------------------------

man find
man cron

run find once a day from cron, thats what i would do
	--- andy



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

Date: 16 Mar 1998 10:15:11 -0500
From: Uri Guttman <uri@sysarch.com>
To: Peter Shankey <shankeyp@charlestoncounty.org>
Subject: Re: File::Copy
Message-Id: <x71zw2lla8.fsf@sysarch.com>

Peter Shankey <shankeyp@charlestoncounty.org> writes:

> #!/usr/bin/perl -w
> use POSIX;
> use File::Copy 'cp';
> $TempFile=POSIX::tmpnam();
> #$TempFile1=POSIX::tmpnam();
> # vars general vars
> $UID="1194";
> $UserList="/home/dptpws/s/ed/ps_0306.txt";
> #step one: change the Login name to lower case and add a uid number to
> each 
> #account to be created from ps_0306.txt  finallly write from the temp
> file
> #back to $UserList
> open(TempFile,">$TempFile")  || die "\ncannont open $TempFile\n\n";
> open(UserList,$UserList)	||	die "\ncannot open $UserList\n\n";
> while(defined ($Line=<UserList>)){ 
> 	@fields=split(/,/,$Line);
> 	$fields[0]=lc"$fields[0]"; # change to lower case
> 	$fields[2]=$UID;
> 	++$UID;
> 	print TempFile "$fields[0],$fields[1],$fields[2]\n";
> 	}
> close(TempFile);
> close(UserList);
> cp("$TempFile","$UserList");
> unlink $TempFile; #deletes the Temp file
> 
> but I still got the message:
> 
> dptpws@ashley/home/dptpws/s/ed>./bi-user-add.1
> Use of uninitialized value at /opt/GNUperl5/lib/File/Copy.pm line 84.

i don't get that warning.

but why are you copying the file? why not rename the original file, and
read from it while writing a new file with the old name?

rename old, temp
open temp for read
open old for write
loop over temp lines
	process lines
	print to old
close old
close temp
unlink temp


in fact his could be done much easier with the -i and -n options:
(/home/dptpws/s/ed/ps_0306.txt is the only command line argument)


#/path/to/perl -i.bak

BEGIN {

	$UID="1194";
}

@fields=split(/,/,$_);
$fields[0]=lc"$fields[0]"; # change to lower case
$fields[2]=$UID;
++$UID;
print "$fields[0],$fields[1],$fields[2]\n";


simple enough!

uri

-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 16 Mar 1998 15:49:07 GMT
From: "wongkl" <wongkl@singnet.com.sg>
Subject: fwd: Redirect to another url
Message-Id: <01bd50f2$51587020$60b515a5@jwtech>


To:comp.lang.perl.misc

 I learning how to use Perl redirect cgi can anyone help me ,
how to use Perl redirect script that can redir you to another url like
 http://www.Domain.com/cgi-bin/redir.cgi?Link=Page_html



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

Date: Mon, 16 Mar 1998 11:56:00 -0500
From: fl_aggie@thepentagon.com (I R A Aggie)
Subject: Re: globbing vs. opendir / readdir
Message-Id: <fl_aggie-1603981156000001@aggie.coaps.fsu.edu>

In article <6ejeec$q8a@julius.ling.ohio-state.edu>,
kcohen@julius.ling.ohio-state.edu (Kevin B Cohen) wrote:

+ glob() is easier to use in that it lets you be more specific about
+ what sorts of files you want,

What's so hard about:

@files = sort grep /\.html$/, readdir(DIR);

? :)

AFAIK, readdir does not give you back sorted file names.

James

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN-local/doc/FAQs/cgi/idiots-guide.html>


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

Date: Mon, 16 Mar 1998 09:56:51 -0800
From: "Alex K" <techsoft@abcpages.com>
Subject: help me with cgi posting using perl
Message-Id: <350d3e38.0@lightning.ica.net>

hey does anybody know how I can POST information with my cgi script to
several servers at the same time?
example would be very appreciated...

With best wishes,
Alex.
-----------------------
FREE WEB SITE SUBMISSION
http://www.philex.net/websub/





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

Date: 16 Mar 1998 17:58:54 GMT
From: scott@softbase.com
Subject: Re: help me with cgi posting using perl
Message-Id: <6ejp8u$et1$2@scully.new-era.net>

Alex K (techsoft@abcpages.com) wrote:
> hey does anybody know how I can POST information with my cgi script to
> several servers at the same time?

It depends on what you mean. As is all too common on Usenet,
*you* know what you're talking about but your post comes
across as very ambiguous and unclear because of imprecise
expression of though.

If by "with" you mean "within", it's trivial. Just fire up
as many connections as you want using Perl's built in TCP/IP
(or even use a module that eventually uses it) and POST your
guts out.

If by "with" you mean "by using the same CGI script on different
servers", you can do this on the client if you use JavaScript
or some other client-side scripter that lets you programmatically
fire off POSTs.

Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more. 


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

Date: 16 Mar 1998 15:36:01 GMT
From: ljairath@wright.aps.uoguelph.ca (Lalit Jairath)
Subject: how to use unix  system command in perl
Message-Id: <6ejgt1$17g@ccshst05.uoguelph.ca>


Hallo Everybody,

1)
In the following using perl script how can i update the month string with
current value of the month based on the date/ctime/ unix command.

The month of February is checked.
(so that it changes the above string to
The month of March is checked.
(and push down the original string with
The month of February is.

2)
Also, how can i update the date variable e.g., 980313 every friday e.g.
to 980320, 980327 etc. with the perl script based on some unix command.


sincerely appreciate your help.

you may pl. e-mail me @
ljairath@wright.aps.uoguelph.ca

Thanks much!

Lalit
~~~~~~

--
*=========================================================================*
| Dr. Lalit Jairath, Ph.D.                    |        E-mail:            |
| Genetic Evaluation Analyst                  | ljairath@aps.uoguelph.ca  |
| Centre for Genetic Improvement of Livestock |                           |
| Animal & Poultry Science                    |                           |
| University of Guelph, Ontario, CANADA       | Tel: (519)824-4120 x3707  |
| N1G 2W1                                     | Fax: (519) 767-0573       |
|-------------------------------------------------------------------------|
|            WWW:  http://www.aps.uoguelph.ca/~ljairath/                  |
*=========================================================================*


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

Date: Mon, 16 Mar 1998 11:52:53 -0500
From: "James R. Edgar" <edgar@pce.net>
Subject: Input
Message-Id: <350D58E5.9894B1A6@pce.net>

I need to know how to be able to call input from a shell prompt instead
of a form

Any help would be appreciated.

James R. Edgar


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

Date: 16 Mar 1998 16:10:44 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Integration with the Perl I/O system
Message-Id: <slrn6gqjo3.e8h.Tom.Grydeland@mitra.phys.uit.no>

On 12 Mar 1998 13:16:52 GMT,
Stefaan A. Eeckels <Stefaan.Eeckels@ecc.lu> wrote:

> I'd really like to be able to
> return a native Perl filehandle, where Perl would
> call my routines instead of the OS equivalents.

Perhaps you want a tie'd filehandle?


> Any hints, pointers and help gratefully accepted.

man perltie might be the place for you.

> Stefaan

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: Mon, 16 Mar 1998 10:23:07 -0600
From: Mark P Stackhouse <stackhou@elk.cray.com>
To: harrison@pixi.com
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <350D51EB.446B@elk.cray.com>

Mr. Harrison,

I'm not quite sure how the HTML tags ended up in my reply (maybe it had
something to do with the editor I was using at the time) but let me
assure you that "private" remains "private" and "public" appears here
only.

Mark


Robert F. Harrison wrote:
> 
> On Sun, 15 Mar 1998 19:49:48 -0600, Mark Stackhouse <stackhou@execpc.com> wrote:
> > <HTML>
> > Mr. Harrison,
> >
> > <P>Thank you for so graciously illustrating one of my points... low brow
> > and brain bash the "Newbie" but let Mr. Oswald get away with the exact
> > point you are making here.
> 
> Mr. Stackhouse;
> 
> You wrote to me in private expessing your concerns and I apologized in
> private. Now I do so in public.  My next statement is not an attempt
> to 'squeak out' of anything, but...because of the formatting and use
> or non-use of quotations I believed it was you making a statement and
> not Mr. Oswald. That is why all the >>>'s and attribution lines are
> important to preserve.
> 
> I am a bit worried however, is all this HTML an indication that you
> are also putting this message up on your webpage? :-)
> 
> >
> > <P>Mark ;-)
> >
> > <P>Robert F. Harrison wrote:
> > <BLOCKQUOTE TYPE=CITE>On Sat, 14 Mar 1998 11:08:55 -0600, Mark Stackhouse
> > &lt;stackhou@execpc.com> wrote:
> > <BR>>
> > <BR>> But first get yourself a grammar and a spelling book; you really
> > need
> > <BR>> it.&nbsp; It's ok to be a little lazy at the keyboard within the
> > confines
> > <BR>> of the social etiquette applicible to your audience, but taken to
> > your
> > <BR>> extreme it's simply insulting and annoying.&nbsp; Express yourself
> > in an
> > <BR>> intelligent and respectful manner and you're liable to fool folks
> > into
> > <BR>> believing that you actually are intelligent and deserving of respect.
> > <BR>> This lesson in life is probably off topic here, but so was your
> > <BR>> request for information, so deal with it.
> >
> > <P>Mr. Stackhouse, allow me to quote RFC 1855 on Netiquette:
> >
> > <P>From Section 3.1 User Guidelines
> > <BR>&nbsp;&nbsp;&nbsp;&nbsp; 3.1.1 General Guidelines for mailing lists
> > and NetNews
> >
> > <P>* Messages and articles should be brief and to the point. Don't
> > <BR>&nbsp; wander off-topic, don't ramble and don't send mail or post
> > <BR>&nbsp; messages solely to point out other people's errors in typing
> > or
> > <BR>&nbsp; spelling. These, more than any other behavior, mark you as an
> > <BR>&nbsp; immature beginner.
> >
> > <P>The entire RFC is available at a host of locations including:
> >
> > <P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <A HREF="http://ds.internic.net/rfc/rfc1855.txt">http://ds.internic.net/rfc/rfc1855.txt</A>
> >
> > <P>Should that location be unavailable a simple search on any search
> > <BR>engine should find any number of copies.
> >
> > <P>--
> > <BR>rfh harrison@pixi.com</BLOCKQUOTE>
> > &nbsp;
> > <BR>&nbsp;
> > <BR>&nbsp;</HTML>
> >
> 
> --
> rfh harrison@pixi.com


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

Date: Mon, 16 Mar 1998 10:28:20 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Is there a "Newsgroup" for Newbies to Perl?
Message-Id: <350D5324.3EAE87C1@houston.Geco-Prakla.slb.com>

> Bob Gwynne wrote:
> 
> 
> 
>      Mark Stackhouse wrote in message
> 
>     >  And if the newbies won't read the damn FAQ, what makes you
>     >  think they'll
>     >  read this cookbook of yours?
>     >
>      Because maybe the Cookbook will actually provide links to
>      what one is looking for!  Today I needed a reference to a
>      rounding function.  OK... go to the FAQ!  Right?
> 
>      FAQ has a question - Does Perl have a round function?  All
>      right... here we go. Click on the hypertext.
> 
>      Now I'm in Perl Docs... do a text search on the word
>      "round"..."Search string not found"  OK... search on
>      "function".
> 
>      Mark reinforces my point.  At the very least, the FAQ should
>      have a more useful search capability. Even the Camel book
>      needs improvement. "Round" and "rounding" do not appear in
>      the index. Oh ho, try "integer" instead. The Camel book
>      sends the reader to int(), which is of some help. I can't
>      comment on the Llama book's treatment of rounding at this
>      time, but I suspect it may also suffer from a weak index.
>      Jon Orwont's book also suffers from a weak index; however,
>      he provides the answer in Chapter 1:   $nearest_integer =
>      ($number > 0) ? int($number + 0.5) : int($number - 0.5).
>      Larry Wall must have decided to leave round(), ceil(), and
>      floor() out of Perl as some sort of feature. Those functions
>      should be added to the next version of Perl.  All of the
>      Perl books that I've seen need better indexes.
> 
> 
> 
>      Bob Gwynne
Have a look on Dejanews, searching for perldoc AND patch in
comp.lang.perl.misc searching through current files in entire archive
will turn up a patch to perldoc, thoughtfully provided by Piers Cawley,
and with a change by me (cause it wasn't working quite right for me).

2 seperate articles, but they make faq searches a bit easier.

My perldoc -q 'round' turned up:
=head1 Found in /usr/local/lib/perl5/pod/perlfaq4.pod
 
=head2 Does perl have a round function?  What about ceil() and floor()?
Trig functions?
 
For rounding to a certain number of digits, sprintf() or printf() is
usually the easiest route.
 
The POSIX module (part of the standard perl distribution) implements
ceil(), floor(), and a number of other mathematical and trigonometric
functions.
 
In 5.000 to 5.003 Perls, trigonometry was done in the Math::Complex
module.  With 5.004, the Math::Trig module (part of the standard perl
distribution) implements the trigonometric functions. Internally it
uses the Math::Complex module and some functions can break out from
the real axis into the complex plane, for example the inverse sine of
2.
 
Rounding in financial applications can have serious implications, and
the rounding method used should be specified precisely.  In these
cases, it probably pays not to trust whichever system rounding is
being used by Perl, but to instead implement the rounding function you
need yourself.
 
=head1 Found in /usr/local/lib/perl5/pod/perlfaq6.pod
 
=head2 What does it mean that regexps are greedy?  How can I get around
it?
 
<snip - not useful to this example>


It still makes you have some idea of what is going on, but I found it a
useful change to the perldoc program.

HTH.

Dave


-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Mon, 16 Mar 1998 11:07:58 -0600
From: schwern@starmedia.net
Subject: Re: Is there any way to evaluate a string as a variable name?
Message-Id: <6ejm5t$dqa$1@nnrp1.dejanews.com>

In article <01bd4edd$7ad59ac0$8fa7f9c7@hamachi.apte.nunet.net>,
  "John Hibscher" <john@apte.com> wrote:
>
> Hello,
>
> Is there any way to evaluate a string as a variable name? For example, I
> have a dynamic number of form fields, each named wc1, wc2, wc3, ..., wcn
> and I know the value of n. Now how do I refer to these fields in perl? I
> tried variations on the following, but I think I'm in error:
>
> for ($i=1; $i<=$wcnum; $i++) {
>   $wcname = 'wc'.$i;
>   print MAIL "$FORM{$wcname}\n\n";
> }
>
> If you could send me a reply via e-mail, I will be very happy. Thanks for
> your time, folks.
>
> Regards,
>
> John Hibscher
>


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


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

Date: Mon, 16 Mar 1998 11:15:06 -0600
From: schwern@starmedia.net
To: grindrod@tfn.com
Subject: Re: ls -l to an array and pull 3 columns on data
Message-Id: <6ejmjb$e66$1@nnrp1.dejanews.com>

Avoid unnecessary system calls.  Use readdir, opendir and stat.

opendir(DIR, $dirname) || die $!;
foreach my $filename (readdir(DIR)) {
	@stat = stat $filename;
	# do something with @stat...
}

stat returns everything that ls -l does, and more and in a consistant format.

In article <6ebe4u$c0e$1@nnrp1.dejanews.com>,
  grindrod@tfn.com wrote:
>
> I am trying to send the output of the ls -l command to and array or
filehandle
> and the print only 3 of the 9 columns of the output for each line. I did not
> see anything in the FAQ or recent messeges addressing this and have exhaused
> mey efforts to get the desired result. Can some shed light on how to do
this?
> I am using perl 5 on SCO Unix.
>
> -----== Posted via Deja News, The Leader in Internet Discussion ==-----
> http://www.dejanews.com/   Now offering spam-free web-based newsreading
>

SCO?  Eww.

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


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

Date: Mon, 16 Mar 1998 08:50:42 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: New Error Message - @INC
Message-Id: <350D3C42.DE720B1C@houston.Geco-Prakla.slb.com>

Lee Feigenbaum wrote:
> 
<snip>
> When I run the script from the command line:
> 
> ./foo.cgi
> 
> There are no errors (no errors when invoked with -w, either), and I
> get CGI.pm's offline debugging mode. Great.
> 
> Now I go to the web, and I get an internal server error. I check the
> error_log, and see:
> 
> Can't locate lib.pm in @INC at /www/htdocs/cgibin/foo.cgi line 7.
> BEGIN failed--compliation aborted at /www/htdocs/cgibin/foo.cgi line
> 7.
> 
What version of perl5 are you using?  On perl5.004_01, use lib works
fine.  On perl5.001_1m, I get the same message about lib.pm.

I strongly suspect that the interactive version of perl (what you get
when you run script.perl) is not the same as the one that gets run from
the web server (it will/should spit out the above in the web logs).

A simple test would be:
#!/usr/local/bin/perl -v
__END__

Both interactively & through web server/browser, you should get perl
information, specifically a version number.

I expect that they will be different, for some reason.
> Any idea what's going on?
> 
> Thanks again,
> Lee
HTH.

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: Mon, 16 Mar 1998 11:25:04 -0600
From: schwern@starmedia.net
To: feigenb@hcs.harvard.edu
Subject: Re: New Error Message - @INC
Message-Id: <6ejn62$eqt$1@nnrp1.dejanews.com>

What's happening is that your web server is running your scripts as a
different user than yourself.  Probably user 'nobody'.  Which means A) Its
PATH is different.  B)  If you put '~' in your lib path it doesn't mean the
same thing.  C) Its entirely possible that its using a completely different
perl than you are.  D) You might have a PERL5LIB environment variable set that
has perl directories in it that the web server doesn't.

So... when you run your program from the CGI, do something like:

BEGIN {  print STDERR "@INC"; }

Then check for the results in the error log.  Or use CGI::Carp or
CGI::LogCarp;

However, it is -very- odd that it can't find lib.pm, which is a standard
module.


You Harvard boys need to learn how to debug. :)

In article <350e171a.27392464@news.fas.harvard.edu>,
  feigenb@hcs.harvard.edu (Lee Feigenbaum) wrote:
>
> I fixed my earlier problem, and now I"m haivng a new strange problem:
>
> Because of very annoying finickiy behavior by my ISP, I have CGI.pm in
> a local directory (cgi-lib), and at the top of my Perl script I have:
>
> use lib '{full-path}/cgi-lib';
> use CGI qw(:cgi);
>
> lib.pm is in /usr/lib/perl5/
>
> /usr/lib/perl5/ is in @INC (I tried jsut prinitng out @INC, it was
> there)
>
> When I run the script from the command line:
>
> ./foo.cgi
>
> There are no errors (no errors when invoked with -w, either), and I
> get CGI.pm's offline debugging mode. Great.
>
> Now I go to the web, and I get an internal server error. I check the
> error_log, and see:
>
> Can't locate lib.pm in @INC at /www/htdocs/cgibin/foo.cgi line 7.
> BEGIN failed--compliation aborted at /www/htdocs/cgibin/foo.cgi line
> 7.
>
> Any idea what's going on?
>
> Thanks again,
> Lee
>


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


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

Date: Mon, 16 Mar 1998 00:09:51 -0600
From: Stefan Adams <pinky@mail.usmo.com>
Subject: passwd in perl
Message-Id: <350CC22F.8FE559D@mail.usmo.com>

Here is my dilema:
I have written an administration perl script that adds and deletes users
and changes their passwords.  The problem is, only root can run this
program.  But more often than not, I have other users that need to
change passwords to all users, but I don't want to give them root
access.  How do I allow a few select users, specified by the admin group
account, to change passwords for all users without giving group write
access to /etc/passwd?
Do I make the program SUID, or make a 'su' call?
Please help me

Stefan Adams



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

Date: 16 Mar 1998 10:19:48 -0600
From: will@Starbase.NeoSoft.COM (Will Morse)
Subject: Re: passwd in perl
Message-Id: <6ejjf4$5i0$1@Starbase.NeoSoft.COM>

What you probably need is a program like sudo.  That isn't a perl
answer, but maybe you don't want to do quite everything in perl.

Will

In article <350CC22F.8FE559D@mail.usmo.com>,
Stefan Adams  <pinky@mail.usmo.com> wrote:
>Here is my dilema:
>I have written an administration perl script that adds and deletes users
>and changes their passwords.  The problem is, only root can run this
>program.  But more often than not, I have other users that need to
>change passwords to all users, but I don't want to give them root
>access.  How do I allow a few select users, specified by the admin group
>account, to change passwords for all users without giving group write
>access to /etc/passwd?
>Do I make the program SUID, or make a 'su' call?
>Please help me
>
>Stefan Adams
>


-- 
# Copyright 1998 Will Morse.  Internet repost/archive freely permitted.
# Hardcopy newspaper, magazine, etc. quoting requires permission.
# 
#      Gravity,                    #    Will Morse
#      not just a good idea,       #    Houston, Texas
#              it's the law.       #    will@starbase.neosoft.com
#
#   These are my views and do not necessarly reflect anyone else.


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

Date: Mon, 16 Mar 1998 09:50:13 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Steve Peters <michboy@caspers.net>
Subject: Re: Perl 5 installation
Message-Id: <350D4A35.968852DD@mail.uca.edu>

[cc'd to sp]

Go here: http://www.perl.com/CPAN-local/authors/Gurusamy_Sarathy/

Get this:  perl5.00402-bindist04-bc.tar.gz

Have fun.

Cameron
camerond@mail.uca.edu

Steve Peters wrote:
> 
> I am trying to install Perl 5 on my system, so I went to
> http://www.perl.com/ and downloaded a file called latest_tar.tar. It
> downloaded successfully and I tried to extract it using WinZip.  
[problems follow]


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

Date: 16 Mar 1998 09:14:19 -0500
From: charlot@CAM.ORG (Richard Bellavance)
Subject: Re: Perl and Windows NT question
Message-Id: <6ejc3r$3b8@ocean.CAM.ORG>

In article <6eioqu$1r0$1@bsdti6.sdm.de>, Steffen Beyer  <sb@sdm.de> wrote:
>
>You just need a C compiler (Borland C++ or MS Visual C++) and then you
>can install additional modules as easily as in Unix:
>

Just to clarify this point, you don't need a C compiler to use this port.
You do need one if you want to compile extension modules that have XS
components.  Pure-Perl modules install just fine.

Have fun !
Richard.
-- 
Richard Bellavance -- charlot@cam.org -- http://www.cam.org/~charlot/
    "All along this path I tread  /  My heart betrays my weary head
     With nothing but my love to save / From the cradle to the grave"
                                 (Eric Clapton, "From the cradle")


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

Date: Mon, 16 Mar 1998 11:59:07 -0500
From: Brad Berson <nospam@beezlebub.com>
Subject: Perl Win32 on NT with MS FP PWS (NCSA 1.3 port)
Message-Id: <350D5A5B.2C48@beezlebub.com>

OK, I give up!  I've been able to get the perl package from Activestate
working on my Win95 machine no problem (running the nicer PWS), even
though it wasn't nice enough to drop in the script map registry entry it
needed.

But my NT4 machine running the NCSA port called "Microsoft FrontPage
Personal Web Server" is not as easy.  What can I do, if anything, to get
the web server to run the .PL scripts?

Thanks for any help,
brad.berson =-at-= rectaltronics.com


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

Date: 16 Mar 1998 16:19:35 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Problem with x in s///x
Message-Id: <slrn6gqk8m.e8h.Tom.Grydeland@mitra.phys.uit.no>

On Thu, 12 Mar 1998 18:53:02 GMT,
David Grove <pete@dave-world.net> wrote:
> Under windows, the following doesn't act like it should...

Yes it (probably) does, you just don't expect the correct behaviour.

> $n = "123123";
> $n =~	s{
> 			(1)
> 			(.)
> 			(3)
> 		}
> 		{
> 			$1
> 			4
> 			$3
> 		}xg;
> print "$n\n";

> Instead of printint 143143, it prints in a column with leading white
> space. In other words, the s/// isn't ignoring the whitespace. Am I
> not understanding this, or is it a bug?

/x only strips whitespace from the regex (the first {} pair), not from
the substitution.  From the above snippet, I'd expect to see


			1
			4
			3
		@

			1
			4
			3
		@


(I've snailed the trailing whitespace.)


-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 16 Mar 1998 17:18:25 GMT
From: jkekoni@cc.hut.fi (Joonas Timo Taavetti Kekoni)
Subject: Re: proces killer
Message-Id: <6ejmt1$72q$1@hiekkalaatikko.cs.hut.fi>

Haaino Beljaars (Beljaars@fys.ruu.nl) wrote:
: I have a simple problem. I am currently running a simple apache http
: daemon. Everybody my execute .cgi's. The only problem is that some .cgi
: processes don't terminate. I want to use a perl to kill a .cgi proces

system("kill `ps xau | grep nobody | grep .cgi |cut -c 9-14` ");

You may need to adjust the arguments of ps and the columns after cut
according to you OS. Mine is redhat linux 5.0 .
work also Dec Unix.


I don't know if there are modules for accessing proces table.


-- 	_-  Joonas Kekoni       OH2MTF	    I                           -_
	_-internet:	jkekoni@cc.hut.fi   I       DO NOT EAT.         -_
	_-slowmail:	j{mer{ntaival 7a176 I                           -_
	_-		02150Espoo          I      It is a monitor      -_
	_-		Finland/Europe      I                           -_


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

Date: 16 Mar 1998 10:25:46 -0500
From: Uri Guttman <uri@sysarch.com>
To: William Kolln <wkolln@cia.com.au>
Subject: Re: Querying number of entries from multiple lines
Message-Id: <x7vhtek685.fsf@sysarch.com>

William Kolln <wkolln@cia.com.au> writes:

> Hope someone can assist....and please forgive the coding....it works
> well but does not copy from text editor into html-based
> editor well.

that is your problem!!! your loop closes before the packageing code.

> I am trying to get the program to read each of the $group values that
> are listed and then determine that if 'cd' is the only value from the
> list, then the packaging will be a value of .07.
> On the other hand if there is any other $group value such as
> 'lp','blp','12' etc the packaging output must be .3
> However, as this script stands, it will only read the last value in the
> list, so that if 'cd' is the last value then it produces an outcome of
> '.07' even though there might be an lp included above it in the list.

> > for ($i=1;$i<$SIZE;$i++) {
> >
> > print "$group $itemname$itemdescrip\$ $itemprice\$ $tmpprice\n";

(snip) poorly formatted code :-)

> > }
    ^
loop closes so this code executes only on the last item.

> > $cdmailer = '.07';
> > $lpmailer = '0.3';
> > if ($group eq 'cd') {
> >         print "Mailer:$cdmailer";
> >         }
> > else {
> >         print "Mailer:$lpmailer";
> >         }


drop the vcard stuff. this is a newsgroup which wants plain text.

hth,

uri


-- 
Uri Guttman                     SYStems ARCHitecture and Software Engineering
uri@sysarch.com                                          Have Perl, Will Hack
http://www.sysarch.com                (781) 643-7504 x*2  FAX: (781) 643-2710
Try the Best Search Engine on the Net -------->  http://www.northernlight.com


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

Date: 16 Mar 1998 16:33:41 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Reference syntax help
Message-Id: <slrn6gql33.e8h.Tom.Grydeland@mitra.phys.uit.no>

On Fri, 13 Mar 1998 13:08:05 -0600,
Wade Williams <wwilliam@cisco.com> wrote:

> while ( ($n,$value) = each(%$v->{killedplanes}))
> 
> line.  Obviously, how I'm refering to the hash is incorrect, but I can't
> figure out the correct synatax.

while ( ($n,$value) = each(%{$v->{killedplanes}}))

The -> only works when you end up with a scalar.  man perlref.


> Wade

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 16 Mar 1998 09:35:33 -0600
From: John Goerzen <jgoerzen@southwind.net>
Subject: Re: Reference to a part of a hash?
Message-Id: <r6zsooiabsq.fsf@peridot.southwind.net>

Ronald J Kimball <rjk@coos.dartmouth.edu> writes:

Ronald,

Thanks for your reply...

> > %hash = ('asdf' => 'qwerty');
> > 
> > $ref = \{$hash{asdf}};
> > 
> > However, this doesn't work.  Any idea how to do this?
> 
> In that context, the outer curly braces are being interpreted as an anonymous
> hash composer, which is definitely not what you want.
> 
> Have you tried it without those braces?  That seems to work for me, creating a
> reference to the value of $hash{asdf}.
> 
> Perhaps by entity you meant the 'key/value pair'.  I don't know how to get a
> reference to that, or if you even can.  But I'm also not sure why you'd want
> to.  You could use a ref to the entire hash and a variable containing the
> specific key.

I want to make a reference to the particular value of a key/value
pair.  This is for use with a "textvariable" thingy in Tk, which
unfortunately cannot use the technique you mention (a ref to the hash
plus a key).

John

> 
> -- 
>  _ / '  _      /         - aka -             rjk@coos.dartmouth.edu
> ( /)//)//)(//)/(    Ronald J. Kimball           chipmunk@m-net.arbornet.org
>     /                                   http://www.ziplink.net/~rjk/
>         "It's funny 'cause it's true ... and vice versa."

-- 
John Goerzen                              Southwind Internet Access, Inc.
E-mail: Business, jgoerzen@southwind.net; Personal, jgoerzen@complete.org
Computer Science Dept., Wichita State University,    jgoerzen@cs.twsu.edu
Developer, Debian GNU/Linux                       <http://www.debian.org>


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

Date: Mon, 16 Mar 1998 14:52:57 +0000
From: Ln1jnm <j.marshall@dial.pipex.com>
Subject: Re: removing everything between < and >
Message-Id: <350D3CC9.6563ADE1@dial.pipex.com>

Yashesh Shroff wrote:

> I would like to remove everything between '<' and '>' in a line and for
> all the instances.  I am trying to work out a script that basically
> removes all the formatting tags in an HTML document.  For the script:
> -----------
> $line = "This is <strong>strong</strong> and this is <b>bold</b> and
> this is plain text.";
> $line =~ s/<.+>//g;
> print $line;
> ----------------------------
> I get the result:
> This is and this is plain text    <<notice that "strong" and "and this
> is" and "bold" are also removed!
> --------------------------------------------
> everything between < and > is removed, however, if there is a second '>'
> in the line, perl takes the largest instance of the match.
>

     try    $line =~ s/<.*?>//g;      -   the *? is a non-greedy pattern
match ie it matches the shortest as opposed to the longest pattern



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

Date: 15 Mar 1998 23:13:17 GMT
From: Andy Tompkins <aet@aryth.webplanets.com>
Subject: Re: Socket IO, non echoed?
Message-Id: <6ehnad$4f$1@aginor.webplanets.com>

I hadn't thought of that, but several problems come to mind.
Although they aren't major...
What if you type your password in, but don't press enter, and for some
reason must leave.  Someone else comes up and changes your terminal
colors..hmmm
Is it possible to determine what color someone has set
foreground/background on there respective terminal? I'm not sure, but i
wouldn't think so.
I guess what im wondering is , what is the actual function of stty?
Does it only work on true ttys, and what IS a tty? Well, what is the
formal definition.
When you telnet to some port, say 6666 of a host, are you not using a tty?

Thanks
	--- andy

Sneex <chasecreek.systemhouse@usa.net> wrote:
> Although I haven't done this with perl, I would assume that the same action,
> using ANSI related modules on CPAN, probably could set the character
> foreground color to the background color thereby hiding it.

> /^Hmmm$/;
> Sneex :)



> Andy Tompkins wrote:

> > Suppose you have two IO::Socket objects, which are being passed around
> > among other objects.  One represents input, the other output, for a single
> > connection instance. (This is from the perspective of the server.)  I
> > would like to do a non echoed read from the input object.
> > As in , assume $cin and $cout are the objects.
> > $cout->print("password: ");
> > my $password = $cin->getline();
> > Ive tried stty echo/-echo, but it did not work.
> > I also tried Term::ReadKey. Also did not work.
> > Is it possible to do this?
> > Thanks
> >         --- andy





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

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

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