in reply to Re: Format headers and filehandles
in thread Format headers and filehandles
Hi,
Use this, because with the previous the selected output for any print, write,etc will be DM, not the desired, so:
select( (select (DM), ($- = 0))[0] );
Will select again the previous output you had before calling select, but assigning the $- variable for that filehandle
But better is to use lexical variables as filehandles, in the code it seems like you have a register to asign each time, and write to a list of files, why not something like this:
for my $file (@files) { open my $fh, '<', $file; select(( select($fh), $~ = "DM", $^ = "DM_TOP" )[0] ); # Data adquisition stuff here write $fh; }
By the way take a look at Perl6::Form, it have a lot of improvements, and not these limitations that Perl 5 formats has.
And the why this seems to happen, think it is because the DM is a global symbol, and it doesn't get reset the values automatically because when you close the filehandle the DM symbol is not erased...
Regards,
|
|---|