I am trying to declare a constant as an one liner like this:
use constant HOME_SCRIPT => "/home/george/". $0 =~ /(.*)\.pl/;
The problem is that this returns: /home/george/1. I.e. it concats the number of matches of regex.
I tried:
use constant HOME_SCRIPT => ("/home/george/"). $0 =~ /(.*)\.pl/;
use constant HOME_SCRIPT => "/home/george/". ($0 =~ /(.*)\.pl/);
but same result.
Is it possible to create an oneliner for this?
use constant HOME_SCRIPT => "/home/george/". ($0 =~ /(.*)\.pl/)[0];
or
use constant HOME_SCRIPT => join "", "/home/george/", $0 =~ /(.*)\.pl/;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With