Documentation for method basename assembled from the following pages:

Class: IO::Path §

From IO::Path

(IO::Path) method basename §

Defined as:

method basename(IO::Path:D:)

Returns the basename part of the path object, which is the name of the filesystem object itself that is referenced by the path.

"docs/README.pod".IO.basename.say# OUTPUT: «README.pod␤» 
"/tmp/".IO.basename.say;           # OUTPUT: «tmp␤»

Note that in IO::Spec::Win32 semantics, the basename of a Windows share is \, not the name of the share itself:

IO::Path::Win32.new('//server/share').basename.say# OUTPUT: «\␤»

Class: IO::Spec::Unix §

From IO::Spec::Unix

(IO::Spec::Unix) method basename §

Defined as:

method basename(Str:D $path --> Str:D)

Takes a path as a string and returns a possibly-empty portion after the last slash:

IO::Spec::Unix.basename("foo/bar/".raku.say# OUTPUT: «""␤» 
IO::Spec::Unix.basename("foo/bar/.").raku.say# OUTPUT: «"."␤» 
IO::Spec::Unix.basename("foo/bar")  .raku.say# OUTPUT: «"bar"␤»

Class: IO::Spec::Win32 §

From IO::Spec::Win32

(IO::Spec::Win32) method basename §

Defined as:

method basename(Str:D $path --> Str:D)

Takes a path as a string and returns a possibly-empty portion after the last slash or backslash:

IO::Spec::Win32.basename("foo/bar/".raku.say# OUTPUT: «""␤» 
IO::Spec::Win32.basename("foo/bar\\").raku.say# OUTPUT: «""␤» 
IO::Spec::Win32.basename("foo/bar/.").raku.say# OUTPUT: «"."␤» 
IO::Spec::Win32.basename("foo/bar")  .raku.say# OUTPUT: «"bar"␤»