[25408] in Perl-Users-Digest
Perl-Users Digest, Issue: 7653 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jan 15 06:05:25 2005
Date: Sat, 15 Jan 2005 03:05:10 -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 Sat, 15 Jan 2005 Volume: 10 Number: 7653
Today's topics:
[perl-python] 20050114 if statement <xah@xahlee.org>
[perl-python] 20050115, for statement <xah@xahlee.org>
Re: Adding a delimiter inbetween number characters and <bik.mido@tiscalinet.it>
Re: Array generation <jl_post@hotmail.com>
Re: Array generation poopdeville@gmail.com
Re: Array generation <usa1@llenroc.ude.invalid>
Re: Array generation poopdeville@gmail.com
Re: Array generation <usa1@llenroc.ude.invalid>
Re: convention regarding lexical filehandles <spamtrap@dot-app.org>
Re: daemonizing a process AND capture stdout, stderr <bik.mido@tiscalinet.it>
Re: How to convert MS doc to plain text using Perl on u <jhsterling@earthlink.net>
Re: Log File parser <bik.mido@tiscalinet.it>
Re: Loop through a text file line by line <bik.mido@tiscalinet.it>
Re: Need help with Perl and MySQL database data load <toreau@gmail.com>
Re: Print question <edgrsprj@ix.netcom.com>
Re: Regular expression lookahead question <peroli@gmail.com>
Re: Regular expression lookahead question <peroli@gmail.com>
Re: Store a single character AFTER a match <usa1@llenroc.ude.invalid>
Re: Store a single character AFTER a match <nobull@mail.com>
Re: Works great! <edgrsprj@ix.netcom.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Jan 2005 19:34:41 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] 20050114 if statement
Message-Id: <1105760081.771782.140700@f14g2000cwb.googlegroups.com>
. # here's an example of if statement in python.
.
. x=-1
. if x<0:
. print 'neg'
. elif x==0:
. print 'zero'
. elif x==1:
. print 'one'
. else:
. print 'other'
.
. # the elif can be omitted.
. ------------------------------
. # here's an example of if statement in perl
.
. $x=31;
. if ($x<0) {
. print 'neg'
. } elsif ($x==0) {
. print 'zero'
. } elsif ($x==1) {
. print 'one'
. } else {
. print 'other'
. }
.
.
. ---------------------------
.
. Note: this post is from the Perl-Python a-day mailing list at
. http://groups.yahoo.com/group/perl-python/
. to subscribe, send an email to perl-python-subscribe@yahoogroups.com
. if you are reading it on a web page, program examples may not run
. because html conversion often breaks the code.
.
. Xah
. xah@xahlee.org
. http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: 15 Jan 2005 01:58:04 -0800
From: "Xah Lee" <xah@xahlee.org>
Subject: [perl-python] 20050115, for statement
Message-Id: <1105783084.748174.307680@f14g2000cwb.googlegroups.com>
=A9 # this is an example of for statement
=A9 # the % symbol calculates the remainder
=A9 # of division.
=A9 # the range(m,n) function
=A9 # gives a list from m to n-1.
=A9
=A9 a =3D range(1,51)
=A9 for x in a:
=A9 if x % 2 =3D=3D 0:
=A9 print x, 'even'
=A9
=A9 # note that in this example, for goes over a list.
=A9 # each time making x the value of the element.
=A9
=A9 ------------------------------------
=A9 # this is similar code in perl
=A9
=A9 @a=3D(1..50);
=A9 for $x (@a) {
=A9 if ( $x%2 =3D=3D0){
=A9 print $x, " even\n";
=A9 }}
=A9
=A9 # PS each daily tip can be run. Just
=A9 # copy the python part and save to a
=A9 # file and run it as "python
=A9 # file.py". Try it.
=A9
=A9
=A9 Note: this post is from the Perl-Python
=A9 a-day mailing list at
=A9 http://groups.yahoo.com/group/perl-python/
=A9 to subscribe, send an email to
=A9 perl-python-subscribe@yahoogroups.com if
=A9 you are reading it on a web page,
=A9 program examples may not run because
=A9 groups.google.com changes the post slightly.
=A9
=A9 Xah
=A9 xah@xahlee.org
=A9 http://xahlee.org/PageTwo_dir/more.html
------------------------------
Date: Sat, 15 Jan 2005 10:05:10 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Adding a delimiter inbetween number characters and letter characters
Message-Id: <e1khu01p8hbpp324hdaf5m3gf15l78a2ms@4ax.com>
On 14 Jan 2005 11:42:14 GMT, Martin Kissner <news@chaos-net.de> wrote:
>> perl -pi -e 's/^(\d+)/$1-/' file1 file2...
>
>He also wants to join lines with no numbers at the beginning with the
>preceding line.
Oh, sorry, I hadn't noticed/didn't remember: you have my apologies.
Well, without even looking at your code, here's what I'd do:
#!/usr/bin/perl -l
use strict;
use warnings;
my $line='';
while (<>) {
chomp;
if (s/^\d+/$&-/) {
print $line;
$line=$_;
} else {
$line .= $_;
}
}
print $line;
__END__
Still _if_ I understood the problem correctly, now.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: 14 Jan 2005 18:10:51 -0800
From: "jl_post@hotmail.com" <jl_post@hotmail.com>
Subject: Re: Array generation
Message-Id: <1105755051.800790.239020@z14g2000cwz.googlegroups.com>
> jl_post@hotmail.com wrote:
> >
> > So I recommend you examine and test your min() and
> > max() functions. I have a feeling that's where your
> > error lies.
> >
poopdevi...@gmail.com replied:
>
> Yes! Actually, the functions min and max were
> operating correctly (well, I'm pretty sure.
> I wasn't getting compile errors at all, and
> the algorithm is *very* simple) but interacted
> badly with RR because used $i as an index but
> failed to protect it:
Ah. Well, that would have been a compile error
if you used "use strict;". That is why so many people
in this newsgroup recommend it so highly. That one
line helps catch so many errors.
I think many people don't like to use it simply
because it complains about things that aren't
necessarily errors. But more experienced Perl
programmers know that the small hassle "use strict;"
creates is miniscule compared to the hours and hours
of debugging time (literally!) you'd spend trying to
find a teeny-tiny error (like misspelling a variable
name or the error you just encountered).
Also, another piece of advice when posting to
this newsgroup via Google Groups:
Since the new "improved" Google Groups removes any
indentation at the beginning of a line (because, according
to Google, they're "wasteful and unnecessary"), you may
want to prefix every line of your code with "| ".
Therefore, a posted loop would look like this:
| foreach (1 .. 100)
| {
| print "$_\n";
| }
You can add "| " to every line of an entire file with this
one-line Perl script:
perl -pe "print '| '" program.pl
Then anyone else can strip them out of your code by typing:
perl -pi.posted -e "s/..//" program.pl
So, remember, always use "use strict;" and "use warnings;"! You'll
be glad you did when it finds more obscure errors for
you.
-- Jean-Luc
------------------------------
Date: 14 Jan 2005 18:30:47 -0800
From: poopdeville@gmail.com
Subject: Re: Array generation
Message-Id: <1105756247.522081.216320@f14g2000cwb.googlegroups.com>
jl_post@hotmail.com wrote:
>
> Also, another piece of advice when posting to
> this newsgroup via Google Groups:
>
> Since the new "improved" Google Groups removes any
> indentation at the beginning of a line (because, according
> to Google, they're "wasteful and unnecessary"), you may
> want to prefix every line of your code with "| ".
Yes, I noticed that. Sorry for the unreadable code. I'll keep that in
mind.
<snip>
> So, remember, always use "use strict;" and "use warnings;"! You'll
> be glad you did when it finds more obscure errors for
> you.
My knowledge of Perl isn't very sophisticated, so I have no idea how to
implement this use strict stuff. But after this debugging session
(yes, I spent hours and hours on it), I'm going to learn. :-)
Thanks again for your help.
'cid 'ooh
------------------------------
Date: Fri, 14 Jan 2005 21:48:32 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Array generation
Message-Id: <pan.2005.01.15.02.48.31.786062@asu1cornelledu>
In article <1105756247.522081.216320@f14g2000cwb.googlegroups.com> posted
on Fri, 14 Jan 2005 18:30:47 -0800, poopdeville wrote:
> jl_post@hotmail.com wrote:
>
>> So, remember, always use "use strict;" and "use warnings;"! You'll
>> be glad you did when it finds more obscure errors for
>> you.
>
> My knowledge of Perl isn't very sophisticated, so I have no idea how to
> implement this use strict stuff.
Hmmmmm ...
#! /usr/bin/perl
use strict;
use warnings;
# Possibly also
# use diagnostics;
# Your script
__END__
All of this stuff is in the posting guidelines. It looks like you have not
read the guidelines. Go read them before you do anything else. Please.
Sinan
--
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.
------------------------------
Date: 14 Jan 2005 19:27:29 -0800
From: poopdeville@gmail.com
Subject: Re: Array generation
Message-Id: <1105759649.614628.111950@f14g2000cwb.googlegroups.com>
A. Sinan Unur wrote:
> #! /usr/bin/perl
>
> use strict;
> use warnings;
>
Yes, I got that far. However, I have no idea what that does. No need
to explain, I'll RTFM. :-)
>
> All of this stuff is in the posting guidelines. It looks like you
have not
> read the guidelines. Go read them before you do anything else.
Please.
>
I just read the 1.5 version of that document, apparently posted earlier
today. Sorry for the (slightly) incomplete script. Was that your only
complaint? (I'm trying to play nice, so if you have any more
criticism, please share. I'll listen.)
'cid 'ooh
------------------------------
Date: Fri, 14 Jan 2005 22:51:32 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Array generation
Message-Id: <pan.2005.01.15.03.51.01.322325@asu1cornelledu>
In article <1105759649.614628.111950@f14g2000cwb.googlegroups.com> posted
on Fri, 14 Jan 2005 19:27:29 -0800, poopdeville wrote:
> A. Sinan Unur wrote:
>> #! /usr/bin/perl
>>
>> use strict;
>> use warnings;
>>
>>
> Yes, I got that far. However, I have no idea what that does. No need
> to explain, I'll RTFM. :-)
perldoc strict
perldoc warnings
They are short and sweet.
>> All of this stuff is in the posting guidelines. It looks like you
>> have not read the guidelines. Go read them before you do anything
>> else. Please.
> I just read the 1.5 version of that document, apparently posted earlier
> today. Sorry for the (slightly) incomplete script. Was that your only
> complaint?
It is not a small issue. You need to post something other people's minds
can easily parse and, if necessary, they can run with minimal effort. The
rationale for this is explained in the document about asking smart
questions (the link to which is in the posting guidelines).
If you post something that is hard to parse (no indenting, s/// on one
line, s!!! on the next for no reason other than to mislead the reader to
thinking that there might be a reason etc), you are imposing a cost on all
the readers of this group.
Thanks.
Sinan
--
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.
------------------------------
Date: Sat, 15 Jan 2005 01:00:28 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: convention regarding lexical filehandles
Message-Id: <RaydnepQNa3jLHXcRVn-rA@adelphia.com>
Abigail wrote:
> Why is it why you accept passing filenames in another ways then
> exactly typing the filename to cat or rm, but when can't do that
> with a Perl program, you balk?
I was balking at what I perceived as your attitude. Everything you've said -
until this message, that is - sounded to me like "the user chose a file
name I think is stupid, so I'll punish him for it."
I think I understand your point better now. You're not saying "use magic
open() all the time, users be damned". I think what you're saying is that
it shouldn't be ruled out as a matter of dogma. Well, I'm not suggesting it
should be. I'm simply pointing out that there are potential traps for the
unwary, so it shouldn't be used blindly.
> Say you have a diff utility written in Perl. Magical open allows you to
> get the difference from the output of two commands:
>
> mydiff 'prog1 |' 'prog2 |'
Okay, point well taken. That's not something I'd thought of - chalk it up to
a failure of imagination. Now that I see it, I have to admit it would be a
*damn* useful thing for an advanced user to have, and magic open() makes it
trivially easy to do.
But by the same token, that same simplicity is also what makes easy for a
newbie programmer to make some serious mistakes if they use magic open()
without being fully aware of the magic. I rank it in the same class as
calling subs with '&', symbolic references and string evals - indispensable
in some situations, but not something that newbies should get into the
habit of using by default, all the time.
Your audience needs to be considered too. Your example assumes trustworthy
skilled users who can be counted upon to choose appropriate file names and
quote them as needed. In my experience - which I'll freely admit might be
very different from yours - that's asking entirely too much of a typical
end user.
I often write GUI apps aimed at a not-very advanced audience. These are the
kind of users who would name a file with their monthly budget in it
"January '05 $$". They'll assign it a leading character of ">" for no other
reason than to make their GUI list it first.
Now, if that user navigates to that file and opens it with an "open file"
dialog, there's no sane reason why the contents of the file should just
vanish - which is what would happen if I simply passed the file as-is to a
magic open().
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sat, 15 Jan 2005 10:05:13 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: daemonizing a process AND capture stdout, stderr
Message-Id: <4hmhu01ilsj1gpm5aqb40jkd5fs995gtvf@4ax.com>
On Sat, 15 Jan 2005 02:25:03 +1100, "Gyruss" <gyruss@hushmail.com>
wrote:
>> You, know, I'm not sure about what you're asking: is it about
>> daemonizing the main script that launches the other processes, or
>> these processes themselves? However whatever you do, a child will
>> always have a parent: in some sense "true orphans" do not exist,
>> because they will be "inherited" by process 0.
>>
>> Given that it's not entirely clear to me what you really want to do,
>
>The result I want is to have my child process live on if the parent process
>is killed. The parent process should just read stderr and stdout from the
Still I do not understand precisely what this has to do with
daemonizing. Childs should survive their parent in any case.
>child process. I want to 'daemonize' the child process (it's not really the
>right term), not the parent process.
Well, if you capture childs' STD{ERR,OUT} and want them to survive the
main process, thus implying that it may die, thus losing those
STD{ERR,OUT}'s, then I'd say that your logic is weak. Why don't you
simply redirect them to regular files or named pipes and have the
parent read from those or adopt any other from of IPC suitable for
your needs as explained in depth in
perldoc perlipc
instead?
HTH,
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sat, 15 Jan 2005 04:44:07 GMT
From: John Sterling <jhsterling@earthlink.net>
Subject: Re: How to convert MS doc to plain text using Perl on unix
Message-Id: <rc1Gd.7225$pZ4.2455@newsread1.news.pas.earthlink.net>
Diandian Zhang wrote:
> Does anyone have an idea, how to do this? Thanks!
http://www.winfield.demon.nl/
system("antiword","word.doc");
------------------------------
Date: Sat, 15 Jan 2005 10:05:11 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Log File parser
Message-Id: <rukhu017phq0sp236g643hqgfeqaqslgef@4ax.com>
Please, when posting include some (properly trimmed down) quoted text
from the article you're replying to, for reference...
On 14 Jan 2005 06:09:45 -0800, "jc8glp1hu" <jgarretthood@gmail.com>
wrote:
>So, are people on google groups to criticize or help people out?
Both, I'd say. Well, as long as to criticize _is_ to help "people"
out.
>When someone asks how to do something, they don't want to be told what
>they already know. He stated that he would like a script to check for
>those two things and mail him the results. So there it is, a script
>that does that.
I was _not_ criticizing the fact that you helped him supplying a ready
made script. I was criticizing how _bad_ it was.
>If someone asks you to do something in perl, why do you even waste your
>time posting a message that says "go to ...perl.com and you will find
>some tips.". That's completely unfair to the person asking the question
This is an oft discussed matter here, and my opinion, as well as that
of many others here and elsewhere is that _that_ kind of answer _can_
be the best help that can be given, at least in certain situations.
there's another thread going on along these lines...
>because if they wanted to know that they would have asked something
>like "Hey, where can I get more information on learning Perl, id like
>to write this script to do .... etc".
The point is that they often, as newbies, do not even know that they
can get the information themselves or how easy it is. You know, it's
that story of "give a man a fish..."!
Said this, _generally_ I am one of those that supplies ready-made
solutions even to relatively trivial questions. But I do not claim
that it is the best thing to do and I'm not arguing with those that
give an RTFM-kinda-answer, nay, generally if a discussion about this
starts, then I support their POVs.
But all this has nothing to do specifically with my post of which
yours is a followup...
>NOW LET ME SIDE W/ SHERM. I do believe that you should come w/ some
Huh?!?
>So instead of criticizing and posting just to have your say in things,
>why don't you try and help someone out when they have a problem.
>
>I wrote that script in about 5 minutes to give him something to go
>from. Instead of coming on here and complaining about someone who took
Well, I posted in about 10 seconds, because I really hadn't more time,
in that case.
I _do_ apologize because taking this into account, my cmts must have
sounded particularly aggressive. Had I had more time, as I have _now_
I would have included a "pars construens" as well as the "pars
denstruens", or at least explain why the latter was there.
>their time to help, why don't you show how you would write it. The main
Ditto as above.
>point here is post if you are going to help, if not then don't waste
>everyone's time.
What is arguable is wether the kind of help you gave was really
helping.
In fact you will first or later discover that Perl has a bad name in
many respects because of bad programming techniques spread around by
script kiddies et similia.
If you post such code in answer to a newbie's request for help, seeing
that indeed it _does_ work, he will get used to such bad programming
techniques...
>Finally, I just don't think the purpose here is to be an almighty
>mentor and oversee what is going on by telling people to read posting
>rules and trying to be a professor pointing people in the right
>direction. This is a place to ask questions about perl to help get your
Still this doesn't have anything to do with my post.
Please note that I quoted properly your article and supplied cmts on
two specific lines of code, albeit harsh ones...
It was up to your intelligence to understand _what_ was being
criticized!
>question answered, so if you know an answer to the post then post about
>it. It just goes back to common courtesy of answering what you are
I _do_ know an answer to _that_ post. I _may_ have given it, if had
had more time, or I may have not, even in that case. But that's not a
point.
I was commenting on _your_ code, and it did make sense to do so.
The kind of code you posted was more of a shell script written in Perl
than a Perl script. Not to say that using any of the external
programs exectuing commands should be prohibited in general, nay,
indeed in certain cases this ability provides the "best" solution for
certain tasks. But abusing it has no sense. if it must be a shell
script, then write a shell script, else use Perl to do (more
efficiently) what Perl can do perfectly well by itself.
>asked. If people are asking a question they are wanting an answer, an
>instant solution, unless of course they ask not to be told how to do it
>and just be given some tips.
Again, this has been discussed many times here and I'm not discussing
it anymore now, I recommend reading some relevant threads. Your POV is
acceptable but has not universal value. Others' opinions may vary and
their POVs are acceptable too.
>Anyway, I am on here to help some people out. The script I wrote gives
>him a starting place to do what he is wanting to do. He is new to perl,
>and wanted some help, so there ya go. Take it and run with it. I hope
Ditto as above wrt spreading bad techniques.
>what I posted has helped you some, despite rude comments from someone
>who didn't have the time to post anything constructive. They apparently
>were never new to the Perl language at all.
Oh, no, I've been new to Perl, and I still often have the sensation of
being new to it, when I learn something unexpected from posters by far
more knowledgeable than me. But that's another matter, believe me...
I've been new to Perl, but AFAICT I've never had that kind of attitude
many newbies show to have (well, I hope so, but I cannot gurantee
anything - I should check my first posts here)...
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sat, 15 Jan 2005 10:05:14 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Loop through a text file line by line
Message-Id: <upmhu0hp6qb0as5ns4hioksstto5dti1h6@4ax.com>
On 14 Jan 2005 16:16:09 GMT, Martin Kissner <news@chaos-net.de> wrote:
>>>This worked for me.
>>
>> So what?!?
>
>I was not sure if I have expressed myself correctly so tried to clear
>up what I meant.
The point is you said more or less "use
while (<>) { #...
if you want to read from _STDIN_". Well, this is plainly false, as
explained in detail in the document page you have been referred to.
Specifically you will be reading from STDIN iff at that point @ARGV is
empty (or $ARGV[0] eq '-').
Hence the fact that "this worked for me" (whatever you were referring
to) was irrelevant.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Sat, 15 Jan 2005 05:45:48 +0100
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Need help with Perl and MySQL database data load
Message-Id: <Yd1Gd.4527$IW4.93595@news2.e.nsc.no>
Oscar wrote:
> my $dbh = DBI->connect("dbi:mysql:sd_tst','localhost:3306','root',
> 'XXXXXXX'",
> {RaiseError => 1, AutoCommit => 1 }
> ) || die "Database connection not made: $DBI::errstr";
The connection string is wrong. As stated in the DBI documentation,
connect() may receive _four_ parameters;
1. Data source
2. Username
3. Password
4. Extra arguments
Your connection string contains _five_ parameters; you should have
specified the host and port in the data source part like this:
my $dsn = 'DBI:mysql:database=sd_tst;host=localhost;port=3306';
my $user = 'root';
my $pass = 'XXXXXXXX';
my %args = ( RaiseError => 1,
AutoCommit => 1 );
my $dbh = DBI->connect( $dns, $user, $pass, \%args )
or die "Can't connect; $DBI:errstr";
--
Tore Aursand <tore@aursand.no>
"Then there was the man who drowned crossing a stream with an average
depth of six inches." (W.I.E. Gates)
------------------------------
Date: Sat, 15 Jan 2005 09:55:58 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: Print question
Message-Id: <OM5Gd.7168$C52.2430@newsread2.news.atl.earthlink.net>
"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:9rlfu0taqvcm9gqck09qpg772tiqr4l69c@4ax.com...
> On Fri, 14 Jan 2005 08:24:18 GMT, "edgrsprj" <edgrsprj@ix.netcom.com>
> Listen: I am willing to be as gentle and as positive as possible, but
> all this sounds so strange, at best! I mean, it's evident that you're
My primary computer program simply compares certain types of data associated
with what are believed to be earthquake fault zone activity related
electromagnetic energy field fluctuations with similar data associated with
past earthquakes. And it generates a type of probability number which
indicates how well the signals and earthquakes match. I am presently using
a database of about 28,000 earthquakes going back to the beginning of 1990.
When good matches are observed then in some cases it indicates, in my
opinion, that another earthquake could be about to occur in the vicinity of
the one involved with the match. The geophysics and electromagnetic energy
field concepts behind the program are quite complex and poorly understood.
But the calculations are relatively simple. There are just a lot of them.
Starting from scratch with a reasonably powerful computer it takes me about
5 hours of number crunching to compare perhaps 200 signals with 28,00
earthquakes.
With some assistance from 2 respected geologists I published one technical
paper on this a number of years ago and own 3 copyrights on the technology.
It was discussed in detail in an invited presentation at an annual disaster
mitigation conference in the People's Republic of China back in 2003. And I
have been working informally on this with groups such as United Nations
personnel for years. It is legitimate. It also represents a relatively new
area of science which is tremendously data processing and computer
programming intensive. And my efforts aimed at getting U.S. and Japan
government agencies to use their very powerful computers to run some basic
and important tests related to the technology have so far been unsuccessful.
------------------------------
Date: 14 Jan 2005 20:48:42 -0800
From: "Peroli" <peroli@gmail.com>
Subject: Re: Regular expression lookahead question
Message-Id: <1105764522.189226.114880@f14g2000cwb.googlegroups.com>
hi Arndt Jonasson,
My apologies for writing it hardly readable. I will change my
style of writing. And for zeebster.... im sorry i have no solutions
currently for your problem.
Peroli Sivaprakasam
------------------------------
Date: 14 Jan 2005 21:02:20 -0800
From: "Peroli" <peroli@gmail.com>
Subject: Re: Regular expression lookahead question
Message-Id: <1105764371.542366.104900@f14g2000cwb.googlegroups.com>
hi Arndt Jonasson,
My apologies for writing it hardly readable. I will change my
style of writing. And for zeebster.... I am sorry i have no solutions
currently for your problem.
Peroli Sivaprakasam
------------------------------
Date: Fri, 14 Jan 2005 21:56:40 -0500
From: "A. Sinan Unur" <usa1@llenroc.ude.invalid>
Subject: Re: Store a single character AFTER a match
Message-Id: <pan.2005.01.15.02.56.09.438532@asu1cornelledu>
In article <1105753042.907689.36220@f14g2000cwb.googlegroups.com> posted
on Fri, 14 Jan 2005 17:37:22 -0800, toomanyjoes wrote:
> Hello I'm trying to edit a text file and after my script finishes save
> that text file. One thing I need to do is save the character AFTER a
> match into a variable.
>
> while (<FILE>){
> s/<(Ra|N\d)>//;
> s!^(.\w\w)( \d+):(\d+)!$1~$2~$3!;
> if (/<nsup>/)
> # Then save the character
You'll need to read the posting guidelines and start paying some attention
to the suggestions there.
Post a short and complete script we can run. Provide sample data. Show
what you want to get as well as what your script produces.
The sequence of punctuation and alphanumeric characters above does not do
the job.
> BTW I finally got the correct syntax to open a file!
>
> #!/usr/local/bin/perl -w
No need for -w above if you are going to use the warnings pragma.
> use warnings;
> use strict;
Sinan.
--
A. Sinan Unur
usa1@llenroc.ude.invalid -- remove invalid and
reverse each component for email address.
------------------------------
Date: Sat, 15 Jan 2005 08:44:11 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Store a single character AFTER a match
Message-Id: <csakr4$lmd$1@sun3.bham.ac.uk>
toomanyjoes@mail.utexas.edu wrote:
> Hello I'm trying to edit a text file and after my script finishes save
> that text file. One thing I need to do is save the character AFTER a
> match into a variable.
>
> while (<FILE>){
> s/<(Ra|N\d)>//;
> s!^(.\w\w)( \d+):(\d+)!$1~$2~$3!;
> if (/<nsup>/)
> # Then save the character
>
> I've tried using the $POSTMATCH variable but it grabs the rest of the
> line, I only want one character.
Er, wouldn't that be the first character of $POSTMATCH?
But $POSTMATCH should be avoided for well documented reasons so it would
be better to simply capure the character.
if (my ($char) = /<nsup>(.)/)
(Note: this doesn't match if the next character if it is a newline - if
you want that then you need a switch (looking it up is left as an
exercise for the reader)).
> Also after I execute my replacements how do I save the changes to the
> text file?
>
> while (<FILE>){
> s/<(Ra|N\d)>//;
> s!^(.\w\w)( \d+):(\d+)!$1~$2~$3!;
> }
> #save the changes made??
> close FILE
This is FAQ: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning of a
file?"
Personally I don't like the terse answer in the latest version of the
FAQ since it no longer mentions the option of writing a replacement file
and renaming it over the original.
See also FAQ "How can I use Perl's -i option from within a program?" and
the CPAN modules Files::Transaction or IO::AtomicFile.
> BTW I finally got the correct syntax to open a file!
>
> #!/usr/local/bin/perl -w
> use warnings;
You don't need both '-w' and 'warnings'. Get rid of '-w'.
------------------------------
Date: Sat, 15 Jan 2005 09:34:05 GMT
From: "edgrsprj" <edgrsprj@ix.netcom.com>
Subject: Re: Works great!
Message-Id: <hs5Gd.7004$KJ2.1867@newsread3.news.atl.earthlink.net>
"Abigail" <abigail@abigail.nl> wrote in message
news:slrncughiu.qo.abigail@alexandra.abigail.nl...
> Michele Dondi (bik.mido@tiscalinet.it) wrote on MMMMCLIV September
> MCMXCIII in <URL:news:3epdu0p6ltfevfhv6nt8u025buh5j9n5sn@4ax.com>:
> .. On Thu, 13 Jan 2005 04:44:13 GMT, "edgrsprj" <edgrsprj@ix.netcom.com>
> .. wrote:
I understand what was said in both of the posts about this and will be using
$|=1; and $|=0; instead of $|++; and $|--; I can see that the use of actual
numbers does eliminate any questions.
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7653
***************************************