Skip to content

Instantly share code, notes, and snippets.

@sharifulin
Created February 17, 2011 14:10
Show Gist options
  • Select an option

  • Save sharifulin/831781 to your computer and use it in GitHub Desktop.

Select an option

Save sharifulin/831781 to your computer and use it in GitHub Desktop.
Format CRC
warn $self->_format_crc(join('', 'a'..'z'), 17, '...', 4);
sub _format_crc {
my $self = shift;
my $crc = shift;
my $size = shift || 15;
my $miss = shift || '...';
my $end = shift || 4;
my $start = $size - $end - length $miss;
$crc =~ s/^(.{$start}).*(.{$end})$/$1$miss$2/;
return $crc;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment