 #!/usr/bin/perl -w use warnings; use strict; my $string = ; while($string ne HELLO WORLD) { $string = ; for(0..length(HELLO WORLD)) { $string .= chr(rand(26) + 32); } } print $string, \n; It'll get there eventually.