[23006] in Perl-Users-Digest
Perl-Users Digest, Issue: 5226 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 15 18:05:55 2003
Date: Tue, 15 Jul 2003 15:05:08 -0700 (PDT)
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, 15 Jul 2003 Volume: 10 Number: 5226
Today's topics:
cgi pgms using 2 versions of perl (Dave Bartels)
Re: Cleaning out a text file. <uri@stemsystems.com>
Re: Determine a child PID <john.thetenant-s@moving-picture.com>
Re: Determine a child PID <pinyaj@rpi.edu>
Re: duplicate removal (JDeBaun)
Re: ERROR.. with regex!! nobull@mail.com
Re: ERROR.. with regex!! <bigj@kamelfreund.de>
Re: ERROR.. with regex!! <krahnj@acm.org>
Re: Flavell's second law? Was: Automatic page forward <jacqui.caren@ntlworld.com>
Re: flock() and W95 <bart.lateur@pandora.be>
Re: shorten expression <john.thetenant-s@moving-picture.com>
Re: shorten expression <todd@tdegruyl.com>
Re: shorten expression <pinyaj@rpi.edu>
Re: shorten expression <pinyaj@rpi.edu>
Re: shorten expression <pinyaj@rpi.edu>
Re: shorten expression <john.thetenant-s@moving-picture.com>
Re: shorten expression (John D)
Re: shorten expression (Sam Holden)
Re: simple, stupid perl package Q <john.thetenant-s@moving-picture.com>
Re: text parse (david)
Re: TOO SLOW: `echo ${LINE} | sed -n 's/^.* proto / (secheese)
Re: transform 3*0.0 into 0.0, 0.0, 0.0 <starobs99@yahoo.com>
Re: Translation with PERL? (Jon)
Re: Translation with PERL? <scriptyrich@yahoo.co.uk>
Re: Use module (maybe) w/o dying <jaspax@u.washington.edu>
using fifo (jr)
Re: What are 'Perl 5 style templates'? <jacqui.caren@ntlworld.com>
Re: Win 32 Ole, Word Automation <brian_helterline@hp.com>
Win32::GUI jnk@kenobiz.com
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 15 Jul 2003 14:14:27 -0700
From: dave.bartels@sungardss.com (Dave Bartels)
Subject: cgi pgms using 2 versions of perl
Message-Id: <4b975214.0307151314.49d71928@posting.google.com>
Greetings;
I find myself calling perl cgi scripts utilizing 2 different versions
of perl. This is because I couldn't get DB-Oracle to talk to Oracle9i
under my previous perl and couldn't get Mozilla ldap modules for the
new environment(perl5.4004_04 and perl-5.8.0.806 respectively). This
is a Solaris8 server running Apache 1.37.
My user maint script offers the possibility of changing user passwords
as well as other info. When the the html page producesed by
maintscriptA is filled in by the user, it is sent in to the server and
calls maintscript2 which edits and processes it. If no password change
is called for maintscript2 returns to maintscriptA with status message
such as "User changed successfully" or the like. These scripts are
handled by perl5.8 and all is well.
If however an ldap update (or add, or delete) is called for,
maintscript2 calls one of my ldapchg.pl (or ldapadd.pl or ldapdel.pl)
scripts which specify on their first line !#/user/bin/perl5.4/perl -
calling for the earlier perl to do the actual ldap work. The update
actually works, returns a status to maintscript2 and the flow operates
the same as the previous description except that somebody is messing
with the actual output to the browser. I end up with an extra
Content-Type header specifying "text/plain" which of course causes the
browser to display the html itself intead of interpreting it.
Has anybody seen anything like this before? Is this related to having
2 perl interpreters working in this environment.
Thanks
------------------------------
Date: Tue, 15 Jul 2003 15:16:45 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Cleaning out a text file.
Message-Id: <x7wuej6crn.fsf@mail.sysarch.com>
>>>>> "JE" == Jürgen Exner <jurgenex@hotmail.com> writes:
JE> Uri Guttman wrote:
>>
>> perldoc -f truncate
>>
>> or unlink and utime will do it.
JE> Careful! If you unlink the file then only this directoy entry will be
JE> removed. If there are several hard links pointing to the same file, then
JE> maybe the OPs intention was to actually empty this original file.
JE> Unlink will actually remove the entry and when re-creating a file with the
JE> same name it will be a new file that is not related to the old file any
JE> longer, i.e. the other hardlinks will still point to the old file.
that is the OP's worry and not mine.
i do know about links and dirs a little :)
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: Tue, 15 Jul 2003 16:01:40 +0100
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: Determine a child PID
Message-Id: <20030715160140.767c9a87.john.thetenant-s@moving-picture.com>
On 15 Jul 2003 07:47:14 -0700
jzh9@yahoo.com (Joey) wrote:
>
> I am trying to determine the PID when opening of a file handle from within
> my main perl code. Here is a snip where i call the open file handle.
>
> $infile = 'infile';
> open(IF, "tail -f $infile|") or die "Cannot open pipe $infile\n";
>
> while (<IF>) {
> do_smothing()
> }
>
> In the example below in unix the main perl code has a pid of perl variable
> $$ (PID=18629) then the open file handle has another PID, a child of the
> parent (PID = 18630)
>
> % ps -ef| grep tail
> user 18632 18455 0 10:42:06 pts/10 0:00 grep tail
> user 18630 18629 0 10:42:02 pts/10 0:00 tail -f infile
> % ps -ef| grep myscript.pl
> user 18634 18455 0 10:42:12 pts/10 0:00 grep myscript.pl
> user 18629 18455 0 10:42:02 pts/10 0:00 /usr/bin/perl ./myscript.pl
>
> Is there a way within perl to get the child PID 18630 ?
>
> Thanks in advance.
> Joey
open() should do that for you. it's in "perldoc -f open",
the bit where it says: "If the `open' involved a pipe, the
return value happens to be the pid of the subprocess."
which is nice.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
------------------------------
Date: Tue, 15 Jul 2003 11:28:51 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Joey <jzh9@yahoo.com>
Subject: Re: Determine a child PID
Message-Id: <Pine.SGI.3.96.1030715112700.17707D-100000@vcmr-64.server.rpi.edu>
[posted & mailed]
On 15 Jul 2003, Joey wrote:
>I am trying to determine the PID when opening of a file handle from within
>my main perl code. Here is a snip where i call the open file handle.
>
>$infile = 'infile';
>open(IF, "tail -f $infile|") or die "Cannot open pipe $infile\n";
When open() is doing more than just opening a file (that is, when you're
piping), it returns not only success or failure, but the actual PID.
my $pid = open(TAIL, "tail -f $infile |")
or die "cannot `tail -f $infile`: $!";
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: 15 Jul 2003 11:53:15 -0700
From: jdebaun@prodigy.net (JDeBaun)
Subject: Re: duplicate removal
Message-Id: <f04056.0307151053.2404b417@posting.google.com>
john62@electronmail.com wrote in message news:<3f10af06_2@127.0.0.1>...
> ok, this is probably another easy question. does anyone
> know how to remove duplicates in a list of strings?
>
> basically, i have a list of newsgroup message subjects.
> sometimes people accidentally post twice, so i need to
> remove the dups.
>
> thx
>
>
> --------------------------------------------------------------------
> For free web access to newsgroups, please visit
> http://www.coldmail.us/. Thanks
> --------------------------------------------------------------------
>
>
> ----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==----
> http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
> ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
try:
@UniqArray = grep(!$saw{$_}++, @DuplicateArray);
------------------------------
Date: 15 Jul 2003 09:47:11 -0700
From: nobull@mail.com
Subject: Re: ERROR.. with regex!!
Message-Id: <4dafc536.0307150847.8da976c@posting.google.com>
darkname <member31962@dbforums.com> wrote in message news:<3111508.1058262112@dbforums.com>...
> I have the following code!!
>
> foreach $line (@fich){
> $i++;
> foreach $comm (@com){
> if(($line eq $comm)||($line=~/$comm/)){
> print"Line $i: $comm";
> }
> }
> }
>
> The problem is that the instruction in the if condition ($line=~/$comm/)
> gives me an error!!! "Nested quantifiers before HERE mark in regex m//**
> << HERE"....
>
> The @comm and @fich arrays contain the contents of two distinct files!
>
> Can someone tell me why this code gives me this error!?
The file from which @com is loaded contains somewhere the sequence
'**'.
Perhaps that's just a mistake in the file.
Perhaps you didn't tell the person who provided the file that you were
expecting a file full of (Perl) regular expressions.
Trying to interpret something that is not a valid regular expression
as a regular expression can lead to errors.
Actually this is not specific to regular expressions - it applies
equally to arithmetic expressions, SQL statemnts, Perl statements,
sentences in French... whatever. In general, trying to interpret
something that is not a valid[whatever] as a [whatever] can lead to
errors.
If you never indended that the file would contain regular expression
then you need to learn out about the \Q interpolation escape (also
known as the quotemeta() function) and/or the index() function.
See also posting guidelines.
------------------------------
Date: Tue, 15 Jul 2003 14:12:39 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: ERROR.. with regex!!
Message-Id: <pan.2003.07.15.06.46.16.474116@kamelfreund.de>
darkname wrote at Tue, 15 Jul 2003 09:41:52 +0000:
> foreach $line (@fich){
> $i++;
> foreach $comm (@com){
> if(($line eq $comm)||($line=~/$comm/)){
> print"Line $i: $comm";
> }
> }
> }
>
> The problem is that the instruction in the if condition ($line=~/$comm/)
> gives me an error!!! "Nested quantifiers before HERE mark in regex m//**
> << HERE"....
>
> The @comm and @fich arrays contain the contents of two distinct files!
>
> Can someone tell me why this code gives me this error!?
I suppose that $comm has some special characters inside, that are
interpreted in regexes. In this case, they seem to create a "Nested
quantifier ..." error (perhaps there is something like ?*? or so inside).
You switch this behaviour completely off with automatic quoting of the
variable content:
/\Q$comm/ instead of only /$comm/, but I'm not sure whether you want it
:-)
Greetings,
Janek
------------------------------
Date: Tue, 15 Jul 2003 18:39:06 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: ERROR.. with regex!!
Message-Id: <3F144A87.CF247F35@acm.org>
darkname wrote:
>
> I have the following code!!
>
> foreach $line (@fich){
> $i++;
> foreach $comm (@com){
> if(($line eq $comm)||($line=~/$comm/)){
> print"Line $i: $comm";
> }
> }
> }
>
> The problem is that the instruction in the if condition ($line=~/$comm/)
> gives me an error!!! "Nested quantifiers before HERE mark in regex m//**
> << HERE"....
>
> The @comm and @fich arrays contain the contents of two distinct files!
>
> Can someone tell me why this code gives me this error!?
The problem is that the contents of $comm contains characters that are
special to regular expressions. Use index() instead:
foreach my $line ( @fich ) {
$i++;
foreach my $comm ( @com ) {
if ( index( $line, $comm ) >= 0 ) {
print "Line $i: $comm";
}
}
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 15 Jul 2003 22:58:10 +0100
From: Jacqui Caren <jacqui.caren@ntlworld.com>
Subject: Re: Flavell's second law? Was: Automatic page forwarding in cgi perl script
Message-Id: <Xns93B9E9AC5941Ajacquicntlworldcom@195.8.68.222>
"Derek.Moody" <derek.moody@clara.net> wrote in news:ant110013e61BxcK@half-
baked-idea.co.uk:
>
> Does this have sufficient status to become Flavell's second law?
> Opinions?
>
Seconded :-)
Jacqui
------------------------------
Date: Tue, 15 Jul 2003 19:19:24 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: flock() and W95
Message-Id: <3sk8hv4v0hqc2lkn56719km95eptojom10@4ax.com>
Gunnar Hjalmarsson wrote:
>Peter Dintelmann wrote:
>> since I have no W95/98 box available, can you tell
>> what the output of
>>
>> perl -MConfig -le "print $Config{d_flock}"
>>
>> is on such a system?
>
>It outputs:
>
>define
Well NT and descendants can flock(), AFAIK. And even though Win95 and
descendatnts can't, they do share the same binaries -- thus: the same
Config settings.
--
Bart.
------------------------------
Date: Tue, 15 Jul 2003 16:14:17 +0100
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: shorten expression
Message-Id: <20030715161417.11497a59.john.thetenant-s@moving-picture.com>
On Tue, 15 Jul 2003 16:42:39 +0200
ZZT <a@b.c> wrote:
>
> Hi,
>
> is there a way to shorten this expression?
>
> $host=~/^(\S*)\s*/; $host=$1;
>
> thanks!
>
$host=~s/\s.*//;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
------------------------------
Date: Tue, 15 Jul 2003 15:20:25 GMT
From: Todd de Gruyl <todd@tdegruyl.com>
Subject: Re: shorten expression
Message-Id: <ZYUQa.8$634.4@nwrdny03.gnilink.net>
ZZT wrote:
> is there a way to shorten this expression?
>
> $host=~/^(\S*)\s*/; $host=$1;
take a look at perldoc -q space
$host =~ s/\s+$//;
--
Todd de Gruyl
Design and Development Solutions | Phone: (413) 221-9450
for the Web and Desktop. | Web: http://www.tdegruyl.com
------------------------------
Date: Tue, 15 Jul 2003 11:26:05 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: shorten expression
Message-Id: <Pine.SGI.3.96.1030715112248.17707C-100000@vcmr-64.server.rpi.edu>
On Tue, 15 Jul 2003, ZZT wrote:
>is there a way to shorten this expression?
>
>$host=~/^(\S*)\s*/; $host=$1;
Well, as it stands, even if the regex FAILS, $host will be set to whatever
$1 was before the regex. Assuming you DON'T want this behavior, then you
can do:
($host) = $host =~ /(\S*)/;
By the way, your regex is weird. The \s* at the end is useless, since it
means it can match zero characters at the end of the regex. Since you
don't even use them, you can remove them. And the ^ anchor isn't needed
either, since (\S*) can match zero characters if necessary.
Another way to do it is
$host =~ s/\s.*//s;
That removes everything from the first space to the end of the string.
But I have a feeling my first approach is better.
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Tue, 15 Jul 2003 11:36:34 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: shorten expression
Message-Id: <Pine.SGI.3.96.1030715113500.23640B-100000@vcmr-64.server.rpi.edu>
On Tue, 15 Jul 2003, John Strauss wrote:
>On Tue, 15 Jul 2003 16:42:39 +0200
>ZZT <a@b.c> wrote:
>>
>> is there a way to shorten this expression?
>>
>> $host=~/^(\S*)\s*/; $host=$1;
>
>$host=~s/\s.*//;
That won't remove a trailing newline, which WILL be a problem. Even if
there's nothing after the newline, the original code will give you a
string with NO WHITESPACE at all; yours will keep a newline at the end of
$host.
Either add the /s modifier to the substitution, or take a different
approach like
($host) = $host =~ /(\S*)/;
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Tue, 15 Jul 2003 11:38:09 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: shorten expression
Message-Id: <Pine.SGI.3.96.1030715113644.23640C-100000@vcmr-64.server.rpi.edu>
On Tue, 15 Jul 2003, Todd de Gruyl wrote:
>ZZT wrote:
>> is there a way to shorten this expression?
>>
>> $host=~/^(\S*)\s*/; $host=$1;
>
>$host =~ s/\s+$//;
How do you know he has a string like "hostname "? Maybe the string is
"hostname ip.ad.dr.ess etc". Just removing the trailing whitespace is not
good enough. The OP clearly needs the content before the first whitespace
(even if it's nothing, it seems).
--
Jeff Pinyan RPI Acacia Brother #734 2003 Rush Chairman
"And I vos head of Gestapo for ten | Michael Palin (as Heinrich Bimmler)
years. Ah! Five years! Nein! No! | in: The North Minehead Bye-Election
Oh. Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)
------------------------------
Date: Tue, 15 Jul 2003 16:51:14 +0100
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: shorten expression
Message-Id: <20030715165114.6463ff6a.john.thetenant-s@moving-picture.com>
On Tue, 15 Jul 2003 11:36:34 -0400
Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote:
>
> On Tue, 15 Jul 2003, John Strauss wrote:
>
> >On Tue, 15 Jul 2003 16:42:39 +0200
> >ZZT <a@b.c> wrote:
> >>
> >> is there a way to shorten this expression?
> >>
> >> $host=~/^(\S*)\s*/; $host=$1;
> >
> >$host=~s/\s.*//;
>
> That won't remove a trailing newline, which WILL be a problem. Even if
> there's nothing after the newline, the original code will give you a
> string with NO WHITESPACE at all; yours will keep a newline at the end of
> $host.
>
> Either add the /s modifier to the substitution, or take a different
> approach like
>
> ($host) = $host =~ /(\S*)/;
>
right.
$host=~s/\s.*//s;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
------------------------------
Date: 15 Jul 2003 10:51:04 -0700
From: johndageek@yahoo.com (John D)
Subject: Re: shorten expression
Message-Id: <c608545f.0307150951.79a773d@posting.google.com>
ZZT <a@b.c> wrote in message news:<bf13t2$n74$1@news1.wdf.sap-ag.de>...
> Hi,
>
> is there a way to shorten this expression?
>
> $host=~/^(\S*)\s*/; $host=$1;
>
> thanks!
several ways but how about
$host=~s/\s+.+//;
or
($host)=$host=~/^(\S*)\s*/;
Enjoy
Jd
------------------------------
Date: 15 Jul 2003 18:16:11 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: shorten expression
Message-Id: <slrnbh8h7a.keo.sholden@flexal.cs.usyd.edu.au>
On 15 Jul 2003 10:51:04 -0700, John D <johndageek@yahoo.com> wrote:
> ZZT <a@b.c> wrote in message news:<bf13t2$n74$1@news1.wdf.sap-ag.de>...
>> Hi,
>>
>> is there a way to shorten this expression?
>>
>> $host=~/^(\S*)\s*/; $host=$1;
>>
>> thanks!
> several ways but how about
> $host=~s/\s+.+//;
That's not the same, for example $host="abc ".
$host=~s/\s+.*//s;
would be an equivalent expression. or:
$host=~s/\s.*//s;
> or
> ($host)=$host=~/^(\S*)\s*/;
Or even:
($host) = split / /, $host, 2;
Of course there's no need for the \s* in that regex. Since just
/^(\S*)/ matches (and captures) exactly the same things.
--
Sam Holden
------------------------------
Date: Tue, 15 Jul 2003 17:10:30 +0100
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: simple, stupid perl package Q
Message-Id: <20030715171030.0e5e53a2.john.thetenant-s@moving-picture.com>
On Wed, 09 Jul 2003 11:09:12 -0700
Joseph Cipale <joec@aracnet.com> wrote:
>
> I have written a package in perl, and I want to include it in a script
> I am developing. I have it in my /home/joec/public_html/cgi directory.
>
> When I try to invoke the script to test the pacakge inclusion, I get the
> following message:
> Can't locate CGILib/Error.pm in @INC (@INC contains:
> /usr/lib/perl5/5.6.0/i686-linux /usr/lib/perl5/5.6.0
> /usr/lib/perl5/site_perl/5.6.0/i686-linux /usr/lib/perl5/site_perl/5.6.0
> /usr/lib/perl5/site_perl/5.005 /usr/lib/perl5/site_perl) at catbird.cgi
> line 19.
>
> In my .cshrc file, I have set the PERL5LIB env var to my path where the
> package
> module is located. Is there anything else I can do/should do to get this
> to work?
>
> Regards,
>
> Joe Cipale
try this. add this line below the shebang line,
but before you call your package:
use lib '/home/joec/public_html/cgi';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail
------------------------------
Date: 15 Jul 2003 11:28:37 -0700
From: dwlepage@yahoo.com (david)
Subject: Re: text parse
Message-Id: <b09a22ae.0307151028.3c9e869d@posting.google.com>
dwlepage@yahoo.com (david) wrote in message news:<b09a22ae.0307141743.2450c9a4@posting.google.com>...
> Im trying to parse a file with data such as this:
> (ip's changed for obvious reasons)
>
> acl add table=ipaddr name=127.0.0.1 burb=Firewall \
> comments='Firewall network object for DNS proxy ACL redirection' \
> lastchangedby='root on 08/12/02 13:36:23'
> acl add table=ipaddr name=127.1.1.1 burb=external \
> lastchangedby='dlepage on 06/24/03 10:25:30'
>
> I want the end output to look like:
>
> acl add name=127.0.0.1 ipaddr=127.0.0.1 comments='Firewall network
> object for DNS proxy ACL redirection'
> acl add name=127.1.1.1 ipaddr=127.1.1.1 comments=
>
> so basically I only want to capture the IP after the 'name=' value,
> and anything in the 'comments' field, if at all. Here is what I have
> so far, which works, but im so new to programming that I know my
> coding stinks. Any suggestions to make this more efficient
> appreciated.
>
> #!/usr/bin/perl -w
> use strict;
>
> my ($ip,$comment);
>
> open(IN, "<$ARGV[0]") || die "Cant open $!";
> flock (IN, 1);
>
> while( <IN> ) {
> s/\\//g; # get rid of newlines
>
> # match on acl's with comments
> if (/^acl add table=ipaddr name=(\d+\.\d+\.\d+\.\d+) burb=(.+)
> comments=
> (.+)/) {
> print "acl add name=$1 ipaddr=$1 comments=$3\n";
> }
>
> # else match without comments
> elsif (/^acl add table=ipaddr name=(\d+\.\d+\.\d+\.\d+)
> burb=(.+)$/) {
> print "acl add name=$1 ipaddr=$1 comments=\n";
> }
> }
> close(IN);
>
> -d
I did find a bug with this. There are continuation lines for each
entry. Each line that I want to analyze should start with the 'add acl
table' - this current version will not properly grab data after the
continuation (\) line. Im trying to remove these now.
------------------------------
Date: Tue, 15 Jul 2003 17:20:04 GMT
From: secheese@hotmail.com (secheese)
Subject: Re: TOO SLOW: `echo ${LINE} | sed -n 's/^.* proto //p' | cut -f1 -d" "`
Message-Id: <3f1412a0.132671942@news.nbnet.nb.ca>
Your suggestion worked beautifully! The speed is incredible now;
guess using built-in shell code is always the better choice than
calling external commands. I never even considered these constructs;
to be honest I had forgotten they existed.
Thanks.
On Mon, 14 Jul 2003 10:22:53 -0500, Ben <ben_altman@deadspam.com>
wrote:
>secheese wrote:
>>
>> PROTOCOL=`echo ${LINE} | sed -n 's/^.* proto //p' | cut -f1 -d" "`
>>
>> Trouble is, this command takes about 10 times as long to run as the
>
> From a POSIX type shell:
> PROTOCOL=${LINE#* proto } # chop everything up to 'proto'
> PROTOCOL=${PROTOCOL%% *} # chop everything down to first field
>
>regards,
>Ben
>
>--
>BTW. I can be contacted at Username:newsgroup4.replies.benaltw
>Domain:xoxy.net
>
------------------------------
Date: Tue, 15 Jul 2003 16:21:52 -0500
From: CM <starobs99@yahoo.com>
Subject: Re: transform 3*0.0 into 0.0, 0.0, 0.0
Message-Id: <bf1r9g$a0md5$1@ID-189674.news.uni-berlin.de>
Thanks a lot, the other one was really wrong and I was diving in the
code that output the results to find the bug.
Now everything is correct.
Cheers,
CM
nobull@mail.com wrote:
> #!/usr/bin/perl
> use strict;
> use warnings;
> while (<>) {
> # chomp() technically redundant here - but a good habit...
> chomp;
>
> # replace comma with space
> tr/,/ /;
>
> # Process the "*"s
> s/(\S+)\s*\*\s*(\S+)/"$1 " x $2/eg;
>
> # Normalise the whitespace
> s/^\s+//; # Strip leading whitespace
> s/\s+$//; # Strip trailing whitespace
> s/\s+/ /g; # All whitespace becomes a single space
>
> print "$_\n";
> }
> __END_
------------------------------
Date: 15 Jul 2003 08:52:00 -0700
From: jmckinley@netbotz.com (Jon)
Subject: Re: Translation with PERL?
Message-Id: <43e4cdd3.0307150752.281fe926@posting.google.com>
Bart Lateur <bart.lateur@pandora.be> wrote in message news:<b1i7hv842prlkpshg45d4q1p3kap7qk3fp@4ax.com>...
> Jon wrote:
>
> >The translation was
> >done with property files holding each language as well as image urls.
> >My questions is can something like this be done with perl and apache.
> >Can a property file be just a text file that is referenced for
> >different languages?
>
> Yes.
>
> As someone else pointed out, you can use modules to manipulate config
> files to load the data. I myself would take a good look at YAML, which
> provides a neat way to store perl data structures in rather plain text
> files. Or you could use tabs separated text files (or CSV), and edit the
> data in a spreadsheet like Excel.
>
> If this is for mod_perl, it might be interesting to cache the data in an
> itnernal global data structure (untested, but I think it should work).
> That is: violate the strict separation of data spaces between scripts on
> purpose, and use a global variable.
>
> You can hang whole hashes off a subkey, for example
>
> $text{NL}{title}
>
> could hold the title for Dutch... while *all* translations for Dutch
> hang under $text{NL}, which is a hash ref.
>
> In this case, unless you want to have to restart the server every time a
> translation changes, you should include a make-like system that check
> the date of the last update of a file, and reload the data if the data
> file had been changed. Be careful to include locking, you don't want to
> reload the same data structure in two scripts at approximately the same
> time.
Very Cool Guys. Thanks. I've been looking into the Config modules,
didn't even know they were there. Look like they'll do the job. Thanks
again.
------------------------------
Date: Tue, 15 Jul 2003 16:58:40 +0000
From: Rich <scriptyrich@yahoo.co.uk>
Subject: Re: Translation with PERL?
Message-Id: <bf18a1$5pi$1@news6.svr.pol.co.uk>
Jon wrote:
> I've been using Perl for the past two years on my companies website.
> I've also enlisted Embeded perl (mod_perl) which is very, very cool!
>
> I've been tasked with redesigning the site again and I must keep
> translation in mind. I've been involved before with translating a
> website that ran off JAVA, jsp pages and webshere. The translation was
> done with property files holding each language as well as image urls.
> My questions is can something like this be done with perl and apache.
> Can a property file be just a text file that is referenced for
> different languages? I'm just hoping some of you out there can give me
> a little advice before I start this project. Any ideas or help are
> greatly appreciated.
>
> Jon
Hi Jon,
Locale::Maketext with Locale::Maketext::Lexicon is the most sophisticated
way to go ATM. You could then use .po[t] format files which are supported
by translation tools such as kbabel.
Another poster suggested something based round YAML - I like YAML, but I
don't think YAML.pm handles utf8 encoding yet, which would probably be a
show stopper.
Cheers,
--
Rich
scriptyrich@yahoo.co.uk
------------------------------
Date: Tue, 15 Jul 2003 13:55:36 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Use module (maybe) w/o dying
Message-Id: <Pine.A41.4.55.0307151352120.91260@dante60.u.washington.edu>
nobull@mail.com sikyal:
> sholden@flexal.cs.usyd.edu.au (Sam Holden) wrote in message news:<slrnbh7fkd.75q.sholden@flexal.cs.usyd.edu.au>...
> > On Tue, 15 Jul 2003 00:07:46 -0700, JS Bangs <jaspax@u.washington.edu> wrote:
> > > I'm stumped. I wanted to use a module if it was available, but not to die
> > > if the module was unavailable. I originally wrote:
> > >
> > > our $WHATIF = 0;
> > > eval {
> > > use Whatif;
> > > $WHATIF = 1;
> > > };
>
> > eval "use Whatif;";
> > $WHATIF = 1 unless $@;
>
> I prefer the idiom:
>
> our $WHATIF = eval "use Whatif; 1";
I had tried the string approach, but with no luck. Looking at the debugger
more carefully, it appears that Whatif is successfully used, but the
whatif block later in the codes doesn't work correctly.
I suspect the problem has to do with the whatif block itself, now. Thanks
for helping me eliminate this as a potential source of the problem.
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog
------------------------------
Date: 15 Jul 2003 09:24:02 -0700
From: scw_00@yahoo.com (jr)
Subject: using fifo
Message-Id: <b574c5ab.0307150824.57d3e9d2@posting.google.com>
i would like to use fifo to maintain a db server connection ( such as
isql ...), so when there is not enough connection error i still can
send kill cmd to db server to kill some users and free up some
connections. i know how to use fifo to a file, but not "isql -Usa
...". Any information is greatly appreciated.
jr
------------------------------
Date: Tue, 15 Jul 2003 22:51:10 +0100
From: Jacqui Caren <jacqui.caren@ntlworld.com>
Subject: Re: What are 'Perl 5 style templates'?
Message-Id: <Xns93B9E87C03AB8jacquicntlworldcom@195.8.68.222>
inwap@inwap.com (Joe Smith) wrote in
news:4gsNa.225$603.12107@iad-read.news.verio.net:
> In article <bdrqav$sj2$1@newsreader.mailgate.org>,
> Kasp <kasp@epatra.com> wrote:
>>My client wrote to me...
>>"All scripts must be written in perl 5. Use Perl 5 style templates for
>>all pages and emails associated with the perl scripts"
>
> Your client sent you an incomplete message.
> The next line of the message should have been:
>
> "Attached is a ZIP file containing acceptable Perl 5 style
> templates."
>
> -Joe
Why bother just type "perldoc perlstyle" :-)
Or am I missing something?
Jacqui
------------------------------
Date: Tue, 15 Jul 2003 13:10:10 -0700
From: "Brian Helterline" <brian_helterline@hp.com>
Subject: Re: Win 32 Ole, Word Automation
Message-Id: <3f1464df$1@usenet01.boi.hp.com>
"Peter Wilson" <peter_wilson@mail.com> wrote in message
news:bf103l$ahp$1@sparta.btinternet.com...
> Hi
>
> Im having problems putting pictures into my word document. I can get
> pictures in but they all appear ontop of each other as oppose to where the
> cursor is, I am also inserting a line on each page as well and that
appears
> at the wrong place as well. So I guess im doing something fundamentally
> wrong. Can anyone tell me what im doing wrong or how to move the picture
> onto each page, this is a small section of a larger document so I would
like
> to have lots of flexibility this is why have decided not to use a mail
> merge.
Try $thisdoc->InlineShapes->AddPicture(.....
so the pictures flow with the text rather than in front/behind the text.
-brian
------------------------------
Date: Tue, 15 Jul 2003 21:37:20 GMT
From: jnk@kenobiz.com
Subject: Win32::GUI
Message-Id: <d1t8hvovo14g2uikal7rcv7foc8kuds36b@4ax.com>
In the documentation that I have read about this module it tells only
about manipulating the windows that you have created with it. What
about windows that are already in existence....how can i manipulate
them. Press buttons, close them and what not.
Should I seek a different module?
Thanks for your time and attention.
------------------------------
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 5226
***************************************