I am trying to truncate a string so that it is only 39 characters long.
The application is a label printing routine, and the label is only long
enough to print 39 characters.
 
I tried this (and many iterations), but it returns the entire string
every time.
 
Can anyone see what I'm doing wrong, or maybe suggest a better way?
 
use strict;
use warnings;

my $txt = 'This is a string that is longer than thirty nine characters
used for testing.';
print "\nRunning a test of grabbing the 1st 39 characters of a
string.\n";
print "Test string.....: $txt\n";
 
$txt =~ s/^(.{1,39})/$1/;
 
print "Resulting string: $txt\n";

Barry Brevik
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to