[25677] in Perl-Users-Digest
Perl-Users Digest, Issue: 7918 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 29 13:12:23 2005
Date: Tue, 29 Mar 2005 10:12:17 -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 Tue, 29 Mar 2005 Volume: 10 Number: 7918
Today's topics:
Question on perl script. <sgtembe@hotmail.com>
regex newbie question <vze2mf4r@verizon.net>
Re: regex newbie question <1usa@llenroc.ude.invalid>
Re: regex newbie question <someone@example.com>
Re: regex newbie question <see_sig@invalid>
Re: regex newbie question <tadmc@augustmail.com>
Re: regex newbie question <someone@example.com>
Re: regex newbie question <vze2mf4r@verizon.net>
Re: regex newbie question <tadmc@augustmail.com>
search/replace for consecutive blank lines <skendric@fhcrc.org>
Re: search/replace for consecutive blank lines <1usa@llenroc.ude.invalid>
Re: search/replace for consecutive blank lines <nobull@mail.com>
Re: search/replace for consecutive blank lines <someone@example.com>
Re: search/replace for consecutive blank lines <tadmc@augustmail.com>
Re: search/replace for consecutive blank lines <skendric@fhcrc.org>
Re: Seeking Recommendations For Perl Shopping Cart Syst <nospam@bigpond.com>
Re: simple help jaw56856@yahoo.com
Re: simple help <mritty@gmail.com>
Re: simple help <tadmc@augustmail.com>
Re: simple help <lynn.watts@ugs.com>
Re: simple help <tadmc@augustmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Mar 2005 07:31:53 -0800
From: "Unix_Shell" <sgtembe@hotmail.com>
Subject: Question on perl script.
Message-Id: <1112110313.611915.119160@l41g2000cwc.googlegroups.com>
Hello Group,
I am very new to the perl language and don't know much about it. I had
a question & maybe someone can help me decipher/modify a script.
We have AIX 5.2 & the script (test.sh) contains the following perl
command:
/usr/bin/perl
-014pe's|^|"'$PAGE1FORM'".(/Page:\s+1\s/?"\n":"'$CONTFORMSFX'\n")|e'
Basically, two values are being passed to this script. Variable
PAGE1FORM will contain $1 (example: "m_inv01") and CONTFORMSFX will
contain $2 (example: "_09").
Basically, the script is invoked as follows:
./test.sh m_inv01 _09 < inrptfile > outrptfile
The perl command processes the inrptfile by substituting the first line
of page 1 with m_inv01 and substituting the first line from page 2
onwards with m_inv01_09 (concatenation of $1 & $2).
Question: How can I make it substitute something completely different
from page 2 onwards? So, if I run the script as follows:
./test.sh m_inv01 pg2form < inrptfile > outrptfile
I would like the perl command to substitute the first line of page 1
with m_inv01 (just like above); however I would like it to substitute
the first line from page 2 onwards with pg2form (i.e. with whatever I
pass as $2 and *not* a concatenation of $1 and $2).
Thanks for any help.
S
------------------------------
Date: Mon, 28 Mar 2005 01:47:40 GMT
From: "ZMAN" <vze2mf4r@verizon.net>
Subject: regex newbie question
Message-Id: <0nJ1e.21235$uw6.16103@trnddc06>
Hello all!
Reading in lines from a file.
I want to ignore all the text before it gets to the line
"<!--document_starts_here-->"
and write out the remainder of the text to a file.
This is the way I'm attempting this..
Thanks in advance!
BZ
open DATAOUT, ">$data_file" or die "can't open $data_file $!";
foreach $line (@lines)
{
if ($line =~ m/<!--document_starts_here-->/i)
{
print "This line contains the word : $line\n";
#### write remainder of file out
}
print DATAOUT "$line";
}
close (DATAOUT)
------------------------------
Date: Mon, 28 Mar 2005 02:05:55 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: regex newbie question
Message-Id: <Xns9626D6A1FFEE1asu1cornelledu@127.0.0.1>
"ZMAN" <vze2mf4r@verizon.net> wrote in news:0nJ1e.21235$uw6.16103
@trnddc06:
> Reading in lines from a file.
> I want to ignore all the text before it gets to the line
> "<!--document_starts_here-->"
> and write out the remainder of the text to a file.
use strict;
use warnings;
missing.
> open DATAOUT, ">$data_file" or die "can't open $data_file $!";
open my $data_out, '>', $data_file or die "Can't open $data_file: $!";
See
perldoc -q always
The question, of course, is where are you reading the data in?
> foreach $line (@lines)
> {
>
> if ($line =~ m/<!--document_starts_here-->/i)
> {
> print "This line contains the word : $line\n";
>
> #### write remainder of file out
> }
>
> print DATAOUT "$line";
>
> }
>
>
> close (DATAOUT)
Please post real code. Please see the posting guidelines for this group
to find out how you can help others help you.
It *seems* to me like you are initially slurping the file. There is no
need for that.
#! /usr/bin/perl
use strict;
use warnings;
while(<DATA>) {
next unless /<!--document_starts_here-->/i;
while(<DATA>) {
print;
}
}
__END__
<html>
<head>
<title>Test</title>
</head>
<!--document_starts_here-->
<body>
<h1>Some document</h1>
<p>ya ba da ba doo</p>
</body>
</html>
------------------------------
Date: Mon, 28 Mar 2005 02:07:46 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: regex newbie question
Message-Id: <SFJ1e.12011$x8.6765@edtnps90>
ZMAN wrote:
>
> Reading in lines from a file.
It looks like you are iterating over an array instead.
> I want to ignore all the text before it gets to the line
> "<!--document_starts_here-->"
> and write out the remainder of the text to a file.
If you were actually reading in from a file it would be a lot easier, like:
while ( <DATAIN> ) {
if ( /<!--document_starts_here-->/i .. eof DATAIN ) {
print DATAOUT;
}
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 27 Mar 2005 21:33:44 -0500
From: Bob Walton <see_sig@invalid>
Subject: Re: regex newbie question
Message-Id: <42476dbd$1_1@127.0.0.1>
ZMAN wrote:
...
> Reading in lines from a file.
> I want to ignore all the text before it gets to the line
> "<!--document_starts_here-->"
> and write out the remainder of the text to a file.
>
> This is the way I'm attempting this..
...
> BZ
>
Let Perl give you all the help it can:
use strict;
use warnings;
Also, please post a short but complete example illustrating the
problem that anyone can copy/paste/execute. Yours fails this on
several accounts: needed variables like $data_file are not
defined, the content of @lines is not defined, etc. See below
for suggested style.
> open DATAOUT, ">$data_file" or die "can't open $data_file $!";
>
> foreach $line (@lines)
> {
>
> if ($line =~ m/<!--document_starts_here-->/i)
> {
> print "This line contains the word : $line\n";
>
> #### write remainder of file out
> }
>
> print DATAOUT "$line";
This print is executed unconditionally, so it will output every
line that is read in. You need to execute this only on lines
following your "starts_here" flag line.
>
> }
>
>
> close (DATAOUT)
Here is one way:
use warnings;
use strict;
my @lines=<DATA>;
my $printok=0;
foreach my $line (@lines){
print "to DATAOUT ->$line" if $printok;
if ($line =~ m/<!--document_starts_here-->/i){
print "This line contains the word : $line";
$printok++;
}
}
__END__
This line should be ignored
<!--document_starts_here-->
This is line 3
line 4
last line
You may also note that I used STDOUT for the output instead of
including the unneeded and slightly painful (for readers of the
post) and superfluous (to the question being asked) output file.
And that I used the <DATA> filehandle to read a definition for
@lines. I also removed the \n at the end of your "This line
contains..." print statement, since $line already contains the \n
read from the input.
There are also trickier ways of doing what you want, such as
defining the input record separator to be the
"document_starts_here" string. Something like:
use warnings;
use strict;
my @lines;
{
local $/="<!--document_starts_here-->\n";
@lines=<DATA>;
}
print $lines[1];
__END__
This line should be ignored
<!--document_starts_here-->
This is line 3
line 4
last line
HTH.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! >100,000 Newsgroups
---= East/West-Coast Server Farms - Total Privacy via Encryption =---
------------------------------
Date: Sun, 27 Mar 2005 21:54:25 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regex newbie question
Message-Id: <slrnd4evvh.3tb.tadmc@magna.augustmail.com>
ZMAN <vze2mf4r@verizon.net> wrote:
> Reading in lines from a file.
No you're not. Your code contains no input statements.
> I want to ignore all the text before it gets to the line
> "<!--document_starts_here-->"
> and write out the remainder of the text to a file.
while ( <> ) {
last if $_ eq "<!--document_starts_here-->\n";
}
while ( <> ) {
print;
}
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 28 Mar 2005 10:07:36 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: regex newbie question
Message-Id: <IHQ1e.126152$gJ3.44822@clgrps13>
Tad McClellan wrote:
> ZMAN <vze2mf4r@verizon.net> wrote:
>
>>Reading in lines from a file.
>
> No you're not. Your code contains no input statements.
>
>>I want to ignore all the text before it gets to the line
>>"<!--document_starts_here-->"
>>and write out the remainder of the text to a file.
>
> while ( <> ) {
> last if $_ eq "<!--document_starts_here-->\n";
I think that the OP wanted a case insensitive match.
> }
>
> while ( <> ) {
> print;
> }
$_ = <> until /<!--document_starts_here-->/i;
print while <>;
# :-)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Tue, 29 Mar 2005 01:19:58 GMT
From: "ZMAN" <vze2mf4r@verizon.net>
Subject: Re: regex newbie question
Message-Id: <2322e.19072$Ax.11810@trnddc04>
John
Thanks! That's just what I needed.
My goal was to pull over some html, remove the PHP, write them to a temp
dir, and then have SWISH index them.
In my haste I didn't post all of my code.
So, here it is, works great and thanks again!
#!/usr/local/bin/perl -w
use strict;
my $dest_dir = "../../temp/";
my $src_dir = "../../html/";
mkdir("$dest_dir",0777) || die "cannot mkdir $dest_dir: $!";
opendir(DIR, $src_dir);
my @files = readdir(DIR);
closedir(DIR);
my $file;
print "Indexing the following files\n";
foreach $file (@files)
{
next if($file eq '.');
next if($file eq '..');
next if($file =~ /\.php/);
next if($file =~ /\.inc/);
next if($file =~ /\.pl/);
next if($file =~ /\.cgi/);
next if($file =~ /\.txt/);
next if($file =~ /_R\.html$/);
next if(! ($file =~ /\.html$/));
print "$file\n";
open(FILE, "<$src_dir$file") or die "Can't open $file : $!";
open (DATAOUT, "> $dest_dir$file") or die "can't open $dest_dir$file
$!";
while ( <FILE> ) {
if ( /<!--document_starts_here-->/i .. eof FILE ) {
print DATAOUT;
}
}
}
close DATAOUT;
close FILE;
system("./swish -c swish.conf");
system("rm -rf $dest_dir");
"John W. Krahn" <someone@example.com> wrote in message
news:SFJ1e.12011$x8.6765@edtnps90...
> ZMAN wrote:
> >
> > Reading in lines from a file.
>
> It looks like you are iterating over an array instead.
>
>
> > I want to ignore all the text before it gets to the line
> > "<!--document_starts_here-->"
> > and write out the remainder of the text to a file.
>
> If you were actually reading in from a file it would be a lot easier,
like:
>
> while ( <DATAIN> ) {
> if ( /<!--document_starts_here-->/i .. eof DATAIN ) {
> print DATAOUT;
> }
> }
>
>
>
> John
> --
> use Perl;
> program
> fulfillment
------------------------------
Date: Mon, 28 Mar 2005 20:45:06 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: regex newbie question
Message-Id: <slrnd4hg9i.7i2.tadmc@magna.augustmail.com>
ZMAN <vze2mf4r@verizon.net> wrote:
> mkdir("$dest_dir",0777) || die "cannot mkdir $dest_dir: $!";
perldoc -q vars
What's wrong with always quoting "$vars"?
mkdir($dest_dir, 0777) || die "cannot mkdir $dest_dir: $!";
> opendir(DIR, $src_dir);
You should test the return value from opendir() just like you did
with mkdir().
> next if($file =~ /\.php/);
> next if($file =~ /\.inc/);
> next if($file =~ /\.pl/);
> next if($file =~ /\.cgi/);
> next if($file =~ /\.txt/);
next if $file =~ /\.(php|inc|pl|cgi|txt)$/; # anchor to end of string
> next if($file =~ /_R\.html$/);
You anchored here, but not the earlier ones.
> next if(! ($file =~ /\.html$/));
next unless $file =~ /\.html$/;
You don't need the earlier batch of tests if you have this
one anyway...
[ snip TOFU ]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Mar 2005 14:01:12 -0800
From: "sbk" <skendric@fhcrc.org>
Subject: search/replace for consecutive blank lines
Message-Id: <1111958097.439644.304940@l41g2000cwc.googlegroups.com>
hi,
how do i search for consecutive blank lines and replace with something
else?
I thought that "s/\n\n/foo/;" would work ... but obviously not.
guru> cat test
#!/opt/vdops/bin/perl
use diagnostics;
use strict;
use warnings;
open INPUT, "<foo" or die "Can't open foo: $!";
while (<INPUT>) {
s/\n\n/dog\n/;
print;
}
close INPUT;
guru> cat foo
Frogs live in ponds. Hit 'Enter' twice.
So do toads. Hit 'Enter' three times.
And newts live near ponds. Don't hit 'Enter' any more.
guru> ./test
Frogs live in ponds. Hit 'Enter' twice.
So do toads. Hit 'Enter' three times.
And newts live near ponds. Don't hit 'Enter' any more.
so that didn't work ... but searching for a single "\n" works just
fine.
guru> cat test
#!/opt/vdops/bin/perl
use diagnostics;
use strict;
use warnings;
open INPUT, "<foo" or die "Can't open foo: $!";
while (<INPUT>) {
s/\n/dog\n/;
print;
}
close INPUT;
guru> ./test
Frogs live in ponds. Hit 'Enter' twice.dog
dog
So do toads. Hit 'Enter' three times.dog
dog
dog
And newts live near ponds. Don't hit 'Enter' any more.dog
guru>
what is it about two "\n" in a row which requires special handling?
perl-5.8.6
--sk
stuart kendrick
fhcrc
------------------------------
Date: Sun, 27 Mar 2005 22:24:43 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: search/replace for consecutive blank lines
Message-Id: <Xns9626B1215A912asu1cornelledu@127.0.0.1>
"sbk" <skendric@fhcrc.org> wrote in news:1111958097.439644.304940
@l41g2000cwc.googlegroups.com:
> hi,
>
> how do i search for consecutive blank lines and replace with something
> else?
>
> I thought that "s/\n\n/foo/;" would work ... but obviously not.
You can consult perldoc perlop:
s/PATTERN/REPLACEMENT/egimosx
...
Options are:
...
g Replace globally, i.e., all occurrences.
s Treat string as single line.
...
> guru> cat test
> #!/opt/vdops/bin/perl
> use diagnostics;
> use strict;
> use warnings;
> open INPUT, "<foo" or die "Can't open foo: $!";
Please use the __DATA__ section to include data with scripts you post.
(See the posting guidelines for this group for more information).
> while (<INPUT>) {
> s/\n\n/dog\n/;
> print;
> }
You are processing *one* line at a time. By definition, there can only
be one ending in each line.
...
> what is it about two "\n" in a row which requires special handling?
See above.
#! /usr/bin/perl
use strict;
use warnings;
{
local $/;
my $str = <DATA>;
$str =~ s/\n\n/dog\n/sg;
print $str;
}
__DATA__
Frogs live in ponds. Hit 'Enter' twice.
So do toads. Hit 'Enter' three times.
And newts live near ponds. Don't hit 'Enter' any more.
__END__
See also:
perldoc -q "How can I read in a file by paragraphs?"
Sinan
------------------------------
Date: Sun, 27 Mar 2005 22:20:07 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: search/replace for consecutive blank lines
Message-Id: <d27b7q$a46$1@sun3.bham.ac.uk>
sbk wrote:
> how do i search for consecutive blank lines and replace with something
> else?
>
> I thought that "s/\n\n/foo/;" would work ...
It would if applied to a string containg multiple lines.
> but obviously not.
...if applied to each line of the data one at a time (since no single
line contains multiple lines - tautologically).
>
>
> guru> cat test
> #!/opt/vdops/bin/perl
> use diagnostics;
> use strict;
> use warnings;
> open INPUT, "<foo" or die "Can't open foo: $!";
local $/; # Read whole file at one go.
> while (<INPUT>) {
> s/\n\n/dog\n/;
> print;
> }
> close INPUT;
For large files you may want to do something smarter with some sort of
rolling buffer.
> what is it about two "\n" in a row which requires special handling?
If you are handling the data one line at a time the two "\n" will be in
different records.
------------------------------
Date: Sun, 27 Mar 2005 23:29:28 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: search/replace for consecutive blank lines
Message-Id: <slH1e.123567$gJ3.49031@clgrps13>
sbk wrote:
>
> how do i search for consecutive blank lines and replace with something
> else?
>
> I thought that "s/\n\n/foo/;" would work ... but obviously not.
It's easy, use paragraph mode:
$/ = ''; #set paragraph mode
while ( <INPUT> ) {
chomp; # remove multiple blank lines
do_something_with_paragraph( $_ );
print $_, 'something else';
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 27 Mar 2005 18:20:48 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: search/replace for consecutive blank lines
Message-Id: <slrnd4ejf0.1qp.tadmc@magna.augustmail.com>
sbk <skendric@fhcrc.org> wrote:
> how do i search for consecutive blank lines and replace with something
> else?
>
> I thought that "s/\n\n/foo/;" would work
It will, if you arrange to have a string that has 2 newlines in it
for that pattern to match against.
What is in $_ there?
> while (<INPUT>) {
How many newlines will there be in $_ here?
(A: one)
> s/\n\n/dog\n/;
How many newlines are required in $_ for the pattern to match?
(A: two)
The match must fail.
> what is it about two "\n" in a row which requires special handling?
Your Question is Asked Frequently:
perldoc -q line
I'm having trouble matching over more than one line. What's wrong?
The 1st few words of the answer predict your problem, and the
2nd paragraph suggests how to solve it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 27 Mar 2005 20:31:58 -0800
From: "sbk" <skendric@fhcrc.org>
Subject: Re: search/replace for consecutive blank lines
Message-Id: <1111984318.113597.291150@o13g2000cwo.googlegroups.com>
thank you for the tips on posting (__DATA__), on using perldoc :(, and
on the use of /sg ...
--sk
------------------------------
Date: Wed, 23 Mar 2005 19:11:45 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Seeking Recommendations For Perl Shopping Cart System
Message-Id: <3acq6lF6932ogU1@individual.net>
John wrote:
> All:
>
> I am looking to get some feedback and recommendations on Shopping Cart and
> E-Commerce systems that are written in Perl and have Open Source licenses.
>
> The requirements will include being able to take and process a credit card
> order on a secure page. I typically use MySQL for database and Apache for
> HTTP server.
>
> If you feel like sharing your experiences with me, I would certainly
> appreciate it and perhaps others can learn from it as well.
>
> Thanks!
>
> John
Most (eg oscommerece x-cart) are written in php. www.amazon.com uses Perl.
I've been slowly writing my own in Perl at www.pchq.com.au but I'm thinking
of abandoning it for something commercial.
gtoomey
------------------------------
Date: 25 Mar 2005 07:30:17 -0800
From: jaw56856@yahoo.com
Subject: Re: simple help
Message-Id: <1111764617.385242.33250@o13g2000cwo.googlegroups.com>
Tad, I had not seen the Posting Guidelines, but have now. Here is the
script that is trying to parse the log file. if i were to just run the
string matching section it work, but when i try and the logic to pick
up where i left off, it never matches.
here is the script
open (test, "TradingManager_ckt49_h.log") || die "no data to check";
open (logfile, "logfile.txt") || die " no log file";
open (errorfile, ">>errorfile.txt") || die " no error file";
@logfile = <logfile>;
$last_runtime = $logfile[$#logfile];
print $last_runtime;
$x = 1;
while (<test> ){
if ($x)
{
$comp_string = substr($_, 0, 20);
if(($last_runtime eq $comp_string) )
{ $x = 0;print ("whooooo\n")}
print ($comp_string, "\n");
}
else
{
#print (" found the starting point\n");
if (/ERROR.*Msg: 249/){
print $_;
#print ("we are here");
print errorfile $_;
}
}
$max_runtime = substr($_, 0, 20);
}
print $max_runtime
open (logfile, ">>logfile.txt") || die " no log file";
print logfile $max_runtime, "\n";
close (test);
close (logfile);
close (errorfile);
_DATA_ <<TradingManager_ckt49_h.log>>
24 Feb 2005 13:01:11 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:02:21 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:03:21 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:04:21 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:05:28 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:06:36 WARNING - <executing script ***
24 Feb 2005 13:07:36 WARNING - <executing script ***
24 Feb 2005 13:09:36 WARNING - <executing script ***
24 Feb 2005 13:10:36 WARNING - <executing script ***
24 Feb 2005 13:11:36 WARNING - <executing script ***
24 Feb 2005 13:12:54 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:13:55 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:14:12 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:15:12 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:16:45 ERROR - <gmem_table_sort.c, line #8088>:
TABLE_PivotInternal(): ***
24 Feb 2006 16:15:58 ERROR - <prc_gui.c, line #2503>: ***
25 Feb 2006 09:17:36 ERROR - <db_api_ct.c, line #2120>: ***
21 Feb 2005 13:56:59 ERROR - <db_api_ct.c, line #241>: *** Msg: 249,
***
21 Feb 2005 13:56:59 ERROR - <db_api_ct.c, line #241>: *** Msg: 248,
***
24 Feb 2006 13:27:45 ERROR - <gmem_table_sort.c, line #8110>:
TABLE_PivotInternal(): ***
21 Feb 2005 13:56:59 ERROR - <db_api_ct.c, line #241>: *** Msg: 249,
***
24 Feb 2006 13:27:46 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2006 16:15:56 ERROR - <prc_pv.c, line #1309>: ***
_DATA_<<logfile.txt>>
25 Feb 2005 09:17:35
25 Feb 2005 09:17:36
25 Feb 2005 09:17:37
25 Feb 2005 09:17:38
25 Feb 2005 09:17:39
25 Feb 2005 09:17:40
25 Feb 2005 09:17:41
25 Feb 2005 09:17:42
25 Feb 2005 09:17:43
25 Feb 2005 09:17:44
25 Feb 2005 09:17:45
25 Feb 2005 09:17:46
25 Feb 2005 09:17:47
25 Feb 2005 09:17:48
25 Feb 2005 09:17:49
25 Feb 2005 09:17:50
25 Feb 2005 09:17:51
25 Feb 2005 09:17:52
25 Feb 2005 09:17:53
25 Feb 2005 09:18:36
24 Feb 2006 13:27:45
24 Feb 2006 16:15:58
24 Feb 2006 16:15:58
24 Feb 2006 16:15:56
24 Feb 2006 16:15:56
24 Feb 2005 13:09:36
------------------------------
Date: Fri, 25 Mar 2005 16:17:17 GMT
From: Paul Lalli <mritty@gmail.com>
Subject: Re: simple help
Message-Id: <hQW0e.23904$qN3.20191@trndny01>
jaw56856@yahoo.com wrote:
> Tad, I had not seen the Posting Guidelines, but have now.
But you decided either to not read them, or not to follow them?
You are still not quoting any context in your follow up.
You still have not created a short-but-complete program, using __DATA__
sections (which is not the same as simply including the data in your
program and telling us to put it in a file with a specific name).
Paul Lalli
------------------------------
Date: Fri, 25 Mar 2005 11:15:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: simple help
Message-Id: <slrnd48hqc.c6v.tadmc@magna.augustmail.com>
jaw56856@yahoo.com <jaw56856@yahoo.com> wrote:
> Tad,
Please post some context when composing a followup.
I've asked you to do this before, why have you chosen to not do that?
> I had not seen the Posting Guidelines, but have now.
My implication was that you would *follow* at least some of
the points made there.
I shrugged it off earlier figuring that you just didn't know
about them, but now you are coming off as a very self-centered
and rude person.
> Here is the
> script
> here is the script
But it is not a short and complete program *that we can run*.
I've asked you to do this before, why have you chosen to not do that?
The Posting Guidelines suggest it too, why have you chosen to not
follow the suggestion?
> open (test, "TradingManager_ckt49_h.log") || die "no data to check";
> open (logfile, "logfile.txt") || die " no log file";
> open (errorfile, ">>errorfile.txt") || die " no error file";
You should use UPPER CASE for filehandles.
I've asked you to do this before, why have you chosen to not do that?
You should include the $! variable in the die message so that
you will know *why* it failed.
> @logfile = <logfile>;
Every line in the array has a newline at the end.
> $last_runtime = $logfile[$#logfile];
$last_runtime = $logfile[-1];
That has a newline at then end too then.
> print $last_runtime;
Didn't you see a newline when you print()ed this?
I suggested this before
print "\$last_runtime is '$last_runtime'\n";
so that you could see what is being compared, why have you
chosen to not do that?
> $comp_string = substr($_, 0, 20);
Is the 20th character from $_ a newline?
> if(($last_runtime eq $comp_string) )
> print ($comp_string, "\n");
I suggested this before
print "\$comp_string is '$comp_string'\n";
so that you could see what is being compared, why have you
chosen to not do that?
> _DATA_ <<TradingManager_ckt49_h.log>>
I've asked you to use a __DATA__ section before, why have you
chosen to not do that?
I am "talking to the hand" here.
You are on your own.
*plonk*
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 25 Mar 2005 11:55:39 -0800
From: "lynn" <lynn.watts@ugs.com>
Subject: Re: simple help
Message-Id: <42446bce$1@usenet.ugs.com>
<jaw56856@yahoo.com> wrote in message
news:1111764617.385242.33250@o13g2000cwo.googlegroups.com...
> Tad, I had not seen the Posting Guidelines, but have now. Here is the
> script that is trying to parse the log file. if i were to just run the
> string matching section it work, but when i try and the logic to pick
> up where i left off, it never matches.
>
(script snipped)
You really need to follow the guidelines that Tad suggested.
You need to make it easy for someone to help you. If I
had asked this question I would have provided a script
that can be run by anyone. (See end of post for example)
Now that, that is done, what is the problem that you are trying to solve?
use strict;
use warnings;
use diagnostics;
my @logfile = qw(
25 Feb 2005 09:17:35
25 Feb 2005 09:17:36
25 Feb 2005 09:17:37
25 Feb 2005 09:17:38
25 Feb 2005 09:17:39
25 Feb 2005 09:17:40
25 Feb 2005 09:17:41
25 Feb 2005 09:17:42
25 Feb 2005 09:17:43
25 Feb 2005 09:17:44
25 Feb 2005 09:17:45
25 Feb 2005 09:17:46
25 Feb 2005 09:17:47
25 Feb 2005 09:17:48
25 Feb 2005 09:17:49
25 Feb 2005 09:17:50
25 Feb 2005 09:17:51
25 Feb 2005 09:17:52
25 Feb 2005 09:17:53
25 Feb 2005 09:18:36
24 Feb 2006 13:27:45
24 Feb 2006 16:15:58
24 Feb 2006 16:15:58
24 Feb 2006 16:15:56
24 Feb 2006 16:15:56
24 Feb 2005 13:09:36
);
#open (TEST, "TradingManager_ckt49_h.log") || die "no data to check:$!\n";
#open (LOGFILE, "logfile.txt") || die " no log file:$!\n";
#open (ERRORFILE, ">>errorfile.txt") || die " no error file:$!\n";
my $last_runtime = $logfile[$#logfile];
print $last_runtime;
my $max_runtime;
my $x = 1;
while (<DATA>) {
if ($x) {
my $comp_string = substr( $_, 0, 20 );
if ( ( $last_runtime eq $comp_string ) ) { $x = 0;
print("whooooo\n") }
print( $comp_string, "\n" );
}
else {
#print (" found the starting point\n");
if (/ERROR.*Msg: 249/) {
print $_;
#print ("we are here");
#print errorfile $_;
}
}
$max_runtime = substr( $_, 0, 20 );
}
print $max_runtime
#open (logfile, ">>logfile.txt") || die " no log file";
#print logfile $max_runtime, "\n";
#close (test);
#close (logfile);
#close (errorfile);
__DATA__
24 Feb 2005 13:01:11 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:02:21 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:03:21 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:04:21 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:05:28 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:06:36 WARNING - <executing script ***
24 Feb 2005 13:07:36 WARNING - <executing script ***
24 Feb 2005 13:09:36 WARNING - <executing script ***
24 Feb 2005 13:10:36 WARNING - <executing script ***
24 Feb 2005 13:11:36 WARNING - <executing script ***
24 Feb 2005 13:12:54 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:13:55 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:14:12 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:15:12 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2005 13:16:45 ERROR - <gmem_table_sort.c, line #8088>:
TABLE_PivotInternal(): ***
24 Feb 2006 16:15:58 ERROR - <prc_gui.c, line #2503>: ***
25 Feb 2006 09:17:36 ERROR - <db_api_ct.c, line #2120>: ***
21 Feb 2005 13:56:59 ERROR - <db_api_ct.c, line #241>: *** Msg: 249,
***
21 Feb 2005 13:56:59 ERROR - <db_api_ct.c, line #241>: *** Msg: 248,
***
24 Feb 2006 13:27:45 ERROR - <gmem_table_sort.c, line #8110>:
TABLE_PivotInternal(): ***
21 Feb 2005 13:56:59 ERROR - <db_api_ct.c, line #241>: *** Msg: 249,
***
24 Feb 2006 13:27:46 ERROR - <gmem_table.c, line #7770>: ***
24 Feb 2006 16:15:56 ERROR - <prc_pv.c, line #1309>: ***
------------------------------
Date: Fri, 25 Mar 2005 16:29:45 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: simple help
Message-Id: <slrnd4946p.dhl.tadmc@magna.augustmail.com>
lynn <lynn.watts@ugs.com> wrote:
><jaw56856@yahoo.com> wrote in message
> news:1111764617.385242.33250@o13g2000cwo.googlegroups.com...
> You really need to follow the guidelines that Tad suggested.
> You need to make it easy for someone to help you. If I
> had asked this question I would have provided a script
> that can be run by anyone. (See end of post for example)
But the problem would have gone away during the exercise
of constructing the small program, and the solution would
have become evident *before* asking hundreds of other people
to help with it.
(this is precisely the purpose of including that suggestion
in the guidelines.
)
> Now that, that is done, what is the problem that you are trying to solve?
> my @logfile = qw(
> 25 Feb 2005 09:17:35
After the OP changed it up to load directly rather than from
a file, the problem would have gone away, and it could be
seen where the problem originated.
The OP's problem was a missing chomp().
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
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 7918
***************************************