for ( $ipaddress, $prefix, $interface, $device, $location, $comment ) { defined and s/^\s+|\s+$//g; # or defined ? s/^\s+|\s+$//g : 1; It does the same thing # or even if (defined) { s/^\s+|\s+$//g } ## Edit : and there is # s/^\s+|\s+$//g if defined; ## That one is quite nice. ## Let's just say there's more than one way to do it. } #### STRING: for( $ipaddress, $prefix, $interface, $device, $location, $comment ) { next STRING unless defined; # We skip any element that is not defined s/^\s+|\s+$//g; }