in reply to Eliminating substr warnings
You know that your usage is ok, so there's no objection to just turning off the warning. I'll show a trick for eliminating some temporary variables, too.
If you want nondestructive treatment of $string, you can make a copy inside the curlies and work on that.my @substrings; { my $size = 10; no warnings 'substr'; push @substrings, substr($string, 0, $size, '') while $string; }
Update: Here's yet another way to do it in 5.8+,
my @substrings = do { local $/ = \10; open my $fh, '<', \$string; <$fh> };
After Compline,
Zaxo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re^2: Eliminating substr warnings
by merlyn (Sage) on Aug 13, 2004 at 00:56 UTC | |
by GreyGlass (Sexton) on Aug 13, 2004 at 15:34 UTC |