Hi everyone,
I'm just learning how to work with modules and am stuck at the very beginning. File::Basename seems simple enough but ... anyway, here's the sample code:
use File::Basename;
my $name = "C:\karate\kid\sucks";
my $basename = basename($name);
print "$basename\n";
I've also tried just about every variation of this. With and without the "C:", lower case "c", "basename($name)" with brackets, without, ... you get the idea. In any scenario, it either crashes or returns back the original $name with some random characters missing.
Although I'm using Windows, I decided to try the Unix code "/karate/kid/sucks" and it works. What the hell? Isn't this module supposed to detect the shell I'm using? What am I doing wrong?
Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
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:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.