Changeset 8948 for lang/perl/Acme-DRYCopyPaste
- Timestamp:
- 04/06/08 01:29:16 (8 months ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/Acme-DRYCopyPaste/trunk/lib/Acme/DRYCopyPaste.pm
r8922 r8948 9 9 my $self = {}; 10 10 bless $self, $class; 11 return $self; 12 } 13 14 sub synopsys { 15 my $self = shift; 16 17 my $code = `perldoc -m $self->{module_name}`; 18 my $start 19 = index( $code, "\n=head1 SYNOPSIS" ) + length("\n=head1 SYNOPSIS"); 20 my $end = index( $code, "\n=", $start + 1 ); 21 my $scrape = substr( $code, $start, $end - $start ); 22 $self->{scrape} = $scrape; 11 23 return $self; 12 24 } … … 24 36 my $to = shift; 25 37 26 my $code = `perldoc -m $self->{module_name}`;27 my @data = split( "\n", $code );38 my $code = `perldoc -m $self->{module_name}`; 39 my @data = split( "\n", $code ); 28 40 my $scrape = ''; 29 for ( my $i = $from - 1 ; $i < $to; $i++ ) {41 for ( my $i = $from - 1; $i < $to; $i++ ) { 30 42 $scrape .= $data[$i] . "\n"; 31 43 } … … 37 49 my $self = shift; 38 50 eval( $self->{scrape} ); 51 warn $@; 39 52 } 40 53 41 54 1; 55 42 56 =head1 NAME 43 57 … … 49 63 my $d = Acme::DRYCopyPaste->new(); 50 64 $d->module('Perl6::Say')->copy( 50, 52)->paste(); 65 $d->synopsys->paste(); # it works but Perl6::Say SYNOPSYS generate error. 51 66 52 67 =head1 DESCRIPTION
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)