File Manipulation

Let’s explore other ways of manipulating files besides reading and writing.

Besides reading and writing files, we can also manipulate them as we would directly from a command line or a file manager.

File test operators

The file test operators, collectively called the -X operators, examine file and directory attributes. To test that a file exists, try this:

Press + to interact
main.pl
some_file
my $filename = 'some_file';
#...
say 'Present!' if -e $filename;
  • The -e operator has a single operand, either the name of a file ...

Get hands-on with 1400+ tech skills courses.