++ed by:
VSESPB MRUIZ

2 PAUSE users

Victor Efimov

open_file(my $f, $filename, %args)

$args{mode} - mode to open, <, > or >> $args{use_filename_encoding} - (TRUE) - encode to binary string, (FALSE) - don't tocuh (already a binary string). Default TRUE $args{file_encoding} or $args{binary} - file content encoding or it's a binary file (mutual exclusive) $args{not_empty} - assert that file is not empty after open

Assertions made (using "confess"):

1) Bad arguments (programmer's error) 2) File is not a plain file 3) File is not a plain file, but after open (race conditions) 4) File is empty and not_empty specified 5) File is empty and not_empty specified, but after open (race conditions)

NOTE: If you want exceptions for (2) and (4) - check it before open_file. And additional checks inside open_file will prevent race conditions