[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl-Forum] [MacPerl] All Perl Solution



Greenblatt & Seay wrote:
> 
> Kent Tegels, a member of the Omaha Perl Mongers, gave me permission to
> forward this clever all Perl Y2K solution to the MacPerl list.
> 
> David Seay
> 
> ------------
> 
> I was recently asked to make sure all my Perl scripts were updated to Y2K.
> Really, I don't see what the problem is, I just run this script and it
> seems to fix everything.
> 
> # No shebang for windows, duh
> @plfiles=glob("*.pl");
> foreach $f (@plfiles) {
> 	open(inf,"<$f")||die($!);
> 	$o = "y2k.".$f;
> 	open(outf,">$o")||die($!);
> 	while(<inf>) {
> 		s/y/k/g;
> 		s/Y/K/g;

If you have to solve a lot of Y2K problems, this would be more efficient:

tr/yY/kK/;

> 		print outf;
> 	}
> 	close outf;
> 	close inf;
> }
> exit;
> 
> And all my Y to K problems were solved!
> 
> Moral of the code:
> You know you're a geek when you write jokes in Perl.

No, you know you're a geek when you correct them.  ;)


Ronald

==== Want to unsubscribe from this list?
==== Send mail with body "unsubscribe" to macperl-forum-request@macperl.org