|Syntactic Confectionery Delight|
Re: Simplifying code (Not obfuscation)by zakb (Pilgrim)
|on Mar 04, 2003 at 10:32 UTC||Need Help??|
In Perl, there's more than one way to do it, and your way is almost perfectly fine (by me).
First up, I would hope that you're using strict and warnings, and that $var is actually declared as my $var. This will help you in the future; see Why use strict/warnings for why.
The other improvement I would suggest is to lose the double quotes in your print statement if all you're printing is $var, i.e.:print $var;
One other thing you may want to do is check whether the system command actually executed successfully. The backquote returns undef if the command failed, and it would be good practice to check for this.
There are undoubtedly other things you can do, but with these suggestions and your code the way it is, it is understandable, readable and maintainable by anyone from a Perl novice to a god.
Update: added bit about checking return value of ``