SPUG: Should I not do while (<FOO> !~ /^mailboxes/) { } ?

Matt Tucker tuck at whistlingfish.net
Fri Feb 22 16:42:49 CST 2002

-- Chris Wilkes <cwilkes-spug at ladro.com> spake thusly:

>   I wanted to read in a mutt configuration file and only pull out one
> of the lines that starts with mailboxes so I did this:

Why not just do:

	#!/usr/bin/perl -w
	$file = ".muttrc";
	open (FOO, $file) || die "Can't open $file\n";
	while (<FOO>) {
        last if =~ /^mailboxes/;
        print "#$_\n";
	close FOO;
	print "$_\n";

This gives you the proper while condition (while reading the file) and
$_ behavior, with an additional exit condition.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://mail.pm.org/archives/spug-list/attachments/20020222/b01a5fd0/attachment.bin

More information about the spug-list mailing list