use strict; my $vrx; while(){ $vrx = $1 if /^10*(\d*)/; print $vrx . $1 . "\n" if /^20*(.*)/; } __DATA__ 1000100 2001foo 2002bar 300badline 2003hello 1000200 2001bish 2002bash #### map{$a=1-$_/10;map{$d=$a;$e=$b=$_/20-2;map{($d,$e)=(2*$d*$e+$a,$e**2 -$d**2+$b);$c=$d**2+$e**2>4?$d=8:_}1..50;print$c}0..59;print$/}0..20