Term::Clui::FileSelect - Perl module to ask the user to select a file.
use Term::Clui::FileSelect; $file = &select_file(-Readable=>1, -TopDir=>"/home", -FPat=>"*.html"); @files = &select_file(-Chdir=>0, -Path=>$ENV{PWD}, -FPat=>"*.mp3"); chdir &select_file(-Directory=>1, -Path=>$ENV{PWD});
This module asks the user to select a file from the filesystem. It uses the Command-line user-interface Term::Clui to dialogue with the user. It offers Rescan and ShowAll buttons. To ease the re-learning burden for the programmer, the options are modelled on those of Tk::FileDialog and of Tk::SimpleFileSelect, but various new options are introduced, namely -TopDir, -TextFile, -Readable, -Writeable, -Executable, -Owned and -Directory
Multiple choice is possible in a limited circumstance; when file_select is invoked in a list context, with -Chdir=>0 and without -Create. It is currently not possible to select multiple files lying in different directories.
Enable the user to change directories. The default is 1. If it is set to 0, and select_file is invoked in a list context, and -Create is not set, then the user can select multiple files.
Enable the user to specify a file that does not exist. The default is 0.
Determines whether hidden files (.*) are displayed. The default is 0.
Disables the ability of the user to change the status of the ShowAll flag. The default is 0 (i.e. the user is by default allowed to change the status).
If True, enables selection of a directory rather than a file. The default is 0. To enforce selection of a directory, use the -Directory option.
Sets the default file selection pattern, in glob format, e.g. *.html. Only files matching this pattern will be displayed. If you want multiple patterns, you can use formats like *.[ch] or {*.cgi,*.pl} - see File::Glob for more details. The default is "*".
The file selected, or the default file. The default default is whatever the user selected last time in this directory.
The path of the selected file, or the initial path. The default is $ENV{HOME}.
The Title of the dialog box. If -Title is specified, then Clui::FileSelect dynamically appends "in /where/ever" to it. If -Title is not specified, Clui::FileSelect displays "in directory /where/ever".
Restricts the user to remain within a directory or its subdirectories. The default is "/". This option, and the following, are not offered by Tk::FileDialog.
Only text files will be displayed. The default is 0.
Only readable files will be displayed. The default is 0.
Only writeable files will be displayed. The default is 0.
Only executable files will be displayed. The default is 0.
Only files owned by the current user will be displayed. This is useful if the user is being asked to choose a file for a chmod or chgrp operation, for example. The default is 0.
Only directories will be displayed. The default is 0.
Three problem filenames will, if present in your file-system, cause confusion. They are Create New File, Show DotFiles and Hide DotFiles
Original author:
Peter J Billam www.pjb.com.au/comp/contact.html
Current maintainer:
Graham Ollis
Based on an old Perl4 library, filemgr.pl, with the options modelled after Tk::FileDialog and Tk::SimpleFileSelect.
http://www.pjb.com.au/ , http://search.cpan.org/~pjb , File::Glob , Term::Clui , Tk::FileDialog , Tk::SimpleFileSelect , perl(1) .