Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: Uploading Time

by SarahM (Monk)
on Jun 13, 2002 at 22:57 UTC ( [id://174367]=note: print w/replies, xml ) Need Help??


in reply to Uploading Time

Well, you could try spliting on / and \ and take the last element. It could look like this
my $path = 'c:\\path\\file'; # The path and file name my $filename = (split (/[\/\\]/, $path))[-1]; # Split on / and \, and +then get the last element

Replies are listed 'Best First'.
Re: Re: Uploading Time
by Anonymous Monk on Jun 13, 2002 at 23:12 UTC
    ok what does \/\\ mean, does mean \ or /, and does -1 mean the last element, what if it was 1.
      /[\/\\]/ is a regex that matches on either '/' or '\'. The first and last '/' starts and ends the regex. The '[' and ']' means match any character between them, instead of a series of charaters. The '\/' mataches '/' and '\\' matches '\', both of them are escaped.

      Split takes the regex and any time it matches, it seperates the string. It then returns a list of values, and the -1 gives you the last item on the list. If you used 1, then you would get the second item on the list (0 is the first element).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (3)
As of 2024-04-26 01:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found