The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

WWW::Mixi::OO::Util - WWW::Mixi::OO's Helper Functions

SYNOPSIS

  use base qw(WWW::Mixi::OO::Util);
  $this->absolute_uri(..., ...);

DESCRIPTION

misc helper functions.

METHODS

absolute_uri
  $util->absolute_uri($uri, [$base]);

Generate absolute URI from base uri. This is simple wrapper for URI class.

relative_uri
  $util->relative_uri($uri, [$base]);

Generate relative URI from base uri. This is simple wrapper for URI class.

remove_tag
  $util->remove_tag($str);

Remove HTML(or XML, or SGML?) tag from string.

extract_balanced_html_parts
  $util->extract_balanced_html_parts(
      ignore_outside => 1,
      element => 'table',
      text => ...);

extract _balanced_ HTML parts from text.

options:

element

element name for balanced check.

text

text to extract.

ignore_outside

ignore nth outside element.

example:

  $util->extract_balanced_html_parts(
      ignore_outside => 1,
      element => 'table',
      text => '<table><table>abc</table><table>cde</table></table>');
  # returns:
  # ('<table>abc</table>', '<table>cde</table>')
exclude_border_element

exclude border element from generate part.

example:

  $util->extract_balanced_html_parts(
      ignore_outside => 1,
      exclude_border_element => 1,
      element => 'table',
      text => '<table><table>abc</table><table>cde</table></table>');
  # returns:
  # ('abc', 'cde')
html_attrs_to_hash
  my %hash = $util->html_attrs_to_hash('href="..."');

or more useful:

  my $case_ignore_hash = $util->generate_ignore_case_hash($util->html_attrs_to_hash('href="..."'));

parse html attributes string to hash.

generate_ignore_case_hash
  my $case_insensitive_hash = $util->generate_ignore_case_hash(%hash);

hash to ignore case hash.

generate_case_preserved_hash

obsolete. renamed to generate_ignore_case_hash

copy_hash_val
  $util->copy_hash_val(\%src_hash, \%dest_hash, qw(foo bar baz));

or

  $util->copy_hash_val(\%src_hash, \%dest_hash, [qw(foo bar)], [qw(baz qux)]);

copy hash value on key exist

regex_parts
  $util->regex_parts->{$foo};

return some regex parts's hashref.

parts:

non_meta

html non-meta char (not ["'<>]).

non_metas

html non-meta chars ($non_meta*).

non_meta_spc

html non-meta-and-spc char (not ["'<> ]).

non_meta_spcs

html non-meta-and-spc chars ($non_meta_spc*).

non_meta_spc_eq

html non-meta-and-spc-eq char (not ["'<> =]).

non_meta_spc_eqs

html non-meta-and-spc-eq chars ($non_meta_spc_eq*).

html_quotedstr_no_paren

html quoted string without grouping paren.

html_quotedstr

html quoted string with grouping.

html_attrval

html attribute value.

html_attr

html attribute

html_maybe_attrs

maybe html attributes found

escape
  $util->escape($str);

equivalent of CGI::escapeHTML.

unescape
  $util->unescape($str);

HTML unescape.

unquote
  $util->unquote($str);

HTML unquote.

rewrite
  $util->rewrite($str);

standard rewrite method. do remove_tag and unescape.

please_override_this
  sub foo { shift->please_override_this }

universal 'please override this' error method.

SEE ALSO

WWW::Mixi::OO

AUTHOR

Topia <topia@clovery.jp>

COPYRIGHT AND LICENSE

Copyright (C) 2005 by Topia.

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.