The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
word wrap issue with grep bowtiextreme HP-UX 4 04-30-2008 07:39 PM
SCO acquisition wrap-up iBot UNIX and Linux RSS News 0 02-19-2008 05:30 PM
Wrap Interactive Script meskue Shell Programming and Scripting 0 06-23-2006 06:21 PM
Should I use sed/ grep/awk for wrap file? vanda_25 Shell Programming and Scripting 6 05-04-2006 12:59 PM
word wrap in vi dangral UNIX for Dummies Questions & Answers 3 10-30-2002 02:45 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2008
trek trek is offline
Registered User
  
 

Join Date: Apr 2008
Location: Austria
Posts: 9
usage of module Text::Wrap;

hi, i want to use module Text::Wrap.
this module provides the option $Text::Wrap::tabstop to change the tabstop from 8 blanks to any nummer.
i want to set it to 30 blanks. but when i change the nummer of blanks nothing happens.

Code:
Text::Wrap::tabstop = 30;
$wtd = wrap("","\t",$1);
or do i have to use another 2nd parameter then tab in wrap() ???

thx
  #2 (permalink)  
Old 06-04-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
What's in $1? The documentation suggests it should be an array of text lines. (You do know that $1 is the string matched by the first set of parentheses of the latest regex match?)
  #3 (permalink)  
Old 06-04-2008
trek trek is offline
Registered User
  
 

Join Date: Apr 2008
Location: Austria
Posts: 9
sure i know what is in $1. after some hours i found out that the function $Text::Wrap:tabstop does not agree with what i tought, but i also don't know what it really does by now.
  #4 (permalink)  
Old 06-05-2008
era era is offline Forum Advisor  
Herder of Useless Cats (On Sabbatical)
  
 

Join Date: Mar 2008
Location: /there/is/only/bin/sh
Posts: 3,652
When text has leading whitespace, it replaces runs of n spaces with a tab character. Normally n should be 8, as that is the hardwired tab width of most terminals, but you can change it to something else if you need to. (I suspect you don't, though.)

The first parameter to wrap says how to indent the first line, and the second parameter says how to indent subsequent lines. If you want them indented by thirty spaces, try " " x 30 for the second parameter.

Code:
vnix$ perl -MText::Wrap -e 'print wrap(""," " x 30, <>)' /etc/motd | head -5
Linux indeed 2.6.24-17-generic #1 SMP Thu May 1 13:57:17 UTC 2008 x86_64
                              
                              The programs included with the Ubuntu system
                              are free software;
                              the exact distribution terms for each program

Last edited by era; 06-05-2008 at 02:11 AM.. Reason: Add example output
Sponsored Links
Closed Thread

Bookmarks

Tags
linux, ubuntu

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 07:00 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0