|
From: alexxx.magni@gmail.com on 16 Nov 2006 05:54 hi people, I need to print to terminal a long $variable containing text, and of course being longer than the terminal width it produces a truncated word that continues on the next line - I'd like to go newline just on spaces... I wrote an approximated version to "prettyprint" it, but it's so awful that I prefer not to show it in public... Do you know of some elegant way to do it? (there should be more than one way...;-) thanks! Alessandro Magni
From: Christian Winter on 16 Nov 2006 06:02 alexxx.magni(a)gmail.com wrote: > hi people, > I need to print to terminal a long $variable containing text, and of > course being longer than the terminal width it produces a truncated > word that continues on the next line - I'd like to go newline just on > spaces... > > I wrote an approximated version to "prettyprint" it, but it's so awful > that I prefer not to show it in public... > > Do you know of some elegant way to do it? (there should be more than > one way...;-) Have a look at the Text::Wrap module. -Chris
From: alexxx.magni@gmail.com on 20 Nov 2006 04:49 thanks! Of course I already had the module installed, and completely forgotten it... I had hope there was an even cleaner way (by some magick regex trick ' '=>'\n' at the appropriate places...) but it's OK enough this way. But, one more small problem: I have to specify manually the number of columns, since the module does not check it by itself. Googling I found just 2 ways to do it: use Text::Wrap qw(wrap $columns); my $columns=`tput cols`; # OR: # $x=`stty -a`;$x=~/columns (\d+)/;$columns=$1; but I dont like neither. Do you know a better way? I tried to use $ENV{COLUMNS} but discovered that this hash value does not exist, during execution - where can I also find the number of columns value? Thanks! Alessandro Christian Winter ha scritto: > alexxx.magni(a)gmail.com wrote: > > hi people, > > I need to print to terminal a long $variable containing text, and of > > course being longer than the terminal width it produces a truncated > > word that continues on the next line - I'd like to go newline just on > > spaces... > > > > I wrote an approximated version to "prettyprint" it, but it's so awful > > that I prefer not to show it in public... > > > > Do you know of some elegant way to do it? (there should be more than > > one way...;-) > > Have a look at the Text::Wrap module. > > -Chris
|
Pages: 1 Prev: how to load 'formats' from a file Next: how to execute 30 transactions at a time |