# Im not sure if this pipe will open; # I'm not on a linux machine right now # so I'll just trust that this works. open (MAN, "/usr/bin/man ssh |"); while () { s/^\s+//g; push(@ml,$_); } # what is this loop supposed to do? # line isnt used anywhere else in the loop and # you aren't modifying @ml at all... foreach $line (@ml) { $line =~s/\n$//; $line =~s/^\n//; $line =~s/^\s+//; } for ($x=0; $x<=45; $x++) { if ($ml[$x]=~/NAME/) { while($ml[$x] !~/SYNOPSIS/) { # forgotten semicolon $nl .= $ml[$x] } } }