[13092] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 502 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 13 12:17:12 1999

Date: Fri, 13 Aug 1999 09:10:15 -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, 13 Aug 1999     Volume: 9 Number: 502

Today's topics:
        tail equiv. using Perl on Win32 ? <rwatkins@springer-ny.com>
    Re: tail equiv. using Perl on Win32 ? <jpeterson@office.colt.net>
    Re: Tom Christiansen "Perl Cookbook" (I R A Darth Aggie)
    Re: Tom Christiansen "Perl Cookbook" ("Bill Jones")
    Re: tree structure (Greg Bacon)
        Trouble getting system to return a value <andyh@pavilion.co.uk>
    Re: Why use Perl when we've got Python?! <jpeterson@office.colt.net>
    Re: Why use Perl when we've got Python?! <I.Clarke@strs.co.uk>
    Re: Why use Perl when we've got Python?! (Sean McAfee)
    Re: Why use Perl when we've got Python?! <tchrist@mox.perl.com>
        Win32::Process <kangas@anlon.com>
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Fri, 13 Aug 1999 11:38:26 -0400
From: Robert Watkins <rwatkins@springer-ny.com>
Subject: tail equiv. using Perl on Win32 ?
Message-Id: <37B43BF2.5A02A993@springer-ny.com>

I need to read the second to last line of a log file (can easily get as
big as 50 Mb), but unfortunately it's on an NT box, not UNIX. On UNIX I
would use tail -2 <logfile> | awk 'NR == 1' and go happily on my way to
use a Perl script to examine the data.

If I simply open the file in Perl and run through each line until I get
to the end, it takes about 30 times as long as the tail/awk combination.
Can Perl do the equivalent of tail any faster than this?

Robert Watkins
Supervising Web Developer
Springer-Verlag NY, Inc.
rwatkins@springer-ny.com

PS -- For those who may be curious: IIS sometimes screws up its log
files by getting stuck on a particular date and time, continuing to log
as if every entry is at this same date and time, thus never rotating the
log and mangling any statistical analysis. The last line of the log file
being written to by IIS contains junk, so I need to examine the second
to last line every so often to see if the date recorded is in fact the
current date.


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

Date: Fri, 13 Aug 1999 16:04:32 GMT
From: Jon Peterson <jpeterson@office.colt.net>
Subject: Re: tail equiv. using Perl on Win32 ?
Message-Id: <kmXs3.87$u07.761@news.colt.net>

Robert Watkins <rwatkins@springer-ny.com> wrote:
> If I simply open the file in Perl and run through each line until I get
> to the end, it takes about 30 times as long as the tail/awk combination.
> Can Perl do the equivalent of tail any faster than this?

Perl's seek function will let you jump to a point in the file. Sadly, it will
only take you to a specified number of bytes into the file, rather than lines.

Still, if you can assume a reasonable maximum line length in the log file, you
can position the file pointer at, say, approximately 20 lines from the end of
the file (to be on the safe side). Then you need only read in twenty lines 
worth of data to determine the penultimate line.

This sounds rather ugly, but I can't think of a better way off hand.



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

Date: 13 Aug 1999 13:55:13 GMT
From: fl_aggie@thepentagon.com (I R A Darth Aggie)
Subject: Re: Tom Christiansen "Perl Cookbook"
Message-Id: <slrn7r8923.20l.fl_aggie@thepentagon.com>

On Thu, 12 Aug 1999 21:22:12 -0400, -Sneex- <bill@fccj.org>, in
<120819992122022396bill@fccj.org> wrote:

+ 1)  Configured wrong by the mail admin and allows relaying, or

1a) buy a copy of the Bat book and figure out how one can act as a relay
    and be configured correctly without letting the entire world relay

James - or read the included sendmail docs...

-- 
Consulting Minister for Consultants, DNRC
The Bill of Rights is paid in Responsibilities - Jean McGuire
To cure your perl CGI problems, please look at:
<url:http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html>


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

Date: Fri, 13 Aug 1999 09:56:00 -0400
From: bill@fccj.org ("Bill Jones")
Subject: Re: Tom Christiansen "Perl Cookbook"
Message-Id: <199908131351.JAA13521@astro.fccj.cc.fl.us>

On Date: 13 Aug 1999 12:10:09 GMT
M.Ray@ulcc.ac.uk (Malcolm Ray) wrote:

>>> >> pages 650-3 in "Perl Cookbook" has a recipe
>>> >> for using the Mail::Mailer module to send email
>>> >> through another machine's mail server.
>>> >
>>> >Hmmm, I don't see that.  Which page is this statement on?
>>>
>>> page 652
>>> "
>>> Here's how to use SMTP with the machine mail.myisp.com as the mail
>>> server:
>>>
>>>   $mailer = Mail::Mailer->new( "smtp", "mail.myisp.com");
>>
>>
>>How do YOU get "through another machine's mail server" from that???
>
> Well, uh, if, for example, the above line were run on, say,
> www.myisp.com, and www.myisp.com is, like, a different machine
> from mail.myisp.com, then, you know, it would be using another machine's
> mail server, wouldn't it?


Thanks :]  You have verified my original assertion.
The original poster wants to use someone else's mail server.

YILSFW,
-Sneex-  :]
____________
IAMOTIHAC: I'm a member of the I hate Acronyms Club!



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

Date: 13 Aug 1999 14:57:35 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: tree structure
Message-Id: <7p1bov$o13$1@info2.uah.edu>

In article <934535498.6244.0.nnrp-13.c29fdfa7@news.demon.co.uk>,
	"Michael Masouras" <m.masouras@on-board-info.com> writes:
: I have a table that represents a tree structure. The table is dynamic and
: there is no limit on the levels it can have.
: 
: It looks like this:
: 
: 1    2
: 2    9
: 9    4
: 
: If I have this in an array, how can I get all the relevant parents of a
: child?  : (e.g. I have $x = 4, how can I get 1, 2,9, 4)?

#! /usr/bin/perl -w

use strict;

use Data::Dumper;
$Data::Dumper::Indent = 1;

sub newnode {
    my($data) = @_;

    { DATA => $data, CHILDREN => [] };
}

sub search {
    my($root,$what) = @_;

    return unless $root;

    if ($root->{DATA} == $what) {
        return $root;
    }
    else {
        return unless @{ $root->{CHILDREN} };

        foreach my $child (@{ $root->{CHILDREN} }) {
            my $result = search($child, $what);

            return $result if $result;
        }
    }
}

sub insert {
    my($tree,$parent,$elt) = @_;

    if (defined $parent) {
        my $node = search $tree, $parent;

        die "Parent `$parent' not in tree\n" unless $node;

        push @{ $node->{CHILDREN} }, newnode $elt;
    }
    else {
        %$tree = %{ newnode $elt };
    }
}

sub path {
    my($root,$what) = @_;

    return unless $root;

    if ($root->{DATA} == $what) {
        return $root->{DATA};
    }
    else {
        return unless @{ $root->{CHILDREN} };

        my @a = $root->{DATA};
        foreach my $child (@{ $root->{CHILDREN} }) {
            my @result = path($child, $what);

            if (@result) {
                push @a, @result;
                return @a;
            }
        }

        return;
    }
}

my $tree = {};

while (<DATA>) {
    my($parent,$child) = split ' ';

    if (defined $tree->{DATA}) {
        insert $tree, $parent, $child;
    }
    else {
        insert $tree, undef,   $parent;
        insert $tree, $parent, $child;
    }
}

print Dumper $tree;

my @path = path $tree, 4;
print Dumper \@path;

__DATA__
1    2
2    9
9    4
2    5


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

Date: Fri, 13 Aug 1999 16:34:56 +0100
From: "Andy Holyer" <andyh@pavilion.co.uk>
Subject: Trouble getting system to return a value
Message-Id: <7p1e13$2kkq$1@grind.server.pavilion.net>

This is almost certainly a RTFM, but I can't see what I'm doing wrong.

Sorry in advance if this is obvious.

I've written a wrapper which will allow my perl program (called digest.pl)
to be run by sending an email. I've got an entry in /etc/aliases like this:

maildigest: "|/usr/local/digest/maildigest"

The script maildigest extracts the sender's email address and checks that a
supplied password matches (to stop outsiders from messing with the script.

Then after a bit of fiddling around it does:

system "$perl_prog $digest_script $init_file" == 0
    or die "Can't run the digest program: $!\n";

I've set $perl_prog etc. earlier in the script. I had to invoke the script
fully because nobody (the user ID the  mail daemon uses) has
/usr/sbin/nologin as its shell.

If $digest_script dies, then I should get an error, right? Well, I don't,
contrary to what Programming Perl would seem to imply. What happens is that
the maildigest script carries on as if nothing has happened, but digest is
never run.

If I do

$output = `$perl_prog $digest_script $init_file 2>&1`;

Then it all goes fine, but that's a terrible waste, since I don't do
anything with the output - it's the side-effect I'm interested in.

There must be something totally obvious I'm doing wrong. Any hints? I've
already looked at access permissions etc.

Thanks in Advance

-Andy Holyer



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

Date: Fri, 13 Aug 1999 14:17:24 GMT
From: Jon Peterson <jpeterson@office.colt.net>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <UNVs3.84$u07.785@news.colt.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

> else decided would be good for them.  Being told in a patronizing tone
> that "Father knows best" evokes feelings of resentment and rebellion
> that are entirely understandable.  Eventually, you have to advance

Indeed, c.l.p.m has a number of fathers quite capable of patronizing 
intonation, and they do seem to evoke a fair amount of resentment and 
rebellion from time to time :-)



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

Date: Fri, 13 Aug 1999 15:25:14 +0100
From: Ian Clarke <I.Clarke@strs.co.uk>
To: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37B42AC9.FB00BCA9@strs.co.uk>

> [courtesy cc of this posting mailed to cited author]

It is a shame that your news software's courtesy does not extend to the
rest of your email.

> :Do you view conformity to an interface, or a coding style, or a protocol
> :to be "service adherence"?
> That would be "servile", and that's not what I'm talking about.

Oops, a typo - hardly a crushing defeat of my argument...

> :In some way, good programming is all about conformity.
> Now that's a line of bull I haven't heard before.

Please place supporting argument here: ___________________________

> :Part of the Object Orientated paradigm is about
> I really don't care about OO, thank you very much.

Why not?

> :Perl advocates seem to delight in the huge number of ways any task can
> :be performed (judging from comments in this thread alone),
> No, we delight in personal creativity.  I'm sorry that you don't.

Again you resort to petty insults.  Perhaps you should read people's
comments with a view to actually providing a response, rather than a
string of childish insults, and unfounded assumptions about my personal
creativity.

> Please do not use Perl.  It is wrong for you.  You aren't up to making
> choices and possibilities, to accepting the responsibility that comes
> with creativiety.  Please return to whatever bondage and discipline
> church whence you originally came.  Leave us in peace.

I am sorry that you find it so difficult to have a reasoned discussion
without resorting to childishness.  You have not answered a single point
I put to you in my last post except with direct contradictions that you
haven't even tried to support.  

Fortunately, others in the newsgroup are more mature and I will continue
to discuss the subject with them.

Ian.


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

Date: Fri, 13 Aug 1999 15:35:47 GMT
From: mcafee@waits.facilities.med.umich.edu (Sean McAfee)
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <nXWs3.1601$J72.278473@news.itd.umich.edu>

In article <37b40eec.11806226@news.iag.net>, Matt <mck@iag.net> wrote:
>On Thu, 12 Aug 1999 17:52:25 GMT,
>mcafee@waits.facilities.med.umich.edu (Sean McAfee) wrote:
>>To help me learn Python, I decided to rewrite some of my Perl scripts
>>in Python.  The first script I chose for conversion was called "getfile";
>>it grabs a file via FTP and prints it on stdout.

>Did you finish the conversion? If so, it would be interesting to see
>the code to compare, for us who know no Python.

Nope.  I decided I ought to read the FTP RFC first, so I grabbed it, but
then never got around to reading it.

-- 
Sean McAfee                                                mcafee@umich.edu
print eval eval eval eval eval eval eval eval eval eval eval eval eval eval
q!q@q#q$q%q^q&q*q-q=q+q|q~q:q? Just Another Perl Hacker ?:~|+=-*&^%$#@!


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

Date: 13 Aug 1999 10:02:04 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Why use Perl when we've got Python?!
Message-Id: <37b4417c@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    Ian Clarke <I.Clarke@strs.co.uk> writes:
:You have not answered a single point I put to you in my last post except
:with direct contradictions that you haven't even tried to support.

Some of your statements were altogether too ludicrous to contemplate an
earnest response.  You have all the trappings of the troll.  I don't know
whether you quite realize this, although you certainly alluded to that
understanding.  If so, then a pox upon you.  If not, then please leave us
in peace.  This is the wrong medium for the knowledge you ostensibly seek.
I have already spent more than six precious hours of my ever-shortening
span upon you, completely gratis.  More you shall not have.  If you expect
to learn whereof we speak, you must first walk a league in our shoes.
Get thee hence.  When you return from your journey, perhaps we might
speak again.  But I doubt whether you will make that honest effort.
Your actions will speak for you.

--tom
-- 
Weinberg's Second Law: If builders built buildings the way programmers
write programs, the first woodpecker to come along would destroy civilization.


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

Date: Fri, 13 Aug 1999 10:54:27 -0500
From: Mike <kangas@anlon.com>
Subject: Win32::Process
Message-Id: <37B43FB3.475368DE@anlon.com>

how do i get a parent process to grab variable values from a child
process or have the child give the variable values to the parent.

thanks ahead of time.

--
Michael Kangas
kangas@anlon.com




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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq" from
almanac@ruby.oce.orst.edu. The real FAQ, as it appeared last in the
newsgroup, can be retrieved with the request "send perl-users FAQ" from
almanac@ruby.oce.orst.edu. Due to their sizes, neither the Meta-FAQ nor
the FAQ are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq" from
almanac@ruby.oce.orst.edu. 

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 V9 Issue 502
*************************************


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