Showing posts with label perl mongers. Show all posts
Showing posts with label perl mongers. Show all posts

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)


Friday, February 10, 2017

These are a few of my favorite modules

I was messing around with Xen on Slackware 14.2 and got my system goofed up.  The console worked but the mouse and keyboard would not function in X.  So, after a bit of flailing, I did a distro upgrade (from Slackware 14.2 to current), re-ran liloconfig and,  ta-dah! -Success!

I noticed Perl didn't work however.  It upgraded Perl but the modules were "mis-matched" it said.  After some googling, I ran across several suggested fixes.  The simplest seemed to me the brute force - delete all Perl references and reinstall Perl - which I did. (perl -E 'map {say $_} @INC')

Now I had a NEW problem.  NO MODULES AT ALL.  Began slowly adding modules as I needed them but today that was getting old.  So I did a quick grep of a few hundred of my Perl programs to see which modules I was using and then did a cpan install of all of them.  It's still running...

Which Perl modules you ask?  Well, to satisfy your curiosity and have this list handy the next time I install a fresh Perl - here's my list:

Gimp Gimp::Fu File::stat Time::localtime DBI Net::LDAP Net::LDAP::Bind Net::LDAP::Search MIME::Lite Net::Nslookup Nmap::Scanner Net::SSL::ExpireDate XML::RSS XML::Simple Test::Simple Net::LDAP::LDIF File::Basename CGI::Carp Net::SNMP SQL::Abstract Text::xSV Pod::HTML2Pod LWP::Simple LWP::UserAgent Net::IMAP::Simple Mojo::UserAgent Data::Dumper Date::Manip Net::Twitter DBD::SQLite Net::DNS Net::Telnet::Cisco DBD::Sybase Crypt::GPG File::Slurp utf8 Socket Net::DNS AnyEvent Net::RabbitFoot WWW::Mechanize HTTP::Cookies File::Copy Bot::BasicBot POE::Component::SSLify Config::General Log::Log4perl::Appender::RRDs LWP::Protocol::https

Wow.  That's actually shorter than I thought.  It looked more impressive as one line.  ;-)

Tuesday, July 21, 2009

Joining The Perl Iron Man Program

Just noticed the Iron Man blogging Challenge at Enlightened Perl. Sounds fun - promoting Perl by blogging about it. Funny - that came up at work recently. The younger guys at work here are convinced Perl died a long time ago and I should be learning Python. "Have you noticed NO ONE is talking about Perl anymore?!" they chided. One thing that lead them to believe that (I think) was my homepage which had a programming republic of Perl icon which had been linked to perl.com for years. Since I force my web page to be the homepage for every server I manage, they see this site a lot (and they like it!). The Perl icon used to take you to this stale website that had all of the really old post dates plainly in view. (Funny - they have removed the post dates now.) But I wanted to convince them Perl wasn't dead (just Perl.com), so I changed my programming republic of Perl icon to point at a custom page of Perl links I threw together. It had active sites like Perl Buzz, Perl Monks, Planet Perl and Use Perl. I also included the [somewhat] nearby and very active Perl Monger Groups: St.Louis Perl Mongers and Purdue Perl Mongers. The guys here are not convinced yet, but maybe the Iron Man competition will throw Perl back on their radar and make it "fashionable" (to them) once again. Meanwhile, I'll still use it to "get things done". :-p