Reprocessing the same file

Is it possible to open, cycle, close, re-open the same file as in:

(But I want to wrap paragraphs, sep by double space, not just lines)

$columns = 37;
use Text::Wrap;
$Text::Wrap::columns= $columns;

open(file from command line)
open(tempfile1)
open(tempfile2)

while (<file>) {
$_=wrap(q(),q(),$_);
print file;
} continue { close ARGV if eof }

open(file from command line)

while (<file>) {
if ($.%4==2) {$_ .= qq(\n).(q(-) x $columns).qq(\n)}
elsif ($.%4==0) {$_ .= qq(\n).(q(=) x $columns).qq(\n)}
else {$_ .= qq(\n)};
print file;
} continue { close ARGV if eof }
delete (tempfile1)
delete (tempfile2)



- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]
vjp2.at [ Do, 08 Februar 2007 15:38 ] [ ID #1623395 ]

Re: Reprocessing the same file

My PC version is 4.0M4 by Okahata (GNU/DOS) Patchlevel 32.

Does that include Text:Wrap?


- = -
Vasos Panagiotopoulos, Columbia'81+, Reagan, Mozart, Pindus, BioStrategist
http://ourworld.compuserve.com/homepages/vjp2/vasos.htm
---{Nothing herein constitutes advice. Everything fully disclaimed.}---
[Homeland Security means private firearms not lazy obstructive guards]
[Urb sprawl confounds terror] [Remorse begets zeal] [Windows is for Bimbos]
vjp2.at [ Do, 08 Februar 2007 16:10 ] [ ID #1623398 ]

Re: Reprocessing the same file

vjp2.at [at] at.BioStrategist.dot.dot.com wrote:
> Is it possible to open, cycle, close, re-open the same file:

Yes.
my $filename = shift or die "$0: Input file name not specified";
open my $file,'<',$filename or die "$0: Cannot read $filename: $!\n";
while(<$file>) {
do something with $_;
}
open my $file,'<',$filename or die "$0: Cannot read $filename: $!\n";
while(<$file>) {
do something with $_;
}

Note that {close ARGV if eof} is not appropriate here.



> (But I want to wrap paragraphs, sep by double space, not just lines)

You need to look up $/ in 'perldoc perlvar', and pay special
attention to what it does when set to the null string.

> open(file from command line)
> open(tempfile1)
> open(tempfile2)

That's not perl code.
Do you not know the syntax for open() ?
It's like trying to run before you've learned how to crawl.
You really need to learn the basics, not expect us to spoon feed you.

-Joe
Joe Smith [ Do, 08 Februar 2007 19:41 ] [ ID #1623405 ]
Perl » alt.perl » Reprocessing the same file

Vorheriges Thema: Stick Lines and Dividers Between Text
Nächstes Thema: big problem ahead