Beefy Boxes and Bandwidth Generously Provided by pair Networks Frank
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

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.
--
bm


Comment on Re: whitespaces replace with tabs - help needed...
Download Code
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?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (7)
As of 2014-04-20 07:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls