Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. use strict;
  2. use warnings;
  3. ##
  4. # Write a script to check the file content without explicitly reading the content.
  5. # It should accept file name with path as command line argument and
  6. # print "The file content is binary." or else β€œThe file content is ascii.” accordingly.
  7. ##
  8. use File::MMagic;
  9. use constant TEXT_TYPE => "The file content is ascii.";
  10. use constant BINARY_TYPE => "The file content is binary.";
  11.  
  12. my $fm = new File::MMagic();
  13. my $type = $fm->checktype_filename($ARGV[0]);
  14. if($type=~m/text\//){
  15. print TEXT_TYPE . "\n";
  16. }
  17. else{
  18. print BINARY_TYPE . "\n";
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement