But I didn't....
Talked to B on the phone for a bit, and then got on the computer to bang my head against some windows cmd, and perl code.....
I thought I had it too, but it's been a few years since I played with perl and the perl side of the scripts are not doing what I want...
Anyone want to take a stab at this???
What I'm getting is a temp file where I need to find the following line:
and what I want to have happen is that I get a stringthat would be:
Should be simple right??? Thats the last piece to go, but I was banging my head on getting the rest of the dang scripts to work together until 7am this morning, and the a tried to catch some shut-eye before comming to work....
Here's what I tried:
Am I missing something for the whitespace in frount of "name:"?
Talked to B on the phone for a bit, and then got on the computer to bang my head against some windows cmd, and perl code.....
I thought I had it too, but it's been a few years since I played with perl and the perl side of the scripts are not doing what I want...
Anyone want to take a stab at this???
What I'm getting is a temp file where I need to find the following line:
name: Last, First M
and what I want to have happen is that I get a stringthat would be:
$fullname="First M Last"
Should be simple right??? Thats the last piece to go, but I was banging my head on getting the rest of the dang scripts to work together until 7am this morning, and the a tried to catch some shut-eye before comming to work....
Here's what I tried:
open (USERINFO, "\\\\$userserver\\$userdirectory\\$username\\Settings\\Personal\\user-info.txt") || die "Open: $!"; #define variable fullname in case it is not found in the file. #$fullname=""; while (defined ($temp =)) { chomp($temp); if ($temp =~ /^ name:\b/) { #Continue searching until a line starting with " name:" is found $temp =~ s/ name:\s+//; $firstname=substr($temp,rindex $temp,", "); #$firstname includes MI $tempname=substr($temp,0,rindex $temp,", "); $lastname=substr($tempname,0,-2); $fullname=$firstname." ".$lastname; } }
Am I missing something for the whitespace in frount of "name:"?
ah...see...Perl is supposed to make life easier...
Date: 2004-08-06 04:01 am (UTC)undef $fullname;
#
while(!defined($fullname) && ($_ = )) #if we've already got a match or EOF, quit; else puts next line in $_
{
if (/^.*name: (\w+), (\w+) (\w).*$/) # do we see a name sequence?
{
$fullname = "$2 $3 $1"; # put things in their proper order
}
}
print "$fullname\n"; # just for grins
sample run:
$ perl lens.pl
junk
blah blah name: Thomas, Peter L
Peter L Thomas
$
crud...
Date: 2004-08-06 04:03 am (UTC)while(!defined($fullname) && ($_ = <STDIN>))
Re: crud...
Date: 2004-08-06 04:18 am (UTC)There's a dozen ways to do everything and some of it just makes my head hurt...
Re: crud...
Date: 2004-08-06 09:13 pm (UTC)I thought this particular example of PERL use wasn't too painful...just took me a while to iterate to it.
Re: Another way to do it
Date: 2004-08-06 09:15 pm (UTC)--Pete