Michael Vincent
and 1 contributors

NAME

File - Provides routines for working with external files

SYNOPSIS

 use App::PerlShell::Plugin::File;

DESCRIPTION

This module provides useful routines for working with external files.

COMMANDS

File - provide help

Provides help.

file_eval - run Perl commands in file

 [$file | @lines =] file_eval "[[/]path/to/]file" [OPTIONS]

Open and parse provided file of Perl commands. By default, entire file is read and then parsed at once.

  Option     Description                       Default Value
  ------     -----------                       -------------
  argv       Argument string to pass to the    (none)
               @ARGV variable in the file
  file       File (with optional path) to      (none)
               execute.
  line       Parse file line-by-line (1 = on)  (off)
  verbose    Show file content       (1 = on)  (off)

Current directory is searched unless relative or absolute path is also provided.

To pass parameters to a file the argv option can contain a string such as would be present on the command line if the file was called from the command line. For example, a script may take an option switch "-r" and a string option for hostname such as "-h name". The argv option can be used as such:

  file "filename.txt", argv => "-h name -r";

In "filename.txt", the arguments can be processed from @ARGV with standard modules like Getopt::Long.

Note the line option should never be used unless debugging or some other strange and odd situation.

Single option indicates file.

no return

Called alone evals (executes) the file contents.

scalar

Called in scalar context returns the contents to the scalar variable without eval-ing them (similar to file_read).

array

Called in array context returns each file line as an item in the array without eval-ing them (similar to file_read). Note array context forces line option on.

file_read - read contents of a file

 [$file | @lines =] file_read "[[/]path/to/]file"

Open file and return the contents. Current directory is searched unless relative or absolute path is also provided.

no return

Called alone prints contents to screen.

scalar

Called in scalar context returns the contents to the scalar variable.

array

Called in array context returns each file line as an item in the array.

LICENSE

This software is released under the same terms as Perl itself. If you don't know what that means visit http://perl.com/.

AUTHOR

Copyright (c) 2013, 2019 Michael Vincent

http://www.VinsWorld.com

All rights reserved