Server IP : 103.119.228.120 / Your IP : 18.188.101.251 Web Server : Apache System : Linux v8.techscape8.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : nobody ( 99) PHP Version : 5.6.40 Disable Function : shell_exec,symlink,system,exec,proc_get_status,proc_nice,proc_terminate,define_syslog_variables,syslog,openlog,closelog,escapeshellcmd,passthru,ocinum cols,ini_alter,leak,listen,chgrp,apache_note,apache_setenv,debugger_on,debugger_off,ftp_exec,dl,dll,myshellexec,proc_open,socket_bind,proc_close,escapeshellarg,parse_ini_filepopen,fpassthru,exec,passthru,escapeshellarg,escapeshellcmd,proc_close,proc_open,ini_alter,popen,show_source,proc_nice,proc_terminate,proc_get_status,proc_close,pfsockopen,leak,apache_child_terminate,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,dl,symlink,shell_exec,system,dl,passthru,escapeshellarg,escapeshellcmd,myshellexec,c99_buff_prepare,c99_sess_put,fpassthru,getdisfunc,fx29exec,fx29exec2,is_windows,disp_freespace,fx29sh_getupdate,fx29_buff_prepare,fx29_sess_put,fx29shexit,fx29fsearch,fx29ftpbrutecheck,fx29sh_tools,fx29sh_about,milw0rm,imagez,sh_name,myshellexec,checkproxyhost,dosyayicek,c99_buff_prepare,c99_sess_put,c99getsource,c99sh_getupdate,c99fsearch,c99shexit,view_perms,posix_getpwuid,posix_getgrgid,posix_kill,parse_perms,parsesort,view_perms_color,set_encoder_input,ls_setcheckboxall,ls_reverse_all,rsg_read,rsg_glob,selfURL,dispsecinfo,unix2DosTime,addFile,system,get_users,view_size,DirFiles,DirFilesWide,DirPrintHTMLHeaders,GetFilesTotal,GetTitles,GetTimeTotal,GetMatchesCount,GetFileMatchesCount,GetResultFiles,fs_copy_dir,fs_copy_obj,fs_move_dir,fs_move_obj,fs_rmdir,SearchText,getmicrotime MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/ssl/local/ssl/share/perl5/vendor_perl/Pod/Perldoc/ |
Upload File : |
package Pod::Perldoc::GetOptsOO; use strict; use vars qw($VERSION); $VERSION = '3.20'; BEGIN { # Make a DEBUG constant ASAP *DEBUG = defined( &Pod::Perldoc::DEBUG ) ? \&Pod::Perldoc::DEBUG : sub(){10}; } sub getopts { my($target, $args, $truth) = @_; $args ||= \@ARGV; $target->aside( "Starting switch processing. Scanning arguments [@$args]\n" ) if $target->can('aside'); return unless @$args; $truth = 1 unless @_ > 2; DEBUG > 3 and print " Truth is $truth\n"; my $error_count = 0; while( @$args and ($_ = $args->[0]) =~ m/^-(.)(.*)/s ) { my($first,$rest) = ($1,$2); if ($_ eq '--') { # early exit if "--" shift @$args; last; } if ($first eq '-' and $rest) { # GNU style long param names ($first, $rest) = split '=', $rest, 2; } my $method = "opt_${first}_with"; if( $target->can($method) ) { # it's argumental if($rest eq '') { # like -f bar shift @$args; $target->warn( "Option $first needs a following argument!\n" ) unless @$args; $rest = shift @$args; } else { # like -fbar (== -f bar) shift @$args; } DEBUG > 3 and print " $method => $rest\n"; $target->$method( $rest ); # Otherwise, it's not argumental... } else { if( $target->can( $method = "opt_$first" ) ) { DEBUG > 3 and print " $method is true ($truth)\n"; $target->$method( $truth ); # Otherwise it's an unknown option... } elsif( $target->can('handle_unknown_option') ) { DEBUG > 3 and print " calling handle_unknown_option('$first')\n"; $error_count += ( $target->handle_unknown_option( $first ) || 0 ); } else { ++$error_count; $target->warn( "Unknown option: $first\n" ); } if($rest eq '') { # like -f shift @$args } else { # like -fbar (== -f -bar ) DEBUG > 2 and print " Setting args->[0] to \"-$rest\"\n"; $args->[0] = "-$rest"; } } } $target->aside( "Ending switch processing. Args are [@$args] with $error_count errors.\n" ) if $target->can('aside'); $error_count == 0; } 1; __END__ =head1 NAME Pod::Perldoc::GetOptsOO - Customized option parser for Pod::Perldoc =head1 SYNOPSIS use Pod::Perldoc::GetOptsOO (); Pod::Perldoc::GetOptsOO::getopts( $obj, \@args, $truth ) or die "wrong usage"; =head1 DESCRIPTION Implements a customized option parser used for L<Pod::Perldoc>. Rather like Getopt::Std's getopts: =over =item Call Pod::Perldoc::GetOptsOO::getopts($object, \@ARGV, $truth) =item Given -n, if there's a opt_n_with, it'll call $object->opt_n_with( ARGUMENT ) (e.g., "-n foo" => $object->opt_n_with('foo'). Ditto "-nfoo") =item Otherwise (given -n) if there's an opt_n, we'll call it $object->opt_n($truth) (Truth defaults to 1) =item Otherwise we try calling $object->handle_unknown_option('n') (and we increment the error count by the return value of it) =item If there's no handle_unknown_option, then we just warn, and then increment the error counter =back The return value of Pod::Perldoc::GetOptsOO::getopts is true if no errors, otherwise it's false. =head1 SEE ALSO L<Pod::Perldoc> =head1 COPYRIGHT AND DISCLAIMERS Copyright (c) 2002-2007 Sean M. Burke. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This program is distributed in the hope that it will be useful, but without any warranty; without even the implied warranty of merchantability or fitness for a particular purpose. =head1 AUTHOR Current maintainer: Mark Allen C<< <mallen@cpan.org> >> Past contributions from: brian d foy C<< <bdfoy@cpan.org> >> Adriano R. Ferreira C<< <ferreira@cpan.org> >>, Sean M. Burke C<< <sburke@cpan.org> >> =cut