BW::Common - Some common utility functions


    use BW::Common
    my $o = BW::Common->new;



Constructs a new BW::Common object.

Returns a blessed BW::Common object reference. Returns undef (VOID) if the object cannot be created.

comma number

Returns a comma-fied string from number.

trim string

Returns the string with leaading and trailing spaces removed

basename string

Returns the string with basename of a filename.

normalize_newlines string

Returns the string with CRs and CRLF pairs normalized to NLs.

readfile filename, [max_length], [layer]

Read a file and return as a string.

max_length is the maximum length to read. It defaults to 1MB (1024 * 1024).

layer is the LAYER string passed to binmode. It defaults to ":raw" (for binary files).


Written by Bill Weinman <>.


Copyright (c) 1995-2010 The BearHeart Group, LLC


    2010-03-08 bw   -- updated basename to work with backslash for MS Win
    2010-02-02 bw   -- first CPAN release
    2009-12-22 bw   -- added readfile
    2009-11-25 bw   -- initial version.