Re: using (dot) . with printf does not incur the results I expected
Richard wrote: what's wrong w/ this ? I used (dot) . to indicate the maximum length of each element in the print but last one does not print out in alinged format.. What am i missing? use warnings; use strict; my $yabal = 'truncated'; my $never = 'sai'; my $noway = 'han1'; my %never = qw(hi how are you today fine i am good and everyday12345678 never12345689); printf "%-.5s %-15s %-.2s\n", $yabal, $never, $noway; for (keys %never) { printf "%.2s %.10s\n", $_, $never{$_}; It looks like you want this instead: printf "%-2.2s %-10.10s\n", $_, $never{$_}; } r...@myserver ~> ././yahoo2 trunc sai ha hi how go and to fine ar you ev never12345 i am John -- Those people who think they know everything are a great annoyance to those of us who do.-- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
Re: using (dot) . with printf does not incur the results I expected
Richard wrote: what's wrong w/ this ? I used (dot) . to indicate the maximum length of each element in the print but last one does not print out in alinged format.. What am i missing? use warnings; use strict; my $yabal = 'truncated'; my $never = 'sai'; my $noway = 'han1'; my %never = qw(hi how are you today fine i am good and everyday12345678 never12345689); printf "%-.5s %-15s %-.2s\n", $yabal, $never, $noway; for (keys %never) { printf "%.2s %.10s\n", $_, $never{$_}; } r...@myserver ~> ././yahoo2 trunc sai ha hi how go and to fine ar you ev never12345 i am I guess I was missing the 2.2 option... my %never = qw(hi how are you today fine i am good and everyday12345678 never12345689); for (keys %never) { printf "%-2.2s %-10.10s\n", $_, $never{$_}; } r...@myserver ~> ./!$ ././yahoo2 trunc sai ha hi how go and to fine ar you ev never12345 i am -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/
using (dot) . with printf does not incur the results I expected
what's wrong w/ this ? I used (dot) . to indicate the maximum length of each element in the print but last one does not print out in alinged format.. What am i missing? use warnings; use strict; my $yabal = 'truncated'; my $never = 'sai'; my $noway = 'han1'; my %never = qw(hi how are you today fine i am good and everyday12345678 never12345689); printf "%-.5s %-15s %-.2s\n", $yabal, $never, $noway; for (keys %never) { printf "%.2s %.10s\n", $_, $never{$_}; } r...@myserver ~> ././yahoo2 trunc sai ha hi how go and to fine ar you ev never12345 i am -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/