Hi Charles,

Hey thanks for your and everyones help on such an offtopic subject.  I have all of the
O'Reilly Perl books, but I something I never picked up on was the assignment of values
to the $1....7.  I am still sure how this works, but had I understood it before it
would have made things allot esaier (and quicker perl code).

One quick question:  So anything that a pattern matches in a () is assigned to a
$1...$9, is this a correct statement?  Since this post has now left the orginal
textus, could you drop me a quick yes or no off the mail-list, if you have a spare
moment.

Thanks agin :-)

Charles Galpin wrote:

> Hi Robert
>
> Boy you have really made this hard on yourself (and us) :)
>
> Why didn't you post this line
>
> 02/18 15:54:26 ##### data dev=ttyC12, pid=13032,
> caller='none',conn='31200/LAPM/V42BIS', name='', cmd='/usr/sbin/pppd',
> user='/AutoPPP/'
>
> and say that you know the pid and the dev, and need to get the other
> fields when you match this line?
>
> My answer would (without all this fanfare) have been
>
> sub w1_connect_info {
>     # This routine extract available info passed in the getty logs.
>     # Here is a sample of the line we are looking for:
>     # 02/18 15:54:26 ##### data dev=ttyC12, pid=13032, caller='none',
> conn='31200/LAPM/V42BIS', name='', cmd='/usr/sbin/pppd', user='/AutoPPP/'
>     my ($getty_id,$ttydev) = @_;
>     my ($line,$item);
>     my (@getty_line);
>
>     open (GETTYFILE, "</var/log/getty.log.$ttydev") || die "Can't open
> log.$ttydev: $!";
>     while (<GETTYFILE>) {
>         if ( /##### data dev=$ttydev, pid=$getty_id, caller='(.*?)',
> conn='(.*?)\/(.*?)\/(.*?)', name='(.*?)', cmd='(.*?)', user='(.*?)'/) {
>              print "getty data: $2/$3/$4\n";
>              print "other stuff you don't seem to care about: caller=$1
> name=$5  cmd=$6 user=$7\n";
>              last;
>          }
>     }
>
>     close GETTYFILE;
>
> } # sub w1_connect_info
>
> make sure you put a space before conn when you unwrap these lines.
>
> since the format is so well defined, you don't need to get fancy here
> charles

--
robert canary
system services
OhioCounty.Net
[EMAIL PROTECTED]
(270)298-9331 Office
(270)298-7449 Fax



-- 
To unsubscribe: mail [EMAIL PROTECTED] with "unsubscribe"
as the Subject.

Reply via email to