Guest User

Untitled

a guest
Jun 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #!/usr/bin/env perl
  2.  
  3. use strict;
  4. use warnings;
  5. use File::MimeInfo::Magic;
  6. @File::MimeInfo::DIRS = qw(/usr/local/share/mime/);
  7. File::MimeInfo->rehash();
  8.  
  9. use URI;
  10.  
  11. my $input_file = $ARGV[0];
  12.  
  13. unless ($input_file) {
  14. while (<DATA>){
  15. print STDERR $_;
  16. }
  17. exit 1;
  18. }
  19.  
  20. my $mime_type = mimetype($input_file);
  21. my $url = URI->new("data:");
  22. $url->media_type($mime_type);
  23. $url->data(scalar(`cat $input_file`));
  24.  
  25. print "\n$url\n";
  26.  
  27. __DATA__
  28. dataurl
  29.  
  30. command line tool for generate data-url scheme.
  31.  
  32. Usage:
  33. dataurl [FILE]
Add Comment
Please, Sign In to add comment