Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
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

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?
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 making s'mores by the fire in the courtyard of the Monastery: (7)
As of 2016-10-01 17:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?






    Results (2 votes). Check out past polls.