Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: word search in perl script

by jcb (Priest)
on Feb 08, 2020 at 19:00 UTC ( #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?

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (8)
As of 2020-05-30 19:21 GMT
Find Nodes?
    Voting Booth?
    If programming languages were movie genres, Perl would be:

    Results (173 votes). Check out past polls.