There are two problems there. qw takes each blank characters separated elements in its operand (most often, words separated by spaces) and reads them in a simple quotish context. Put a simpler way, qw(A $b C %h); could also be written ('A', '$b', 'C', '%h'). In Ruby there is a qw-like construct that allows double-quotish interpretation, but this is Perl. So you instead have to write use lib ("$some_path/lib",); (the comma is optional, I just always put an extra comma in a single element list).
The second issue is that use is called straightaway, so you could say that perl reads your program :
there is a global variable called $some_path
add to path $some_path/lib
$some_path = dirname(File::Spec->rel2abs(__FILE__));
This is of course really simplified.
The BEGIN keyword means that a block has to be executed during compile time, and not to wait after compilation completion. You should write:
$some_path = "/my/path";
use lib "$some_path/lib"; # Yeah, you don't even need the parenthesis,
+ Perl is clever enough for you
# Edit : thanks dave_the_m for the correction
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] ||