in reply to how to shorten given string?
The answer to that question depends entirely on what you consider to be the significant portion of the original string; the portion that you can't afford to lose.
Your example script attempts to just truncate the source string at 20 characters. You can do that quickly like this:
my $short_string = substr $_, 0, 20;
But that truncates your string to become: "Ipod batteries for A". Are you ok with that? Or do you need to define a more complex set of rules as to how the original string should be shortened?
Dave
|
|---|