View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Mark Fowler > Clone-AsUTF8Bytes > Clone::AsUTF8Bytes



Annotate this POD

View/Report Bugs
Module Version: 0.34   Source  


Clone::AsUTF8Bytes - recursively copy Perl data converting to UTF-8 bytes


  package Foo;
  use parent 'Clone::AsUTF8Bytes';

  package main;
  my $original = Foo->new;
  $copy = $original->clone_as_utf8_bytes;
  # or

  use Clone::AsUTF8Bytes qw(clone_as_utf8_bytes);
  $a = { 'M\x{f8}\x{f8}se' => "\x{1F44D}" };
  $b = [ "L\x{e9}on', "\N{SNOWMAN}" ];
  $c = Foo->new;

  $d = clone_as_utf8_bytes($a);
  $e = clone_as_utf8_bytes($b);
  $f = clone_as_utf8_bytes($c);


This module provides a clone_as_utf8_bytes() method which makes recursive copies of nested hash, array, scalar and reference types, including tied variables and objects, modifying the characters in the strings as it does so into UTF-8 bytes. For example the Perl string L\x{e9}on in the data strucutre will be converted to the string L\x{c3}\x{a9}on.

clone_as_ut8_bytes() takes a scalar argument and duplicates and modifies it. To duplicate lists, arrays or hashes, pass them in by reference. e.g.

    my $copy = clone (\@array);

    # or

    my %copy = %{ clone (\%hash) };


This module is essentially the Clone module slightly altered to do the utf-8 byte conversion.


Copyright 2013 OmniTI. All Rights Reserved.

Majority of code in this module copyright 2001-2012 Ray Finch. All Rights Reserved.

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


Coversion from Clone to Clone::AsUTF8Bytes was performed by Mark Fowler. <>.

Original Clone module - which makes up the overall majority of the module - was written by Ray Finch <>. Breno G. de Oliveira <> and Florian Ragwitz <> performed routine maintenance releases on the Clone module since 2012.

syntax highlighting: