Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How do I replace \t and regarding to the alignment requirement ?

by Corion (Patriarch)
on Apr 19, 2012 at 13:34 UTC ( [id://965955]=note: print w/replies, xml ) Need Help??


in reply to How do I replace \t and regarding to the alignment requirement ?

Searching for tab expand and tabs only yields the expand and unexpand programs in ppt. They even do seem to support arbitrary tab stops. I would look at ripping the code out of one of these, as there doesn't seem to be a Text:: module that provides that functionality.

Aaahah. Searching for tabstop finds Text::Format, which claims to have ->expand as a subroutine.

Replies are listed 'Best First'.
Re^2: How do I replace \t and regarding to the alignment requirement ?
by PerlOnTheWay (Monk) on Apr 19, 2012 at 13:49 UTC
    expand blindly replaces 1 tab with 8 spaces,so it's not fit for this task...

      Weird - at least this version of expand works for me, and the source code suggests that it should work just as it does:

      Q:\>copy con test.txt blah a blah ^Z 1 file(s) copied. Q:\>perl -w expand.pl test.txt blah a blah Q:\>perl -w expand.pl test.txt|perl -ple "s!\t!x!g" blah a blah Q:\>perl -w expand.pl test.txt|perl -ple "s! !_!g" blah____a_______blah Q:\>type test.txt|perl -ple "s! !_!g" blah a blah

      If expand is not working for you, maybe the code I linked to does work for you and you can reuse that?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://965955]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-04-18 11:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found