Thursday, December 13, 2018

Bitten by an old "bug"?

So thankful to find brian d foy's post about LWP::Protocol::https yesterday after some really old scripts just wouldn't work on a new system.  I could tell it was having an issue with the https - but, like Brian (in 2011?!) I thought all of my usual SSL libraries would cover it (which they did).  Installing all of my modules takes about an hour.  So, I continued to flail during this time.  By the time I saw Brian's post, the problem fixed itself (after I installed my own CPAN favorites).

Not knowing my cluster of favorite CPAN modules had fixed this, I quickly did a "install  LWP::Protocol::https" to which cpan replied "installed and already up to date".  "So why isn't it working?!", I thought.  I tried again and it was.

So, to recap, if you plan on using "LWP::Simple qw(getstore)" to grab something from a HTTPS web site and you get a error 501 - this is what you need to fix your problem: LWP::Protocol::https (which was split out in 2011 and I evidently missed the memo).

Monday, November 19, 2018

Perl, Awk or other?

I had some quickie output from an ad hoc Ansible command. I love Ansible! The data was quick to acquire and accurate. But the readability was not optimal. "Hmmm...", I thought, "It'd be good enough if it just separated the data elements with a space." Actually, this comes up a lot with my quickie ad hoc Ansible reports so I do what I always do: Perl!


That worked perfectly but it was so simple I thought it should be a one-liner. BTW, I really enjoyed Peteris Krumins' Sed, Awk and Perl one-liner books. I bought them all in PDF and then bought the pretty No Starch Press version of Perl One-Liners (makes a great coffee table book - I just pick it up and open it to any page and I'm intrigued - Fun!) So, I took a stab at it. It worked perfectly the first time but it was really just my same program in one-liner format. So here it is. If you have a more elegant solution let me know.



  perl -pe 'if (m/SUCCESS/) {print "\n$_"} else {print $_} ' JavaReport.txt
  
P.S. The I tried Awk:
 
 awk '/SUCCESS/ { print "\n" } {print}' JavaReport.txt  
  
(although this isn't quite right)


Thursday, November 1, 2018

Being Lazy

Just discovered Array::Utils!  Wonderful!  To think I was going to write a "find unique elements in an array" myself.  Nope!

use Array::Utils qw(:all);
my @unique = unique(@a, @b);