/[cvs]/nfo/perl/libs/shortcuts.pm
ViewVC logotype

Diff of /nfo/perl/libs/shortcuts.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by joko, Sat Mar 29 07:24:10 2003 UTC revision 1.8 by joko, Fri Apr 4 17:31:59 2003 UTC
# Line 2  Line 2 
2  ##  $Id$  ##  $Id$
3  ## ---------------------------------------------------------------------------  ## ---------------------------------------------------------------------------
4  ##  $Log$  ##  $Log$
5    ##  Revision 1.8  2003/04/04 17:31:59  joko
6    ##  + sub make_guid
7    ##
8  ##  Revision 1.7  2003/03/29 07:24:10  joko  ##  Revision 1.7  2003/03/29 07:24:10  joko
9  ##  enhanced 'run_cmd': now tries to execute program with appropriate application (e.g. 'cmd.exe' or 'perl')  ##  enhanced 'run_cmd': now tries to execute program with appropriate application (e.g. 'cmd.exe' or 'perl')
10  ##  ##
# Line 39  our @EXPORT_OK = qw( Line 42  our @EXPORT_OK = qw(
42    run_cmd run_cmds    run_cmd run_cmds
43    get_chomped    get_chomped
44    bool2status    bool2status
45      make_guid
46  );  );
47    
48    
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   main  
   
49  use Data::Dumper;  use Data::Dumper;
50  use POSIX qw( strftime );  use POSIX qw( strftime );
51  #use IPC::Run qw( run timeout );  #use IPC::Run qw( run timeout );
52  use IPC::Run qw( start pump finish timeout ) ;  use IPC::Run qw( start pump finish timeout ) ;
53    use Carp;
54    
55    
56    
57  # $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;  # $now_string = strftime "%a %b %e %H:%M:%S %Y", localtime;
58  # see "perldoc -f localtime"  # see "perldoc -f localtime"
   
59  sub now {  sub now {
60    my $options = shift;    my $options = shift;
61    my $pattern = "%Y-%m-%d %H:%M:%S";    my $pattern = "%Y-%m-%d %H:%M:%S";
# Line 153  sub bool2status { Line 157  sub bool2status {
157    
158  sub RUNNING_IN_HELL () { $^O eq 'MSWin32' }  sub RUNNING_IN_HELL () { $^O eq 'MSWin32' }
159    
160    # create global unique identifers using Data::UUID
161    # if updating this code, please also modify Tangram::Storage::make_guid
162    sub make_guid
163      {
164        my $self = shift;
165    
166        my $guid;
167    
168        # try to use Data::UUID first ...
169        eval("use Data::UUID;");
170        if (!$@) {
171          my $ug = Data::UUID->new();
172          $guid = $ug->create_str();
173          
174        # ... if this fails, try to fallback to Data::UUID::PurePerl instead ...
175        } else {
176          eval("use Data::UUID::PurePerl;");
177          if (!$@) {
178            $guid = Data::UUID::PurePerl::generate_id();
179          } else {
180            croak "couldn't create globally unique identifier";
181          }
182        }
183        
184        return $guid;
185      }
186    
187  1;  1;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed