Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use warnings;
- use strict;
- use File::Find;
- my @name;
- my $filename;
- my $line;
- my @severity = ();
- my @files;
- my @info = ();
- my $key;
- my %hoa;
- my $xmlfile;
- my $comment;
- my @comments;
- open( OUTPUT, "> $ARGV[0]" );
- my $dir = 'c:/programs/TEST/Test';
- while ( defined( $input = glob( $dir . "\*.txt" ) ) ) {
- open( INPUT, "< $input" );
- while (<INPUT>) {
- chomp;
- if (/File/) {
- my @line = split /:/;
- $key = $line[1];
- push @{ $hoa{$key} }, "Filenamen";
- }
- if ( /XML/ ... /File/ ) {
- $xmlfile = $1;
- push @{ $hoa{$key} }, "XML file is $xmlfilen";
- }
- if (/Important/) {
- push @{ $hoa{$key} }, "Severity is $_n";
- }
- if (/^D/) {
- next if /Important/;
- push @{ $hoa{$key} }, "Given comment is $_n";
- }
- push @{ $hoa{$key} }, "this stringn";
- }
- }
- foreach my $k ( keys %hoa ) {
- my @list = @{ $hoa{$k} };
- foreach my $l (@list) {
- print OUTPUT $l, "n";
- }
- }
- }
- close INPUT;
- close OUTPUT;
- use strict;
- use warnings;
- use File::Find;
- my ($outfile) = @ARGV;
- my $dir = 'c:/programs/TEST/Test';
- my %hoa;
- my $key;
- while (my $input = glob "$dir/*.txt") {
- open my $in, '<', $input or die $!;
- while (<$in>) {
- chomp;
- if (/File/) {
- my $key = (split /:/)[1];
- push @{ $hoa{$key} }, "Filenamen";
- }
- if (/XML/ ... /File/) {
- my $xmlfile = $1;
- push @{ $hoa{$key} }, "XML file is $xmlfilen";
- }
- if (/Important/) {
- push @{ $hoa{$key} }, "Severity is $_n";
- }
- if (/^D/) {
- next if /Important/;
- push @{ $hoa{$key} }, "Given comment is $_n";
- }
- push @{ $hoa{$key} }, "this stringn";
- }
- close $in;
- }
- open my $out, '>', $outfile or die $!;
- foreach my $k (keys %hoa) {
- foreach my $l (@{ $hoa{$k} }) {
- print $out $l, "n";
- }
- }
- close $out;
- for (values(%hoa)) { push @{$_}, "this string"; }
- my %autoviv = ( a => ['foo'], b => undef );
- push @$_, "PUSH" for values %autoviv; # ( a => ['foo', 'PUSH'], b => ['PUSH'] )
- my %fatal = ( a => {} );
- push @$_, "PUSH" for values %fatal; # FATAL: "Not an ARRAY reference at..."
- my %dangerous = (a => "foo");
- push @$_, "PUSH" for values %dangerous; # Yikes! @foo is now ("PUSH")
- use strict;
- my %kablam = (a => "foo");
- push @$_, "PUSH" for values %kablam; # "Can't use string ("foo") as an ARRAY ref ..."
- #!/usr/bin/perl
- use warnings;
- use strict;
- use Data::Dumper;
- my %hash = qw|
- key1 value1
- key2 value2
- key3 value3
- |;
- my %hash = map { $_ . "this string" => $hash{ $_ } } keys %hash;
- print Dump %hash;
- perl script.pl
- $VAR1 = {
- 'key3this string' => 'value3',
- 'key2this string' => 'value2',
- 'key1this string' => 'value1'
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement