File Coverage

blib/lib/Tie/DataUUID.pm
Criterion Covered Total %
statement 26 26 100.0
branch 2 2 100.0
condition 2 3 66.6
subroutine 7 7 100.0
pod n/a
total 37 38 97.3


line stmt bran cond sub pod time code
1             package Tie::DataUUID;
2              
3 4     4   53345 use strict;
  4         9  
  4         186  
4 4     4   23 use vars qw($VERSION @ISA);
  4         7  
  4         262  
5              
6 4     4   4687 use Tie::Scalar;
  4         3609  
  4         196  
7             @ISA = qw(Tie::StdScalar);
8              
9             $VERSION = "1.02";
10              
11 4     4   3944 use Data::UUID;
  4         22854  
  4         1007  
12              
13             =head1 NAME
14              
15             Tie::DataUUID - tie interface to Data::UUID;
16              
17             =head1 SYNOPSIS
18              
19             use Tie::DataUUID;
20             tie my $uuid, "Tie::DataUUID";
21              
22             print "A uuid is $uuid, another is $uuid\n"
23              
24             =head1 DESCRIPTION
25              
26             A simple tie interface to the B module. Yes, this doesn't
27             do much - it's just me being to lazy when I have to keep creating
28             UUIDs from within strings.
29              
30             To be really totally and utterly lazy you can use the exporting
31             interface that exports the C<$uuid> variable so you don't even have to
32             tie things yourself:
33              
34             use Tie::DataUUID qw($uuid);
35             print "A uuid is $uuid, another is $uuid\n"
36              
37             In both cases the standard UUID string (that looks like
38             'E63E9204-9516-11D8-9C9F-AE87831498F6') are produced.
39              
40             =cut
41              
42             my $datauuid = Data::UUID->new();
43              
44             sub import
45             {
46 4     4   46 my $class = shift;
47              
48 4         14 foreach my $args (@_) {
49             {
50 2 100 66     5 unless (defined $args && $args eq '$'.'uuid') {
  2         23  
51 1         28 die qq{"$args" is not exported by the }.__PACKAGE__.qq{ module\n}
52             }
53              
54 1         2 my $uuid;
55 1         9 tie $uuid, $class;
56 4     4   42 no strict 'refs'; # about to export symbols
  4         16  
  4         584  
57 1         9 *{ caller() . "::uuid" } = \$uuid;
  1         10  
58             }
59             }
60              
61             return
62 3         2110 }
63              
64 8     8   2492 sub FETCH { return $datauuid->create_str }
65              
66             =head1 AUTHOR
67              
68             Written by Mark Fowler Emark@twoshortplanks.comE
69              
70             Copyright Fotango 2004. All Rights Reserved.
71              
72             Copyright Mark Fowler 2009, 2013. All Rights Reserved.
73              
74             This program is free software; you can redistribute it
75             and/or modify it under the same terms as Perl itself.
76              
77             =head1 BUGS
78              
79             Bugs (or feature requests) should be reported via this distribution's
80             CPAN RT queue. This can be found at
81             L
82              
83             You can also address issues by forking this distribution
84             on github and sending pull requests. It can be found at
85             L
86              
87             =head1 SEE ALSO
88              
89             L, L
90              
91             =cut
92              
93             1;