[9843] in Perl-Users-Digest
Perl-Users Digest, Issue: 3436 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 13 09:07:33 1998
Date: Thu, 13 Aug 98 06:00:51 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 13 Aug 1998 Volume: 8 Number: 3436
Today's topics:
$string = chomp <FILEHANDLE> ??? <tmgil@keg.cs.vu.nl>
Re: $string = chomp <FILEHANDLE> ??? (Maurice Aubrey)
Re: A glob - Problem (or a map ??) (Frank Zimmermann)
Re: A Regexp problem (Michael J Gebis)
Re: Access DB on same machine <perlguy@inlink.com>
Re: Analyzing HTTP traffic? <sidi@angband.org>
Converting to lowecase <hauk@forumnett.no>
Re: Converting to lowecase (Mark-Jason Dominus)
Re: Converting to lowecase (Dermot McKay)
Re: Converting to lowecase <perlguy@inlink.com>
Re: Date Question... <sidi@angband.org>
Re: File::Copy (Gabor)
Re: Free Web Stuff (-)
Re: HELP !!! Date without century !!! <perlguy@inlink.com>
Help: NT User ID, Full Name + Perl 5? <webmaster@sharbor.com>
Interaction with Access Database <admin@bwsd.com>
IO redirection on Win32 b_pillai@hotmail.com
Re: problem loading html page via perl location command (-)
Re: problem loading html page via perl location command (Maurice Aubrey)
Re: Q: How to read a file piece by piece (Mike Stok)
Read directory and not files (Chua Boon Yiang)
Re: Read directory and not files (Mark-Jason Dominus)
Re: Read directory and not files (M.J.T. Guy)
Re: Read directory and not files <perlguy@inlink.com>
Remove lines from output <admin@kewl.com.au>
Re: run external program from perl <sidi@angband.org>
Re: Run perl script "in-line"? <lee.davies@NOSPAMsaaconsultants.com>
using ssi-like in perl script <whermans@mail.dma.be>
Re: What is the purpose of Perl (Paddy Spencer)
Re: X-file (?=...), case postponed. (Patrick Timmins)
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 13 Aug 1998 11:03:45 GMT
From: "Thomer M. Gil" <tmgil@keg.cs.vu.nl>
Subject: $string = chomp <FILEHANDLE> ???
Message-Id: <6quh6h$3sf$1@star.cs.vu.nl>
Hi there,
I'm having a stupid problem here, and since
I'm very new to Perl I don't know the answer.
I'm trying to read a line from a file and
put its chomp-ed value in a scalar:
$string = chomp <FILEHANDLE>;
This gives an error.
I realize that I can give up and do it in
2 lines, but I'm stubborn and curious.
Is it possible?
Thanks,
Thomer
------------------------------
Date: Thu, 13 Aug 1998 11:22:03 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: $string = chomp <FILEHANDLE> ???
Message-Id: <slrn6t5j2s.4rt.maurice@we-24-130-48-83.we.mediaone.net>
On 13 Aug 1998 11:03:45 GMT, Thomer M. Gil <tmgil@keg.cs.vu.nl> wrote:
>
> I'm having a stupid problem here, and since
> I'm very new to Perl I don't know the answer.
>
> I'm trying to read a line from a file and
> put its chomp-ed value in a scalar:
>
> $string = chomp <FILEHANDLE>;
from 'perldoc -f chop' :
You can actually chop anything that's an lvalue, including an assignment:
chop($cwd = `pwd`);
chop($answer = <STDIN>);
--
Maurice Aubrey <maurice@hevanet.com>
If you can persuade your customer to tatoo your name on their chest,
they probably will not switch brands.
- An Indiana University professor on Harley-Davidson owners
------------------------------
Date: Thu, 13 Aug 1998 08:00:04 GMT
From: fz@hlsv.de (Frank Zimmermann)
Subject: Re: A glob - Problem (or a map ??)
Message-Id: <35d29a64.7943992@172.16.254.11>
On Thu, 13 Aug 1998 07:03:46 GMT, fz@hlsv.de (Frank Zimmermann) wrote:
>I want to get a file list of all (*.foo|*.bar) files in the current
>directory. (Working with linux/bash)
>
>I used
>
>@filelist = map{ glob($_)} "*.foo", "*.bar";
>
>But now it happens that some filenames have one or more
>space(s) in it: "firstpart__seconpart.foo"
>This gave me 2 nonsense entrys resp..
>"firstpart"
>"secondpart.foo"
>
>How can I solve this problem?
The following solution I just found out (are there better ones?):
opendir CURRDIR, "." or die "Problem...: $!";
@filelist = grep /(.*.foo|.*.bar)/, readdir CURRDIR;
closedir CURRDIR;
Frank.
--
Frank Zimmermann
HLSV / ZV4
Tel : 0511 8073 - 795
email: fz@hlsv.de
------------------------------
Date: 13 Aug 1998 06:35:42 GMT
From: gebis@fee.ecn.purdue.edu (Michael J Gebis)
Subject: Re: A Regexp problem
Message-Id: <6qu1fu$k@mozo.cc.purdue.edu>
abigail@fnx.com (Abigail) writes:
}BTW, 'regex' is much easier to pronounce than 'regexp'.
You can get through this newsgroup a lot faster if you don't read it
out loud.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 13 Aug 1998 11:59:40 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Access DB on same machine
Message-Id: <35D2D52C.DEB66BBE@inlink.com>
Go to http://www.roth.net/odbc
I do it all of the time with NT/IIS and the above URL is where I got all
of my information to get started...
Good luck,
Brent
------------------------------
Date: 13 Aug 1998 09:47:37 GMT
From: Chris Sidi <sidi@angband.org>
Subject: Re: Analyzing HTTP traffic?
Message-Id: <6qucnp$1o4$2@news-int.gatech.edu>
paydirt@freemail.yeehaa.com wrote:
> I don't think it would be possible for Perl to intercept traffic. For that to
> work, Perl would have to establish a listening connection on the port 80 which
> normally your webserver software uses. Since it is already being used by your
> webserver software, Perl will not listen on it.
It might not be straightforward at all, but could you write a packet sniffer in
perl to watch the port even though the web server has it?
I'M NOT RECOMMENDING THIS AS A SOLN, (especially since you need to have root
access right?)... I'm just curious if packet sniffers can be written in perl
instead of C.
-Sidi
------------------------------
Date: Thu, 13 Aug 1998 10:10:52 +0200
From: Hauk Langlo <hauk@forumnett.no>
Subject: Converting to lowecase
Message-Id: <35D29F8B.504D181E@forumnett.no>
Hi there, this should be an easy one. I only have to ask for help
because I do not have my exellent book at hand right now.
How do I convert all the word characters within $_[0] to lowercase. I
guess it must be something like this:
$_[0] =~ s/\w/SOMETHING/g;
Thanks on advance.
Regards
Hauk Langlo
--
----------------------------------
Hauk Langlo
Hauk@forumnett.no
http://www.forumnett.no/~hauk
(+047) 93438940
----------------------------------
------------------------------
Date: 13 Aug 1998 04:42:34 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Converting to lowecase
Message-Id: <6qu8tq$c1h$1@monet.op.net>
In article <35D29F8B.504D181E@forumnett.no>,
Hauk Langlo <hauk@forumnett.no> wrote:
>Hi there, this should be an easy one. I only have to ask for help
>because I do not have my exellent book at hand right now.
Hauk,
you have an exellent manual at hand right now, because it comes with
Perl. You can search in the manual like this:
perl -ne 'print "$ARGV: $_" if /lowercase/' *.pod
If you look at what comes out, you will see
perlfunc.pod: Returns an lowercased version of EXPR. This is the internal function
That tells you to look in `perlfunc.pod' for that phrase. When you
find it, you will have the answer you seek.
------------------------------
Date: Thu, 13 Aug 1998 09:54:22 GMT
From: MCKAYD@aplbt1.agw.bt.co.uk (Dermot McKay)
Subject: Re: Converting to lowecase
Message-Id: <6qudea$ovp$1@pheidippides.axion.bt.co.uk>
In article <35D29F8B.504D181E@forumnett.no>, Hauk Langlo <hauk@forumnett.no>
wrote:
>Hi there, this should be an easy one. I only have to ask for help
>because I do not have my exellent book at hand right now.
>
>How do I convert all the word characters within $_[0] to lowercase. I
>guess it must be something like this:
>
>$_[0] =~ s/\w/SOMETHING/g;
You can do this two ways.
$_[0] =~ s/$_[0]!\L$&!;
or
$_[0]=(lc($_[0]);
OK Dermot
------------------------------
Date: Thu, 13 Aug 1998 11:44:54 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Converting to lowecase
Message-Id: <35D2D1B6.134813A0@inlink.com>
Hauk Langlo wrote:
>
> Hi there, this should be an easy one. I only have to ask for help
> because I do not have my exellent book at hand right now.
You do not need any excellent books to look up Perl information. Go to
http://www.perl.com and click on "Documentation". There is enough there
to keep you busy for a while...
> How do I convert all the word characters within $_[0] to lowercase. I
> guess it must be something like this:
>
> $_[0] =~ s/\w/SOMETHING/g;
Nope, it is even easier.
$_[0]=lc($_[0]);
HTH,
Brent
------------------------------
Date: 13 Aug 1998 10:06:05 GMT
From: Chris Sidi <sidi@angband.org>
Subject: Re: Date Question...
Message-Id: <6qudqd$1o4$5@news-int.gatech.edu>
Larry Rosler <lr@hpl.hp.com> wrote:
> One obvious (now) fix is to add one hour to make sure the date is
> correct.
> Thanks for finding this bug.
[I cancelled two previous posts - sorry if you saw those]
Since we have to deal with Daylight Savings Time, I think we should
abstract the fix. Once you have the fix, finding a relative time (like
the past Sunday 3am) is straightforward math. (Also, I have to comment my
code for non-CS people to maintain, and I'd rather call a
subroutine/module than explain all the tricks/gotchas.)
I've been looking at the source of Time/Local.pm and Time-module's
ParseDate.pm to see how they deal with DST. See
http://angband.org/~sidi/pub_tmp/Time/ for the sources. They mess with
time offsets of GMT to the local time zone that I don't think buy us
anything for finding simple relative times.
I'm leaning towards the following subroutine... the code below also
includes some good test times and appears to handle them fine. I welcome
a more robust or efficient soln.
-Sidi
(Code also at http://angband.org/~sidi/pub_tmp/dst_check2.pl)
#!/usr/bin/perl -w
use strict;
my $debug = 1;
#pass in a time and a desired hour
#time will be shifted by +-3600 seconds if needed to match desired hour.
sub check_for_dst_shift {
my ($time, $target_hour) = @_;
my $test_hour = (localtime($time))[2];
if ($test_hour != $target_hour) {
if ( (localtime($time+3600))[2] == $target_hour ) {
$time += 3600;
warn "added 3600 seconds\n" if $debug;
}
elsif ( (localtime($time-3600))[2] == $target_hour ) {
$time -= 3600;
warn "subtracted 3600 seconds\n" if $debug;
}
else { #this block is somewhat optional
my $hours_off = abs($target_hour - $test_hour);
if ($hours_off > 1 and $hours_off != 23) {
die "check_for_dst_shift: time too far off from desired hour\n";
}
else {
warn "There is no $target_hour hour - it's leap forward day.\n"
if $debug;
}
}
}
return $time;
}
use Time::Local;
my @times_to_test = (
time(),
timelocal(0,45,0, 6,3,98), #less than 24hrs after spring forward
timelocal(0,45,0,26,9,98), #less than 24hrs after fall back
timelocal(0,30,2, 6,3,98), #there is no Apr 5 2:30am!
timelocal(0,30,1,26,9,98), #there are two Oct 25 1:30ams!
);
my $now;
for $now (@times_to_test) {
print "Now is $now: " . localtime($now) . "\n";
my $now_hour = (localtime($now))[2];
my $day_ago = $now - 24*60*60;
$day_ago = check_for_dst_shift($day_ago, $now_hour);
print "Day ago is $day_ago: " . localtime($day_ago) . "\n\n";
}
------------------------------
Date: 13 Aug 1998 12:14:45 GMT
From: gabor@vmunix.com (Gabor)
Subject: Re: File::Copy
Message-Id: <slrn6t5m70.af7.gabor@guava.vmunix.com>
In comp.lang.perl.misc, Russ Allbery <rra@stanford.edu> wrote :
# Gabor <gabor@vmunix.com> writes:
# > In comp.lang.perl.misc, Russ Allbery <rra@stanford.edu> wrote:
#
# >> Nope. You need to read them in from the source file and reapply them
# >> to the destination, and I don't know of a platform-independent way of
# >> doing that. For Unix, you'd do something like:
#
# > If you use File::NCopy, it will do it for you. Plus it can recursively
# > copy directories or more than one file to a directory.
#
# I assume that it still doesn't solve the platform-independence problem?
No, but if people are willing to contribute to me any way to do it on
their platfrom, I will try and add it. I only program for Unix so I
don't know and don't have the time to research it. But I do have access
to NT at least to implement it.
The recursive copy and the copy of multiple sources to a single
directory should work everywhere. Plus, it takes globs(?* in names). :)
------------------------------
Date: Thu, 13 Aug 1998 12:12:36 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: Free Web Stuff
Message-Id: <35d2d7e6.158534685@news2.cais.com>
comdog@computerdog.com (brian d foy) Said this:
>In article <6qsdg5$l3p$1@nnrp1.dejanews.com>, veronica@iminet.com posted:
>
>>This is the new wave on the Internet. Add interactivity to your site.
>
>yeah, welcome to 1994!
>
Shit, that was even old-hat by 1994. "new wave" wow! Golly, I should
get my hula hoop and watch old episodes of gilligan's island!!!
>i wonder which version of Perl this uses *snicker*
Probably perl 4? Maybe?
------------------------------
Date: Thu, 13 Aug 1998 12:05:24 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: HELP !!! Date without century !!!
Message-Id: <35D2D684.22464F37@inlink.com>
Laurent MARTIN wrote:
>
> Hi !
>
> I'm working with Perl for a few days and I've got a trouble with dates :
> localtime(time) doesn't return any century indication. How can I get
> dates on 4 digits instead of 2 digits ?
You HAVE documentation! Go to http://www.perl.com and click on
"Documentation"
You may also want to read the FAQs.
> I'm sure you know the answer, so please mail it to me
> (laurent@gide.isdnet.net) 'cause I'm not coming there very often. Thank
> you !!!
Sorry, post it here, read it here...
HTH,
Brent
------------------------------
Date: Thu, 13 Aug 1998 07:46:05 -0500
From: "Jeffrey D. Hoffman" <webmaster@sharbor.com>
Subject: Help: NT User ID, Full Name + Perl 5?
Message-Id: <35D2E00D.6AD5@teldta.com>
Using Win32::NetAdmin I can query our Windows NT 4.0 Domain Server for a
list of users and the array returned includes every user's ID but not
their full name. I need both.
Is this a limitation of NetAdmin or is it the NT network that is not
returning the user's full name?
Is there an alternative to Win32::NetAdmin that returns the users ID and
the user's real name?
Thanks in advance!
------------------
Jeffrey D. Hoffman, TDS Computing Services
------------------------------
Date: Thu, 13 Aug 1998 05:44:53 -0500
From: Beck Web Servers & Design <admin@bwsd.com>
Subject: Interaction with Access Database
Message-Id: <35D2C3A5.BFB9726E@bwsd.com>
Is it possible to interact with a Microsoft Access Database file sitting
on a Unix box running Apache? I know there's a module, but has anyone
written a script to interact with an MS Access file. The server has
FrontPage extensions installed, but as far as I can tell, FrontPage db
connectivity will only work with a Microsoft server. If anyone can
point me in the right direction, with a sample script, or one that's in
action with the code, I'd appreciate it.
Thanks,
--
Eric Beck, BWSD
http://web-design.net/index.shtml
mailto:admin@web-design.net
Phone: 905 436 6814 Fax: 905 725 4023
============================================================
BECK WEB SERVERS & DESIGN - WHERE SUPPORT AND SERVICE ARE #1
============================================================
------------------------------
Date: Thu, 13 Aug 1998 09:32:11 GMT
From: b_pillai@hotmail.com
Subject: IO redirection on Win32
Message-Id: <6qubqr$b1e$1@nnrp1.dejanews.com>
Hi,
I am very new to the world of perl. I am porting some perl
scripts from UNIX to NT. I have perl 5.004_02.
The scripts are using dup2, exec, fork calls.
Can someone please help me out suggesting a way
or a equivalent command on perl for Win32.
Thanks in advance
Biju
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: Thu, 13 Aug 1998 12:09:40 GMT
From: root.noharvest.\@not_even\here.com (-)
Subject: Re: problem loading html page via perl location command
Message-Id: <35d2d4bd.157725626@news2.cais.com>
jackass@freewwweb.com (Joshua Weinberg) Said this:
>
>I have a mysterious problem that's just cropped up. I have a CGI
>script that checks for membership status on a password protected
>page. Once everything checks out then viola;
>
>print "Location: /$file/index.html", "\n\n";
>
>exit( 0 );
>
>
>
>
>the &file is passed by html and is the subdirectory name where
>the user wants to go. All this has been working like gangbusters
>except for all of the sudden now instead of loading the pages.
>index.html (which is a frame document) loads, but the subsequent
>html that should load into the frame cannot be found because the
>browser is looking for them in the cgi-bin directory.
>
>I've tried including:
>
>chdir("../../htdocs/$file") || die "Cannot chdir to /$file: $!" ;
>
>print "Location: /$file/index.html", "\n\n";
>
>exit( 0 );
>
>before the print location but it still doesn't get out of the
>CGI-BIN. What's happening? Why all of the sudden does the
>simple print location statement not work? Is there something
>about the statement syntax that is incorrect?
This problem has nothing to do with perl. Perl is functioning just
fine here, it's doing exactly what you've told it to do. The problem
is with your knowledge of HTML and HTTP headers.
When you send a header like
Location: /directory/index.html
The browser appends that to the current directory, so obviously if you
call this script located in
http://www.server.com/cgi-bin/redirect/blah.pl, the resulting
Location: header after appending is
http://www.server.com/cgi-bin/redirect/directory/index.html
This is a "relative URL" you are handing to the web browser, as
opposed to a "fully qualified URL". Your solution should be something
like this:
print "Location: http://www.blah.com/$file/index.html\n\n";
>
>Any help would be appreciated and please email your comments
>to;
>
>jackass@freewwweb.com
>
>As I don't follow newsgroup threads effectively.
You shouldn't expect personalized help from Usenet, it's a public
forum. If you ask a question here, look for your answer here.
------------------------------
Date: Thu, 13 Aug 1998 12:57:36 GMT
From: maurice@hevanet.com (Maurice Aubrey)
Subject: Re: problem loading html page via perl location command
Message-Id: <slrn6t5om2.513.maurice@we-24-130-48-83.we.mediaone.net>
On Thu, 13 Aug 1998 12:09:40 GMT, root.noharvest.\@not_even\here.com
<root.noharvest.\@not_even\here.com> wrote:
>This problem has nothing to do with perl. Perl is functioning just
>fine here, it's doing exactly what you've told it to do. The problem
>is with your knowledge of HTML and HTTP headers.
>
>When you send a header like
>
>Location: /directory/index.html
>
>The browser appends that to the current directory, so obviously if you
>call this script located in
>http://www.server.com/cgi-bin/redirect/blah.pl, the resulting
>Location: header after appending is
>http://www.server.com/cgi-bin/redirect/directory/index.html
>
>This is a "relative URL" you are handing to the web browser, as
>opposed to a "fully qualified URL". Your solution should be something
>like this:
Hmmm...
perl -MURI::URL -e "print (url ('/directory/index.html',
'http://www.server.com/cgi-bin/redirect/blah.pl')->abs)"
http://www.server.com/directory/index.html
--
Maurice Aubrey <maurice@hevanet.com>
I have made this letter longer than usual because I lack the time
to make it shorter.
- Blaise Pascal
------------------------------
Date: 13 Aug 1998 12:43:11 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Q: How to read a file piece by piece
Message-Id: <6qun0v$qiu@news-central.tiac.net>
In article <6qtjfa$b0h$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>Because of standard I/O buffering, you have probably written the tar
>data before the HTTP header here. You really need to have
>>sub Send_As_tgz {
> my $old_bar = $|;
> $| = 1;
>> print "Content-Type: application/zip\n";
>> print "Content-Disposition: attachment; filename=\"$file_name.tgz\"\n\n";
>> system $TAR, '-C', $Rwhere, 'czf', '-', $who;
> $|=$old_bar;
>>}
What's wrong with using local to automatically save and restore $| e.g.
sub Send_As_tgz {
local $| = 1;
...
}
... or is using local these days considered as politically incorrect as
using goto ?
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: Thu, 13 Aug 1998 08:27:24 GMT
From: chuaby@hotmail.com (Chua Boon Yiang)
Subject: Read directory and not files
Message-Id: <35d2a301.26551382@news.cyberway.com.sg>
Hi
I am using perl on NT. Just wondering if there is anyway just to read
the directories name and not filenames using readdir() function ?
Thanks
Boon Yiang
------------------------------
Date: 13 Aug 1998 05:08:47 -0400
From: mjd@op.net (Mark-Jason Dominus)
Subject: Re: Read directory and not files
Message-Id: <6quaev$c28$1@monet.op.net>
In article <35d2a301.26551382@news.cyberway.com.sg>,
Chua Boon Yiang <chuaby@hotmail.com> wrote:
>I am using perl on NT. Just wondering if there is anyway just to read
>the directories name and not filenames using readdir() function ?
No, but you can use
@directories = grep {-d} readdir D;
to get a list of only directories.
------------------------------
Date: 13 Aug 1998 11:02:50 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Read directory and not files
Message-Id: <6quh4q$een$1@pegasus.csx.cam.ac.uk>
In article <6quaev$c28$1@monet.op.net>, Mark-Jason Dominus <mjd@op.net> wrote:
>In article <35d2a301.26551382@news.cyberway.com.sg>,
>Chua Boon Yiang <chuaby@hotmail.com> wrote:
>>I am using perl on NT. Just wondering if there is anyway just to read
>>the directories name and not filenames using readdir() function ?
>
>No, but you can use
>
> @directories = grep {-d} readdir D;
>
>to get a list of only directories.
That'll only work if the directory happens to be the current directory.
Otherwise you'll need to use something like
@directories = grep {-d "$dir/$_"} readdir D;
And you probably want to treat "." and ".." specially.
Mike Guy
------------------------------
Date: Thu, 13 Aug 1998 11:37:03 GMT
From: Brent Michalski <perlguy@inlink.com>
Subject: Re: Read directory and not files
Message-Id: <35D2CFDF.8C6063D7@inlink.com>
I use the below code to read my subdirectory structure. Although it
still reads the filenames with readdir, I only store the directory names
in the array @dirs.
To use it, set $start to the directory you want the subroutine to start
at and then call it. It will get all of the subdirectories and store
them in the @dirs array. Then, just run through the @dirs array to do
whatever you want to do with each subdirectory name.
This subroutine, combined with some of the NT command-line utilities is
great! I used it along with the "showacls" program to generate a copy
of all rights on my NT system.
Good luck!
Brent
-----------------
$start="c:/";
&GetDirs($start);
sub GetDirs{
my $start=$_[0];
opendir(DIR,$start) || die "Error $! opening directory.";
my(@filenames) = readdir(DIR);
close(DIR);
foreach $list (@filenames){
my $fullpath=$start."/".$list;
if(-d $fullpath){
if($list !~ /^(\.{1,2})$/){
push @dirs, $fullpath;
&GetDirs($fullpath); # Recursive call
}
}
}
} # End of sub GetDirs
------------------------------
Date: Thu, 13 Aug 1998 22:53:53 +1000
From: "Craig Nuttall" <admin@kewl.com.au>
Subject: Remove lines from output
Message-Id: <6qunjr$5in$1@nswpull.telstra.net>
This does what I want.
for (keys %ppp) {
my ($port, $timeon, $pid) = split /\s+/, $ppp{$_};
if ($port ne "ttyE60,") {
print "$port $timeon $pid\n";
}
}
how do I remove more than just ttyE60, from the report
eg ttyE60 and ttyE61 and etc etc
Any help appreciated
Craig
admin@kewl.com.au
The effort of learning provides the gift of teaching :-)
------------------------------
Date: 13 Aug 1998 09:41:22 GMT
From: Chris Sidi <sidi@angband.org>
Subject: Re: run external program from perl
Message-Id: <6qucc2$1o4$1@news-int.gatech.edu>
paydirt@freemail.yeehaa.com wrote:
> I don't know how well this would fit your situation, but there was
> another post similar to yours. I would recommend the same thing. Look
> into a language called Expect. It is not hard to learn, and it works
> well with existing applications, and Perl too.
> ~Prime
If he just wants to kick the program off, and wait for it to finish before
continuing the perl script, he wants system() or backticks in perl. If he wants
to kick it off and immediately continue executing the perl script, never
checking on it's status, I guess he'd put a "&" in the system command string.
If he needs to control a program interactively, "pretending to be a user",
then he'll want Expect... Expect is sorta like those modem dialin macros
with commands similar to "waitfor 'password:'; put $password;"
-Sidi
------------------------------
Date: Thu, 13 Aug 1998 08:39:15 GMT
From: "Lee Davies" <lee.davies@NOSPAMsaaconsultants.com>
Subject: Re: Run perl script "in-line"?
Message-Id: <TCxA1.1095$xR1.117426@news-reader.bt.net>
Andreas Hack wrote in message <35d1f87b.6269144@linux>...
>Lee,
>
>do you want information about the web-server, or about the client?
>Andreas Hack
I need information about the server - hostname, port, IP address etc.
------------------------------
Date: Thu, 13 Aug 1998 13:37:35 +0200
From: "Wouter Hermans" <whermans@mail.dma.be>
Subject: using ssi-like in perl script
Message-Id: <6quj7g$675$1@xenon.inbe.net>
hi
ok i'm a rather newbie on perl cgi, but i need rather urgently a way to read
in a html file and show it through the cgi.
this is the setup:
the site uses on each page some ssi for showing buttons and text. on my iis
server it doesn't seem possible to make a print "<!--#include
file="blah.html"-->"; in the script. it just shows <!--#include
file="blah.html"--> when you look at the source of the page the search cgi
has generated.
so i need a way to read the full contents of a file in another directory on
the server, and display it...
thanks
wouter hermans
------------------------------
Date: Thu, 13 Aug 1998 10:14:37 GMT
From: paddy.spencer@parallax.co.uk (Paddy Spencer)
Subject: Re: What is the purpose of Perl
Message-Id: <903003277.683913@red.parallax.co.uk>
Kello Wed, 12 Aug 1998 22:09:07 GMT, gburnore@databasix.com (Gary L.
Burnore) kirjoittanut:
: On Wed, 12 Aug 1998 21:49:14 GMT, in article
: <6qt2qc$kje$1@ligarius.ultra.net>, sowmaster@juicepigs.com (Bob Trieger)
: wrote:
: >#!/usr/local/bin/perl -w
: >use strict;
: >
: >print 'Let there be light';
: >my %Adam = ( 'rib' => 'wife');
So you're saying that when God made the first man, he made a hash of
him?
I can relate to that...
--
Paddy Spencer
Parallax Solutions Ltd (http://www.parallax.co.uk/)
------------------------------
Date: Thu, 13 Aug 1998 08:15:13 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: X-file (?=...), case postponed.
Message-Id: <6qu7ag$74s$1@nnrp1.dejanews.com>
In article <1ddo5ve.bugjws54wh1oN@bay2-150.quincy.ziplink.net>,
rjk@coos.dartmouth.edu (Ronald J Kimball) wrote:
> Patrick Timmins <ptimmins@netserv.unmc.edu> wrote:
>
> [discussion of split(/(?=(.*)/)]
>
> > My arguement is consistent with the above fine documentation. The
> > argument is over *when* does a parenthetical substring in a split
> > throw its' matching substring into the array? As specified in the
> > fine documentation a few lines down from your citing of the fine
> > documentation:
> >
> > If the PATTERN contains parentheses, additional array elements are
> > created from each matching substring in the delimiter.
>
> The delimiters are put in the array between the elements they delimit,
> of course.
Where did it say that?
>
> > So I'm just arguing that this should follow common sense and
> > mathematical form. Since '(.*)' is enclosed in '(?=..)' and then in
> > the '/../' of split, it should be evaluated first [ the way '(1+3)'
> > is evaluated first in 'sqrt(4*(1+3))' ]. Just because you know
> > sqrt(0*(1+3)) is going to equal zero before you ever get to evaluating
> > the '(1+3)', doesn't mean that you should skip over evaluating the
> > '(1+3)', mathematically.
>
> If split used mathematical expressions instead of regular expressions,
> this might have some relevance.
>
> Regular expressions are not evaluated from the inside out, they are
> evaluated from left to right. If you insist on viewing the first
> argument to split as a mathematical expression, you're never going to
> get it.
I don't insist, and I already get it. I'm just saying it could be
unambiguous, but instead it isn't, because no where is it mentioned
*when* the delimiters get throw into the array. And as far as the left
to right bit, there is such a thing as back tracking, you know. :)
Quick! Tell me what is in $1 before you evaluate what is in $2:
$_ = "boink";
/(.*)(oink)/;
or, doing inside out, just like a mathematical expression:
$_ = "boink";
/(boink(not!))/
The left to right numbering of $1, $2, etc, is to make it easy on us,
but regexes backtrack, and do, indeed, enforce mathematical rules of
precedence. That *is* relevant in my book.
>
> Otherwise I guess that /(ab(cd)ef)/ put 'cd' in $1 and 'abcdef' in $2...
Again, the numbering argument is silly. I don't care what they're called,
in your example you will never know what is in $1 until you evaluate what is
in $2, just like a mathematical expression.
>
> > Logically, I would expect Perl to do this with split, and the first
> > element of the array should be the delimiter specified by '(.*)',
> > which would be the whole EXPR, if '(.*)' were, logically, the first thing
> > being evaluated.
>
> Suppose the string being split is 'a|b|c'. So, you want to put the
> delimiter *before* the first element?? split(/(\|)/, 'a|b|c') would
> return ('|', 'a', '|', 'b', 'c') or something like that. That's hardly
> logical...
No. That *is* illogical. Why would it throw out a parenthetical delimiter
before it has reached one? That would be just as illogical as throwing out
a 'J' before a 'Just another Perl Hacker\n' delimiter in:
split/(?=(.*))/s, "Just another Perl Hacker\n";
since, as we have shown, the (.*) should properly be evaluated
before the (?= ..)
>
> Logically, the first element of the array should be the first element of
> the delimited string. And that's how split works.
Really, I could have sworn I read somewhere, and I quote:
"If the PATTERN contains parentheses, additional array elements are
created from each matching substring in the delimiter."
You would think that if these delimiter substrings were encountered
*before* any other characters in EXPR, that this would get thrown on
to the array first in something like:
split/(?=(.*))/s, "Just another Perl Hacker\n";
since, as we have shown, the (.*) should properly be evaluated
before the (?= ..)
>
> > Since Perl doesn't do this logical sort of thing (and maybe for good
> > reason, as pointed out by Dave Lorand), it confused me. Since this
> > little bit of straying from logic isn't mentioned in the fine
> > documentation, it makes seeing sigs in the ilk of
> >
> > @arr = split /(?=(.*))/s , "Just another Perl Hacker\n";
> > for (@arr) { print "$_"; }
> >
> > doubly confusing, as I'm sure you'll agree! :)
>
> No, I would not agree. Perl is being quite logical.
Perl is many things to many people, I guess. Some more than others.
>
> for (1..100) {
> print "mathematical expressions != regular expressions\n";
> }
>
true, but tack on to that:
while (logical) {
print "RE's obey mathematical parenthetical rules of precedence\n";
}
Patrick Timmins
U. Nebraska Medical Center
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp Create Your Own Free Member Forum
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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 3436
**************************************