[12496] in Perl-Users-Digest
Perl-Users Digest, Issue: 6096 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jun 22 15:07:19 1999
Date: Tue, 22 Jun 99 12:00:22 -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 Tue, 22 Jun 1999 Volume: 8 Number: 6096
Today's topics:
Re: [Req:] Date::Abigail <cassell@mail.cor.epa.gov>
Re: A month behind using localtime(time) ? (Bart Lateur)
Re: aarrggghhh opening a file... <crt@highvision.com>
Re: cannot use |- multiple times (Dave Meyer)
Re: DIE DIE DIE Prisoners of Bill <upsetter@ziplink.net>
Re: function to read a line & return it (Larry Rosler)
Help - PERL - DBI install johnbishop@my-deja.com
Help - PERL - DBI install johnbishop@my-deja.com
Re: How many questions about localtime? <cassell@mail.cor.epa.gov>
Re: how to remove spaces in a line <srishti@vsnl.com>
Re: Interpreting MS-ASCII - anyone have a filter? (Kenny McCormack)
Re: Looking for very small, basic bulletin board system <cassell@mail.cor.epa.gov>
move file pointer? bing-du@tamu.edu
Re: move file pointer? <tchrist@mox.perl.com>
Re: multidimensional arrays with functions push and pop <cassell@mail.cor.epa.gov>
Multiple command args... <daedalus@nokturnal.com>
Perl Modules and Win98 (Andrea Busia)
Re: Perl Modules and Win98 <craig@mathworks.com>
Re: printing multiple lines <srishti@vsnl.com>
Re: read files in Perl <tchrist@mox.perl.com>
Re: Recursive Delete (Larry Rosler)
Re: Safe expression evaluation <cassell@mail.cor.epa.gov>
Re: Statistics for comp.lang.perl.misc (Matt Knecht)
unable to create or rename files in subdirectories (JQ)
Re: unable to create or rename files in subdirectories <tchrist@mox.perl.com>
What am I missing? <tom.kralidis@ccrs.nrcanDOTgc.ca>
Re: What am I missing? <anfi@bigfoot.com>
Re: What is First line in Perl5 in Sun Micro... <cassell@mail.cor.epa.gov>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 Jun 1999 11:07:09 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: [Req:] Date::Abigail
Message-Id: <376FD0CD.7449C876@mail.cor.epa.gov>
Abigail wrote:
>
> Lee (rlb@intrinsix.ca) wrote on MMCXX September MCMXCIII in
> <URL:news:B394004B9668E2912D@204.112.166.88>:
> ^^ Have you considered making your date functions available to the great
> ^^ unwashed masses? And may I request an update for WebTV time?
>
> One of my sigs does.
Errm, are you sure WebTV users can *tell* time?
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 22 Jun 1999 17:54:07 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: A month behind using localtime(time) ?
Message-Id: <3770cd5f.2673309@news.skynet.be>
Eric The Read wrote:
>Did you actually read the documentation of localtime? If you had, you'd
>have seen this behaviour explicitly documented.
>
>> Does that mean that January is $mon 0 ?
>
>Wow, you *are* good.
perldoc -f localtime
-->
# 0 1 2 3 4 5 6 7 8
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time);
All array elements are numeric, and come straight out of
a struct tm. In particular this means that `$mon' has
the range `0..11' and `$wday' has the range `0..6' with
sunday as day `0'.
Nope. It says that the range for the months is 0..11, but it doesn't say
which month is 0.
Bart.
------------------------------
Date: Tue, 22 Jun 1999 17:51:21 GMT
From: Casey Tweten <crt@highvision.com>
Subject: Re: aarrggghhh opening a file...
Message-Id: <7koiek$fcl$1@nnrp1.deja.com>
In article
<Pine.GSO.4.02A.9906220903360.1698-100000@user2.teleport.com>,
Tom Phoenix <rootbeer@redcat.com> wrote:
> > open IDOUT, ">$forumfile" || die "Couldn't open: $!";
>
> That's a good try, but it's not doing what you want. Check the
precedence
> chart and try again. Cheers!
*oye* open ( IDOUT, ">$forumfile" ) || die "Couldn't open: $!";
Thanks Tom
--
<joke>
This is 100% certifiable,
Virus Free Code.
</joke>
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 22 Jun 1999 18:14:06 GMT
From: dmeyer@virtc.com (Dave Meyer)
Subject: Re: cannot use |- multiple times
Message-Id: <7kojkf$3cv$1@jhereg.dmeyer.org>
According to Tom Phoenix <rootbeer@redcat.com>:
> On Mon, 21 Jun 1999, Dave Meyer wrote:
>
> > I'm trying to use the |- argument to open() to fork several child
> > processes which the parent can communicate with. If I try this with
> > one child, I get the behavior I expect; if I try this with two (or
> > more) children, my program blocks trying to write to the second child.
>
> The problem seems to be that the second child still has a filehandle open
> for writing to the first. But if you close a piped filehandle, you have to
> wait for that process to finish.
>
> Instead, you should fork the child processes with fork(), "manually"
> setting up the pipe to each one. Then, each child process should close the
> pipes to the others. Since you didn't create these with a piped open, Perl
> won't wait for the other process to quit.
Thanks for the help. It turns out that I don't need a manual fork() -
if I save the filehandle after the gensym but before the open("|-"), I
can just have the children close the filehandles. The revised test
program is attached, in case anyone's interested.
#!/usr/bin/perl
use strict;
use Symbol;
my $num_children=$ARGV[0];
select(STDOUT); $|=1;
my @kids=();
for (my $i=0; $i<$num_children; ++$i) {
my $fh=gensym();
push(@kids, { 'fh' => $fh } );
my $pid=open($fh,"|-");
die "Problem forking" unless defined($pid);
$kids[$i]->{'pid'}=$pid;
if ($pid == 0) {
# child
foreach (@kids) {
close($_->{'fh'});
}
print "child $i ($$): listening\n";
while (<STDIN>) {
print "child $i ($$): got $_";
}
print "child $i ($$): exiting\n";
exit(0);
}
# parent
print "parent: self=$$,child=$pid\n";
}
my $ctr=0;
foreach (@kids) {
my $pid=$_->{'pid'};
my $fh=$_->{'fh'};
print "sending to $pid\n";
print $fh "SEND $pid\n";
}
foreach (@kids) {
close($_->{'fh'});
waitpid($_->{'pid'},0);
print $_->{'pid'}," gone\n";
}
print "success\n";
exit(0);
--
David M. Meyer
meyer@virtc.com
------------------------------
Date: Tue, 22 Jun 1999 18:46:35 GMT
From: Scratchie <upsetter@ziplink.net>
Subject: Re: DIE DIE DIE Prisoners of Bill
Message-Id: <fSQb3.956$7X1.243640@news.shore.net>
Steffen Beyer <sb@sdm.de> wrote:
: Why not just ignoring them?
: You're making your life miserable yourself.
: Relax, calm down! Go fishing! Or whatever relaxes you. :-)
Unfortunately, I think this *is* what relaxes him! :)
--Art
--
--------------------------------------------------------------------------
National Ska & Reggae Calendar
http://www.agitators.com/calendar/
--------------------------------------------------------------------------
------------------------------
Date: Tue, 22 Jun 1999 11:17:44 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: function to read a line & return it
Message-Id: <MPG.11d97320c25f0f63989c1c@nntp.hpl.hp.com>
In article <376FBB13.BE2A843C@mail.cor.epa.gov> on Tue, 22 Jun 1999
09:34:27 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
...
> @time_stuff = localtime;
> $time_stuff = localtime;
>
> for example. It actually isn't fragile at all. However,
> sometimes the *programmer* is the fragile component of the
> system. :-)
The fragile part is the semantic distinction between
my $x;
and
my($x);
'my' is documented in perlfunc, so it must be a function, right? And
the parentheses around the arguments to a function are optional, right?
Of course, 'my' is not a function, and the operands are not arguments,
and the parenthesis have semantics.
my $x; # This is 'my EXPR;'
and
my($x); # This is 'my LIST;'
The distinction between those two cases is not intuitive, to say the
least!
And then we get into:
my $x, $y; # WRONG!
and
my($x, $y); # This is 'my LIST;'
So one really should sympathize with the problems of Perl novices in
regard to scalar vs list context.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 22 Jun 1999 17:57:07 GMT
From: johnbishop@my-deja.com
Subject: Help - PERL - DBI install
Message-Id: <7koipc$fh0$1@nnrp1.deja.com>
We are struggling with the install of DBI 1.08 on AIX on an SP2.
Can someone help me out on this - I'm more of a DBA than UNIX admin.
Has my license expired? Our admin says that the compiler should be
fine.
Here's the output.
# perl Makefile.PL
*** Note:
The optional PlRPC-modules (RPC::PlServer etc) are not installed.
If you want to use the DBD::Proxy driver and DBI::ProxyServer
modules, then you'll need to install the RPC::PlServer,
RPC::PlClient,
Storable and Net::Daemon modules. The DBI CPAN Bundle may help you.
You can install them any time after installing the DBI.
You do *not* need these modules for typical DBI usage.
Optional modules are available from any CPAN mirror, in particular
http://www.perl.com/CPAN/modules/by-module
http://www.perl.org/CPAN/modules/by-module
ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module
Writing Makefile for DBI
Remember to actually *read* the README file!
Build, TEST and INSTALL Perl 5 first.
Do NOT build the DBI under the Perl source tree.
Use 'make test' to execute self tests.
Use 'make install' to install the DBI and then delete this working
directory before unpacking and building any DBD::* drivers.
# make
cc -c -qmaxmem=8192 -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -I/usr/local/include -O -DVERSION=\"1.08\"
-DXS_VERSION=\"1.08\" -I/usr/local/lib/perl5/aix/5.00404/CORE
-DDBI_NO_THREADS Perl.c
1506-333 (S) License failure: acquire: No servers available for this
vendor (network license server/library).
make: 1254-004 The error code from the last command is 1.
Stop.
Here's our version
# perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=aix, osvers=4.2.1.0, archname=aix
uname='aix willard 2 4 004246d04c00 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O', gccversion=
cppflags='-qmaxmem=8192 -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -I/usr/local/include'
ccflags ='-qmaxmem=8192 -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=1, d_casti32=define, d_castneg=undef
intsize=4, alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='ld', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lnsl -ldbm -ldl -lld -lm -lc -lbsd -lPW
libc=/lib/libc.a, so=a
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='-bE:perl.exp'
cccdlflags=' ', lddlflags='-H512 -T512 -bhalt:4 -bM:SRE
-bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -b noentry -lc
-L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under aix
Compiled at May 7 1998 16:01:33
@INC:
/usr/local/lib/perl5/aix/5.00404
/usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/aix
/usr/local/lib/perl5/site_perl
Here's my PATH
PATH=/usr/lpp/ssp/rcmd/bin:/bin:/usr/bin:/usr/sbin:/etc:/usr/ucb:/usr/bi
n/X11:/usr/local/bin:/local/sysadm:/local/bin:.:/usr/lpp/ssp/bin:/usr/lp
p/ssp/kerberos/bin:/usr/UniInstall/services/bin:/usr/UniInstall/services
/tools:/usr/UniInstall/agents/bin:/var/ifor:/usr/opt/ifor/ls/conf
Any help is appreciated!
JB
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 22 Jun 1999 18:00:14 GMT
From: johnbishop@my-deja.com
Subject: Help - PERL - DBI install
Message-Id: <7koiv6$fkk$1@nnrp1.deja.com>
We are struggling with the install of DBI 1.08 on AIX on an SP2.
Can someone help me out on this - I'm more of a DBA than UNIX admin.
Has my license expired? Our admin says that the compiler should be
fine.
Here's the output.
# perl Makefile.PL
*** Note:
The optional PlRPC-modules (RPC::PlServer etc) are not installed.
If you want to use the DBD::Proxy driver and DBI::ProxyServer
modules, then you'll need to install the RPC::PlServer,
RPC::PlClient,
Storable and Net::Daemon modules. The DBI CPAN Bundle may help you.
You can install them any time after installing the DBI.
You do *not* need these modules for typical DBI usage.
Optional modules are available from any CPAN mirror, in particular
http://www.perl.com/CPAN/modules/by-module
http://www.perl.org/CPAN/modules/by-module
ftp://ftp.funet.fi/pub/languages/perl/CPAN/modules/by-module
Writing Makefile for DBI
Remember to actually *read* the README file!
Build, TEST and INSTALL Perl 5 first.
Do NOT build the DBI under the Perl source tree.
Use 'make test' to execute self tests.
Use 'make install' to install the DBI and then delete this working
directory before unpacking and building any DBD::* drivers.
# make
cc -c -qmaxmem=8192 -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -I/usr/local/include -O -DVERSION=\"1.08\"
-DXS_VERSION=\"1.08\" -I/usr/local/lib/perl5/aix/5.00404/CORE
-DDBI_NO_THREADS Perl.c
1506-333 (S) License failure: acquire: No servers available for this
vendor (network license server/library).
make: 1254-004 The error code from the last command is 1.
Stop.
Here's our version
# perl -V
Summary of my perl5 (5.0 patchlevel 4 subversion 4) configuration:
Platform:
osname=aix, osvers=4.2.1.0, archname=aix
uname='aix willard 2 4 004246d04c00 '
hint=recommended, useposix=true, d_sigaction=define
bincompat3=y useperlio=undef d_sfio=undef
Compiler:
cc='cc', optimize='-O', gccversion=
cppflags='-qmaxmem=8192 -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -I/usr/local/include'
ccflags ='-qmaxmem=8192 -D_ALL_SOURCE -D_ANSI_C_SOURCE
-D_POSIX_SOURCE -I/usr/local/include'
stdchar='unsigned char', d_stdstdio=define, usevfork=false
voidflags=15, castflags=1, d_casti32=define, d_castneg=undef
intsize=4, alignbytes=8, usemymalloc=n, prototype=define
Linker and Libraries:
ld='ld', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib /usr/ccs/lib
libs=-lnsl -ldbm -ldl -lld -lm -lc -lbsd -lPW
libc=/lib/libc.a, so=a
useshrplib=false, libperl=libperl.a
Dynamic Linking:
dlsrc=dl_aix.xs, dlext=so, d_dlsymun=undef, ccdlflags='-bE:perl.exp'
cccdlflags=' ', lddlflags='-H512 -T512 -bhalt:4 -bM:SRE
-bI:$(PERL_INC)/perl.exp -bE:$(BASEEXT).exp -b noentry -lc
-L/usr/local/lib'
Characteristics of this binary (from libperl):
Built under aix
Compiled at May 7 1998 16:01:33
@INC:
/usr/local/lib/perl5/aix/5.00404
/usr/local/lib/perl5
/usr/local/lib/perl5/site_perl/aix
/usr/local/lib/perl5/site_perl
Here's my PATH
PATH=/usr/lpp/ssp/rcmd/bin:/bin:/usr/bin:/usr/sbin:/etc:/usr/ucb:/usr/bi
n/X11:/usr/local/bin:/local/sysadm:/local/bin:.:/usr/lpp/ssp/bin:/usr/lp
p/ssp/kerberos/bin:/usr/UniInstall/services/bin:/usr/UniInstall/services
/tools:/usr/UniInstall/agents/bin:/var/ifor:/usr/opt/ifor/ls/conf
Any help is appreciated!
JB
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: Tue, 22 Jun 1999 11:37:32 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How many questions about localtime?
Message-Id: <376FD7EC.43B67EBF@mail.cor.epa.gov>
Matt Sergeant wrote:
>
> How many questions about the return values of localtime() does it take
> before one goes mad reading this ng?
>
> Answers on a postcard.
Sorry, I've already gone mad. I can't answer, since they
don't let me have have sharp objects like pens and pencils
anymore. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 23 Jun 1999 00:15:14 +0530
From: srishti <srishti@vsnl.com>
To: weiq@cs.dal.ca
Subject: Re: how to remove spaces in a line
Message-Id: <376FD9BA.EC61E9B1@vsnl.com>
use
s/^ *//;
^ here represents begining of line.
write back in case of some problem,
Deepak.
weiq@cs.dal.ca wrote:
>
> Hi, Friends
>
> I am wondering if anyone can help me how to remove the spaces in the
> begining of a new line
>
> such as when user entered
> " there are 11 or more spaces in the front"
> -----------------------------------------------
> What I want is: remove all the spaces in the begining and
> let the spaces in other places unchanged. Such as:
>
> "there are 11 or more spaces in the front"
>
> Thanks and have nice day
>
> Wei
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
------------------------------
Date: 22 Jun 1999 12:58:17 -0500
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: Interpreting MS-ASCII - anyone have a filter?
Message-Id: <7koirp$a4t$1@yin.interaccess.com>
In article <MPG.11d94cadced59426989c1a@nntp.hpl.hp.com>,
Larry Rosler <lr@hpl.hp.com> wrote:
>[Posted and a courtesy copy sent.]
>
>In article <376f9a38@cs.colorado.edu> on 22 Jun 1999 08:14:16 -0700, Tom
>Christiansen <tchrist@mox.perl.com> says...
>...
>> # De-moron-ise Illegal Text and HTML from Microsoft Applications
>> #
>> # by John Walker -- January 1998
>> # http://www.fourmilab.ch/
>> # revised by Larry Rosler -- May 1999
>> # http://www.hpl.hp.com/personal/Larry_Rosler/
Well, unfortunately, this program *almost* works for me.
When I run it, I get:
demoroniser /etc/group > /dev/null
String found where operator expected at /mydir/bin/demoroniser line 33, near ""$0: warning -- untranslated character 0x%.2X in line $iline of `%s'\n""
(Missing operator before "$0: warning -- untranslated character 0x%.2X in line $iline of `%s'\n"?)
Also, when I run it on a file that contains the 0x92 character (which
is the most common offending character in Redmondware generated files),
I get:
/mydir/bin/demoroniser: warning -- untranslated character 0x92 in line 20 of `MyFile'
/mydir/bin/demoroniser: warning -- untranslated character 0x92 in line 28 of `MyFile'
/mydir/bin/demoroniser: warning -- untranslated character 0x92 in line 35 of `MyFile'
/mydir/bin/demoroniser: warning -- untranslated character 0x92 in line 36 of `MyFile'
And it leaves those chars (0x92) intact in the output. Translating
them was the whole point of the exercise.
------------------------------
Date: Tue, 22 Jun 1999 11:33:18 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Looking for very small, basic bulletin board system
Message-Id: <376FD6EE.C7E6486F@mail.cor.epa.gov>
yvan@wharris.com wrote:
>
> I need a very small and basic bulletin board system for use in a web
> page. What I would like is a cgi script that would allow me to do the
> following:
> [snip]
> Would anyone
> here know where I might find a script that would allow me to do this?
> Your assistance would be much appreciated.
You'll be happy to know that there's a thousand of these on the
web. Just don't go to Matt's Script Archive. Happy searching!
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 22 Jun 1999 18:21:09 GMT
From: bing-du@tamu.edu
Subject: move file pointer?
Message-Id: <7kok69$g5g$1@nnrp1.deja.com>
Greetings all...,
I have a code snippet. It prints out all those lines in the file that
match the specific patterns.
foreach $pattern (@patterns)
{
open(FILE, "file");
while (<FILE>)
{
if (/$pattern/)
{ print $_;}
}
close(FILE);
}
My question is:
Instead of opening and closing the file repeatedly, is there any way to
let the file pointer point to the first line of the file for the next
pattern checking? Or any other better way for doing this?
Thanks in advance for your suggestions and ideas,
Bing
TAMU Computing and Information Services
Systems Group
Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.
------------------------------
Date: 22 Jun 1999 12:34:26 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: move file pointer?
Message-Id: <376fd732@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
bing-du@tamu.edu writes:
:Or any other better way for doing this?
#!/usr/bin/perl
# popgrep5 - grep for abbreviations of places that say "pop"
# version 5: qr// version
use 5.005;
@popstates = qw(CO ON MI WI MN);
@poppats = map { qr/\b$_\b/ } @popstates;
while (<>) {
for $patobj (@poppats) {
print if /$patobj/;
}
}
--
: I've heard that there is a shell (bourne or csh) to perl filter, does
: anyone know of this or where I can get it?
Yeah, you filter it through Tom Christiansen. :-) --Larry Wall
------------------------------
Date: Tue, 22 Jun 1999 11:31:23 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: multidimensional arrays with functions push and pop
Message-Id: <376FD67B.BBE871B8@mail.cor.epa.gov>
Darrin Edwards wrote:
> How's that saying go, "Learn what you know, share
> what you don't"? Sheesh.
I thought it was:
"Learn what you don't know to be wrong.
Share what you didn't check to be true."
HTH,
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 22 Jun 1999 11:34:38 -0700
From: KJ <daedalus@nokturnal.com>
Subject: Multiple command args...
Message-Id: <376FD73D.6E2BC1A@nokturnal.com>
I am writing a custom script to pass in one or many gzipped weblog
access files and
then parsing them for certain content that we need to keep track of. My
current and
biggest problem is properly taking the .gz files from @ARGV and
gunzipping them and
concatenating them onto each other....
$gunzip = '/usr/contrib/bin/gunzip -c';
sub somefunc
{
if(!@ARGV) { usage(); }
elsif($ARGV[0] && !$ARGV[1])
{
$log = $ARGV[0];
&process_log($log);
}
else
{
print STDOUT "Processing log(s): @ARGV\n";
while($log = shift)
{
&process_log($log);
}
}
}
Ive tried various things that I thought would do the trick, but Ive had
no success. I also need to preserve the original gz file. Thanks
KJ
------------------------------
Date: Tue, 22 Jun 1999 17:31:16 GMT
From: busia@tiscalinet.it (Andrea Busia)
Subject: Perl Modules and Win98
Message-Id: <376fc3ce.36322282@news.tiscalinet.it>
Someone know how to install a perl module on the activestate perl
5.00502 for win98? When I try to use the cgywin make for windows it
gives me an error message like
Makefile:771 *** Missing Separator. Stop.
Thanks
Andrea Busia
------------------------------
Date: Tue, 22 Jun 1999 14:15:34 -0400
From: Craig Ciquera <craig@mathworks.com>
Subject: Re: Perl Modules and Win98
Message-Id: <376FD2C6.7A09D532@mathworks.com>
Andrea Busia wrote:
> Someone know how to install a perl module on the activestate perl
> 5.00502 for win98?
use ppm it should be on your path.
Craig
------------------------------
Date: Wed, 23 Jun 1999 00:12:13 +0530
From: srishti <srishti@vsnl.com>
To: ted fiedler <tfiedler@ptd.net>
Subject: Re: printing multiple lines
Message-Id: <376FD905.645F9359@vsnl.com>
Change to something like:
while(<TDAT>) {
if (/015/) {
s/015//g;
print $_;
$LineRequired = 2;
}
if(--$MoreLinesRequired > 0) {
print;
}
}
ted fiedler wrote:
>
> ok what i am doing is searching for a tag in a file -- 015
> when i find this tag how do i not only print the first line but the two
> lines which come after it??? also i want to remove the 015???
> thanks in advance...
>
> #!/usr/bin/perl
> use File::Copy;
> del_old();
> copy ("test3.dat","output/working");
> open (TDAT, "+< output/working") ||
> die"cannot open file: $!\n";
> open (RECORDCOUNT, "> output/records") ||
> die"cannot create a file called records: $!";
> while(<TDAT>) {
> if (/015/) {
> print $_;
> }
> }
> close(TDAT);
>
> sub del_old {
> $working="output/working";
> $records="output/records";
> unlink($working, $records);
> }
------------------------------
Date: 22 Jun 1999 12:01:28 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: read files in Perl
Message-Id: <376fcf78@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc, trebleclef@earthling.net writes:
:in vain to get this working, but I
:keep getting
:
: 28: Syntax error: "(" unexpected
:
:i would appreciate assistance with this, as i am a
:perl newbie
SEVENTY-THREE USELESS LINES DELETED! PLEASE FIX
YOUR NEWSREADER AND STOP OVERQUOTING!
% man perldiag
...
syntax error at line %d: `%s' unexpected
(A) You've accidentally run your script through the Bourne shell
instead of Perl. Check the #! line, or manually feed your script
into Perl yourself.
--
"All of us who are concerned for peace and the triumph of reason and
justice must be keenly aware how small an influence reason and honest
good will have upon events in the political field."
- Albert Einstein
------------------------------
Date: Tue, 22 Jun 1999 11:43:06 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Recursive Delete
Message-Id: <MPG.11d979159c917ac7989c1d@nntp.hpl.hp.com>
In article <slrn7mv7e8.k1b.abigail@alexandra.delanet.com> on 22 Jun 1999
09:29:36 -0500, Abigail <abigail@delanet.com> says...
> Joe (Joa@inc.com) wrote on MMCXXI September MCMXCIII in
> <URL:news:Joa-2106991944460001@haines-du-01-07.seaknet-dom.alaska.edu>:
...
> -- sub delete_directory {
> -- opendir(DIRECTORY, "$_[0]") or &error_die('Unable to delete directory',
> -- "(<B>$_[0]</B>)",
...
> -- @directories = grep !/\./, readdir DIRECTORY; # list only the directories
>
> That's wrong, unless all files and no directories contain a period,
> which is a scary assumption. Why not
> @directories = grep {-d && !/^\.\.?$/} readdir DIRECTORY; ?
Who has stolen our beloved Abigail and replaced him/her/it with you?
@directories = grep {-d "$_[0]/$_" && !/^\.\.?$/} readdir DIRECTORY;
...
> -- foreach $directory (@directories) {delete_directory ($_[0]/$directory);}
>
> Why do you divide $_[0] by $directory?
Thanks for the reminder not to divide $_[0] by $_ in my snippet. :-)
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 22 Jun 1999 11:08:40 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Safe expression evaluation
Message-Id: <376FD128.24363C0@mail.cor.epa.gov>
Marcel van der Laan wrote:
> I'd like to, but the whole mox.perl.com site seems to be down, from where
> I'm at. Is it mirrored anywhere?
Works for me with no problems at all. Have you checked your
Life::Karma module lately? :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 22 Jun 1999 18:12:55 GMT
From: hex@voicenet.com (Matt Knecht)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <HmQb3.111$VL6.19265@news2.voicenet.com>
Paul David Fardy <pdf@morgan.ucs.mun.ca> wrote:
>
>Indeed. What regular expression(s) would you use to identify
>quoted material?
/^>/
--
Matt Knecht <hex@voicenet.com>
------------------------------
Date: Tue, 22 Jun 1999 18:27:27 GMT
From: pigs_can_fly@mindless.com (JQ)
Subject: unable to create or rename files in subdirectories
Message-Id: <3772d2c9.41303568@news.cyberway.com.sg>
Hi
I am unable to create or rename files that exist in subdirectories.
Everything works fine if I create or rename files that are in the same
directory as my script:
open(HANDLE, ">newfile.txt");
print HANDLE "contents\n";
close(HANDLE);
or
rename "newfile.txt", "oldfile.txt";
------------------------------------
However, these do not work in Unix:
open(HANDLE, ">backup/newfile.txt");
print HANDLE "contents\n";
close(HANDLE);
or
rename "backup/newfile.txt", "backup/oldfile.txt";
I have even tried specifying the entire path.
Can someone point me in the right direction? Is this more a Unix
question rather than a perl question? If so, I apologise.
Thanks
JQ
------------------------------
Date: 22 Jun 1999 12:35:10 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: unable to create or rename files in subdirectories
Message-Id: <376fd75e@cs.colorado.edu>
[courtesy cc of this posting mailed to cited author]
In comp.lang.perl.misc,
pigs_can_fly@mindless.com (JQ) writes:
:Can someone point me in the right direction?
$!
--
OOPS! You naughty creature! You didn't run Configure with sh!
I will attempt to remedy the situation by running sh for you...
--Larry Wall in Configure from the perl distribution
------------------------------
Date: Tue, 22 Jun 1999 13:59:10 -0400
From: Tom Kralidis <tom.kralidis@ccrs.nrcanDOTgc.ca>
Subject: What am I missing?
Message-Id: <376FCEED.8087B138@ccrs.nrcanDOTgc.ca>
Hi,
I'm writing a perl srcipt (5.004_04 for irix) to create a new file with
4 default lines, then extract specific info (from two lines) from a file
(in the same dir), appending to the new file.
So far I have written the new file, and extracted the info into the new
file. Now, I want to keep only specific parts of the line. Here's the
two sample lines:
file origin (lower left corner): easting 471620.0 northing 5464085.0
number of lines 400, pixels 415
The first char of each line is a space. I need only 471620.0, 5464085.0
and 400 (from next line)
I have tried:
s/.*origin.*easting (\d{6}\W\d) northing (\d{7}\W\d)/$1 $2/;
for the first line, and
s/.*lines (\d{4})/$1/;
for the second line.
I have tried this in two instances: 1) from the original file 2) to the
passed lines in the new file, both with no luck.
Any ideas would be much appreciated.
Thanks
..Tom
-----------------------------------------------------------------------------------------
Tom Kralidis Geo-Spatial Technologist
Canada Centre for Remote Sensing Tel: (613) 947-1828
Data Acquisition Division Fax: (613) 947-1408
User Systems Development Section email:
tom.kralidis@ccrs.nrcanDotgc.ca
588 Booth Street , Room 241
http://www.ccrs.nrcan.gc.ca
Ottawa , Ontario K1A 0Y7
http://www.algonqinc.on.ca/~kral0003
-----------------------------------------------------------------------------------------
------------------------------
Date: Tue, 22 Jun 1999 20:14:43 +0200
From: Andrzej Filip <anfi@bigfoot.com>
Subject: Re: What am I missing?
Message-Id: <376FD292.8350AC35@bigfoot.com>
Tom Kralidis wrote:
> I'm writing a perl srcipt (5.004_04 for irix) to create a new file with
> 4 default lines, then extract specific info (from two lines) from a file
> (in the same dir), appending to the new file.
>
> So far I have written the new file, and extracted the info into the new
> file. Now, I want to keep only specific parts of the line. Here's the
> two sample lines:
>
> file origin (lower left corner): easting 471620.0 northing 5464085.0
> number of lines 400, pixels 415
>
> The first char of each line is a space. I need only 471620.0, 5464085.0
> and 400 (from next line)
>
> I have tried:
>
> s/.*origin.*easting (\d{6}\W\d) northing (\d{7}\W\d)/$1 $2/;
>
> for the first line, and
>
> s/.*lines (\d{4})/$1/;
>
> for the second line.
>
> I have tried this in two instances: 1) from the original file 2) to the
> passed lines in the new file, both with no luck.
>
> Any ideas would be much appreciated.
1) Check file size using "-s file_name" if it non zero and less
than a few KB (e.g. 16 KB) than use sysread to read whole file
into a variable
2) than try to use
print "OK!\n" if
($E,$N,$P)=/easting (\d+\.\d).*?northing (\d+\.\d).*?lines (\d+),/s;
--
Andrzej (Andrew) A. Filip fax: +1(801)327-6278
mailto:anfi@bigfoot.com http://www.bigfoot.com/~anfi
Postings: http://www.deja.com/profile.xp?author=Andrzej%20Filip&ST=PS
------------------------------
Date: Tue, 22 Jun 1999 11:05:52 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: What is First line in Perl5 in Sun Micro...
Message-Id: <376FD080.23D9A231@mail.cor.epa.gov>
Abigail wrote:
> But sometimes, it's as exotic as /net/crown/froot6/ABNA/perl/bin/perl.
That may sound like a joke, but in fact right now we have the latest
version sitting at:
/usr/local/pkg/perl5.005_03/bin/perl
while we're running regression tests on it. So don't assume it's
(1) on your path; (2) easy to find; or (3) even named 'perl'
instead of perl_latest or perl.500503 or whatever.
> Perhaps you should talk with your sysadmin.
Always listen to Abigail. This is the only sure way to find out.
And even this can fail. Particularly if you were the one
mail-bombing him last week. :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 12 Dec 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 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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 6096
**************************************