<div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="gmail_quote"><div>The reason why I need the open statement is in the loop -- I need to print a selected portion of the content *<b>of each loop</b>*. If I don't do it this way and open outside the loop instead, I'll get the portion only from the first loop.</div>
<div><br></div></div>Think of double loop here, where content() maybe the foreach loop that you gave.<div><br></div></blockquote><div><br>That doesn't seem to be a problem to me, given my understanding of what you describe.<br>
<br>Imagine content() takes a parameter $i, and returns a list of lines, which you want the 10-20 range of lines printed to STDOUT. (It takes $i as a param just so that any given run of content() isn't the same, let's say.)<br>
<br><div style="margin-left: 40px;"><span style="font-family: courier new,monospace;">foreach my $i ( 'a' .. 'z' ) {</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> open TEST "|sed -n '10,20p'";</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;"> print TEST content($i);</span><br style="font-family: courier new,monospace;"><span style="font-family: courier new,monospace;"> close TEST;</span><br style="font-family: courier new,monospace;">
<span style="font-family: courier new,monospace;">} # foreach</span><br style="font-family: courier new,monospace;"></div><br>So now each time you call content you'll print lines 10-20 of its return value to STDOUT.<br>
<br><br></div></div>