People's tolerance for this sort of thing varies, but it looks very obfuscated to me. Some general advice:
- Never set $/ without local-izing it inside of a block. It's very dangerous.
- Get some whitespace in there! Even feeding your existing code to perltidy improves the readability because it adds whitespace.
- Take it easy on $_ and @_ and $x. In most cases, a meaningful variable name is better. Unless your program is about geometry, it should probably never contain a $x.
- Unpack those map/grep/split pileups. Use multiple lines. Write it differently if necessary to pull them apart. Doing too much on one line makes your code unreadable.
- Explicit "return" statements make your intent clearer. Use them.