Path::Class::URI(3pm)

πŸ’– Path::Class::URI πŸ’–

okay bestie, so this is Path::Class::URI β€” it serializes and deserializes Path::Class objects as file:// URI ✨ (yes, both directions, she does it all πŸ’…)


🌸 SYNOPSIS 🌸

use Path::Class;
use Path::Class::URI;

my $file = file('bob', 'john.txt');
my $uri  = $file->uri; # file:bob/john.txt

file('', 'tmp', 'bar.txt')->uri; # file:///tmp/bar.txt

my $file = file_from_uri("file:///tmp/bar.txt"); # or URI::file object
$fh = $file->open;

πŸ¦‹ DESCRIPTION πŸ¦‹

So Path::Class::URI is an extension to Path::Class that lets you serialize a file path from and to file:// form URI objects. it's giving glow-up for your paths, fr fr 🫢

This module encodes and decodes non URI-safe characters using its literal byte encodings. And heads up: if you call uri methods on Win32 Path::File objects, you'll get local filename encodings. that's just how she is 😭

If you want to avoid that and always use UTF-8 filename encodings in URI, go check out Path::Class::Unicode, which is bundled in this distribution. she's the sister module, no cap πŸ‘‘


πŸ’… METHODS πŸ’…

✨ uri (Path::Class::Entity)

$uri = $file->uri;
$uri = $dir->uri;

returns a URI object representing Path::Class file and directory. periodt πŸ’–

✨ from_uri (Path::Class::Entity)

$file = Path::Class::File->from_uri($uri);
$dir  = Path::Class::Dir->from_uri($uri);

Deserializes a URI object (or a string, she's flexible like that πŸ’) into Path::Class objects.

✨ file_from_uri, dir_from_uri

Shortcuts for those from_uri methods. Exported by default πŸŽ€ so you don't even have to ask, she's already there.


πŸ‘‘ AUTHOR πŸ‘‘

Tatsuhiko Miyagawa <miyagawa@cpan.org> β€” icon, legend, the moment 🌟


πŸ“œ LICENSE πŸ“œ

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸ“


πŸ”₯ SEE ALSO πŸ”₯

  • Path::Class
  • URI::file

mwah πŸ’‹ that's the whole page bestie. this one's from perl v5.36.0, dated 2023-02-11 β€” go forth and URI-ify ur paths, ily 🫢✨

πŸ“¦ where this page comes from