String-Rexx

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

    - Added more tests for fixed functions 


0.03  Thu Jul 30, 2003
    - Corrected Abstract 
    - removed CVS/ entries from manifest

0.02  Thu Jul 30, 2003
    -  This release is institutes stroger refactoring and paramaeter checking:
    -  Added Params::Validate  to center, copies, errortext, left, 
       right, space, verify, insert, lastpos, overlay, wordindex, xrange,
       compare, delstr, d2h, wordlength, word, wordindex, subword, and wordpos.
    -  Added the new fuction abbrev()
    -  wordpos(): on failure, it now returns 0 instead of undef. 
    -  Refactored strip(). Added exceptions and (skipable) exception tests.
    -  These fuctions now count \S sequences as words: words, delword,
       subword.
    -  translate(), changed mandatory options and some funtionality. See pod .


0.01  Tue Jul  8 02:13:19 2003

MANIFEST  view on Meta::CPAN

t/01c_coverage.t
t/01s_spelling.t
t/02_hasversion.t
t/03_meta.t
t/05_minimumversion.t
t/07_strict.t
t/10_right.t
t/10a_main.t
t/11_Pos.t
t/11a_wordlength.t
t/12_overlay.t
t/12a_words.t
t/13_Length.t
t/13a_subword.t
t/14_left.t
t/14a_strip.t
t/15_lastpos.t
t/15a_Substr.t
t/16_insert.t
t/16a_word.t
t/17_delword.t

lib/String/Rexx.pm  view on Meta::CPAN


use base  'Exporter';
#use AutoLoader qw(AUTOLOAD);


our %EXPORT_TAGS = ( 'all' => [ qw(
       centre     center     changestr    compare    copies     countstr 
       delstr     delword    datatype     d2c        b2d        d2x    
       x2b        b2x        x2c          x2d        c2x   
       d2b        errortext  insert       lastpos    left       Length     
       overlay    Pos        right        Reverse    Abbrev     sign
       space      Substr     strip        subword    translate  verify 
       word       wordindex  wordlength   wordpos    words      xrange   
) ] );

our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );

our $VERSION = '0.08';

use constant BINARY        =>  qr/^[01]{0,32}$/;
use constant REAL          =>  $RE{num}{real};

lib/String/Rexx.pm  view on Meta::CPAN

=item left( 'string' , length,   [, 'char']  )

  Returns the leftmost $length chars. If there are not
  enough characters, the string is padded (prepended) with char characters.
  Char defaults to space.

=item Length( 'string' )

 Returns the length of string.

=item overlay( 'source', 'target' [, start] [, length] [, pad]  )

 Overstrikes the $target string, with $source .


=item Reverse( 'string' )

  Reverses the order of characters in string.

=item Pos( 'needle' , 'haystack',   [, start ]  )

lib/String/Rexx.pm  view on Meta::CPAN

                                          { type  => SCALAR              },
                                          { regex => qr/^\+?\s*\d+$/     },
                                          { type  => SCALAR, default=>' '},;

        my $padding = $char  x  (($len||return '') - length $str) ;
        substr( $str,  0,  $len) . $padding ;
}
sub Length ($)  {
       length shift();
}
sub overlay ($$;$$$)  {
      my ($source , $target, $start, $len, $char ) = validate_pos @_ ,
                                       { type  => SCALAR },
                                       { type  => SCALAR },
                                       { regex => qr/^\+?\s*\d+$/ , default => 1            },
                                       { regex => qr/^\+?\s*\d+$/ , default => length $_[0] },
                                       { regex => qr/^.$/         , default => ' '          };

      $source                 .=   $char x ($len-length $source) ;
      substr( $source, $len )  =   ''                            ;
      substr( $target, --$start, (length $source) , $source )    ;

t/12_overlay.t  view on Meta::CPAN

use strict     ;
use Test::More ;
use String::Rexx qw(overlay);
 
BEGIN { plan tests =>  15  };


### Basic Usage
is   overlay( 'YAS',  'The Republic'       )     =>   'YAS Republic'     ;
is   overlay( 'YAS',  'The Republic', 1    )     =>   'YAS Republic'     ;
is   overlay( 'YAS',  'The Republic', 2    )     =>   'TYASRepublic'     ;


is   overlay( 'YAS',  'The Republic', 1, 1 )     =>   'Yhe Republic'     ;
is   overlay( 'YAS',  'The Republic', 1, 2 )     =>   'YAe Republic'     ;
is   overlay( 'YAS',  'The Republic', 1, 3 )     =>   'YAS Republic'     ;
is   overlay( 'YAS',  'The Republic', 1, 5 )     =>   'YAS  epublic'     ;

is   overlay( ''   ,  'The Republic', 1, 1 )     =>   ' he Republic'     ;
is   overlay( ''   ,  'The Republic', 1, 2 )     =>   '  e Republic'     ;

### Extra

is   overlay( 'YAS',  '', 1, 1             )     =>   'Y'                ;
is   overlay( 'YAS',  '', 1, 2             )     =>   'YA'               ;
is   overlay( 'YAS',  '', 1, 4             )     =>   'YAS '             ;
is   overlay( 'YAS',  '', 1, 4, '_'        )     =>   'YAS_'             ;
is   overlay( 'YAS',  '', 1, 5, '_'        )     =>   'YAS__'            ;
is   overlay( 'YAS',  'The Republic', 1, 5, '_') =>   'YAS__epublic'     ;

t/makefile  view on Meta::CPAN

.PHONY: $(shell ls)
.SILENT: 

#all:  00_main.t      01_wordlength.t    02_words.t  
#all:  03_subword.t   04_strip.t         05_Substr.t
#all:  06_word.t      07_verify.t        08_space.t
#all:  09_reverse.t   10_right.t         11_Pos.t  
#all:  12_overlay.t   13_Length.t        14_left.t
#all:  15_lastpos.t   16_insert.t        17_delword.t
#all:  18_delstr.t    19_countstr.t      20_copies.t
#all:  21_compare.t   22_changestr.t     23_center.t
#all:  24_xrange.t    25_wordindex.t     26_translate.t
#all:  27_datatype.t  28_wordpos.t       29_Abbrev.t
#all:  30_b2d.t       31_d2x.t           32_sign.t
#all:  33_x2b.t       34_b2x.t           35_x2c.t
#all:                 37_x2d.t           38_c2x.t
#all:  39_d2b.t       pod.t              pod-coverage.t



( run in 1.300 second using v1.01-cache-2.11-cpan-49f99fa48dc )