You're welcome, you did a good job of turning my pseudo-code into working code!
One suggestion: don't create variables outside a loop if they're only used within the loop. So your @array1 can be instantiated inside your first loop, like this:
my @array1 = split (" ", $_);
Same thing with @array2, $str, and $string. The way you're doing it will work, but it may introduce bugs in more complicated code, because those variables will continue to exist after those loops are finished, and could conflict with other uses elsewhere. It's best to keep variables inside as small a context as possible, so only create them outside a loop if you need them to continue to exist after the loop is finished.
Aaron B.
Available for small or large Perl jobs and *nix system administration; see my home node.
|