[22611] in Perl-Users-Digest
Perl-Users Digest, Issue: 4832 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Apr 11 14:07:47 2003
Date: Fri, 11 Apr 2003 11:05:07 -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 Fri, 11 Apr 2003 Volume: 10 Number: 4832
Today's topics:
Re: A better way to extract a substring? <barryk2@SPAM-KILLER.mts.net>
Re: avoid using extra variable <ericosman@rcn.com>
Re: avoid using extra variable <abigail@abigail.nl>
Re: avoid using extra variable <spikey-wan@bigfoot.com>
best way to trap 'die' (or : when break circ-refs in o <pilsl_usenet@goldfisch.at>
Re: Convert curses screen output to space-delimited tex (Malcolm Dew-Jones)
Dual www servers (Mike)
Re: Dual www servers (Mike)
Re: Dual www servers <annoyed@you.now>
Re: extract the first word in a string <Rexlustrous@subdimension.com>
Re: hashes as lists (Sara)
Re: hashes as lists <mjcarman@mchsi.com>
Help having trobule installing a CPAN module <dlaw001@yahoo_no_spam_.co.uk>
Re: Help with script to parse a log file and run a comm <Andrew.McGregor@amtrak.co.uk>
Re: Help with script to parse a log file and run a comm <abigail@abigail.nl>
Re: How it wipe out or delete or init an array? <barryk2@SPAM-KILLER.mts.net>
Re: memleak in perl 5.8.0 ? <pilsl_usenet@goldfisch.at>
Re: mod_perl uses old values in subroutines ctcgag@hotmail.com
need help in parseing file with a wierd arrangment of d (Triger)
Re: need help in parseing file with a wierd arrangment <mbudash@sonic.net>
Re: perl compiler for win32 platform? <a@b.c>
Re: pipes and kill ctcgag@hotmail.com
Re: Sending Mail with HTML links <usenet@dwall.fastmail.fm>
Simple (hopefully) perl Q <joec@aracnet.com>
Re: Simple (hopefully) perl Q <mbudash@sonic.net>
Re: Weird behavior of PERL counter <jurgenex@hotmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 11 Apr 2003 08:20:15 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: A better way to extract a substring?
Message-Id: <MPG.19007d0564594e7989795@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <WTila.4927$2x2.2329774@dca1-nnrp1.news.algx.net>, federico
(fcanton@rei.edu) says...
> I am new to Perl. I am currently using this line to remove the quotes
> around a string:
>
> if ($line =~ /^\'/ && $line =~ /\'$/){$line = substr $line, 1, (length
> $line) - 2};
>
> As the code indicates, the quotes should be removed only when they are found
> at both ends of the string.
>
> I am liking Perl, and I feel there must be a more elegant or economical way
> of doing this.
>
> Would anyone please teach me how?
>
> Thank you very much.
>
> federico
if ( $line =~ m/^'(.*)'$/ ) {
$line = $1;
}
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Fri, 11 Apr 2003 10:16:29 -0400
From: Eric Osman <ericosman@rcn.com>
Subject: Re: avoid using extra variable
Message-Id: <3E96CE3D.8060804@rcn.com>
I'm sorry. I didn't use a good example.
Here's a better one.
The desire is to display one less than an index within a print
statement.
First, here's an example that shows the desired result:
my $index = 7;
my $prevIndex = $index - 1;
print "The previous index which is $prevIndex is an even number\n";
The result is this:
The previous index which is 6 is an even number
However, notice how we used an extra variable called "prevIndex".
The following attempt to avoid the variable doesn't produce the desired
result:
my $index = 7;
print "The previous index which is $index-1 is an even number\n";
The above produces
The previous index which is 7-1 is an even number
So, my question is, is there an easy way to put the expression
within the quoted string and get the desired result, without
using the extra variable ?
/Eric
------------------------------
Date: 11 Apr 2003 14:29:13 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: avoid using extra variable
Message-Id: <slrnb9dk9p.9qf.abigail@alexandra.abigail.nl>
Eric Osman (ericosman@rcn.com) wrote on MMMDX September MCMXCIII in
<URL:news:3E96CE3D.8060804@rcn.com>:
??
??
?? I'm sorry. I didn't use a good example.
??
?? Here's a better one.
??
?? The desire is to display one less than an index within a print
?? statement.
??
?? First, here's an example that shows the desired result:
??
?? my $index = 7;
?? my $prevIndex = $index - 1;
?? print "The previous index which is $prevIndex is an even number\n";
??
?? The result is this:
??
?? The previous index which is 6 is an even number
??
?? However, notice how we used an extra variable called "prevIndex".
??
?? The following attempt to avoid the variable doesn't produce the desired
?? result:
??
?? my $index = 7;
?? print "The previous index which is $index-1 is an even number\n";
??
?? The above produces
??
?? The previous index which is 7-1 is an even number
??
??
?? So, my question is, is there an easy way to put the expression
?? within the quoted string and get the desired result, without
?? using the extra variable ?
my $index = 6;
print "The previous index which is ${\($index - 1)} is an even number.\n";
print "The previous index which is @{[$index - 1]} is an even number.\n";
Abigail
--
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
------------------------------
Date: Fri, 11 Apr 2003 15:34:21 +0100
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: avoid using extra variable
Message-Id: <b76jrh$mr4$1@newshost.mot.com>
> my $index = 7;
> print "The previous index which is $index-1 is an even number\n";
>
> The above produces
>
> The previous index which is 7-1 is an even number
Which is exactly what you told it to print.
Try:
print "The previous index which is ", $index-1, " is an even number\n";
See what the difference is?
R.
------------------------------
Date: Fri, 11 Apr 2003 16:55:13 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: best way to trap 'die' (or : when break circ-refs in objects) ?
Message-Id: <3e96d761$1@e-post.inode.at>
For I use circular references in my objects the DESTROY-sub is not called
upon destruction of the object, but only when global desctruction is done.
This is far to late, cause my perlinterpreter is running over long times
(mod_perl) and therefore memleaking.
Now it would be easy to break the circular references before the object is
destroyed, but this will not work if the application ends because some
embedded modules will end in a die-error.
So I would like to trap this die-errors to break the circular references
immediately and therefore DESTROY is called before the application dies.
In the following example I would somehow execute the following command as
reaction to the die-command before the application dies:
" $s->{self}=''; "
I looked at sigtrap but I'm not sure if this is what I'm looking for.
thnx,
peter
-------------------------
#!/usr/bin/perl
use strict;
package test;
sub new{
my $class=shift; my $s={}; bless($s,$class);
$s->{self}=$s; # the circular reference
return $s;
}
sub DESTROY {
my $s=shift;
warn "DESTROY TEST";
$s->{self}='';
}
package main;
my $s=test->new();
print " \n";
die "uups";
---------------------
ps: I cannot avoid the circular references, cause I use anonymous subs that
include anonymous subs which are all refered from my object ...
--
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: 11 Apr 2003 10:14:31 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: Convert curses screen output to space-delimited text output ?
Message-Id: <3e96f7f7@news.victoria.tc.ca>
Sean O'Neill (sean@deletethistorespond.seanoneill.deletethistorespond.info) wrote:
: Does anyone know of a modules or combo of modules that will take
: curses screen output and convert it to space-delimited text output ?
for once in a while use (like documenting), simply use a mouse to cut and
paste the text
col -b works for some formated text (don't know if it handles this
though)
can you tell curses that you have a different terminal, like an old
teletype, and see what it outputs? That might produce something that
was easier to convert.
------------------------------
Date: Fri, 11 Apr 2003 16:30:53 GMT
From: mike@nospam.com (Mike)
Subject: Dual www servers
Message-Id: <3e96ec1f.130484236@news.webperception.com>
I have an apache server on a lenux box, SOHO, serving as a gateway,
and mail server hooked up to DSL with a fixed IP. I would like to
compliment it with a second box sharing the www load, each with its
own mysql and tomcat.
What howto(s), technology do I look at. I realize this is not an easy
subject but I want to learn.
------------------------------
Date: Fri, 11 Apr 2003 16:31:58 GMT
From: mike@nospam.com (Mike)
Subject: Re: Dual www servers
Message-Id: <3e96ed65.130810135@news.webperception.com>
Sorry, posted in wrong group.
On Fri, 11 Apr 2003 16:30:53 GMT, mike@nospam.com (Mike) wrote:
>
>
>
>I have an apache server on a lenux box, SOHO, serving as a gateway,
>and mail server hooked up to DSL with a fixed IP. I would like to
>compliment it with a second box sharing the www load, each with its
>own mysql and tomcat.
>
>What howto(s), technology do I look at. I realize this is not an easy
>subject but I want to learn.
------------------------------
Date: Fri, 11 Apr 2003 11:35:05 -0500
From: Ivan Marsh <annoyed@you.now>
Subject: Re: Dual www servers
Message-Id: <b76qmb$1ds$1@grandcanyon.binc.net>
Mike wrote:
> I have an apache server on a lenux box, SOHO, serving as a gateway,
> and mail server hooked up to DSL with a fixed IP. I would like to
> compliment it with a second box sharing the www load, each with its
> own mysql and tomcat.
>
> What howto(s), technology do I look at. I realize this is not an easy
> subject but I want to learn.
Hey Mike,
You need a round-robin or load balancing DNS to do that.
Not Perl I should point out.
--
i.m.
All views, opinions and alleged facts expressed by this tactless moron are
protected by the constitution of the United States of America and should be
taken as good natured and friendly unless specifically stated otherwise.
------------------------------
Date: Fri, 11 Apr 2003 11:59:46 -0400
From: "Rex Lustrous" <Rexlustrous@subdimension.com>
Subject: Re: extract the first word in a string
Message-Id: <b76oou$bquq0$1@ID-165463.news.dfncis.de>
Hi, I am posting an email conversation on my personal mailbox,
with a solution that worked for me!
Thanks to all for the replies.
- RT
----------------------------------------------------------------
----- Original Message -----
From: "HELTERLINE,BRIAN (HP-Corvallis,ex1)"
To: Rex Lustrous
Sent: Thursday, April 10, 2003 3:34 PM
Subject: Re: extract the first word in a string
If this is what is left, it looks like you want the 9th char to the end
of
the string.
my $input = '02/17/03San Francisco';
my $city = substr $input, 8;
or to to it all at once using a regular expression:
my $string = 'Settled Date:04/30/02BostonSale';
my ( $m $d, $y, $city ) = $string =~ /Settle
Date:(\d\d)/(\d\d)/(\d\d)(.*)Sale/'
If you don't want the settle date, you don't have have to capture it.
- brian
-----Original Message-----
From: Rex Lustrous
Sent: Thursday, April 10, 2003 12:43 PM
To: HELTERLINE,BRIAN (HP-Corvallis,ex1)
Subject: Re: extract the first word in a string
Would this work if the data has a few lines like this ?
Thanks for the immediate response.
But would it work if some of the lines don't have any date information ?
e.g.
"Settled Date:BostonSale"
"Settled Date:04/30/02New YorkSale"
"Settled Date:San FranciscoSale"
I don't really care for the date information. All I need is to be able to
extract the City name.
Thanks in advance,
- RT
----- Original Message -----
From: "HELTERLINE,BRIAN (HP-Corvallis,ex1)"
To: "'Rex Lustrous'"
Sent: Thursday, April 10, 2003 5:49 PM
Subject: RE: extract the first word in a string
No,
my original RE would not work without a date. you
did not specify the date part was optional.
If *only* the date is optional, then try this:
my $string = 'Settled Date:04/30/02BostonSale';
my ( $city ) = $string =~ /Settle Date:[\d/]*(.*)Sale/'
This says to:
Match the literal 'Settle Date:'
Match the character class of digit or '/' zero or more times
Match and capture the next character zero or more times
Match the literal 'Sale'
-brian
-----Original Message-----
From: Rex Lustrous
Sent: Thursday, April 10, 2003 12:43 PM
To: HELTERLINE,BRIAN (HP-Corvallis,ex1)
Subject: Re: extract the first word in a string
Wow!!! Thank you so much, it works like a clock for both cases!!
- RT
----------------------------------------------------------------
------------------------------
Date: 11 Apr 2003 07:24:00 -0700
From: genericax@hotmail.com (Sara)
Subject: Re: hashes as lists
Message-Id: <776e0325.0304110624.9c187bf@posting.google.com>
genericax@hotmail.com (Sara) wrote in message news:<776e0325.0304101020.20b6e59f@posting.google.com>...
> Eric Wilhelm <ericw@nospam.ku.edu> wrote in message news:<pan.2003.04.10.07.52.06.315922.23897@nospam.ku.edu>...
> Thanks Eric, although seemingly obvious, these little hints can be
> invaluable!
>
> Along the same lines, something I picked up in like my 5th re-read of
> Camel:
>
> %h = reverse %h
>
> makes the keys of %h the values and visa versa..
>
> Treating hashes with list-type ops can be very handy indeed and leads
> to some succint syntax.
>
> -Gx
By the way- at first glance, at least to me, this *looked like* the
reverse operator was overloaded for hashes to operate on them
differently than arrays. I quickly regained my Perl-sense however and
after a little thought realized that wasn't the case. It simple treats
the hash as an (even-element) array, and reversing it switches keys
and values since the pairwise groupsing are reversed. Of course the
order of definitions are also reversed, but as any Perlista knows that
has no consequence for the hash type since its unordered anyway.
Just a nice side-effect in essence, but a handy one indeed.
Now I have a request. Eric and I talked about (2) useful ways to deal
with hashes with a succinct and effective syntax. I suspect the Guru's
know about 1000 more that we hadn't thought of- so even though it may
see obvious to you, please post more here? Not only for hashes, any
shortcut you use that may not be obvious to everyone? I know I'd
appreciate learning many more.
Bottom line- the effectiveness of a Perl programming is proportionate
to the simplicity of code. Looking back over my old code I amaze
myself at how BAD the code is! I frequently think "did *I* really
write THAT!?".. Largely its a matter of volume- what used to take
10-12 lines I can now do in 1 or 2, for example using "map" instead of
writing loops on arrays. I take it as a good sign that my old code was
"bad" however, as it implies the code I write now is "better" :)
I hope I never get so good (and arrogant?) however as to think "there
is nothing left to learn in Perl", so if you have shortcuts please
post them!
Have a great weekend!
Gx
By
------------------------------
Date: Fri, 11 Apr 2003 11:21:04 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: hashes as lists
Message-Id: <b76q1h$i4n9@onews.collins.rockwell.com>
On 4/11/2003 9:24 AM, Sara wrote:
> genericax@hotmail.com (Sara) wrote in message
> news:<776e0325.0304101020.20b6e59f@posting.google.com>...
>>
>> %h = reverse %h
>>
>> makes the keys of %h the values and visa versa..
>
> By the way- at first glance, at least to me, this *looked like* the
> reverse operator was overloaded for hashes to operate on them
> differently than arrays.
reverse() is a function, not an operator.
Perl doesn't have strong typing, so overloading doesn't come into play
all that often. What does happen constantly is for a function to behave
differently depending on it's _context_.
print join ',', reverse('abc', 'xyz'); # xyz,abc
print join ',', scalar reverse('abc', 'xyz'); # zyxcba
> I quickly regained my Perl-sense however and after a little thought
> realized that wasn't the case. It simple treats the hash as an
> (even-element) array
<pedantic>
reverse() doesn't "treat" the hash as an array, it provides list context
to it, and that's how a hash behaves in list context.
</pedantic>
> reversing it switches keys and values since the pairwise groupsing
> are reversed.
...because that's how reverse() behaves in list context, which is what
the %h on the left side of the assignment provides.
> Of course the order of definitions are also reversed, but as any
> Perlista knows that has no consequence for the hash type since its
> unordered anyway.
Unless, as Tad pointed out, the hash contains more than one key with the
same value. (Or if the values are references, but that's another issue.)
> Just a nice side-effect in essence, but a handy one indeed.
It's not a side effect; it's the result of the carefully considered
language design.
> Eric and I talked about (2) useful ways to deal with hashes with a
> succinct and effective syntax. I suspect the Guru's know about 1000
> more that we hadn't thought of- so even though it may see obvious to
> you, please post more here? Not only for hashes, any shortcut you
> use that may not be obvious to everyone? I know I'd appreciate
> learning many more.
That's an awfully open-ended question. You're better off to lurk here,
paying close attention to the answers the regulars give. You can learn
an amazing amount of Perl that way.
> I hope I never get so good (and arrogant?) however as to think "there
> is nothing left to learn in Perl",
Doubtful. Even Larry has admitted learning new things occasionally. :)
-mjc
------------------------------
Date: Fri, 11 Apr 2003 17:45:09 +0100
From: "Newbie" <dlaw001@yahoo_no_spam_.co.uk>
Subject: Help having trobule installing a CPAN module
Message-Id: <ogCla.2164$X45.1542@newsfep3-gui.server.ntli.net>
Hi
I'm trying to install some cpan modules, I using windoze 98 2nd. Ed. Cygwin
(not to sure of the version). I set the cpan script (size, where to find the
packages)
ant type at the cpan> install MIME::Entity
It goes away and gets the relevant bundle (mime-tools-xxx in this case), and
gets any
dependancies required. Runs the tests, which pass successfully, but then the
following happens
Running make install
12963 [main] perl 292415 fork_copy: user/cygwin data pass 2 failed,
0x970000.
0x27F2000, done 0, windows pid 4294549109, Win32 error 8
2006044 [proc] perl 292415 wait_subproc: wait failed. nchildren 1, wait
1000, W
n32 error 6
2008765 [proc] perl 292415 wait_subproc: nchildren 1, event[1] 0x1A0,
pchildren
0] 0x83889000, events[0] 0x138, Win32 error 6
2020490 [proc] perl 292415 wait_subproc: pid 418187, dwProcessId 4294549109,
hP
ocess 0x1A0, progname 'C:\TOOLS\CYGWIN\BIN\PERL.EXE'
28984700 [main] perl 292415 fork_copy: user/cygwin data pass 2 failed,
0x970000
.0x27F2000, done 0, windows pid 4294562273, Win32 error 8
56349378 [main] perl 292415 fork_copy: user/cygwin data pass 2 failed,
0x970000
.0x27F2000, done 0, windows pid 4294529405, Win32 error 8
Use of uninitialized value in <HANDLE> at
/usr/lib/perl5/5.6.1/cygwin-multi/CPA
.pm line 4720.
Does anybody have any idea whats going on ?
Any help or pointers would be greatly appreciated I would like to get this
working
on cygwin on windoze machine, thus doing it on a unix box is not really an
option at
this stage.
Many Thanks
Tubs
=
To reply via email please remove the _no_spam_ from address
------------------------------
Date: Fri, 11 Apr 2003 15:08:41 +0100
From: Andrew McGregor <Andrew.McGregor@amtrak.co.uk>
Subject: Re: Help with script to parse a log file and run a command.
Message-Id: <3E96CC69.6050707@amtrak.co.uk>
MichaelS wrote:
> Hi All,
>
> I am trying to write a shell script to parse through a mysql error log
> and if it find's a specific error, one to do with replication, that it
> will run a command to shutdown the current mysql server. I was
> originally trying to do it with bash and borne shell. Unfortunately,
> matching regular expressions with bash, especially when there are
> spaces, doesn't work very nice.
>
Perl regex is similar to bash regex.
> Could someone point me to some pointers or examples of how to do this
> in perl.
>
These pointers should cover most of how to achieve what you require.
perldoc -f open
perldoc -f readline
perldoc -f close
perldoc perlre - this may be enough to help you with your bash solution
perldoc -f system
search.cpan.org for File::Copy
perldoc -f unlink
If you don't have perldoc installed try, www.perldoc.com
> Essentially, it will parse through the error log file looking for
> "error running query". If it see's that error, it will run the
> shutdown command for mysql in init.d. It will also move the error log
> file to a backup location and touch a new one. If it doesn't see the
> error, the script will simply exit.
>
After reading relevant parts of the above you are having problems then
post the troublesome code and someone will help.
> Thanks in advance for your help,
> Michael
Andy
------------------------------
Date: 11 Apr 2003 14:37:07 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Help with script to parse a log file and run a command.
Message-Id: <slrnb9dkoj.9qf.abigail@alexandra.abigail.nl>
MichaelS (spivackm@calib.com) wrote on MMMDX September MCMXCIII in
<URL:news:c5144b08.0304110420.420b9929@posting.google.com>:
:) Hi All,
:)
:) I am trying to write a shell script to parse through a mysql error log
:) and if it find's a specific error, one to do with replication, that it
:) will run a command to shutdown the current mysql server. I was
:) originally trying to do it with bash and borne shell. Unfortunately,
:) matching regular expressions with bash, especially when there are
:) spaces, doesn't work very nice.
:)
:) Could someone point me to some pointers or examples of how to do this
:) in perl.
:)
:) Essentially, it will parse through the error log file looking for
:) "error running query". If it see's that error, it will run the
:) shutdown command for mysql in init.d. It will also move the error log
:) file to a backup location and touch a new one. If it doesn't see the
:) error, the script will simply exit.
# Untested.
use strict;
use warnings;
my $error_log = "/var/log/mysql/errors";
open my $fh => $error_log or die "Failed to open $error_log: $!\n";
while (<$fh>) {
if (/error running query/) {
close $fh;
system "/etc/init.d/mysql" => "stop";
warn "Failed to stop mysql, error ", $? >> 8, "\n" if $?;
use POSIX 'strftime';
my $back = strftime "$errorlog.%Y%m%d:%H%M%S", localtime;
rename $error_log => $back or die "Failed to backup errorlog: $!\n";
exit 1;
}
}
exit 0;
__END__
Personally, I would do log rotation when starting the service.
Abigail
--
BEGIN {my $x = "Knuth heals rare project\n";
$^H {integer} = sub {my $y = shift; $_ = substr $x => $y & 0x1F, 1;
$y > 32 ? uc : lc}; $^H = hex join "" => 2, 1, 1, 0, 0}
print 52,2,10,23,16,8,1,19,3,6,15,12,5,49,21,14,9,11,36,13,22,32,7,18,24;
------------------------------
Date: Fri, 11 Apr 2003 08:18:34 -0500
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: How it wipe out or delete or init an array?
Message-Id: <MPG.19007ca28b75d3b2989794@news.mts.net>
[This followup was posted to comp.lang.perl.misc]
In article <b742hq$a39fs$1@ID-181664.news.dfncis.de>, jtpr
(spam@jimryan.com) says...
> If I have an array @array that has a bunch of stuff in it, how can I "zero
> it out" so to speak? So I can reuse it.
>
> --
> -Jim
> change "spam" to "ryan' before replying by mail.
@array = ();
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Fri, 11 Apr 2003 16:48:33 +0200
From: peter pilsl <pilsl_usenet@goldfisch.at>
Subject: Re: memleak in perl 5.8.0 ?
Message-Id: <3e96d5d1$1@e-post.inode.at>
peter pilsl wrote:
>
> An object holds an anomyous sub which uses another anonymous sub inside
> the same structure.
>
Which results in a circular reference and therefore explicitely is not
garbagecollected upon object-destruction (yet) as its stated in man perlobj.
Sorry, I should have read the manuals closely before.
thnx,
peter
--
peter pilsl
pilsl_usenet@goldfisch.at
http://www.goldfisch.at
------------------------------
Date: 11 Apr 2003 16:48:46 GMT
From: ctcgag@hotmail.com
Subject: Re: mod_perl uses old values in subroutines
Message-Id: <20030411124846.734$WH@newsreader.com>
stry_cat@yahoo.com (Tom Cat) wrote:
> I recently found out that mod_perl "saves" subroutines and apparently
> uses values passed to the subroutines from previous runs instead of
> the current values.
That seems rather unlikely. Unless you are using "passed" to mean
something other than what is usually means.
>
> Is there anyway around this "feature"?
>
> What I have is a multi-page form. The user inputs data and clicks
> submit. The submit page first calls a subroutine to make sure the
> required data has been submitted. if not it calls the subroutine that
> makes the first page. the first page subroutine is supposed to checks
> for $incomplete == 1
See, if you passed in the values, you would be checking to see
if $_[2] == 1 or something like that. Perhaps if you posted
some brief code that replicates the problem, it would help us
help you.
...
> Is there an easier way to do what I'm doing?
We really don't know what you're doing, since you didn't post any
code!
>
> Thanks,
>
> Tom
> P.S. I would post the code but it's rather long and I really don't
> expect y'all to debug it for me.
Shorten the code to something that isn't rather long but still
reflects what you are talking about. Copying a file, then selecting
a big block of text and deleting it, are rather easy operations
on modern systems.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: 11 Apr 2003 12:19:33 -0500
From: trewetuyt@mister.com (Triger)
Subject: need help in parseing file with a wierd arrangment of data
Message-Id: <3e96f873$0$87532$45beb828@newscene.com>
I have a file that we need to read evey hour it happens to have a wierd format
any help in parseing it would be appreciated
Background
We have a Load system that measures loads on electrical components each hour
and records those values. each value has a unique tag (key) associated with
it and is stored as the tag + the value for the hour
a tag looks like the following : 11FISK3P We have send the load system a
file with 50,000 tags like it and every hour it reads that file looks at the
tags we requested extracts the data for the tag and sends it to us
The file being sent is an ASCII comma separated value file. Data is coming in
the form of:
Two lines
1st - Date format used, tag, tag, tag, tag, tag,tag,...50,000th tag
2nd- date value, tag value,tag value,tag value,tag value,..50,000th tag value
sample: (showing 3 tags and values)
%d-%b-%y %H:%M:%S,11FISK3P,714MEDP,56TYRFT,...
3/4/2003 10:15,104, 8567, 5674.2, ..,
we need to create a file with the following format. note that the instead of
2 lines each tag tagvalue combination is in its own line giving me 50,000
lines
is this possible with perl
DateTime Tag hourly value
3/4/2003 10:15 11FISK3P 104
3/4/2003 10:15 714MEDP 8567
3/4/2003 10:15 56TYRFT 5674.2
.
.
.
50,000th row
------------------------------
Date: Fri, 11 Apr 2003 17:54:33 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: need help in parseing file with a wierd arrangment of data
Message-Id: <mbudash-9569A6.10543211042003@typhoon.sonic.net>
In article <3e96f873$0$87532$45beb828@newscene.com>,
trewetuyt@mister.com (Triger) wrote:
> I have a file that we need to read evey hour it happens to have a wierd
> format
> any help in parseing it would be appreciated
>
> Background
> We have a Load system that measures loads on electrical components each hour
> and records those values. each value has a unique tag (key) associated with
> it and is stored as the tag + the value for the hour
>
> a tag looks like the following : 11FISK3P We have send the load system a
> file with 50,000 tags like it and every hour it reads that file looks at the
> tags we requested extracts the data for the tag and sends it to us
>
> The file being sent is an ASCII comma separated value file. Data is coming in
> the form of:
>
> Two lines
> 1st - Date format used, tag, tag, tag, tag, tag,tag,...50,000th tag
> 2nd- date value, tag value,tag value,tag value,tag value,..50,000th tag value
>
> sample: (showing 3 tags and values)
>
> %d-%b-%y %H:%M:%S,11FISK3P,714MEDP,56TYRFT,...
> 3/4/2003 10:15,104, 8567, 5674.2, ..,
>
> we need to create a file with the following format. note that the instead of
> 2 lines each tag tagvalue combination is in its own line giving me 50,000
> lines
>
> is this possible with perl
>
> DateTime Tag hourly value
> 3/4/2003 10:15 11FISK3P 104
> 3/4/2003 10:15 714MEDP 8567
> 3/4/2003 10:15 56TYRFT 5674.2
> .
> .
> .
> 50,000th row
>
yes. you don't say what separator you want to use in your new file, and
you also don't say what you want to do if the file format is other than
what is expected, so i'm leaving out any error checking in that regard,
BUT...
one way:
my $thefile = 'thefile';
open (FILE, $thefile) or die ("Can't open $thefile: $!");
my @lines = <FILE>;
chomp @lines;
close (FILE);
my @tags;
(undef, @tags) = split /\s*,\s*/, $lines[0];
my ($date, @vals);
($date, @vals) = split /\s*,\s*/, $lines[1];
my $newfile_separator = "\t";
my $newfile = 'newfile';
open (NEWFILE, ">$newfile") or die ("Can't create $newfile: $!");
for my $i (0..$#tags) {
print NEWFILE
"$date$newfile_separator$tags[$i]$newfile_separator$vals[$i]\n";
}
close (NEWFILE);
hope this helps...
--
Michael Budash
------------------------------
Date: Fri, 11 Apr 2003 15:30:51 +0200
From: ZZT <a@b.c>
Subject: Re: perl compiler for win32 platform?
Message-Id: <b76g2c$p87$1@news1.wdf.sap-ag.de>
Simon Andrews wrote:
> Get the latest version of PAR from CPAN. It includes a tool called pp
> which will turn any Perl program into a windows .exe (you may also have
> to distribute a perl dll).
>
> It works really well now, even on complex GUI-based scripts.
>
> http://search.cpan.org/author/AUTRIJUS/PAR-0.67/
>
> Pretty easy to install too. No C-compiler necessary, and a very helpful
> makefile script.
Simon, where can I get the binary parl.exe ?
I get an error back from pp:
can't find par loader
thank you
------------------------------
Date: 11 Apr 2003 16:25:13 GMT
From: ctcgag@hotmail.com
Subject: Re: pipes and kill
Message-Id: <20030411122513.609$8q@newsreader.com>
zix6@yahoo.com (Zix) wrote:
> I open up a pipe using:
>
> my $pid = open H, "myprog |" or die "...";
>
> looking at the process table using ps I see 2 entries, one being:
>
> sh -c myprog
>
> and the other just:
>
> myprog
>
> later on, in the Perl script, I decide to close down the pipe using:
>
> kill 9, $pid;
That is rather violent. Why not just close H?
(Or at least kill it with 15?)
> How, can I kill, in the Perl script, the actual process that is
> running and not just the shell process?
Most likely by closing the pipe properly, using close H.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Fri, 11 Apr 2003 15:19:39 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Sending Mail with HTML links
Message-Id: <Xns935A733B2F6EDdkwwashere@216.168.3.30>
<news@roaima.freeserve.co.uk> wrote:
> Mike <mshavel@optonline.net> wrote:
>
>> The interesting
>> thing is that it works correctly in Eudora 5.1.
>
> No it doesn't. Eudora is guessing your plain text email that contains
> HTML markup should be displayed as HTML. This is the same broken
> behaviour that IE exhibits.
Nothing to do with Perl, but nearly every email client I've tried in
recent years recognizes URIs and sends them to a browser if you select
(click on, in a GUI) the link. I suppose there are other uses for HTML
email, but as far as I'm concerned HTML email is an annoyance I would
happily send to at least the third circle of Hell to be pelted with filth
and excrement.
------------------------------
Date: Fri, 11 Apr 2003 10:29:35 -0700
From: Joseph Cipale <joec@aracnet.com>
Subject: Simple (hopefully) perl Q
Message-Id: <3E96FB7F.1A61725@aracnet.com>
I have a perl script in which I read in a series of files, munge the
data, and then
output the data back to a file. The purpose being to convert the data
into a format that can be easily imported into a spreadsheet. For
eaxample:
<OLD>
This
Is
old
data
format
<NEW>
This;Is;old;data;format;
The problem I am seeing is that when I read in the data, I can perform a
quick verification on it abd see that prior to stripping away the <cr>,
the data is correct.
Once I perform a 'chomp' on $_, the data is converted to a value of '1'.
Code is enclosed below. ANy have any ideas here?
Joe
--
Code snippet:
$dot = ".";
$scln = ";";
@fle_id = @ARGV;
print "Open control db...\n";
$file_name = $ARGV[0].$dot."dte";
$new_file = $file_name.$dot."new";
print "$file_name";
open(OUT, ">$new_file") or die "Couldn't open $file_name for writing\n";
open(A, $file_name);
while(<A>) {
$Data = chomp($_);
print $Data;
$Line = chomp($Data);
print "$Line;";
}
close(A);
close(OUT);
------------------------------
Date: Fri, 11 Apr 2003 17:58:42 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Simple (hopefully) perl Q
Message-Id: <mbudash-6D55CE.10584111042003@typhoon.sonic.net>
In article <3E96FB7F.1A61725@aracnet.com>,
Joseph Cipale <joec@aracnet.com> wrote:
[snip]
> Once I perform a 'chomp' on $_, the data is converted to a value of '1'.
[snip]
perldoc -f chomp
hint: what does 'chomp' return?
hth-
--
Michael Budash
------------------------------
Date: Fri, 11 Apr 2003 13:42:24 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Weird behavior of PERL counter
Message-Id: <4Dzla.63104$aQ3.37571@nwrddc02.gnilink.net>
Pablo Rodriguez wrote:
> I'm noticing a weird behavior in a basic text counter I have in my
> webpage. I have the following code to update a text file (counter.txt)
> and display the result on the page:
[...]
> Any ideas of what is happening and how can it be prevented from
> happening.
I suggest consulting TFM, see "perldoc -q increment", first paragraph.
jue
------------------------------
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 4832
***************************************