DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Snippets has posted 5883 posts at DZone. View Full User Profile

Cutting Of Part Of The Unicode Line

12.01.2006
| 1984 views |
  • submit to reddit
        // description of your code here

sub left_subject{
	my $self=shift;
	my $count=shift;
	use utf8;
	my $topic=$self->subject;
	utf8::decode($topic);
	utf8::upgrade($topic);
	my ($subtopic)=($topic=~/(.{0,$count})/);
#	utf8::decode($subtopic);
	$subtopic=~s/\b\w{1,5}$//;
	utf8::downgrade($subtopic);
	return $subtopic.'...';
}