WWW::URLToys - gather and download URLs from URLs
use WWW::URLToys qw/:DEFAULT ut_command_loop/; my @utlist; $SIG{'INT'} = 'ut_stop_download'; if(@ARGV > 0) { my $initial_command = join ' ',@ARGV; ut_exec_command($initial_command,\@utlist); }; ut_command_loop(*STDIN,\@utlist);
WWW::URLToys is a separation of the program URLToys into its core code (this module), and the programs that use it (urltoys and urltoysw). This module has been made available via CPAN to allow others to use URLToys commands on their Perl arrays, and to create interfaces for URLToys that far surpass those of the original creator.
@result = ut_exec_command("make",\@somearray);
Exported by default, this command runs any single URLToys command on a list, and returns the list that the command would expect it to return.
ut_command_loop($filepointer,\@list);
This will execute a string of commands from any file pointer. If the file pointer is the standard input, it will prompt the user to type in commands with the URLToys command prompt.
ut_stop_download();
This command will stop a download. Useful for stopping a command while inside a callback or Tk callback (if you use a GUI).
loadconfig("filename");
Loads a URLToys configuration from a file.
saveconfig("filename");
Saves the current URLToys configuration to a file.
All callbacks are set via the %ut_callback hash. Setting any of the keywords for the callbacks to a sub of your own, you override the callback and receive it instead. All of them are sent 3 variables: which callback, value1, and value2.
An example:
sub print_text { my ($type,$text,$ignored) = @_; print $text; }; $ut_callback{'print'} = \&print_text;
Here is a list of them:
Callback Description Calls by Default Value 1 Value 2 print Called with the 'print' command cb_tty text to print Ignored extra Things that can safely be ignored cb_tty text to print Ignored help Syntax Help cb_tty text to print Ignored error Error Messages cb_tty text to print Ignored action Explains the current action cb_ignore Current action text Ignored makeupdate Text explaining what 'make' is doing cb_tty text to print Ignored dlbeat Sent when download of unknown size gets data cb_dlbeat Ignored Ignored dlupdate Text explaining what 'get' is doing cb_tty text to print Ignored output Regular output Text by program cb_tty text to print Ignored title Sets the title of the window cb_title text for window title Ignored warnuser BADFLUX: Returns 1 on allow, 0 on no allow cb_warnuser ref to array of bad cmds Ignored variable Updates a variable to the main script cb_ignore variable name value of variable complete When a get or resume finishes cb_ignore directory that finished Ignored begin When a get or resume starts cb_ignore directory its coming to Ignored
The return value of the callbacks are ignored except the "warnuser" one, which is to warn a user on a potentially bad flux. It's very important that this returns a 0 if the user does not wish to run the flux! You must override this if you create a GUI flux. Please see urltoysw for an example.
$config_file $config_useragent $config_ext_regex $config_ext_ignore $config_custom_headers $config_href_regex $config_img_regex $config_prompt $config_name_template $config_save_url_list $config_explain_regex_error $config_useundo $config_use_xttitle $config_pausetime $config_downloaddir $config_dirslashes $config_seq_warning_size $config_proxy
These are all given by the EXPORT tag "configvars", except $config_file, which is exported by default.
As of yet the actions returned by the action callback, and the variables set by the 'variable' callback are undocumented.
To install WWW::URLToys, copy and paste the appropriate command in to your terminal.
cpanm
cpanm WWW::URLToys
CPAN shell
perl -MCPAN -e shell install WWW::URLToys
For more information on module installation, please visit the detailed CPAN module installation guide.