
7stud
Enthusiast
Jan 31, 2010, 7:00 PM
Post #2 of 3
(2338 views)
|
I think the number of spaces in a tab is set by the user, i.e. it's system dependent. Whether perl is able to change the system's setting, I don't know. But I'm left wondering why anything like that would be necessary when you can write one line of perl code to replace the tabs in a string with four spaces.
use strict; use warnings; use 5.010; my $str = "Hello\tworld"; my $replacement = ' ' x 4; $str =~ s/\t/$replacement/; say '123456789012345'; say $str; --output:-- 123456789012345 Hello world
(This post was edited by 7stud on Jan 31, 2010, 7:20 PM)
|