}
+void str_analyze_C( const char *string )
+{
+ /* Martin A. Hansen, July 2009 */
+
+ /* Scans a string incrementing the char count in an array. */
+
+ int count[ 256 ] = { 0 }; /* Integer array spanning the ASCII alphabet */
+ int i;
+
+ for ( i = 0; i < strlen( string ); i++ ) {
+ count[ ( int ) string[ i ] ]++;
+ }
+
+ Inline_Stack_Vars;
+ Inline_Stack_Reset;
+
+ for ( i = 0; i < 256; i++ ) {
+ Inline_Stack_Push( sv_2mortal( newSViv( count[ i ] ) ) );
+ }
+
+ Inline_Stack_Done;
+}
+
+
END_C
$file_max = length "File";
$line_max = length "Line";
- if ( $line =~ /^ at (.+) line (\d+)$/ )
+ if ( $line =~ /^ at (.+) line (\d+)\.?$/ )
{
$file = $1;
$line_no = $2;
}
+sub str_analyze
+{
+ # Martin A. Hansen, July 2009.
+
+ # Analyzes the string composition of a given string.
+
+ my ( $str, # string to analyze
+ ) = @_;
+
+ # Returns hash
+
+ my ( @composition, %hash, $i );
+
+ @composition = Maasha::Common::str_analyze_C( $str );
+
+ for ( $i = 32; $i <= 126; $i++ ) { # Only include printable chars
+ $hash{ chr $i } = $composition[ $i ]
+ }
+
+ return wantarray ? %hash : \%hash;
+}
+
+
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
1;