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

Re: whitespaces replace with tabs - help needed...

by bm (Hermit)
on Aug 14, 2003 at 15:23 UTC ( #283908=note: print w/replies, xml ) Need Help??

in reply to whitespaces replace with tabs - help needed...

Why re-invent the wheel?
use Text::Tabs; my $tabstop = 4; @lines_with_tabs = unexpand(@lines_without_tabs);
This module is part of (my) core Perl.

Replies are listed 'Best First'.
Re: Re: whitespaces replace with tabs - help needed...
by thelenm (Vicar) on Aug 14, 2003 at 18:12 UTC

    Of course, this doesn't actually substitute each space character with a tab, as the original poster claims to want (whether that's what s/he really wants is an open question :)...

    Also, the my declaration creates a new lexical variable called $tabstop, which doesn't have any effect on the module's behavior. Instead, you can just get rid of the my since $Text::Tabs::tabstop is exported by the module.

    -- Mike

    XML::Simpler does not require XML::Parser or a SAX parser. It does require File::Slurp.
    -- grantm, perldoc XML::Simpler

Re: Re: whitespaces replace with tabs - help needed...
by inelukii (Sexton) on Aug 15, 2003 at 12:38 UTC
    I know we are discussing a Perl solution, but for something like this (and assuming you are using some flavor of linux) you can simply use the existing "expand" utility...

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://283908]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (3)
As of 2018-01-20 07:21 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (226 votes). Check out past polls.