[boulder.pm] hash for multiple filehandles?
Robert L. Harris
Robert.L.Harris at rnd-consulting.com
Wed Jul 19 13:09:03 CDT 2000
I'm finally getting to try this. I'm using an associative array though.
I have this roughly:
use Symbol ();
my (%Handle)=Symbol::gensym();
foreach $i (keys(%Records)) {
$Handle{$i}="OUT"."$i";
open($Handle{$i}, ">$Out.$i") || die "Can't open Outputfile $Out.$i :$!:\n";
}
if ($Handle{$RecNum} eq "T") {
print $Handle{$i} "$Line\n";
}
foreach $i (keys(%Records)) {
open($Handle{$i}, ">$Out.$i") || die "Can't open Outputfile $Out.$i :$!:\n";
close($Handle{$i});
system("$CHMOD 0775 $Out.$i");
}
I'm getting this:
String found where operator expected at ./DefMungeSplit.pl line 219, near "}
"$Line\n"" (#1)
(S) The Perl lexer knows whether to expect a term or an operator. If it
sees what it knows to be a term when it was expecting to see an operator,
it gives you this warning. Usually it indicates that an operator or
delimiter was omitted, such as a semicolon.
(Missing operator before "$Line\n"?)
and 219 is the "print $Handle{$i}...." line...
Thoughts?
Robert
Thus spake Rob Nagler (nagler at bivio.com):
> > I have a very large file. it has about 30 record types. We currently
> > use about 15 of those. Right now, I open 15 filehandles, manucally,
> > have 15 print statements, and 15 closes. There has got to be a
> > better way.
>
> use Symbol ();
> my($foo) = Symbol::gensym();
> open($foo, ">hello") || die;
> (print $foo "hello\n") || die;
> close($foo) || die;
>
> I believe Symbol is a standard perl library.
>
> Rob
:wq!
---------------------------------------------------------------------------
Robert L. Harris | Micros~1 :
Senior System Engineer | For when quality, reliability
at RnD Consulting | and security just aren't
\_ that important!
DISCLAIMER:
These are MY OPINIONS ALONE. I speak for no-one else.
FYI:
perl -e 'print $i=pack(c5,(41*2),sqrt(7056),(unpack(c,H)-2),oct(115),10);'
More information about the Boulder-pm
mailing list