Brandon Prudent > MiscUtils-1.0.0 > MiscUtils

Download:
MiscUtils-1.0.0.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 1.0.0   Source  

NAME ^

MiscUtils - Miscellanous Utitlies. Provided in hopes that you will add your own functions.

SYNOPSIS ^

    use MiscUtils;

    print rindent(4).'I am 4 tabs over!';

    mkdirs('/xtra/shared/mp3s/by/author/m/mo/mono/life_in_mono.mp3');

    # hypothetical - see discussion below
    this_useful_function_I_wrote_and_use_constantly ('I added it in myself');

DESCRIPTION ^

MiscUtils is a collection of utility functions I found myself using in alot of my scripts. Then I thought it would be better to just throw them all into one huge unrelated, incoherant module. Then I thought it would be good to share with the world. Then I thought the world would benifit even more if they threw in thier own functions they constantly use.

DISCLAIMER

This module is mostly provided as a means of making quick hacks quicker. For a serious or distributed script you should not rely on or require anyone to have this module. To get the functions out of this module into your serious or distributed scripts, just cut and paste directly into your script or module(s). The module is nothing special, so don't be afraid to hack it up.

PROVIDED FUNCTIONS ^

rindent

Returns x number of tabs.

Arguments

  1. The number of spaces to indent.

Returns: (string) argument number of tabs

Example: print rindent(4).'I am 4 tabs over!';

indent

Prints onto a filehandle or stdout x number of tabs.

Arguments

  1. The number of spaces to indent.
  2. A reference to a filehandle [optional] [default:STDOUT]

Returns: nothing

Example: indent(4); print "I am 4 tabs over!\n";

mkdirs

Makes the directories specified in the path.

Arguments

  1. The full file/path name to be made if it does not exist.

Returns: 1 upon success, 0 upon failure.

Example: if (mkdirs('/xtra/shared/mp3s/by/author/m/mo/mono/life_in_mono.mp3')) { # /xtra/shared/mp3s/by/author/m/mo/mono/ will definitaly exist. }

swap_dirs

Simplify relative path, path blending.

Arguments

  1. The full file/path name
  2. The first part of the path that will be swapped.
  3. The first part of the path that you want to swap with.

Returns: The new path.

Example: print swap_dirs('/publicwww/oldsite/index.php', '/publicwww/', 'http://lackluster.tzo.com:1024/'); # prints http://lackluster.tzo.com:1024/oldsite/index.php

debug

Debug (pretty print) array ref, hash ref, or scalar. Not as cool as Data::Dumper

Arguments

  1. The item to be debugged. Arrays and Hashes must be in reference form.
  2. Variable/Output name.
  3. Indentation level [optional|internal]

Returns: nothing

Example: my @words = qw(a ab abc abcd); debug (\@words, 'my words');

filter_text

Transforms non-XML-data elements to useful stoarge.

Arguments

  1. Text to transform.

Returns: Transformed Text.

Example: print $some_var_with_smart_quotes_and_punctuation;

BUGS ^

Uh.... are you sure they aren't yours? Let me know if you find any.

AUTHOR ^

BPrudent (Brandon Prudent)

email: xlacklusterx@hotmail.com

syntax highlighting: