techm has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

I tried everything before posting this ... so here it goes. I'm using a ClearCase::CtCmd module to work with ClearCase instead of a command line tool.

Here's a snippet: my ($res, $txt, $err) = $ct->exec("$lspvob"); In this case $txt results in a pretty big string with newlines. So I want to filter every line so I used (it's in Q&A section): my $fh = new FileHandle("printf \'$txt\' |") or die; Oddly:

print $txt; # prints the text as expected. while (<$fh>){ # prints only part of the text. print $_; }
Any idea why is this happeining? Or any other way to filter the lines or create an array that contains all of the lines?

Thanks in advance!

Edit by dws to add <code> tags

Edit kudra, 2002-08-28 Changed title

Replies are listed 'Best First'.
Re: strings again
by dws (Chancellor) on Aug 27, 2002 at 21:55 UTC
    In this case $txt results in a pretty big string with newlines. So I want to filter every line ...

    If $txt is a big string with embedded newlines, then why are you using it to open a filehandle?

    Wouldn't

    foreach my $line ( split("\n", $txt) ) { # do something to filter $line }
    do what you need?

Re: strings again
by Aristotle (Chancellor) on Aug 27, 2002 at 22:03 UTC
    Quick note on style: the quotes in my ($res, $txt, $err) = $ct->exec("$lspvob"); aren't necessary. This is Perl, not a shell script.

    Makeshifts last the longest.

Re: strings again
by techm (Initiate) on Aug 27, 2002 at 22:15 UTC
    Oh thanks, that did the trcik - I'm almost sure I tried something like this before ... well ... thanks again!