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.
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.
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.
----------------------------------------
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
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.
Following up on previous XML sorting efforts, where I mostly wanted to sort by tag name, then by NAME attribute, but for some elements, there were other attributes that I wanted to sort by. I first did the tag_name/NAME_attribute sort with XML::Filter::XSLT then sorted by the other odd elements using XML::Filter::Sort.
Out of curiosity, I wanted to try to do it all with XSLT, so I came up with:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:output method="xml" version="1.0"
encoding="iso-8859-1" indent="yes" omit-xml-declaration="no"/>
<xsl:template match="/">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="//*">
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:apply-templates select="D">
<xsl:sort select="@FOO"/>
</xsl:apply-templates>
<xsl:apply-templates select="*[not(self::D)]">
<xsl:sort select="name()"/>
<xsl:sort select="@NAME"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Which sorts "D" elements by the FOO attribute, and everything else by tag name then NAME attribute. The difference between this and my previous method is that now "D" tags will come before "A" tags (and any others), whereas before they were still sorted by tag name. I think I can get the former two-pass approach behavior in one XSLT document, but for now, it's more trouble than it's worth. It would be easy if you could define a sort callback function....
Today is the day I'm glad I never got rid of all my vinyl. Though I haven't heard any of it for about 12 years, I've managed to to hang on to most of it...and the irony is that although my wife is the one who has encouraged jettisoning the records, she's the one who gave me the turntable w/the USB connection (big thank you to you dear).
So, what to record first? A while back, I did sell my copy of Generic Flipper, and I'm still kicking myself for that, though I do still have Public Flipper Limited, but that's not exactly a family friendly album (I'll record that one some late night or when no one's home). I've also got some 78's of Yehudi and Hephzibah Menuhin playing Beethoven's Sonata No. 9 in A (Op. 47 "Kreutzer Sonata"), but I don't yet have a 78 needle, so I'll leave that one for now. And besides, Amazon seems to have it, though I'm not sure if their 6:48 version is what I have (what is the play time of 4 78 disks anyway?).
So first up on the platter is Jon and the Nightriders, which seems to have been never released to CD, though it's the greatest surf album ever recorded...IMHO