Re: awk or sed?
On Sat, Sep 25, 1999 at 02:13:15PM +1200, Tim Thomson wrote
> On Fri, 24 Sep 1999, Brad wrote:
>
> > On Sat, 25 Sep 1999, Tim Thomson wrote:
> >
> > > On Wed, 22 Sep 1999, Steve Lamb wrote:
> > >
> > > > while(<>){
> > > > if ($_ =~ /inet addr:(\n+)\.(\n+)\.(\n+)\.(\n+)/){
> > > > $ipaddr = "$1.$2.$3.$4";
> > > > }
> > > > $return = `nslookup $1.$2.$3.$4`;
> > > > print($return);
> > > > }
> > >
> > > Thanks for all replies. It was actually cut I was thinking of initially.
> > > I couldn't get this one to go, nothing was going into $1,$2, or $ipaddr.
> >
> > Simple typo. Use \d (digit) instead of \n (linebreak).
>
> I was thinking it was just something like that. I've been meaning to learn
> perl for awhile. Any good starting points, apart from going through
> source code? Thanks for the link to that awk link, looks good.
>
If you can follow the above code, you could do worse
than read manpages perlre, perlop & perlfunc.
My favourite perl fragment:
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'
Not very efficient, but *concise*.
John P.
--
huiac@camtech.net.au
john@huiac.apana.org.au
"Oh - I - you know - my job is to fear everything." - Bill Gates in Denmark
Reply to: