jimsgib...@gmail.com (Jim Gibson) writes: >> On Aug 13, 2017, at 6:02 PM, Harry Putnam <rea...@newsguy.com> wrote: >> >> My aim: >>
[...] >> my @text; >> >> while (<>) { >> if (/$rgx/) { >> print "\n"; >> print wrap(",", @text); >> } >> } >> >> It wasn't at all clear from perldoc Text::Wrap how @text is supposed >> to be populated. > > @text is a list of scalar strings passed to the wrap subroutine. You > can pass a single string also. Try this loop instead: Argh, yes I see > while (<>) { > if (/$rgx/) { > print "\n"; > print wrap(",", $_); > } > } > > It is usually better to use explicit variables: > > while ( my $line = <> ) { > if (/$rgx/) { > print "\n"; > print wrap(",", $line); > } > } Thanks for clearing that up, and the good practices tip. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/