X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=samples%2Fhash2array.pl;h=863ba885721a1de1c42bc9929d4b51426a34f76b;hb=refs%2Ftags%2Fv0.02;hp=b26950a272eb343c311d2aea274e634965ff51e1;hpb=2966b83e4eb41f8bd7f8c354e078bce07ced1fea;p=perl%2Fmodules%2Fautovivification.git diff --git a/samples/hash2array.pl b/samples/hash2array.pl index b26950a..863ba88 100644 --- a/samples/hash2array.pl +++ b/samples/hash2array.pl @@ -37,10 +37,12 @@ while (<$hash_t>) { $in_data = 1; print $array_t $_; } elsif (!$in_data) { - s{s/\^\$/%/}{s/^\$/@/}; + s{'%'}{'\@'}; print $array_t $_; } else { + s!(\ba\b)?(\s*)HASH\b!($1 ? 'an': '') . "$2ARRAY"!eg; s!->{([a-z])}!'->[' . num($1) . ']'!eg; + s!%(\{?)\$!\@$1\$!g; my $buf; my $suffix = $_; my ($bracket, $prefix); @@ -49,6 +51,7 @@ while (<$hash_t>) { } $buf .= $suffix; $buf =~ s/\s+/ /g; + $buf =~ s/\s+$//; print $array_t "$buf\n"; } }