Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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 contemplating the Monastery: (6)
As of 2015-08-03 02:10 GMT
Find Nodes?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...

    Results (20 votes), past polls