[31660] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 2923 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 27 00:09:44 2010

Date: Mon, 26 Apr 2010 21:09: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           Mon, 26 Apr 2010     Volume: 11 Number: 2923

Today's topics:
    Re: alternative for ctime <ben@morrow.me.uk>
    Re: alternative for ctime <usenet-nospam@seebs.net>
    Re: alternative for ctime <ben@morrow.me.uk>
    Re: alternative for ctime <usenet-nospam@seebs.net>
    Re: alternative for ctime (Randal L. Schwartz)
    Re: alternative for ctime <john@castleamber.com>
    Re: alternative for ctime <rengaprasath@gmail.com>
    Re: alternative for ctime <john@castleamber.com>
        checksum calculation for file offsets <gourabbaksi@gmail.com>
    Re: checksum calculation for file offsets <jurgenex@hotmail.com>
    Re: checksum calculation for file offsets <tadmc@seesig.invalid>
    Re: FAQ 4.34 How do I extract selected columns from a s <brian.d.foy@gmail.com>
    Re: FAQ 7.26 How can I find out my current or calling p <brian.d.foy@gmail.com>
    Re: FAQ 7.26 How can I find out my current or calling p <ben@morrow.me.uk>
    Re: Get XML content using XML::Twig <klaus03@gmail.com>
    Re: Get XML content using XML::Twig sln@netherlands.com
    Re: Get XML content using XML::Twig <john@castleamber.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 26 Apr 2010 21:42:49 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: alternative for ctime
Message-Id: <9faha7-clj1.ln1@osiris.mauzo.dyndns.org>


Quoth jwkrahn@shaw.ca:
> GRP wrote:
> > 
> > I would like to write a script to grep some pattern in few set of log
> > files and alert it...
> > 
> > In order to avoid duplicate alert i plan to store the "FILENAME:ERR-
> > LINE-NUMBER:FILE-CREATION-TIME"  in a flat file (colon delimiter) , so
> > that next time if the same pattern found in same line it will check
> > against the flat file and won't alert. At the same time if it happens
> > in different line number it wud check in flat file & the 2nd filed
> > would be different so it will alert.
> > 
> > Since i can't find a way to get ctime in unix (i tried with perl as
> > well), would be there any other way to achieve this or better logic?
> 
> You can get the ctime, that is easy, but you can't get the 
> "FILE-CREATION-TIME" because unix doesn't store that anywhere.

Some Unices do (all the BSDs, for instance), but Perl doesn't provide an
interface to it (except from XS, obviously). I've been wondering about
extending File::stat to support this...

Ben



------------------------------

Date: 26 Apr 2010 21:16:28 GMT
From: Seebs <usenet-nospam@seebs.net>
Subject: Re: alternative for ctime
Message-Id: <slrnhtc0lc.ran.usenet-nospam@guild.seebs.net>

On 2010-04-26, Ben Morrow <ben@morrow.me.uk> wrote:
> Some Unices do (all the BSDs, for instance),

??

I don't see anything in stat(2), where should I be looking?

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!


------------------------------

Date: Mon, 26 Apr 2010 22:29:34 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: alternative for ctime
Message-Id: <u6dha7-suj1.ln1@osiris.mauzo.dyndns.org>


Quoth Seebs <usenet-nospam@seebs.net>:
> On 2010-04-26, Ben Morrow <ben@morrow.me.uk> wrote:
> > Some Unices do (all the BSDs, for instance),
> 
> I don't see anything in stat(2), where should I be looking?

In my stat(2) (FreeBSD 7.3-RELEASE) I have

|      st_birthtime  Time when the inode was created.

It's possible this is just a FreeBSD thing, but I thought it was a
4.4-ism.

Ben



------------------------------

Date: 26 Apr 2010 22:42:59 GMT
From: Seebs <usenet-nospam@seebs.net>
Subject: Re: alternative for ctime
Message-Id: <slrnhtc5nj.rr4.usenet-nospam@guild.seebs.net>

On 2010-04-26, Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth Seebs <usenet-nospam@seebs.net>:
>> On 2010-04-26, Ben Morrow <ben@morrow.me.uk> wrote:
>> > Some Unices do (all the BSDs, for instance),

>> I don't see anything in stat(2), where should I be looking?

> In my stat(2) (FreeBSD 7.3-RELEASE) I have

>|      st_birthtime  Time when the inode was created.

> It's possible this is just a FreeBSD thing, but I thought it was a
> 4.4-ism.

Don't see it in NetBSD, so it's not an original 4.4ism.  Could be that
newer *BSD have it, but it's not in 4.4.  Wish the man page would give
history for that kind of thing.

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam@seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!


------------------------------

Date: Mon, 26 Apr 2010 18:50:43 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: alternative for ctime
Message-Id: <86zl0phde4.fsf@red.stonehenge.com>

>>>>> "Ben" == Ben Morrow <ben@morrow.me.uk> writes:

Ben> In my stat(2) (FreeBSD 7.3-RELEASE) I have

Ben> |      st_birthtime  Time when the inode was created.

Ben> It's possible this is just a FreeBSD thing, but I thought it was a
Ben> 4.4-ism.

Definitely not in the One True Unix, therefore, not portable.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


------------------------------

Date: Mon, 26 Apr 2010 21:17:15 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: alternative for ctime
Message-Id: <871ve13ahg.fsf@castleamber.com>

GRP <rengaprasath@gmail.com> writes:

> hi,
>
> I would like to write a script to grep some pattern in few set of log
> files and alert it...
>
> In order to avoid duplicate alert i plan to store the "FILENAME:ERR-
> LINE-NUMBER:FILE-CREATION-TIME"  in a flat file (colon delimiter) , so
> that next time if the same pattern found in same line it will check
> against the flat file and won't alert. At the same time if it happens
> in different line number it wud check in flat file & the 2nd filed
> would be different so it will alert.

It might help if you describe when a clash can occur, i.e. why do you
need the inode creation time, and why is filename:err-line-no not unique
(I can think of reasons, but want to know the ones in your situation.)

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


------------------------------

Date: Mon, 26 Apr 2010 19:53:40 -0700 (PDT)
From: GRP <rengaprasath@gmail.com>
Subject: Re: alternative for ctime
Message-Id: <2384b3fa-61c9-4070-8f5f-48ddf73105ef@y38g2000prb.googlegroups.com>

On Apr 27, 10:17=A0am, John Bokma <j...@castleamber.com> wrote:
> GRP <rengapras...@gmail.com> writes:
> > hi,
>
> > I would like to write a script to grep some pattern in few set of log
> > files and alert it...
>
> > In order to avoid duplicate alert i plan to store the "FILENAME:ERR-
> > LINE-NUMBER:FILE-CREATION-TIME" =A0in a flat file (colon delimiter) , s=
o
> > that next time if the same pattern found in same line it will check
> > against the flat file and won't alert. At the same time if it happens
> > in different line number it wud check in flat file & the 2nd filed
> > would be different so it will alert.
>
> It might help if you describe when a clash can occur, i.e. why do you
> need the inode creation time, and why is filename:err-line-no not unique
> (I can think of reasons, but want to know the ones in your situation.)
>
> --
> John Bokma =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 j3b
>
> Hacking & Hiking in Mexico - =A0http://johnbokma.com/http://castleamber.c=
om/- Perl & Python Development

Hi John,

For example lets say i run my script at 10am where i found the error
pattern in the line number 100, i will store in a flat file in this
format "FILENAME:LINE-NUMBER" and the script will alert a msg to
tivoli. In the next run at 10.30am, assume there is no error found
other than line number 100, my script should not alert it since it's
already alerted. In order to achieve this along with "FILENAME:LINE-
NUMBER" i need to store some other value which is constant (ex. file
creation time , not change time), so that i can compare against it and
if found different i assume error happened in different line.

Since there is no way to capture file-creation-time i;m looking for
some other way to achieve this or probably you can suggest better
logic to achieve this...

thanks



------------------------------

Date: Mon, 26 Apr 2010 22:40:51 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: alternative for ctime
Message-Id: <87fx2ho94s.fsf@castleamber.com>

GRP <rengaprasath@gmail.com> writes:

> On Apr 27, 10:17 am, John Bokma <j...@castleamber.com> wrote:
>> GRP <rengapras...@gmail.com> writes:
>> > hi,
>>
>> > I would like to write a script to grep some pattern in few set of log
>> > files and alert it...
>>
>> > In order to avoid duplicate alert i plan to store the "FILENAME:ERR-
>> > LINE-NUMBER:FILE-CREATION-TIME"  in a flat file (colon delimiter) , so
>> > that next time if the same pattern found in same line it will check
>> > against the flat file and won't alert. At the same time if it happens
>> > in different line number it wud check in flat file & the 2nd filed
>> > would be different so it will alert.
>>
>> It might help if you describe when a clash can occur, i.e. why do you
>> need the inode creation time, and why is filename:err-line-no not unique
>> (I can think of reasons, but want to know the ones in your situation.)

> For example lets say i run my script at 10am where i found the error
> pattern in the line number 100, i will store in a flat file in this
> format "FILENAME:LINE-NUMBER" and the script will alert a msg to
> tivoli. In the next run at 10.30am, assume there is no error found
> other than line number 100, my script should not alert it since it's
> already alerted.

Clear, but FILENAME:LINE-NUMBER is already sufficient to stop that from
happening, unless you forgot to mention something.

> In order to achieve this along with "FILENAME:LINE-
> NUMBER" i need to store some other value which is constant (ex. file
> creation time , not change time), so that i can compare against it and
> if found different i assume error happened in different line.

Do the lines in the file have a time stamp?

> Since there is no way to capture file-creation-time i;m looking for
> some other way to achieve this or probably you can suggest better
> logic to achieve this...

I am still missing important information. Give an example of a
possible clash.

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


------------------------------

Date: Mon, 26 Apr 2010 08:28:56 -0700 (PDT)
From: Ironhide <gourabbaksi@gmail.com>
Subject: checksum calculation for file offsets
Message-Id: <4b926ef0-b8ec-4014-832a-cf9a9529c8e3@z7g2000yqb.googlegroups.com>

Hi,

This is what I am trying to achieve.

Create a copy of a file.
User inputs starting offset and end offset for the file.
For this range the perl program should calculate the md5sum
for both the original file and the copied file and compare them
both.

Any idea how to go about dealing with the offsets?


------------------------------

Date: Mon, 26 Apr 2010 09:09:53 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: checksum calculation for file offsets
Message-Id: <jiebt5tjmr750ui2q9oj6sru3h544g1dbd@4ax.com>

Ironhide <gourabbaksi@gmail.com> wrote:
>Create a copy of a file.
>User inputs starting offset and end offset for the file.
>For this range the perl program should calculate the md5sum
>for both the original file and the copied file and compare them
>both.
>
>Any idea how to go about dealing with the offsets?

All the MD5 modules I have seen accept text as input. So just read those
parts from both files and then run the MD5 algorithm on the extracted
text.

jue


------------------------------

Date: Mon, 26 Apr 2010 11:26:02 -0500
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: checksum calculation for file offsets
Message-Id: <slrnhtbfcl.ims.tadmc@tadbox.sbcglobal.net>

Ironhide <gourabbaksi@gmail.com> wrote:

> User inputs starting offset and end offset for the file.
> For this range the perl program should calculate the md5sum

> Any idea how to go about dealing with the offsets?


    perldoc Tie::File


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.


------------------------------

Date: Mon, 26 Apr 2010 12:50:14 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.34 How do I extract selected columns from a string?
Message-Id: <260420101250146169%brian.d.foy@gmail.com>

In article <6p5at5dok54j88jjehstce5n6nhmv92d9q@4ax.com>, Jürgen Exner
<jurgenex@hotmail.com> wrote:

> PerlFAQ Server <brian@theperlreview.com> wrote:
> >    If you know where the columns that contain the data, [...]
> 
> This sentence a verb.

Fixed, thanks,


------------------------------

Date: Mon, 26 Apr 2010 12:47:35 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 7.26 How can I find out my current or calling package?
Message-Id: <260420101247356646%brian.d.foy@gmail.com>

In article <q3rea7-dt91.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
<ben@morrow.me.uk> wrote:

> Quoth brian d foy <brian.d.foy@gmail.com>:
> > In article <qma4a7-scj2.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
> > <ben@morrow.me.uk> wrote:
> > > 
> > > Should this answer mention ->DOES at this point? AIUI, most of the time
> > > it's a more appropriate test than ->isa, but I must admit I'm not
> > > entirely clear on the difference between the two.
> > 
> > Yes, that should be DOES now.
> > 
> > The difference between the two is that isa() checks for inheritance
> > while DOES() checks that the object performs a role despite
> > inheritance. Roles, traits, and mixins want to provide functionality
> > without inheritance.
> 
> Yes, but when do you care? If an object conforms to a given interface,
> what difference does it make (from outside the object) whether those
> methods are implemented through inheritance, delegation, mixins, or
> whatever?

Well, you care when you need to check for the ability to handle a role.
You can't do that with isa() because it's not an inheritance
relationship. isa() implies an implementation detail, while DOES() does
not.


------------------------------

Date: Mon, 26 Apr 2010 21:49:15 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: FAQ 7.26 How can I find out my current or calling package?
Message-Id: <braha7-clj1.ln1@osiris.mauzo.dyndns.org>


Quoth brian d foy <brian.d.foy@gmail.com>:
> In article <q3rea7-dt91.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
> <ben@morrow.me.uk> wrote:
> 
> > Quoth brian d foy <brian.d.foy@gmail.com>:
> > > In article <qma4a7-scj2.ln1@osiris.mauzo.dyndns.org>, Ben Morrow
> > > <ben@morrow.me.uk> wrote:
> > > > 
> > > > Should this answer mention ->DOES at this point? AIUI, most of the time
> > > > it's a more appropriate test than ->isa, but I must admit I'm not
> > > > entirely clear on the difference between the two.
> > > 
> > > Yes, that should be DOES now.
> > > 
> > > The difference between the two is that isa() checks for inheritance
> > > while DOES() checks that the object performs a role despite
> > > inheritance. Roles, traits, and mixins want to provide functionality
> > > without inheritance.
> > 
> > Yes, but when do you care? If an object conforms to a given interface,
> > what difference does it make (from outside the object) whether those
> > methods are implemented through inheritance, delegation, mixins, or
> > whatever?
> 
> Well, you care when you need to check for the ability to handle a role.
> You can't do that with isa() because it's not an inheritance
> relationship. isa() implies an implementation detail, while DOES() does
> not.

I'm not being clear, I think. What I want to know is

    Under what circumstances is it *correct* for $obj->DOES("Foo") to
    return true but *incorrect* for $obj->isa("Foo") to return true?

If ->isa is restricted to only checking @ISA for inheritance, then why
is it overridable? Does this mean that modules like Test::MockObject
which return true from ->isa for classes they don't 'inherit' from (via
@ISA) are acting incorrectly?

Ben



------------------------------

Date: Mon, 26 Apr 2010 13:13:24 -0700 (PDT)
From: Klaus <klaus03@gmail.com>
Subject: Re: Get XML content using XML::Twig
Message-Id: <4515beae-98ec-469e-b152-71fcfbf2b58f@r6g2000vbh.googlegroups.com>

On 22 avr, 10:29, Klaus <klau...@gmail.com> wrote:
> On 21 avr, 14:35, alwaysonnet <kalyanrajsi...@gmail.com> wrote:
> > Hello all,
> > I'm trying to parse the XML using XML::Twig Module as my XML could be
> > very large to handle using XML::Simple.
> Klaus <klau...@gmail.com> wrote:
> > However, let me bring in a shameless plug:
> > You could also use my module XML::Reader
> >http://search.cpan.org/~keichner/XML-Reader-0.32/lib/XML/Reader.pm
> s...@netherlands.com wrote:
> > > Indeed shameless.
>
> > > [...]
>
> > > It would be good though to have a capture mechanism, where
> > > xml capture can be triggered on/off by the user, later to
> > > be regurgitated to the user (on demand), and given to an
> > > xml::simple style mechanism to turn it into filtered records.
>
> use XML::Reader;
> my $rdr =3D XML::Reader->newhd(\*DATA, {filter =3D> 3,
> =A0 =A0 using =3D> '/Data/ConnectionList/Connection/FileItemList/FileItem=
/
> FileType'});

I have now released XML::Reader 0.34
http://search.cpan.org/~keichner/XML-Reader-0.34/lib/XML/Reader.pm

This new version allows to write the same program (...the program that
uses XML::Reader to capture sub-trees from a potentially very big XML
file into a buffer and pass that buffer to XML::Simple...) even
shorter:

use strict;
use warnings;
use XML::Reader 0.34;

use XML::Simple;
use Data::Dumper;

my $rdr =3D XML::Reader->newhd(\*DATA, {filter =3D> 5},
   { root =3D> '/Data/ConnectionList/Connection/FileItemList/FileItem/
FileType', branch =3D> '*' },
 );

while ($rdr->iterate) {
   my $buffer =3D $rdr->rval;
   my $ref =3D XMLin($buffer);
   print Dumper($ref), "\n\n";
}


------------------------------

Date: Mon, 26 Apr 2010 14:58:28 -0700
From: sln@netherlands.com
Subject: Re: Get XML content using XML::Twig
Message-Id: <oq2ct59bjel6t2iibtk3higf4oerskaqdb@4ax.com>

On Mon, 26 Apr 2010 13:13:24 -0700 (PDT), Klaus <klaus03@gmail.com> wrote:

>On 22 avr, 10:29, Klaus <klau...@gmail.com> wrote:
>> On 21 avr, 14:35, alwaysonnet <kalyanrajsi...@gmail.com> wrote:
>> > Hello all,
>> > I'm trying to parse the XML using XML::Twig Module as my XML could be
>> > very large to handle using XML::Simple.
>> Klaus <klau...@gmail.com> wrote:
>> > However, let me bring in a shameless plug:
>> > You could also use my module XML::Reader
>> >http://search.cpan.org/~keichner/XML-Reader-0.32/lib/XML/Reader.pm
>> s...@netherlands.com wrote:
>> > > Indeed shameless.
>>
>> > > [...]
>>
>> > > It would be good though to have a capture mechanism, where
>> > > xml capture can be triggered on/off by the user, later to
>> > > be regurgitated to the user (on demand), and given to an
>> > > xml::simple style mechanism to turn it into filtered records.
>>
>> use XML::Reader;
>> my $rdr = XML::Reader->newhd(\*DATA, {filter => 3,
>>     using => '/Data/ConnectionList/Connection/FileItemList/FileItem/
>> FileType'});
>
>I have now released XML::Reader 0.34
>http://search.cpan.org/~keichner/XML-Reader-0.34/lib/XML/Reader.pm
>
>This new version allows to write the same program (...the program that
>uses XML::Reader to capture sub-trees from a potentially very big XML
>file into a buffer and pass that buffer to XML::Simple...) even
>shorter:
>
>use strict;
>use warnings;
>use XML::Reader 0.34;
>
>use XML::Simple;
>use Data::Dumper;
>
>my $rdr = XML::Reader->newhd(\*DATA, {filter => 5},
>   { root => '/Data/ConnectionList/Connection/FileItemList/FileItem/
>FileType', branch => '*' },
> );
>
>while ($rdr->iterate) {
>   my $buffer = $rdr->rval;
>   my $ref = XMLin($buffer);
>   print Dumper($ref), "\n\n";
>}

Good job on this.

my $buffer = '';

while ($rdr->iterate) {
   $buffer .= $rdr->rval;
}

if (length $buffer) {
   my $ref = XMLin('<FileItem>'.$buffer.'</FileItem>');
   print Dumper($ref), "\n\n";
}

-sln


------------------------------

Date: Mon, 26 Apr 2010 19:01:43 -0500
From: John Bokma <john@castleamber.com>
Subject: Re: Get XML content using XML::Twig
Message-Id: <87ljc9n4pk.fsf@castleamber.com>

Klaus <klaus03@gmail.com> writes:

> my $rdr = XML::Reader->newhd(\*DATA, {filter => 5},

To me filter is very unclear. I understand that it are options to the
program, but just 5 is very confusing. Maybe split "filter" in several
options which combined result in 1,2,3,4,5 ?

why is the constructor called newhd?

anyway, thanks for mentioning this module, I will check it out when I
have more time.

-- 
John Bokma                                                               j3b

Hacking & Hiking in Mexico -  http://johnbokma.com/
http://castleamber.com/ - Perl & Python Development


------------------------------

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 2923
***************************************


home help back first fref pref prev next nref lref last post