Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

substitute tabs

Status
Not open for further replies.

ryancomps

Programmer
Jan 17, 2003
18
0
0
IE
I don't know if this is possible but I hope someone can help me.

I have a file read into an array. I want to replace every occurance of a tab (\t) with a space. Is there a pattern that represents a tab?

foreach $line (@program)
{
$line =~ s/TAB-PATTERN/ /g;
}

Thanks in advance

Ryan
 
I thought the same but it doesn't seem to work.
 
[tt]\t[/tt] would work if the file really does contain tabs. Many text editors, though, replace tabs with appropriate numbers of spaces, so you would also want to replace multiple spaces with a single space:

[tt]$line =~ s/\s+/ /g;[/tt]
(this would replace tabs as well)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top