[28146] in Perl-Users-Digest
Perl-Users Digest, Issue: 9510 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 21 18:10:16 2006
Date: Fri, 21 Jul 2006 15:10: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 Fri, 21 Jul 2006 Volume: 10 Number: 9510
Today's topics:
Re: Problem with Date::Manip <r.ted.byers@rogers.com>
Re: Problem with Date::Manip <r.ted.byers@rogers.com>
Re: Problem with Date::Manip <mritty@gmail.com>
Re: Problem with Date::Manip <r.ted.byers@rogers.com>
Re: problems using oddmuse with mod_perl2 inside apache <no@email.com>
Software Frameworks <jmillion@integrity-apps.com>
Re: subroutine <weberw@adelphia.net>
Re: subroutine <mumia.w.18.spam+nospam.usenet@earthlink.net>
Trouble with parsing text file and grabbing values need donaldjones@gmail.com
Re: Trouble with parsing text file and grabbing values xhoster@gmail.com
Re: Trouble with parsing text file and grabbing values <donaldjones@gmail.com>
Re: Trouble with parsing text file and grabbing values <mumia.w.18.spam+nospam.usenet@earthlink.net>
Re: Trouble with parsing text file and grabbing values <DJStunks@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 21 Jul 2006 08:43:01 -0700
From: "Ted" <r.ted.byers@rogers.com>
Subject: Re: Problem with Date::Manip
Message-Id: <1153496581.430884.181140@h48g2000cwc.googlegroups.com>
>
> Maybe you want to read up on http://tinyurl.com/g99gj
>
Thanks. That solves one part of the problem. However, the main part
of the problem remains.
I see the following in my Manip.pm:
===========================
# First day of the week (1=monday, 7=sunday). ISO 8601 says monday.
$Cnf{"FirstDay"}=1;
# First and last day of the work week (1=monday, 7=sunday)
$Cnf{"WorkWeekBeg"}=1;
$Cnf{"WorkWeekEnd"}=5;
===========================
So why does "substr(DateCalc($day,ParseDateDelta("$delta business
days")),0,8);" behave as if "$Cnf{"WorkWeekEnd"}=7;" when it is clearly
set to 5.
Thanks,
Ted
------------------------------
Date: 21 Jul 2006 09:30:40 -0700
From: "Ted" <r.ted.byers@rogers.com>
Subject: Re: Problem with Date::Manip
Message-Id: <1153499440.713392.148890@75g2000cwc.googlegroups.com>
The problem must be in my use of the function DateCalc, or a bug in it.
The following code:
$date = DateCalc("today","+ 3 business days",\$err);
print "$date\n";
$date = DateCalc("today","- 3 business days",\$err);
print "$date\n";
$date = DateCalc("today","+ 7 business days",\$err);
print "$date\n";
$date = DateCalc("today","- 7 business days",\$err);
print "$date\n";
$date = "today";
print "\n$date\n";
$newdate = Date_NextWorkDay($date,1);
print "$newdate\n";
$newdate = Date_PrevWorkDay($date,1);
print "$newdate\n";
$newdate = Date_PrevWorkDay($date,5);
print "$newdate\n";
$newdate = Date_PrevWorkDay(20060717,1);
print "$newdate\n";
produces the following output:
2006072412:20:25
2006071812:20:25
2006072812:20:25
2006071412:20:25
today
2006072412:20:25
2006072012:20:25
2006071412:20:25
2006071400:00:00
Clearly, the result obtained from DateCalc is wrong in that it appears
to ignore the specification of the work week in Manip.pm. OTOH,
Date_PrevWorkDay is giving me the correct result.
Have I used DateCalc incorrectly or is there a bug in DateCalc?
Ted
------------------------------
Date: 21 Jul 2006 10:38:10 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Problem with Date::Manip
Message-Id: <1153503489.978527.69940@b28g2000cwb.googlegroups.com>
Ted wrote:
> The problem must be in my use of the function DateCalc, or a bug in it.
>
> The following code:
>
> $date = DateCalc("today","+ 3 business days",\$err);
I haven't analyzed this fully yet, so I have no answer for you.
However, I do note that if you change the above to:
$date = DateCalc("today","+ 3 days",\$err, 2);
then you do get the expected results. This is explicitly setting the
mode to Business mode. I don't know why the results are different when
trying to use "business" in the string, as the docs pretty clearly say
that that should trigger Business mode as well...
Paul Lalli
------------------------------
Date: 21 Jul 2006 11:52:34 -0700
From: "Ted" <r.ted.byers@rogers.com>
Subject: Re: Problem with Date::Manip
Message-Id: <1153507954.568355.236530@75g2000cwc.googlegroups.com>
Paul Lalli wrote:
> Ted wrote:
> > The problem must be in my use of the function DateCalc, or a bug in it.
> >
> > The following code:
> >
> > $date = DateCalc("today","+ 3 business days",\$err);
>
> I haven't analyzed this fully yet, so I have no answer for you.
> However, I do note that if you change the above to:
> $date = DateCalc("today","+ 3 days",\$err, 2);
> then you do get the expected results. This is explicitly setting the
> mode to Business mode. I don't know why the results are different when
> trying to use "business" in the string, as the docs pretty clearly say
> that that should trigger Business mode as well...
>
> Paul Lalli
Thanks Paul,
I can confirm that changing my code to explicitly set the mode to
business mode gets all my code using DateCalc working as expected. So
it seems I hit a bug of some sort in DateCalc that results in
"business" not triggering business mode. Perhaps now a note to the
fellow who developed it is warranted?
Thanks
Ted
------------------------------
Date: Fri, 21 Jul 2006 19:24:37 +0100
From: Brian Wakem <no@email.com>
Subject: Re: problems using oddmuse with mod_perl2 inside apache2.2 perl 5.8.6
Message-Id: <4ickf5F33gilU1@individual.net>
Fergus McMenemie wrote:
> HI,
>
> mod_perl newby! Running oddmuse as a cgi works fine. However inside
> mod_perl I only get a blank screen. No error messages of any kind
> in any of the apache log files. Other basic mod_perl scripts work fine.
The second to last line in the source, which calls the sub that gets
everything going is:
DoWikiRequest() if $RunCGI and not exists $ENV{MOD_PERL}; # Do everything.
So if running under mod_perl nothing will happen at all, which is what you
are (not) seeing.
--
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png
------------------------------
Date: 21 Jul 2006 13:45:13 -0700
From: "skinman" <jmillion@integrity-apps.com>
Subject: Software Frameworks
Message-Id: <1153514713.761796.192030@m79g2000cwm.googlegroups.com>
Folks,
I've been writing some Web pages/apps using PERL, PHP4/5, and Java.
I'm wondering about more template-based systems to keep from
reinventing
the wheel. I may just do a few of each style so the next person that
follows me
can pick what they like best? If it can be considered a pseudo
framework, I
like the PHP5 / PEAR stuff so far - HTML_QuickForm, DB, nice stuff.
But the
PERL Mason stuff is looking good too. The more strongly-typed Java
framework
things offer some cool out-of-the-box graphics ability (from something
like SourceForge's EchoPoint) but getting Java Webapps up and running
is a different animal than the
PHP and PERL scripting. What have been your experiences with PERL
Mason?
------------------------------
Date: 21 Jul 2006 13:22:39 -0700
From: "weberw@adelphia.net" <weberw@adelphia.net>
Subject: Re: subroutine
Message-Id: <1153513359.539874.165900@i42g2000cwa.googlegroups.com>
Sorry about double posting. I click the send button only once so I am
not sure why this is happening. Maybe because I am posting to multiple
user groups. Example, perl beginners and perl misc. Would this cause
double posting to occur?
------------------------------
Date: Fri, 21 Jul 2006 21:30:13 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: subroutine
Message-Id: <FHbwg.7890$vO.6043@newsread4.news.pas.earthlink.net>
On 07/21/2006 03:22 PM, weberw@adelphia.net wrote:
> Sorry about double posting. I click the send button only
> once so I am not sure why this is happening. Maybe because
> I am posting to multiple user groups. Example, perl
> beginners and perl misc. Would this cause double posting
> to occur?
>
That's called multi-posting. Don't do it. People who read both
groups find it annoying, and they aren't going to be annoyed
by you for long before they blacklist you.
It's probably too late since two of the more knowledgeable
people in this newsgroup have already blocked or decided to
ignore your messages.
Too bad. I sent you a private e-mail warning you to follow the
posting guidelines for this newsgroup or you would probably be
blacklisted. It's happened. You didn't read my e-mail. You
didn't read the posting guidelines. You didn't follow the
posting guidelines.
Following the posting guidelines is not optional. Ignore the
posting guidelines and get blacklisted. That's how it works.
------------------------------
Date: 21 Jul 2006 10:18:29 -0700
From: donaldjones@gmail.com
Subject: Trouble with parsing text file and grabbing values needed
Message-Id: <1153502309.206491.60740@p79g2000cwp.googlegroups.com>
I have a large text file with many records I'd like to parse and
extract data. I'm trying to conceptually figure out how to pull out
what I need and put in a CSV file. Here is a snipped of what 2 records
look like, the beginning of each records always has a "TEST1:" and an
"NN:" within the first line:
-------------------snip----------------------
TEST1: DTP:07/17/06 SSZ4 NN:007-74 REC:01 UN:PZZ PG: 001+
CCTL FUN:007-74 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
PT:2005 2004
DOE, JOHN PZY:C01 TMR:DV,DI-03/02 UI:DI ZZL:07/10/06 SEQU:2
RRRU NONE
ZMTH ZMTH 1 2 3 5 DDAA YXA XXA XXS
ZMTH 11/02/02 2 0102 156 156 11
ZMTH 11/02/02 2 0202 156 156 11
ZMTH 11/02/02 2 0302 156 156 22
ZMTH 11/02/02 2 0402 96 96 11
TEST1: DTP:07/17/06 SSZ4 NN:745-88 REC:01 UN:PZZ PG: 001+
CCTL FUN:745-88 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
PT:2005 2004
DOE, JOHN PZY:C01 TMR:DV,DI-03/02 UI:DI ZZL:07/10/06 SEQU:2
RRRU NONE
ZMTH ZMTH 1 2 3 5 DDAA YXA XXA XXS
ZMTH 11/02/02 2 0102 156 156 11
ZMTH 11/02/02 2 0202 156 156 11
ZMTH 11/02/02 2 0302 156 156 22
ZMTH 11/02/02 2 0402 96 96 11
-------------------snip----------------------
Here is an example of what I'm looking for to put in a CSV File, with
the first line being the header of each piece of data I'm trying to
grab:
NN,CFL,Name,UI
007-74,L0E,JOHN DOE,DI
So as you can see, I want to be able to pull out the value after each
##: (for particular ##:'s or all of them if that's easy) where ## is a
character representation followed by a colon that identifies each piece
of data in the text file snippet above. Also want to note that the
name has no delimiter, but always comes on the 4th line of each record,
at the beginning.
I'm not looking for someone to write the program for me, but was
looking for some ideas on how to go about grabbing this data out and
putting into another file. I use Perl mainly as a system administrator
to get tasks done as needed and can figure out where to go if pointed
in the right direction. I'm used to working with the same predictable
fileds on each line for parsing and splitting, but not when the values
can be found in a span of multiple lines.
I've googled for this a few times, but I haven't found quite what I'm
looking for.
Any ideas? Any help would be greatly appreciated.
------------------------------
Date: 21 Jul 2006 17:28:16 GMT
From: xhoster@gmail.com
Subject: Re: Trouble with parsing text file and grabbing values needed
Message-Id: <20060721133356.779$Nr@newsreader.com>
donaldjones@gmail.com wrote:
> I have a large text file with many records I'd like to parse and
> extract data. I'm trying to conceptually figure out how to pull out
> what I need and put in a CSV file. Here is a snipped of what 2 records
> look like, the beginning of each records always has a "TEST1:" and an
> "NN:" within the first line:
Will "TEST1:" ever occur *other* than on the first line of a record?
If not, then you can set $/='TEST1:' to isolate records. (You will have to
burn the very first read on the file, because TEST1: is considered the end
rather than the beginning of each record, which causes a spurious empty
(other than TEST1: itself) first record.
>
> -------------------snip----------------------
>
> TEST1: DTP:07/17/06 SSZ4 NN:007-74 REC:01 UN:PZZ PG: 001+
> CCTL FUN:007-74 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
> PT:2005 2004
> DOE, JOHN PZY:C01 TMR:DV,DI-03/02 UI:DI ZZL:07/10/06 SEQU:2
> RRRU NONE
> ZMTH ZMTH 1 2 3 5 DDAA YXA XXA XXS
> ZMTH 11/02/02 2 0102 156 156 11
> ZMTH 11/02/02 2 0202 156 156 11
> ZMTH 11/02/02 2 0302 156 156 22
> ZMTH 11/02/02 2 0402 96 96 11
> TEST1: DTP:07/17/06 SSZ4 NN:745-88 REC:01 UN:PZZ PG: 001+
> CCTL FUN:745-88 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
> PT:2005 2004
> DOE, JOHN PZY:C01 TMR:DV,DI-03/02 UI:DI ZZL:07/10/06 SEQU:2
> RRRU NONE
> ZMTH ZMTH 1 2 3 5 DDAA YXA XXA XXS
> ZMTH 11/02/02 2 0102 156 156 11
> ZMTH 11/02/02 2 0202 156 156 11
> ZMTH 11/02/02 2 0302 156 156 22
> ZMTH 11/02/02 2 0402 96 96 11
>
> -------------------snip----------------------
>
> Here is an example of what I'm looking for to put in a CSV File, with
> the first line being the header of each piece of data I'm trying to
> grab:
>
> NN,CFL,Name,UI
> 007-74,L0E,JOHN DOE,DI
>
> So as you can see, I want to be able to pull out the value after each
> ##: (for particular ##:'s or all of them if that's easy) where ## is a
> character representation followed by a colon that identifies each piece
> of data in the text file snippet above.
Eh, I don't see that. Do you want just the three you specified (NN, CFL,
UI) or do you want all the others fitting that format (MT, FSS, etc.) as
well?
Also, are these always in the same order? Always on the same line?
Can any of these field labels be a ending substring of any other of the
labels?
> Also want to note that the
> name has no delimiter, but always comes on the 4th line of each record,
> at the beginning.
skip over 3 lines, then skip over the initial white space on the 4th line,
then take everything upto the first PZY: (not taking the whitespace before
PZY:)
$record =~ /^.*\n.*\n.*\n\s*(.*?)\s+PZY:/ or die;
my $name=$1;
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 21 Jul 2006 10:56:33 -0700
From: "DJ" <donaldjones@gmail.com>
Subject: Re: Trouble with parsing text file and grabbing values needed
Message-Id: <1153504593.851639.55100@i42g2000cwa.googlegroups.com>
xhoster@gmail.com wrote:
> Will "TEST1:" ever occur *other* than on the first line of a record?
> If not, then you can set $/='TEST1:' to isolate records. (You will have to
> burn the very first read on the file, because TEST1: is considered the end
> rather than the beginning of each record, which causes a spurious empty
> (other than TEST1: itself) first record.
"TEST1:" Will only occur on the first line of a record
> Eh, I don't see that. Do you want just the three you specified (NN, CFL,
> UI) or do you want all the others fitting that format (MT, FSS, etc.) as
> well?
I would like to pull out all of them if possible (NN, CFL, MT, FSS) and
then decide later if I want to put in the CSV file
> Also, are these always in the same order? Always on the same line?
> Can any of these field labels be a ending substring of any other of the
> labels?
It is always the same order, however, some of the records have extra
lines every so often that we are not interested in. The field labels
aren't an ending substring of other labels so you can pretty much
consider them always "field labels" when you see "###:"
> skip over 3 lines, then skip over the initial white space on the 4th line,
> then take everything upto the first PZY: (not taking the whitespace before
> PZY:)
>
> $record =~ /^.*\n.*\n.*\n\s*(.*?)\s+PZY:/ or die;
> my $name=$1;
I'll give this part a shot...
Thanks for your reply!
------------------------------
Date: Fri, 21 Jul 2006 19:03:31 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: Trouble with parsing text file and grabbing values needed
Message-Id: <7y9wg.7827$vO.4774@newsread4.news.pas.earthlink.net>
On 07/21/2006 12:18 PM, donaldjones@gmail.com wrote:
> I have a large text file with many records I'd like to parse and
> extract data. I'm trying to conceptually figure out how to pull out
> what I need and put in a CSV file. Here is a snipped of what 2 records
> look like, the beginning of each records always has a "TEST1:" and an
> "NN:" within the first line:
>
> -------------------snip----------------------
>
> TEST1: DTP:07/17/06 SSZ4 NN:007-74 REC:01 UN:PZZ PG: 001+
> CCTL FUN:007-74 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
> PT:2005 2004
> [...]
I would follow xhoster's advise and set $/ (the record
separator sequence) to "TEST1:". You can also find a regular
expression that matches your "##:" sequences. Use the match
operator with the /g option to get all of them.
Those "##:" sequences look like they are 2-3 alphabetic
characters followed by a colon followed by several
non-whitespace characters.
Read "perldoc perlrequick" and "perldoc perlre" to find out
how to make the right regular expression for your needs.
Good luck.
------------------------------
Date: 21 Jul 2006 14:39:52 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Trouble with parsing text file and grabbing values needed
Message-Id: <1153517992.027570.198460@s13g2000cwa.googlegroups.com>
donaldjones@gmail.com wrote:
> I have a large text file with many records I'd like to parse and
> extract data. I'm trying to conceptually figure out how to pull out
> what I need and put in a CSV file. Here is a snipped of what 2 records
> look like, the beginning of each records always has a "TEST1:" and an
> "NN:" within the first line:
>
> -------------------snip----------------------
>
> TEST1: DTP:07/17/06 SSZ4 NN:007-74 REC:01 UN:PZZ PG: 001+
> CCTL FUN:007-74 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
> PT:2005 2004
> DOE, JOHN PZY:C01 TMR:DV,DI-03/02 UI:DI ZZL:07/10/06 SEQU:2
> RRRU NONE
> ZMTH ZMTH 1 2 3 5 DDAA YXA XXA XXS
> ZMTH 11/02/02 2 0102 156 156 11
> ZMTH 11/02/02 2 0202 156 156 11
> ZMTH 11/02/02 2 0302 156 156 22
> ZMTH 11/02/02 2 0402 96 96 11
> TEST1: DTP:07/17/06 SSZ4 NN:745-88 REC:01 UN:PZZ PG: 001+
> CCTL FUN:745-88 CFL:L0E MT:09/11/05-R FSS:L0E MN:L00
> PT:2005 2004
> DOE, JOHN PZY:C01 TMR:DV,DI-03/02 UI:DI ZZL:07/10/06 SEQU:2
> RRRU NONE
> ZMTH ZMTH 1 2 3 5 DDAA YXA XXA XXS
> ZMTH 11/02/02 2 0102 156 156 11
> ZMTH 11/02/02 2 0202 156 156 11
> ZMTH 11/02/02 2 0302 156 156 22
> ZMTH 11/02/02 2 0402 96 96 11
>
>
> -------------------snip----------------------
ugly. I parse records similar to this using Parse::RecDescent, but
it's slow so if you have 10,000,000 of them you might be waiting a
while...
plus the learning curve for P::RD is pretty steep.
-jp
------------------------------
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 9510
***************************************