Stories
Slash Boxes
Comments

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

runrig (3385)

runrig
  reversethis-{gro.napc} {ta} {wguod}

Just another perl hacker somewhere near Disneyland

I have this homenode [perlmonks.org] of little consequence on Perl Monks [perlmonks.org] that you probably have no interest in whatsoever.

I also have some modules [cpan.org] on CPAN [cpan.org] some of which are marginally [cpan.org] more [cpan.org] useful [cpan.org] than others.

Journal of runrig (3385)

Sunday September 28, 2008
01:47 PM

Saving the planet (and some $$$)

Update: I've decided the sub-title of this post is "I still don't want a pickle: s/motor/bi/"

It's about an 8 mile drive to work, and I decided that it was time to see about riding my bike instead. And there's all sorts of reasons for doing it, and people ask ("But what about...") about all sorts of reasons for not doing it. But the biggest reason is that instead of dreading the drive home and wondering if I should take the freeway or surface streets (and not caring much more about the trip to work), I actually look forward to the commute, each way, whether it's cold and foggy, or hot and sweltering (I'm not yet prepared for rain, so I'll drive if that's the case, 'cuz you know that in Southern California we're afraid of melting if it rains, even a little).

01:37 PM

I Don't Want A Pickle

Once upon a time there was a marine base. And it was decommissioned. And there was some discussion over what to do with the space left by the decommissioned marine base. Some people wanted an airport, some people wanted a park. There was a vote. And the park people won.

And Arlo Guthrie played while a big orange balloon went up and down. And everyone who "thought that guy was dead"[1] got to hear Alice's Restaurant (for free!), and lots of other songs and stories, and it was funny, and entertaining, and a wonderful time was had by all. But we didn't get there early enough to get passes for the Orange Balloon :-(

So a few weeks later, we went back earlier to get passes, rode the Orange Balloon, and listened to some more music (a "Wartime Radio Revue", which was cool, but not Arlo Guthrie... :-), and a wonderful time was had by all (again) :-)

[1] I called my wife Friday morning when I heard on the radio about the show:

  • Me: "Hey, Arlo Guthrie is playing tomorrow night"
  • Her: "Isn't he dead?"

The first thing he said onstage was "I bet some of you heard about this and said "I thought that guy was dead..."

01:18 PM

PowerCenter XML

Everyone I talk with says that mucking with the XML exported by Informatica's PowerCenter is not recommended, or that they tried and failed...so I had no choice but to ignore that advice when we were upgrading from version 7 to 8. I think the advice must be from people who don't quite know what they're doing, and/or "parse" with grep/awk/sed.

I've been messing with more XML in the last few weeks than I have in the last few years. I have my own (shared) opinion about Informatica/ETL (and I've taken up Aristotle's call to action), but at least it provides an opportunity to practice some XML-fu. Most transformations were simple changing of some attributes, but there was one issue where after importing into v8, if you delete a group from a Union transformation, the GUI crashes. So I created a Union transformation from scratch, exported it, and compared it to what I was importing, and hey, there was some stuff missing! So I wrote the following:

  # Fix Union transformations
  my $union_cnt;
  for my $trans (
    $root->findnodes(q[
      //TRANSFORMATION[@TYPE="Custom Transformation" and @TEMPLATENAME="Union Transformation"]
    ])
  ) {
    $union_cnt++;
    my $name = $trans->getAttribute('NAME');
    my $parent = $trans->parentNode();
    print "X: Fixing Union transformation $name\n";
    my @output;
    for my $field (
      $trans->findnodes(q[
        TRANSFORMFIELD[@GROUP="OUTPUT"]/@NAME
      ])
    ) {
      push @output, $field->value();
    }
    my %dep;
    my $dep_cnt;
    for my $field (
      $trans->findnodes(q[
        TRANSFORMFIELD[@PORTTYPE="INPUT"]
      ])
    ) {
      my $name  = $field->getAttribute('NAME');
      my $group = $field->getAttribute('GROUP');
      my $dep_group = $output[$dep{$group}++];
      my $new = $trans->addNewChild( '', 'FIELDDEPENDENCY' );
      $new->setAttribute( 'INPUTFIELD', $name );
      $new->setAttribute( 'OUTPUTFIELD', $dep_group );
    }
  }
  $_->unbindNode() for $root->findnodes('//text()');

Warning: this code is not endorsed or guaranteed by anyone for anything!

The removing of all text nodes was so that the result would stay pretty-printed after output (is there a better/easier way?):

  eval { $doc->toFile($file, 1) } or die "Could not write to $file: $@";

And there are no text nodes with anything but whitespace anyway. XML::LibXML seemed hard to use at first, but once you get used to how the docs are arranged (and learn some XPath), it's quite easy.

12:46 PM

Suck followup

It may not have been blogged about in the most diplomatic way, but to follow up on my previous post, I followed btilly's diplomatic advice pretty much, and found out that the code was written by a college intern, who was now gone, but a couple of other developers were now reponsible for maintaining (or rewriting) it, and were glad to get some advice and feedback.
Friday August 08, 2008
10:17 PM

You suck or silence?

When someone posts a "utility" on the company intraweb, and it's perl, and it's about 900 lines long, with no strict or warnings, has no indentation, needlessly builds strings and splits to an array when qw() would've been appropriate, needlessly uses ".*" in regular expressions, (mis)uses subroutine prototypes, has lots of repeated code that could be factored into subroutines, and lots of other things you'd expect to see in the sort of code that has all the previous issues, and you've already written a library to do the same thing and more (in fewer lines...though slightly more if you count the documentation), what do you do?
Friday July 25, 2008
07:00 PM

Novell Netware checksum

Dear lazyweb,

When I rightclick on a file on my work Windows system and go to File-Properties, there's a "NetWare Version" tab which has a "View Version, Copyright, and Check Sum Info" button. When you click that, you get a 48-bit checksum of the file in hex. Does anyone know how this checksum is calculated, or even how to find an external exe to run (or a dll and how to use it) to get this value? I've tried comparing the value against as many known checksum algorithms as possible before tearing my hair out.

Update: and why I want this? We are currently required to enter this value into some document, and the only way to cut n paste it is via screen copy...you can not copy just the text.

Update: nevermind...we have switched to using Jacksum.

Saturday June 28, 2008
09:05 PM

So long its been good to know you

The internet is a strange universe where we mostly know one another (or don't really know one another) through bits and bytes and blog entries and email. It was through PerlMonks that I first knew of VSarkiss, and found that he lived relatively nearby, and we met up once. It was about a year ago (more or less) that he came to be working at the same place I was through a different consulting agency (though it's a big company so I didn't see him much). Then he disappeared, I emailed him and never heard back, and finally just recently I got around to asking someone about him, and was told that he passed away. So long Vahe... :'-(
Friday March 14, 2008
05:53 PM

Building perl and libs on HP-UX

I must keep this somewhere in one place semi-permanent...boring stuff plus hoops to jump through to get XML(LibXML and LibXSLT), and DBD::Oracle and DBD::Sybase working on HP-UX (I have no explanation for having to run 'perl Makefile.PL' over and over). I don't remember if I needed to use 'chatr' to change some of the shared libraries to get them to load:

----------------------------------------
Notes on Building perl 5.10.0 and various
libraries on HP-UX (11.11)

All of the following was installed under
/users/foo
Adjust all prefix parameters accordingly
to install in another directory (or remove
to install in default location).
----------------------------------------

First perl itself:

> which cc
must be /opt/softbench/bin/cc compiler
(default HP /usr/bin/cc compiler will not work)
(gcc compiler can work, but everything here was done
with softbench compiler).

# Add prefix to install in non-standard path
sh Configure -Dprefix=/users/foo

keep default of building non-threaded perl, but
add '-lcl -lpthread' to beginning of libraries to include.
(So that DBD::Oracle will build dynamically later).

make
make test
make install

----------------------------------------
XML::LibXML and XML::LibXSLT:
----------------------------------------
First install shared libraries:

install binaries of zlib(libz), iconv, and gettext
libraries, unless you really feel like building them
(install in local directory if necessary..e.g./users/foo/lib
and include files in /users/foo/include).

Build source for libxml library:
Set env variables:
export CC=cc
export LDFLAGS="-L/users/foo/lib -I/users/foo/include"

./configure --prefix=/users/foo --without-threads --without-thread-alloc --with-iconv=/users/foo --with-zlib=/users/foo

make
make install

# Fix permission on config info file:
chmod +x /users/foo/bin/xml2-config

----------------------------------------
Build source for libxslt library:
Set env variables:
export CC=cc
export LDFLAGS="-L/users/foo/lib -I/users/foo/include"

./configure --prefix=/users/foo
make
make install

# Fix permission on config info file:
chmod +x /users/foo/bin/xslt-config

----------------------------------------
Build source for XML::LibXML::Common:
perl Makefile.PL
  (doesn't always work first time..repeat until Makefile is created)

make
make test
make install

----------------------------------------
Build source for XML::NamespaceSupport:

perl Makefile.PL
make
make test
make install
----------------------------------------
Build source for XML::SAX:

perl Makefile.PL
make
make test
make install
----------------------------------------
Build source for XML::LibXML:

perl Makefile.PL (repeat until Makefile is created)
make
make test
make install
----------------------------------------
Build source for XML::LibXSLT:

Change the following lines (this might be fixed in a future
version):
#xsystem("$Config{make} $file test 'OTHERLDFLAGS=$opt'");
xsystem("$Config{make} $file test");

#$result = try_link(<<"SRC", $libs);
$result = try_link(<<"SRC", undef);

perl Makefile.PL LIBS=-L/users/foo/lib INC="-I/users/foo/include -I/users/foo/include/libxml2"
make
make test
  (a couple of tests, e.g. exslt tests, will fail, install exslt library
  if you need exslt)
make install
----------------------------------------
Build source for DBI

perl Makefile.PL
make
make test (many tests are skipped)
make install
----------------------------------------
Build source for DBD::Oracle (1.20)

perl Makefile.PL

edit Makefile:
# Look for
$(LD) -Wl,+b"$(LD_RUN_PATH)"  $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB)  \
# Remove "-Wl,"
$(LD) +b"$(LD_RUN_PATH)"  $(LDDLFLAGS) $(LDFROM) $(OTHERLDFLAGS) -o $@ $(MYEXTLIB)  \

make
make test
  (many 'connects' fail unless you set env vars for a test db)
  (many charset tests skipped on old versions of Oracle)
make install
----------------------------------------
Build source for DBD::Sybase (1.08)

Edit Sybase.pm:
# Look for:
sub dl_load_flags { if($^O eq 'aix') { 0x00 } else { 0x01 }}
# Change to:
sub dl_load_flags { if($^O eq 'aix') { 0x00 } else { 0x00 }}

update: patch to display line numbers on RaiseError:
*** ../DBD-Sybase-1.08/dbdimp.c Thu Apr 19 11:31:19 2007
--- dbdimp.c    Thu Jun 19 14:09:45 2008
***************
*** 545,550 ****
--- 545,551 ----
        else
            retcode = CS_SUCCEED;

+       sv_catpv(DBIc_ERRSTR(imp_dbh), " ");
        return retcode;
      } else {
        if(srvmsg->msgnumber) {

perl Makefile.PL (prompts for test server/db and user/passwd)
make
make test
make install

Thursday February 28, 2008
03:40 AM

Hey buddy

I received a pleasant surprise when I got home today. "Close your eyes and hold out your hands," my wife and daughter said. A new CD. For me :) And I'd never heard of it. I really like Ry Cooder, but I haven't been paying attention lately to what he's been doing, so My Name Is Buddy was a complete revelation. It's great...there's a song about a pig named J. Edgar Hoover (uh huh, it's just about the pig, yeah, right). There's a socially relevant story line about a cat, a mouse, and a toad...but I'm just going to enjoy the music for the first 3 or 4 or 7 listens. And it's got two (count'em!), Two Seegers playing on the album. And in a great confluence of synergistic coincidence, there was a great show on PBS tonight about Pete Seeger ("The Power of Music"). If anyone can stop a war with a banjo, he can :-)
Thursday February 21, 2008
01:39 PM

Local "network" printer

My wife just bought a Dell laptop with Windows Vista...the Desktop is Windows XP with a printer connected directly to it, and the printer was configured to be "shared". Tried to get the printer working from the laptop...click "add a printer", then "Is this a local or network printer?". Well, it's on the network, it sure doesn't seem local, but the network discovery thing doesn't find it, and you get "Access Denied" when trying to connect to it. Google, google, and low and behold, it's really a "local" printer, though you do give it the "\\systemname\printername" path in one of the entry fields.

Very intuitive. Also, the salesman who was trying to sell us another printer when buying the laptop was telling us "the old printer probably won't work...there probably no printer driver for Vista...". BS.

Of course, my wife needed something printed out right now because she was going out right now, and another option was to export the Word document to PDF, and email it to ourselves and print it out at the other computer. But Word didn't natively export to PDF, you had to install a Microsoft Plug-in for that, and you needed the "validation code" that came with word to install it, and we didn't have that handy. Eventually, I did also install PDFCreator, but that was around the same time I found out about the "Local Printer" thing.

What would we do without the internet? Spend useless hours on hold with Technical Support probably.