]> Raphaƫl G. Git Repositories - carabistouilles/blobdiff - analyse.pl
Rename analyse
[carabistouilles] / analyse.pl
diff --git a/analyse.pl b/analyse.pl
new file mode 100755 (executable)
index 0000000..92eb375
--- /dev/null
@@ -0,0 +1,41 @@
+#! /usr/bin/perl
+
+# Best practice
+use strict;
+use warnings;
+
+# Load POSIX
+use POSIX qw(EXIT_SUCCESS EXIT_FAILURE);
+
+# Load siren module
+use lib::siren;
+
+# Show usage
+if (scalar(@ARGV) < 1) {
+       print "Usage: $0 sirens_fxt.txt\n";
+       exit EXIT_FAILURE;
+}
+
+# Test file
+if (! -f $ARGV[0]) {
+       print "$ARGV[0] needs to be a valid file\n";
+       exit EXIT_FAILURE;
+}
+
+# Test file readability
+if (! -r $ARGV[0]) {
+       print "$ARGV[0] needs to be readable\n";
+       exit EXIT_FAILURE;
+}
+
+# New siren object
+my $siren = lib::siren->new();
+
+# Parse data
+$siren->parse($ARGV[0]);
+
+# Show result
+print $siren->show();
+
+# Success
+exit EXIT_SUCCESS;