Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Exploring Type::Tiny Part 4: Using Types::Standard as a Ref::Util-Like Library

by tobyink (Canon)
on Aug 12, 2018 at 15:50 UTC ( [id://1220275]=CUFP: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
       use Types::Standard qw(is_ArrayRef is_HashRef);
       
       if (is_ArrayRef($var)) {
    ...
       elsif (is_HashRef($var)) {
          ...;
       }
    
  2. or download this
       use Types::Standard qw(ArrayRef HashRef);
       
       if (ArrayRef->check($var)) {
    ...
       elsif (HashRef->check($var)) {
          ...;
       }
    
  3. or download this
       use Types::Standard qw(assert_Object assert_ArrayRef);
       
       sub process_data {
    ...
          my $data  = assert_ArrayRef( $_[1] );
          ...;
       }
    
  4. or download this
       use Types::Path::Tiny qw( to_Path );
       
       my $path = to_Path($thing);
    
  5. or download this
       use Types::Path::Tiny qw( assert_Path to_Path );
       
       my $path = assert_Path( to_Path($thing) );
    
  6. or download this
       if (is_ArrayRef[Int]($var)) {
          ...;
       }
    
  7. or download this
       use Types::Standard qw(ArrayRef Int);
       
       BEGIN {
    ...
       if (is_ArrayRef_of_Int($var)) {
          ...;
       }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: CUFP [id://1220275]
Front-paged by Athanasius
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (2)
As of 2024-04-26 00:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found