, , -
use strict;
use warnings;
, , . Perl- .
use JSON;
use XML::Simple;
use File::Spec;
, .
$num_args = $#ARGV + 1;
if ($num_args != 1) {
print "\nUsage: $0 <input directory>\n";
exit;
}
if (@ARGV != 1) {
print ...
exit;
}
.
opendir(DIR, $dir) or die "cannot open directory";
@docs = grep(/\.xml$/,readdir(DIR));
foreach $file (@docs) {
my $abs_path = join("",$dir,$file);
readdir, , , glob(). :
my @docs = glob "$dir/*.xml";
( , ), path ). : examples/foo.xml.
sub print_output {
my $output_object = $_[0];
print $output_object;
}
, sub , print.
, , ( @ARGV). :
if (not -e $dir) {
$dir = "default";
}