From: JP <mailto:[EMAIL PROTECTED]> wrote:
: Got it!
:
: $string =~ s/(\S{40}/\1 /g;
You should really consider turning warnings on.
#!/usr/bin/perl -w
or:
use warnings;
: does exactly the trick I need.
There's a typo. The parenthesis doesn't close. When
you post code, try to cut and paste it from the source.
: now I wonder if it is possible to print the resulting
: spaced string without changing $string itself? do I
: really need a temporary variable or is it possible to
: do something like:
:
: print $string s/(\S{4})/\1 /g;
Use a subroutine that returns the value without
affecting the original. Then print the returned value.
print break( $string, 4 );
sub break {
my $copy = shift;
$copy =~ s/(\S{$_[0]})/$1 /g;
return $copy;
}
HTH,
Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>