PEPPLER.ORG
Michael Peppler
Sybase Consulting
Menu
Home
Sybase on Linux
Install Guide for Sybase on Linux
General Sybase Resources
General Perl Resources
Freeware
Sybperl
Sybase::Simple
DBD::Sybase
BCP Tool
Bug Tracker
Mailing List Archive
Downloads Directory
FAQs
Sybase on Linux FAQ
Sybperl FAQ
Personal
Michael Peppler's resume

sybperl-l Archive

Up    Prev    Next    

From: "Scott Zetlan" <scottzetlan at aol dot com>
Subject: Sybase::BLK: feature note
Date: Jan 11 2002 4:42PM

All --

For those of you working with or thinking of using Sybase::BLK, please note
that the handling of field separators (SEPARATOR config key) has changed
slightly from Sybase::BCP.  Sybase::BLK treats SEPARATOR as a regular
expression, where Sybase::BCP treated it as an exact string to match.  As a
result, the example in the original documentation (which was copied into
Sybase::BLK):
        #!/usr/local/bin/perl

        use Sybase::BLK;

        $bcp = new Sybase::BLK sa, undef, TROLL;

        $bcp->config(INPUT => '../../Sybperl/xab',
                 OUTPUT => 'excalibur.dbo.t3',
                 BATCH_SIZE => 200,
                 REORDER => {1 => 'account',
                     3 => 'date',
                     2 => 'seq_no',
                     11 => 'broker'},
                 SEPARATOR => '|');
        $bcp->run;
doesn't work as expected.  The expression /|/ is passed to split, causing
each character in the record to be split into its own field -- the pipe is
treated as an "or" operator between two unspecified characters, resulting in
a null split pattern, just as if you'd used split //.  Instead, you would
need to set SEPARATOR => '\|', which would force a match on the '|'
character.

Using regular expression matching on the field separator allows you to
handle multiple different candidate separators in a character class, split
on quoted data, etc.  I tested both with the new method and the old method,
and there was no noticeable performance impact.

Thanks to Stuart Bullock for pointing out the inconsistency.

Scott