Ver código fonte

Changed to filter-like (stdin/stdout) behavior

Alois Mahdal 11 anos atrás
pai
commit
bad26a7836
2 arquivos alterados com 7 adições e 17 exclusões
  1. 4
    12
      bin/pl2yml
  2. 3
    5
      bin/yml2pl

+ 4
- 12
bin/pl2yml Ver arquivo

@@ -2,17 +2,9 @@
2 2
 
3 3
 use strict;
4 4
 use warnings;
5
-use YAML::Tiny;
5
+use YAML;
6 6
 
7
-my $file = shift @ARGV
8
-    or &usage;
7
+my $string = join "", <>;
8
+my $var = eval $string;
9 9
 
10
-do $file;
11
-
12
-my $yaml = YAML::Tiny->new;
13
-
14
-$yaml->[0] = $VAR1;
15
-
16
-print $yaml->write_string;
17
-
18
-sub usage { print "usage: pl2yml FILE\n"; }
10
+print Dump($var);

+ 3
- 5
bin/yml2pl Ver arquivo

@@ -2,14 +2,12 @@
2 2
 
3 3
 use strict;
4 4
 use warnings;
5
-use YAML::Tiny;
5
+use YAML;
6 6
 use Data::Dumper;
7 7
 
8
-my $file = shift @ARGV
9
-    or &usage;
8
+my $string = join "", <>;
10 9
 
11
-my $data = YAML::Tiny->read($file)
12
-    or die "cannot read $file: " . YAML::Tiny->errstr . "\n";
10
+my $data = Load($string);
13 11
 
14 12
 print Dumper($data);
15 13