Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: word search in perl script

by jcb (Parson)
on Feb 09, 2020 at 00:00 UTC ( [id://11112652]=note: print w/replies, xml ) Need Help??


in reply to word search in perl script

You are making pairs of API requests. You could be working with inconsistent results. You should be opening a pipe and reading one consistent report. Try replacing lines 24 - 29 with something like: (untested)

open my $awspipe, '-|', qw/aws cloudformation describe-stack-drift­- +detection-status --stack-drift-detect­ion-id/, $ID or die "open aws pipe: $!"; while (<$awspipe>) { chomp; my @f = split /"/; $DETECTION = $f[3] if /DetectionStatus/; $SYNC = $f[3] if /StackDriftStatus/; } close $awspipe or die "close aws pipe: $!";

I translated your grep/awk pipeline because I do not know what your input data looks like, but Perl programmers would normally use regexes with a capture group instead of splitting on " and matching key names blindly. If the aws command outputs JSON, normal practice is to parse the objects using JSON instead of slicing up the text.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (5)
As of 2024-04-19 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found