Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.78 KB | None | 0 0
  1. use warnings;
  2. use strict;
  3. use File::Find;
  4.  
  5. my @name;
  6. my $filename;
  7. my $line;
  8. my @severity = ();
  9. my @files;
  10. my @info = ();
  11. my $key;
  12. my %hoa;
  13. my $xmlfile;
  14. my $comment;
  15. my @comments;
  16.  
  17. open( OUTPUT, "> $ARGV[0]" );
  18. my $dir = 'c:/programs/TEST/Test';
  19.  
  20. while ( defined( $input = glob( $dir . "\*.txt" ) ) ) {
  21. open( INPUT, "< $input" );
  22.  
  23. while (<INPUT>) {
  24. chomp;
  25.  
  26. if (/File/) {
  27. my @line = split /:/;
  28. $key = $line[1];
  29. push @{ $hoa{$key} }, "Filenamen";
  30. }
  31.  
  32. if ( /XML/ ... /File/ ) {
  33. $xmlfile = $1;
  34. push @{ $hoa{$key} }, "XML file is $xmlfilen";
  35.  
  36. }
  37. if (/Important/) {
  38. push @{ $hoa{$key} }, "Severity is $_n";
  39. }
  40. if (/^D/) {
  41. next if /Important/;
  42. push @{ $hoa{$key} }, "Given comment is $_n";
  43. }
  44. push @{ $hoa{$key} }, "this stringn";
  45. }
  46.  
  47. }
  48.  
  49. foreach my $k ( keys %hoa ) {
  50. my @list = @{ $hoa{$k} };
  51. foreach my $l (@list) {
  52. print OUTPUT $l, "n";
  53. }
  54. }
  55.  
  56. }
  57. close INPUT;
  58. close OUTPUT;
  59.  
  60. use strict;
  61. use warnings;
  62.  
  63. use File::Find;
  64.  
  65. my ($outfile) = @ARGV;
  66.  
  67. my $dir = 'c:/programs/TEST/Test';
  68.  
  69. my %hoa;
  70. my $key;
  71.  
  72. while (my $input = glob "$dir/*.txt") {
  73.  
  74. open my $in, '<', $input or die $!;
  75.  
  76. while (<$in>) {
  77.  
  78. chomp;
  79.  
  80. if (/File/) {
  81. my $key = (split /:/)[1];
  82. push @{ $hoa{$key} }, "Filenamen";
  83. }
  84.  
  85. if (/XML/ ... /File/) {
  86. my $xmlfile = $1;
  87. push @{ $hoa{$key} }, "XML file is $xmlfilen";
  88. }
  89.  
  90. if (/Important/) {
  91. push @{ $hoa{$key} }, "Severity is $_n";
  92. }
  93.  
  94. if (/^D/) {
  95. next if /Important/;
  96. push @{ $hoa{$key} }, "Given comment is $_n";
  97. }
  98.  
  99. push @{ $hoa{$key} }, "this stringn";
  100. }
  101.  
  102. close $in;
  103. }
  104.  
  105. open my $out, '>', $outfile or die $!;
  106.  
  107. foreach my $k (keys %hoa) {
  108. foreach my $l (@{ $hoa{$k} }) {
  109. print $out $l, "n";
  110. }
  111. }
  112.  
  113. close $out;
  114.  
  115. for (values(%hoa)) { push @{$_}, "this string"; }
  116.  
  117. my %autoviv = ( a => ['foo'], b => undef );
  118. push @$_, "PUSH" for values %autoviv; # ( a => ['foo', 'PUSH'], b => ['PUSH'] )
  119.  
  120. my %fatal = ( a => {} );
  121. push @$_, "PUSH" for values %fatal; # FATAL: "Not an ARRAY reference at..."
  122.  
  123. my %dangerous = (a => "foo");
  124. push @$_, "PUSH" for values %dangerous; # Yikes! @foo is now ("PUSH")
  125.  
  126. use strict;
  127. my %kablam = (a => "foo");
  128. push @$_, "PUSH" for values %kablam; # "Can't use string ("foo") as an ARRAY ref ..."
  129.  
  130. #!/usr/bin/perl
  131.  
  132. use warnings;
  133. use strict;
  134. use Data::Dumper;
  135.  
  136. my %hash = qw|
  137. key1 value1
  138. key2 value2
  139. key3 value3
  140. |;
  141.  
  142. my %hash = map { $_ . "this string" => $hash{ $_ } } keys %hash;
  143.  
  144. print Dump %hash;
  145.  
  146. perl script.pl
  147.  
  148. $VAR1 = {
  149. 'key3this string' => 'value3',
  150. 'key2this string' => 'value2',
  151. 'key1this string' => 'value1'
  152. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement