Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Using system (); with Strawberry Perl

by jwkrahn (Abbot)
on Nov 25, 2021 at 07:11 UTC ( [id://11139102]=note: print w/replies, xml ) Need Help??


in reply to Using system (); with Strawberry Perl

Hello hadrons, I haven't used Windows in over 20 years but these may work.

(Obviously I can't test these because ... no Windows)

system ('grep -l "DATAmessage.*3\.0" *.xml > 3.0_files_arraydata.txt') +;
open my $FH, '>', '3.0_files_arraydata.txt' or die "Cannot open '3.0_files_arraydata.txt' because: $!"; { local @ARGV = <*.xml> or die "Cannot find any '*.xml' files\n"; while ( <> ) { if ( /DATAmessage.*3\.0/ ) { print $FH "$ARGV\n"; close ARGV; } } }

system ("mv temp_3.0_files_onixarraydata.txt 3.0_files_arraydata.txt") +;
rename 'temp_3.0_files_onixarraydata.txt', '3.0_files_arraydata.txt' or die "Cannot move 'temp_3.0_files_onixarraydata.txt' because: $! +";

system ("cat *files_arraydata.txt > data2.txt");
open my $FH, '>', 'data2.txt' or die "Cannot open 'data2.txt' because: $!"; { local @ARGV = <*files_arraydata.txt> or die "Cannot find any '*files_arraydata.txt' files\n"; print $FH $_ while <>; }

system ("rm data2.txt");
unlink 'data2.txt' or die "Cannot delete 'data2.txt' because: $!";

system ("sort -u data2.txt > data.txt");
open my $IN, '<', 'data2.txt' or die "Cannot open 'data2.txt' because: $!"; open my $OUT, '>', 'data.txt' or die "Cannot open 'data.txt' because: $!"; { my %unique; print $OUT sort grep { ! $unique{ $_ }++ } <$IN>; }

Replies are listed 'Best First'.
Re^2: Using system (); with Strawberry Perl
by hadrons (Novice) on Nov 25, 2021 at 19:09 UTC
    Every line worked - thank you so much. How do I indicate that this is the answer?

      That's not the way Perl Monks works, as indicated by the quote below.

      Most languages are like stackoverflow: I have a question, I want the best answer. Perl is like PerlMonks: I have a doubt, I want to read an interesting discussion about it that is likely to go on a tangent. q-:

      -- tye in Re: What is PerlMonks? (why Perl)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11139102]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-04-16 05:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found