[23506] in Perl-Users-Digest
Perl-Users Digest, Issue: 5716 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 27 14:11:45 2003
Date: Mon, 27 Oct 2003 11:05:13 -0800 (PST)
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, 27 Oct 2003 Volume: 10 Number: 5716
Today's topics:
Re: A global has among threads <admin@asarian-host.net>
Re: A global has among threads <usenet@morrow.me.uk>
Re: About Expect. <glex_nospam@qwest.invalid>
Re: About Expect. <elp@pnsihq.com>
Re: And printing enviromental variables (Nataku)
array of hashrefs (nested) <fm_duendeBASURA@yahoo.com>
Re: array of hashrefs (nested) <xx087@freenet.carleton.ca>
Re: array of hashrefs (nested) <fm_duendeBASURA@yahoo.com>
Re: array of hashrefs (nested) (Roy Johnson)
Re: Balanced Text?? <michael.p.broida@boeing_oops.com>
Re: Balanced Text?? (Malcolm Dew-Jones)
Re: error from - eval "do script" - unsolved: does not <usenet@morrow.me.uk>
Re: error from - eval "do script" - unsolved: does not <lmai@mytum.de>
Re: error from - eval "do script" - unsolved: does not <usenet@morrow.me.uk>
Re: Help with script to move email files based on date (Roy Johnson)
Re: How to catch runtime error? (laszlo)
Re: how to do something (Roy Johnson)
Re: How to generate this list? (David Combs)
Re: Installing Module on Remote Host (Mike)
Re: IO::Socket::INET - Listen on exactly two IPs the sa <uri@stemsystems.com>
Re: Perl and IIS - script runs but 'The page cannot be <jgibson@mail.arc.nasa.gov>
Perl module for analyzing log files? (D. Alvarado)
Re: Perl module for analyzing log files? <glex_nospam@qwest.invalid>
Re: Printing folder contents (Roy Johnson)
Re: Question (Kobe Clinton)
Re: rsh & perl -Directory creation not possible (qazmlp)
Running system() commands in background (qazmlp)
Re: Running system() commands in background <HelgiBriem_1@hotmail.com>
Re: Running system() commands in background <flavell@ph.gla.ac.uk>
Sorting case insensitively (John Deuf)
Re: Sorting case insensitively <bernard.el-haginDODGE_THIS@lido-tech.net>
Re: Sorting case insensitively <ak+usenet@freeshell.org>
Re: Sorting case insensitively <uri@stemsystems.com>
Re: Sorting case insensitively <usenet@morrow.me.uk>
Re: strange effect with [:lower:] in perl <abigail@abigail.nl>
Re: strange effect with [:lower:] in perl <flavell@ph.gla.ac.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 27 Oct 2003 15:42:23 +0100
From: "Mark" <admin@asarian-host.net>
Subject: Re: A global has among threads
Message-Id: <Zb2dnZwxDpZIswCiRVn-hQ@giganews.com>
"Ben Morrow" <usenet@morrow.me.uk> wrote in message
news:bnhrnr$imk$2@wisteria.csv.warwick.ac.uk...
> "Mark" <admin@asarian-host.net> wrote:
> > Short of resorting to using shmget and all the other shared memory
stuff,
> > I was wondering whether there is ANY way to maintain a global hash,
> > shared among all threads?
>
> You want to start by reading perldoc threads::shared. Note that you
> *must* use the locking primitives, or you will get in a terrible mess
> :).
>
> Ben
Thank you for your answer. I have a question left, though. :) Suppose I have
a hash with domain names, say %domains, would this then be the correct way
to access the hash per thread?
----------------------------------
use threads ();
use threads::shared ();
my %domains : shared;
lock $domains{'adomain'};
$domains{'adomain'} = $ip;
----------------------------------
See, the doc says you cannot specifically unlock until the lock falls "out
of scope". And it is not entirely clear to me what that means in this
context. I got the awful suspicion it means 'until the thread has ended'. Or
does it mean (as I want it to mean), until a change has been made to the
variable? (or a read be done from it, etc).
Thanks,
- Mark
------------------------------
Date: Mon, 27 Oct 2003 15:41:06 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: A global has among threads
Message-Id: <bnjeai$6tn$3@wisteria.csv.warwick.ac.uk>
"Mark" <admin@asarian-host.net> wrote:
> Suppose I have a hash with domain names, say %domains, would this
> then be the correct way to access the hash per thread?
> ----------------------------------
> use threads ();
> use threads::shared ();
>
> my %domains : shared;
>
{
> lock $domains{'adomain'};
> $domains{'adomain'} = $ip;
} # here %domains is unlocked
> ----------------------------------
>
> See, the doc says you cannot specifically unlock until the lock falls "out
> of scope". And it is not entirely clear to me what that means in this
> context.
It means 'until the end of the innermost enclosing lexical scope'
i.e. {} block, entire file, or string eval. So if you put the lock
call inside a block the var will be unlocked at the end of the block.
> I got the awful suspicion it means 'until the thread has ended'.
!!! Now, how much use would that be? :)
> Or does it mean (as I want it to mean), until a change has been made
> to the variable? (or a read be done from it, etc).
Or indeed that... the whole point of locking is so you can
read...check...write without anyone else interfering. If you don't
understand why that's important, then you probably ought to read a
tutorial on concurrent programming before you try writing threaded
Perl: someone else here can probably make a better recommendation than
me.
Ben
--
"The Earth is degenerating these days. Bribery and corruption abound.
Children no longer mind their parents, every man wants to write a book,
and it is evident that the end of the world is fast approaching."
-Assyrian stone tablet, c.2800 BC ben@morrow.me.uk
------------------------------
Date: Mon, 27 Oct 2003 10:03:20 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: About Expect.
Message-Id: <8ibnb.67$uS.16231@news.uswest.net>
Dr. Pastor wrote:
> Jim:
> Any written or verbal comment about the successful usage of Expect on W2K
> pro
> would be suitable, as well as examples. (I did some search with Google.)
> Regards.
To narrow your question to those who have likely used Expect.pm, try the
Expect discussion group on SourceForge:
http://sourceforge.net/projects/expectperl/
Lots of example code has been posted in the discussions.
------------------------------
Date: Mon, 27 Oct 2003 17:51:48 GMT
From: "Dr. Pastor" <elp@pnsihq.com>
Subject: Re: About Expect.
Message-Id: <UWcnb.4109$RQ1.901@newsread3.news.pas.earthlink.net>
Many thanks for the info!
Regards.
"J. Gleixner" <glex_nospam@qwest.invalid> wrote in message
news:8ibnb.67$uS.16231@news.uswest.net...
> Dr. Pastor wrote:
> > Jim:
> > Any written or verbal comment about the successful usage of Expect on
W2K
> > pro
> > would be suitable, as well as examples. (I did some search with Google.)
> > Regards.
>
> To narrow your question to those who have likely used Expect.pm, try the
> Expect discussion group on SourceForge:
>
> http://sourceforge.net/projects/expectperl/
>
> Lots of example code has been posted in the discussions.
>
------------------------------
Date: 27 Oct 2003 06:47:48 -0800
From: Crapnut566@yahoo.com (Nataku)
Subject: Re: And printing enviromental variables
Message-Id: <7e48fc99.0310270647.5cc774db@posting.google.com>
The %ENV hash contains all of the environmental variables that Perl
knows about. The key of this hash is the name of the variable ( like
HOME ) and the value is, naturally, the value contained within that
variable.
So, to get all the env variables, you can access this hash in any one
of the standard ways.
foreach( my $key ( keys %ENV ) ){
print ( "$key -> ".$ENV{$key}."\n" );
}
or
while( my ($key, $value) = each %ENV ){
print ( "$key -> $value\n" );
}
The second is preferred as the first will dump all of the keys into a
list. Normally the ENV hash isnt that big, but for large hashes this
could consume a significant portion of memory - while the second
simply goes through one at a time.
I highly reccomend reading through the perldoc, it contains answers to
many a question like this.
<mh> wrote in message news:<3f9d0922$1@news.dnainternet.net>...
> I'd also like to print out the
> enviromental variables. I understand that, keys %ENV i somehow related but
> how to use it?
------------------------------
Date: Mon, 27 Oct 2003 15:53:02 GMT
From: monkeys paw <fm_duendeBASURA@yahoo.com>
Subject: array of hashrefs (nested)
Message-Id: <xbbnb.40819$Fm2.16610@attbi_s04>
I have the following code that is behaving stragely:
use Data::Dumper;
%pair = (
'Subject' => 'Vapor,Bob-war,new-tag',
'Analyst' => 'simi'
);
for my $heading (sort keys %pair) {
@tags = ();
for my $tag (split /,/, $pair{$heading}) {
push @tags, {tag_key => $tag, tag_name => $tag};
}
push @headings, {
heading_name => $heading,
tags => \@tags,
};
}
print Dumper(\@headings) ;
The output is:
HAT2: $VAR1 = [
{
'tags' => [
{
'tag_key' => 'Vapor',
'tag_name' => 'Vapor'
},
{
'tag_key' => 'Bob-war',
'tag_name' => 'Bob-war'
},
{
'tag_key' => 'new-tag',
'tag_name' => 'new-tag'
}
],
'heading_name' => 'Analyst'
},
{
'tags' => $VAR1->[0]{'tags'},
'heading_name' => 'Subject'
}
];
What is causing the 'tags' => $VAR1->[0]{'tags'}, line to
show up?? I would expect it to be
'tags' => {
'tag_key' => 'new-tag',
'tag_name' => 'new-tag'
}
------------------------------
Date: 27 Oct 2003 16:09:33 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: array of hashrefs (nested)
Message-Id: <slrnbpqgr1.8v6.xx087@smeagol.ncf.ca>
monkeys paw <fm_duendeBASURA@yahoo.com> wrote:
[...]
> for my $heading (sort keys %pair) {
> @tags = ();
You want: my @tags = ();
[...]
> What is causing the 'tags' => $VAR1->[0]{'tags'}, line to
> show up?? I would expect it to be
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Mon, 27 Oct 2003 17:00:25 GMT
From: monkeys paw <fm_duendeBASURA@yahoo.com>
Subject: Re: array of hashrefs (nested)
Message-Id: <xacnb.32830$ao4.63799@attbi_s51>
Glenn Jackman wrote:
> monkeys paw <fm_duendeBASURA@yahoo.com> wrote:
> [...]
>> for my $heading (sort keys %pair) {
>> @tags = ();
>
> You want: my @tags = ();
>
> [...]
>> What is causing the 'tags' => $VAR1->[0]{'tags'}, line to
>> show up?? I would expect it to be
>
Thanks Glenn, that does work. Not sure why tho??
------------------------------
Date: 27 Oct 2003 10:14:33 -0800
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: array of hashrefs (nested)
Message-Id: <3ee08638.0310271014.3c788bf1@posting.google.com>
You are using a reference to a global variable, @tags, which you are
overwriting each pass through the loop.
use strict;
would have helped. Then you would have known to declare it as "my" and
it probably would have given you the results you were expecting.
VAR1 is Dumper's name for the reference to @tags.
------------------------------
Date: Mon, 27 Oct 2003 16:50:48 GMT
From: MPBroida <michael.p.broida@boeing_oops.com>
Subject: Re: Balanced Text??
Message-Id: <3F9D4CE8.66DD7F59@boeing_oops.com>
Tad McClellan wrote:
>
> MPBroida <michael.p.broida@boeing_oops.com> wrote:
> > Tad McClellan wrote:
> >>
> >> > But I don't recall whether the package/module is:
> >> > Text::Balanced
> >> > or:
> >> > Balanced::Text
> >>
> >> perldoc -q Balanced
> >>
> >> Can I use Perl regular expressions to match balanced text?
> >
> > But that perldoc section does NOT refer to either
> > "Balanced::Text" or "Text::Balanced", and that's
> > what I was hunting for: the real name of that module/
> > package/whatever it is.
>
> Huh?
>
> Can I use Perl regular expressions to match balanced text?
>
> Historically, Perl regular expressions were not
> capable of matching balanced text. As of more
> recent versions of perl including 5.6.1 experimen
> tal features have been added that make it possible
> to do this. Look at the documentation for the
> (??{ }) construct in recent perlre manual pages to
> see an example of matching balanced parentheses.
> Be sure to take special notice of the warnings
> present in the manual before making use of this
> feature.
>
> CPAN contains many modules that can be useful for
> matching text depending on the context. Damian
> Conway provides some useful patterns in Reg
> exp::Common. The module Text::Balanced provides a
> ^^^^^^^^^^^^^^
> general solution to this problem.
Hmm, must be a different Perl version. I get quite a bit
less info, and NO mention of the specific Text::Balanced
package.
I'm using 5.6.0, "binary build 616 provided by ActiveState <etc>".
I've noticed that the perldoc contents are a bit newer and more
complete than the 2nd Edition Camel book, but it's probably a
bit less complete than the version you're using. Unfortunately,
there's little chance of updating the version here: too many
tools depend on it working EXACTLY as it does now. "Someday"
we'll update.
Thanks for the updated info. :)
Mike
------------------------------
Date: 27 Oct 2003 09:27:39 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Balanced Text??
Message-Id: <3f9d558b@news.victoria.tc.ca>
MPBroida (michael.p.broida@boeing_oops.com) wrote:
: > exp::Common. The module Text::Balanced provides a
: > ^^^^^^^^^^^^^^
: > general solution to this problem.
: Unfortunately,
: there's little chance of updating the version here: too many
: tools depend on it working EXACTLY as it does now. "Someday"
: we'll update.
: Thanks for the updated info. :)
Text::Balanced says it requires perl 5.005
(Which is much less than 5.6.anything)
so I don't understand why you don't just install the module and use it.
------------------------------
Date: Mon, 27 Oct 2003 15:30:24 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: error from - eval "do script" - unsolved: does not set $@
Message-Id: <bnjdmg$6tn$1@wisteria.csv.warwick.ac.uk>
"Sunil" <sunil_franklin@hotmail.com> wrote:
> This works as I expect and I am able to handle errors using $@
> eval do 'setvars.pl';
>
> but my code like
> my $fullFileName = 'setvars.pl';
> my $evalStr = "do \'$fullFileName\'";
> eval "$evalStr";
> does not seem to set the $@ variable even though I am able to see the error
> in the console.
Read perldoc -f do again. do() does not throw an exception (call
die()) under any circumstances, so you do not need an eval. Also, do
returns errors in either $! or $@, depending on whether it opened the
file or not. So you want something like:
my $fullFileName = 'setvars.pl';
$@ = undef;
do $fullFileName or die "do failed: " . ($@ || $!);
You should avoid string eval at all costs: it is very slow and can do
very unexpected things if you are not careful.
Ben
--
. | .
\ / The clueometer is reading zero.
. .
__ <-----@ __ ben@morrow.me.uk
------------------------------
Date: Mon, 27 Oct 2003 16:24:11 +0000 (UTC)
From: Lukas Mai <lmai@mytum.de>
Subject: Re: error from - eval "do script" - unsolved: does not set $@
Message-Id: <bnjgrb$377e3$1@sunsystem5.informatik.tu-muenchen.de>
Ben Morrow <usenet@morrow.me.uk> wrote:
> my $fullFileName = 'setvars.pl';
> $@ = undef;
You don't have to clear $@. Perldoc -f eval says:
If there was no error, $@ is guaranteed to be a NULL string.
> do $fullFileName or die "do failed: " . ($@ || $!);
HTH, Lukas
------------------------------
Date: Mon, 27 Oct 2003 16:48:56 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: error from - eval "do script" - unsolved: does not set $@
Message-Id: <bnji9o$946$1@wisteria.csv.warwick.ac.uk>
Lukas Mai <lmai@mytum.de> wrote:
> Ben Morrow <usenet@morrow.me.uk> wrote:
>
> > my $fullFileName = 'setvars.pl';
> > $@ = undef;
>
> You don't have to clear $@. Perldoc -f eval says:
> If there was no error, $@ is guaranteed to be a NULL string.
perldoc -f do doesn't though...
You are, however, correct: do does clear $@ anyway.
I guess it's implied by L<perlvar/$@>.
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else * ben@morrow.me.uk
------------------------------
Date: 27 Oct 2003 07:21:45 -0800
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Help with script to move email files based on date field in header
Message-Id: <3ee08638.0310270721.20349de9@posting.google.com>
mw <mw@stopthespam.here> wrote in message news:<MPG.1a04b0287c37a50b989680@24.69.255.211>...
> ie:
> Date: Sat, 28 May 2003 21:44:27 -0400
>
> Basically I would a script that would move all emails with the word Apr
> in the email date header to a directory called April. All emails with
> the word May in the email date header to be moved to the May directory
> and so on...
This ought to do what you want, except for simplicity, I named the
directories with the three-letter month abbreviations expected in the
files.
my @mons = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
my $pat = join('|', @mons);
for (@mons) {
mkdir $_ or warn "Could not make dir $_: $!\n";
}
opendir DIR, '.' or die "Could not read .: $!\n";
while (my $f = readdir DIR) {
next unless -f $f;
open IN, $f or warn "Could not open $f: $!\n";
while (<IN>) {
if (/^Date:/) {
if (/($pat)/o) {
rename $f, $1/$f or warn "Could not move $f to $1\n";
}
else {
warn "No month found in $f\n";
}
last;
}
}
}
------------------------------
Date: 27 Oct 2003 08:04:38 -0800
From: GlgAs@Netscape.net (laszlo)
Subject: Re: How to catch runtime error?
Message-Id: <945e4584.0310270804.23c699@posting.google.com>
> >
> > perldoc -f eval
> >
> > for how to use $SIG{__WARN__}.
>
> As an alternative, one can make the warning in question fatal and
> catch it in eval. In this case:
>
> eval { use warnings FATAL => qw( uninitialized); <whatever> }
>
> That is sometimes easier than fiddling with a handler.
>
> Anno
Thanks for both info. I put
use warnings FATAL => qw(all);
statement in front of my text to be avaluated, and the interpreter
faithfully listed all the warnings.
------------------------------
Date: 27 Oct 2003 10:21:49 -0800
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: how to do something
Message-Id: <3ee08638.0310271021.a3b3db0@posting.google.com>
"Lex" <nospam@peng.nl> wrote in message news:<tFymb.26696$nQ4.623972@news-reader.eresmas.com>...
I think what you're looking for is:
> for (0 .. $i) {
redo unless &html_recordheadline (&array_to_hash($_, @results));
> }
------^^^^^^^^^^^
------------------------------
Date: Mon, 27 Oct 2003 16:52:22 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: How to generate this list?
Message-Id: <bnjig5$4lj$1@reader1.panix.com>
In article <3F7DCAF2.7DF0A772@acm.org>, John W. Krahn <krahnj@acm.org> wrote:
>Roy Johnson wrote:
>>
>> "John W. Krahn" <krahnj@acm.org> wrote in message news:<3F7B247C.586F33C@acm.org>...
>>
>> > I don't know if this is the best way but:
>> >
>> > my @array = qw/ A A A A B B C D D D /;
>> >
>> > print "$_\n" for glob "{@{[ join ',', @array ]}}" x @array;
>>
>> Would you explain the magic?
>
>glob uses the comma separated list in braces as alternatives in the
>result.
>
>$ perl -le'print for glob "{AB,CD}XY"'
>ABXY
>CDXY
>$ perl -le'print for glob "{A,B}{C,D}XY"'
>ACXY
>ADXY
>BCXY
>BDXY
>
>So it passes a string of all the alternatives to glob which creates a
>list of the alternatives.
Yes, the clever curly-bracket notation from csh -- forms
the cartesian product.
Also works if they're *nested*.
Now this, for John, Abigail, MJD, etc:
"YOUR TASK, MR. PHELPS, IS TO PROGRAM THAT CSH ALGORITHM"
How about an efficient algorithm on doing that?
(I once saw a 5-liner in ML that did it, but what
with the redefined-operators and other clever tricks in
that particular program, I had no idea how it worked -- still
don't. (don't even have a copy -- drat!) )
Perhaps first show it in some algol-like notation --
then, I suppose, in perl, with it's fancy data-structures,
maps, greps, etc.
THANKS!
David
------------------------------
Date: 27 Oct 2003 07:15:20 -0800
From: csdude@hotmail.com (Mike)
Subject: Re: Installing Module on Remote Host
Message-Id: <46cdc619.0310270715.cd6e8bd@posting.google.com>
>> use lib "/home3/mysite/modules";
> If that '3' is in your real code things won't work.
My apologies for the confusion. In the original post, I was trying to
take out as much unnecessary code as possible, and while the 3 is
indeed there for my host, I had taken it out to simplify things in the
beginning (or so I thought)...
Sorry about that,
Mike
------------------------------
Date: Mon, 27 Oct 2003 14:50:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: IO::Socket::INET - Listen on exactly two IPs the same time?
Message-Id: <x7oew23faq.fsf@mail.sysarch.com>
>>>>> "AR\" == Andrew Rich \(VK4TEC\) <Andrew> writes:
AR\> have you just invented a super new lan card that runs two ip addresses at
AR\> once ?
no. he is probably using an IP alias technique supported on most
OSs. actually it seems he was separating internal (localhost) and
external connections which amounts the the same problem of listening on
more then one IP address. and for your information, lan cards listen to
mac (ethernet) addresses and not IP addresses.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 27 Oct 2003 10:56:57 -0800
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: Perl and IIS - script runs but 'The page cannot be displayed'
Message-Id: <271020031056574181%jgibson@mail.arc.nasa.gov>
In article <2b68957a.0310241707.3ad7fc65@posting.google.com>, stew dean
<stewart@webslave.dircon.co.uk> wrote:
[snip]
> To get my script to work in the command line I created a new version -
> one with the variables passed to the script hard coded (although there
> are ways of doing it via the command line I've been informed) and also
> with absolute paths rather the relative ones the server doesnt mind.
Here is one suggestion: you can input the root or base directory for
your relative paths using a command-line argument. If this argument is
not present, then you can set an internal argument to a default value
such as '' (empty), '.' (default directory), or '/' (root directory),
or whatever works for your web server. This command-line argument will
not be set when executed by the web server.
When executed from a command line, the special variable @ARGV contains
the "words" entered on the command line after the script name and
separated by whitespace. You may interpret these strings anyway you
wish. CGI programs do not use this function, since the CGI data is
passed to the program by the server in environment variables. AFAIK,
command lines are never set in a CGI program (I could be wrong about
this).
Here is some code showing 3 different ways to retrieve the command line
arguments in a program:
#!/opt/perl/bin/perl -w
use strict;
use warnings;
# set a default (may be different for your server)
my $base = '/';
# only one argument, no checking
if( $#ARGV >= 0 ) {
$base = $ARGV[0];
}
# argument entered as "-base /base/path", no checking
for my $i ( 0..$#ARGV ) {
if( $ARGV[$i] eq "-base" ) {
$base = $ARGV[++$i];
}
}
# argument entered as "-base /base/path", with checking
for my $i ( 0..$#ARGV ) {
if( $ARGV[$i] eq "-base" ) {
if( $i < $#ARGV ) {
$base = $ARGV[++$i];
}else{
die("-base option needs path argument\n");
}
}
}
# use the base path
print "root path is $base\n";
my $file = 'index.html';
my $fullpath = $base . $file;
print "file path is $fullpath\n";
For more information, enter "perldoc perlvar" at your friend the
command line prompt and search for "ARGV".
>
> It gave me a whole new set of errors before spitting out my HTML (all
> present and correct). These errors that I didnt see via the browser
> once fixed resulted in the end HTML being displayed when run via the
> browser.
>
> The mistakes in the perl where not syntax but warnings of wide
> characters and errors where an array memeber was called up that wasnt
> defined (like, in one example the eighth day in the week).
>
> So thanks for taking the time as your post, although not dead on
> target, did lead to me solving the problem. Now I'm looking for a way
> to avoid using the command line again (except to install modules etc)
> so I only need one script.
Using the method described above, you can modify your script to be
usable at the command line as well. I shudder at the prospect of
developing or maintaining a 20-page perl CGI script without the use of
the command line.
>
> Juding from some responces I've got (some have been downright nasty)
> this may be better in the cgi group but cheers anyway.
>
> Stew Dean
------------------------------
Date: 27 Oct 2003 09:23:16 -0800
From: laredotornado@zipmail.com (D. Alvarado)
Subject: Perl module for analyzing log files?
Message-Id: <9fe1f2ad.0310270923.4f3c395d@posting.google.com>
Can anyone recommend a module that I can use to break apart Apache log
files? We are doing out log file analysis on a separate machine and I
would like to find a Perl module to help me code a primitive log file
analysis program that will analyze log files as they are dumped to the
machine. Thanks - Dave
------------------------------
Date: Mon, 27 Oct 2003 12:01:47 -0600
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: Perl module for analyzing log files?
Message-Id: <a1dnb.77$uS.25826@news.uswest.net>
D. Alvarado wrote:
> Can anyone recommend a module that I can use to break apart Apache log
> files? We are doing out log file analysis on a separate machine and I
> would like to find a Perl module to help me code a primitive log file
> analysis program that will analyze log files as they are dumped to the
> machine. Thanks - Dave
To find modules, start with CPAN:
http://search.cpan.org/
Apache::ParseLog is probably what you're after.
------------------------------
Date: 27 Oct 2003 09:04:39 -0800
From: rjohnson@shell.com (Roy Johnson)
Subject: Re: Printing folder contents
Message-Id: <3ee08638.0310270904.5f38b07f@posting.google.com>
<mh> wrote in message news:<3f9d0827$1@news.dnainternet.net>...
> I'.m trying to make a simple program which would print the contents of c:\
> folder.
> (files and first sub-folders). Am i at the right track? (this doesn't work)
>
> #!/usr/bin/perl
> use strict;
> print "Content-Type: text/plain\n\n";
> my @folder = <c:\*>;
> foreach my $file (@folder)
> {
> print "$file\n";
> }
> # end
How does it fail? What it should do is load up @folder with a listing
of the files in c:\, and then print the listing.
------------------------------
Date: 27 Oct 2003 10:46:15 -0800
From: kapavars@yahoo.com (Kobe Clinton)
Subject: Re: Question
Message-Id: <52ea746.0310271046.3c42fd5d@posting.google.com>
Thanks for helping me out on the module thing. I am actually working
on it...
By the way,,, I don't even know how this message shot up twice on the
board. I am using Google groups to post messages as against the
Outlook express that I have been using until a while ago. I think that
could be the problem.
Thanks again
James Willmore <jwillmore@remove.adelphia.net> wrote in message news:<20031027040005.5141ed51.jwillmore@remove.adelphia.net>...
> On 26 Oct 2003 19:45:42 -0800
> kapavars@yahoo.com (Kobe Clinton) wrote:
>
> > I would like to know if there is a perl module that would actually
> > help me send gif, gpeg files(like company logos) through Perl.
> > I am able to use net::smtp to generate mails containg text
> > information, however I would like to add company logo in every mail
> > I send.
> > Please let me know
>
> Hummm ... I'm thinking you _may_ have read this before, but ....
>
> MIME::Lite. MIME::Lite::HTML.
>
> To _create_ images, you coulde use GD.
>
> You _could_ also use Net::SMTP or other email modules, but it's, IMHO,
> a royal pain.
>
> HTH
>
> --
> Jim
>
> Copyright notice: all code written by the author in this post is
> released under the GPL. http://www.gnu.org/licenses/gpl.txt
> for more information.
>
> a fortune quote ...
> As long as the answer is right, who cares if the question is
> <wrong?
------------------------------
Date: 27 Oct 2003 06:45:19 -0800
From: qazmlp1209@rediffmail.com (qazmlp)
Subject: Re: rsh & perl -Directory creation not possible
Message-Id: <db9bbf31.0310270645.62719980@posting.google.com>
"Tintin" <me@privacy.net> wrote in message news:<bnat60$v94hk$1@ID-172104.news.uni-berlin.de>...
> "qazmlp" <qazmlp1209@rediffmail.com> wrote in message
> news:db9bbf31.0310210745.5c7c926b@posting.google.com...
> > "Tintin" <me@privacy.net> wrote in message
> news:<bn336u$r9k3k$1@ID-172104.news.uni-berlin.de>...
> > > "qazmlp" <qazmlp1209@rediffmail.com> wrote in message
> > > news:db9bbf31.0310210142.1b5acfed@posting.google.com...
> > > > I have a perl script which creates a directory in the local machine.
> > > > But, if I call this script from the remote machine using rsh, the
> > > > directory is not created. And there is no error message reported. Why
> > > > is that so ?
> > > >
> > > > What is the remedy for this ?
> > >
> > > Does your script have something like?
> > >
> > > mkdir '/path/to/dir' or die "Can not mkdir /path/to/dir $!\n";
> > >
> > > If not, why not?
> >
> > I have mkdir command in the script.
> > When the rsh was executed with 'mkdir' directly, it worked and the
> > directory was created. But, when the perl script(containing mkdir) was
> > executed, it did not work.
>
> You still haven't answered by previous question.
>
> Post a relevant snippet of your code.
Here is an excerpt from the script:
$opath=$ProtName;
opendir(DIR,$opath) || system("mkdir $ProtName");
closedir (DIR);
I don't know whether it helps to find the cause of the problem.
Meanwhile, the problem was solved by selecting the option,
"execute all rsh commands as user: ", for rsh in remote machine.
------------------------------
Date: 27 Oct 2003 06:49:37 -0800
From: qazmlp1209@rediffmail.com (qazmlp)
Subject: Running system() commands in background
Message-Id: <db9bbf31.0310270649.5c6b3376@posting.google.com>
Whenever system("command") is called in a perl script, a new
(commandline) window opens and shows the execution of the "command".
What do I need to do if
I have to run the command in the background? Basically, I do not
prefer the user to see what is happening when the perl script is being
executed.
The test was done in Win2K & the solution is required in the same.
Thanks!
------------------------------
Date: Mon, 27 Oct 2003 14:59:15 +0000
From: Helgi Briem <HelgiBriem_1@hotmail.com>
Subject: Re: Running system() commands in background
Message-Id: <akcqpv0723gl98a2b1g3oc2n37s8d15oau@4ax.com>
On 27 Oct 2003 06:49:37 -0800, qazmlp1209@rediffmail.com (qazmlp)
wrote:
>Whenever system("command") is called in a perl script, a new
>(commandline) window opens and shows the execution of the "command".
>What do I need to do if
>I have to run the command in the background? Basically, I do not
>prefer the user to see what is happening when the perl script is being
>executed.
>
>The test was done in Win2K & the solution is required in the same.
Have a look at perldoc perlwin32
Specifically, you want to run your script using wperl.exe
instead of perl.exe.
------------------------------
Date: Mon, 27 Oct 2003 15:00:39 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: Running system() commands in background
Message-Id: <Pine.LNX.4.53.0310271458360.27527@ppepc56.ph.gla.ac.uk>
On Mon, 27 Oct 2003, qazmlp wrote:
> Whenever system("command") is called in a perl script, a new
> (commandline) window opens and shows the execution of the "command".
> What do I need to do if
> I have to run the command in the background?
What you need to do is to read the Windows-specific documentation for
whichever Windows port of Perl you are using.
AFAIR, in the case of ActiveState Perl, it tells you that you'd
execute wperl instead of perl. It worked for me (it's been a while,
which is why I'm suggesting you read the doc instead of just blindly
following anything I might say).
------------------------------
Date: 27 Oct 2003 06:26:21 -0800
From: google@spongers.com (John Deuf)
Subject: Sorting case insensitively
Message-Id: <9760255.0310270626.3708125d@posting.google.com>
Is there a way to sort case insensitively an array (without creating
another array with lowercase values for instance) ?
------------------------------
Date: Mon, 27 Oct 2003 14:36:42 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Sorting case insensitively
Message-Id: <Xns94219E971EF41elhber1lidotechnet@62.89.127.66>
google@spongers.com (John Deuf) wrote in
news:9760255.0310270626.3708125d@posting.google.com:
> Is there a way to sort case insensitively an array (without creating
> another array with lowercase values for instance) ?
my @sorted = sort { lc $a cmp lc $b } @unsorted;
--
Cheers,
Bernard
------------------------------
Date: Mon, 27 Oct 2003 14:43:11 +0000 (UTC)
From: Andreas Kahari <ak+usenet@freeshell.org>
Subject: Re: Sorting case insensitively
Message-Id: <slrnbpqbnu.84i.ak+usenet@norge.freeshell.org>
In article <9760255.0310270626.3708125d@posting.google.com>, John Deuf wrote:
> Is there a way to sort case insensitively an array (without creating
> another array with lowercase values for instance) ?
sort { uc($a) cmp uc($b) } @arr;
--
Andreas Kähäri
------------------------------
Date: Mon, 27 Oct 2003 15:14:43 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Sorting case insensitively
Message-Id: <x7d6ci3e70.fsf@mail.sysarch.com>
>>>>> "AK" == Andreas Kahari <ak+usenet@freeshell.org> writes:
AK> sort { uc($a) cmp uc($b) } @arr;
>>>>> "BE" == Bernard El-Hagin <bernard.el-haginDODGE_THIS@lido-tech.net> writes:
BE> my @sorted = sort { lc $a cmp lc $b } @unsorted;
now make up your minds!! which one of those is better? will there be
another war on uc vs lc?
:)
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 27 Oct 2003 15:33:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Sorting case insensitively
Message-Id: <bnjdrd$6tn$2@wisteria.csv.warwick.ac.uk>
Uri Guttman <uri@stemsystems.com> wrote:
> >>>>> "AK" == Andreas Kahari <ak+usenet@freeshell.org> writes:
>
> AK> sort { uc($a) cmp uc($b) } @arr;
>
> >>>>> "BE" == Bernard El-Hagin
> <bernard.el-haginDODGE_THIS@lido-tech.net> writes:
> BE> my @sorted = sort { lc $a cmp lc $b } @unsorted;
>
> now make up your minds!! which one of those is better? will there be
> another war on uc vs lc?
I thought there was a Right Answer to this: lc, as Unicode defines
mappings upper -> lower and title -> lower...?
Ben
--
For the last month, a large number of PSNs in the Arpa[Inter-]net have been
reporting symptoms of congestion ... These reports have been accompanied by an
increasing number of user complaints ... As of June,... the Arpanet contained
47 nodes and 63 links. [ftp://rtfm.mit.edu/pub/arpaprob.txt] * ben@morrow.me.uk
------------------------------
Date: 27 Oct 2003 16:09:53 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <slrnbpqgqg.cte.abigail@alexandra.abigail.nl>
T. Sander (roetz7@unicum.de) wrote on MMMDCCIX September MCMXCIII in
<URL:news:1b27f62d.0310270504.242cac55@posting.google.com>:
==
== Thank you for your reply. Now it works.
== But why have I to use two [?
== Where is the difference between [a-z] and [:lower:]? For [a-z] I get the ra
== of letters and not only 'a','-' and 'z'. Why not the same for [:lower:]?
== In which case can I use only [:lower:] without an additional [] pair?
Because now you *can* do the same as with ranges: you can combine them.
[a-z0-9] # Lowercase letters *and* digits.
[[:lower:][:digit:]] # Lowercase letters *and* digits.
Or:
[01[:alpha:]%] # 0, 1, letters and %.
Furthermore, the POSIX specification says you have to do it this way,
and it's not just Perl:
$ echo "Hel8oo" | grep '[:digit:]'
$ echo "Hel8oo" | grep '[[:digit:]]'
Hel8oo
$
Abigail
--
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
/ / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / /
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'
------------------------------
Date: Mon, 27 Oct 2003 16:20:05 +0000
From: "Alan J. Flavell" <flavell@ph.gla.ac.uk>
Subject: Re: strange effect with [:lower:] in perl
Message-Id: <Pine.LNX.4.53.0310271613300.27527@ppepc56.ph.gla.ac.uk>
On Mon, 27 Oct 2003, Abigail wrote:
> Because now you *can* do the same as with ranges: you can combine them.
>
> [a-z0-9] # Lowercase letters *and* digits.
Surely that only refers to a subset of what Unicode considers to be
"letters"?
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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.
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 V10 Issue 5716
***************************************