8.3. The Even Better WaySo far, our examples have shown the two-argument form of open, but that actually has a catch: the open mode and the filename both live in the second argument. That means that we have to store two different things in one string, and we have to trust Perl to be able to figure it out. To get around that, we break the second argument into two separate arguments. open my $log_fh, '>>', 'castaways.log' or die "Could not open castaways.log: $!"; This three-argument form has the added advantage of access to the Perl IO filters. We won't go into too much detail here.[*] The open function's entry in perlfunc is over 400 lines, even though it has its own perldoc tutorial, perlopentut.
|