Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 17 Jun 2000 02:35:05 -0400
From:      Joseph Jacobson <jacobson@pobox.com>
To:        current@freebsd.org
Cc:        peter@netplex.com.au, chris@calldei.com
Subject:   Re: GENERIC from today does not detect system console on my box
Message-ID:  <200006170635.CAA03347@home.my.domain>

index | next in thread | raw e-mail


>Chris Costello wrote:
>> On Friday, June 16, 2000, Peter Wemm wrote:
>> > Err.. how did you run it?  'perl < MYKERNEL'?  If you run 'perl MYKERNEL'
>> > it will generate nothing because I was kinda lame and didn't know how to do
>> > argument parsing. :-]
>> 
>>    Couldn't have hurt to ask.
>> 
>> while (defined($ARGV[0])) {
>>         # ... parse ...
>>         shift;
>> }
>> 
>>    It'd work as perl script.pl arg1 arg2 ...  or as ./script.pl
>> arg1 arg2 ... (if +x).
>
>How about that and as a stdin pipe as well if no args are specified?


while (<>) {
  # parse
  # ...
}

does this.  It is a simple construct, but magical and generally
does what you want.  You can even modify the @ARGV array in the middle of
the loop and have it work correctly.  Perl is filled with these programming
shortcuts, thus its beauty and strength.

Joe



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-current" in the body of the message



home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200006170635.CAA03347>