From:                   "Jenda Krynicky" <[EMAIL PROTECTED]>
> From: Kev <[EMAIL PROTECTED]>
> > Hi everyone,
> > 
> > I'm having a problem that may either lie in PostgreSQL or in perl, and
> > I'm not sure which.  I originally posted this on pgsql.general, and
> > only heard back that someone else has this problem too.  I'm running
> > perl 5.10 on Windows 2003 Server, although I believe the version
> > embedded in pgsql at the moment is still 5.8.
> > 
> > The basic problem is that I generate the code of a function, and then
> > want to check whether this is the same code stored in the database or
> > not, but diff shows "differences" where there aren't any (or shouldn't
> > be any, since nothing in the database has changed), and worse, perl's
> > 'eq' and 'ne' operators agree with diff that the strings are
> > different.  But at least visually the two texts being compared are
> > identical, and if I copy and paste the results from Firefox into
> > TextPad and then run "compare files", it says they're identical.
> 
> Run the two strings through
> 
> sub nicehex {
>   my $s = $_[0];
> ...


Noone's perfect. Here is a correct version, that one cut off the last 
few characters.

sub nicehex {
  my $s = $_[0];
  my $hex = unpack 'H*', $s;
  $s =~ tr/\x00-\x0A/./;
  $hex =~ s/(..)/$1 /g;

  my @hex = ($hex =~ /(.{1,47}) /g);
  my @s = ($s =~ /(.{1,16})/g);

  $hex[-1] .= ' ' x (47 - length($hex[-1]));

  my $res = '';
  while (@s) {
    $res .= shift(@hex) . '   |' .shift(@s) . "\n";
  }
  return $res;
}

Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to