Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Getting a base name

by Tanalis (Curate)
on Jul 20, 2005 at 08:31 UTC ( #476415=note: print w/ replies, xml ) Need Help??

in reply to Getting a base name

You need to escape the '.' in your split:

$base = ( split(/\./,$fname) )[0];
Adding -Mstrict and -w (always a good idea), the following works fine for me:
perl -Mstrict -w -e ' my $fname = "test.txt"; my $base = ( split(/\./,$fname) )[0]; print "$base\n";'
Update: And, as others have mentioned, you have single quotes inside single quotes, too :)

Hope that helps ..

Comment on Re: Getting a base name
Select or Download Code

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://476415]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2016-02-13 18:30 GMT
Find Nodes?
    Voting Booth?

    How many photographs, souvenirs, artworks, trophies or other decorative objects are displayed in your home?

    Results (442 votes), past polls