GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Data::Object::Args(3) User Contributed Perl Documentation Data::Object::Args(3)

Data::Object::Args - Args Class

Args Class for Perl 5

  package main;

  use Data::Object::Args;

  local @ARGV = qw(--help execute);

  my $args = Data::Object::Args->new(
    named => { flag => 0, command => 1 }
  );

  # $args->flag; # $ARGV[0]
  # $args->get(0); # $ARGV[0]
  # $args->get(1); # $ARGV[1]
  # $args->action; # $ARGV[1]
  # $args->exists(0); # exists $ARGV[0]
  # $args->exists('flag'); # exists $ARGV[0]
  # $args->get('flag'); # $ARGV[0]

This package provides methods for accessing @ARGS items.

This package integrates behaviors from:

Data::Object::Role::Buildable

Data::Object::Role::Proxyable

Data::Object::Role::Stashable

This package uses type constraints from:

Types::Standard

This package has the following attributes:

  named(HashRef)

This attribute is read-only, accepts "(HashRef)" values, and is optional.

This package implements the following methods:

  exists(Str $key) : Any

The exists method takes a name or index and returns truthy if an associated value exists.

exists example #1
  # given: synopsis

  $args->exists(0); # truthy
    
exists example #2
  # given: synopsis

  $args->exists('flag'); # truthy
    
exists example #3
  # given: synopsis

  $args->exists(2); # falsy
    

  get(Str $key) : Any

The get method takes a name or index and returns the associated value.

get example #1
  # given: synopsis

  $args->get(0); # --help
    
get example #2
  # given: synopsis

  $args->get('flag'); # --help
    
get example #3
  # given: synopsis

  $args->get(2); # undef
    

  name(Str $key) : Any

The name method takes a name or index and returns index if the the associated value exists.

name example #1
  # given: synopsis

  $args->name('flag'); # 0
    

  set(Str $key, Maybe[Any] $value) : Any

The set method takes a name or index and sets the value provided if the associated argument exists.

set example #1
  # given: synopsis

  $args->set(0, '-?'); # -?
    
set example #2
  # given: synopsis

  $args->set('flag', '-?'); # -?
    
set example #3
  # given: synopsis

  $args->set('verbose', 1); # undef

  # is not set
    

  stashed() : HashRef

The stashed method returns the stashed data associated with the object.

stashed example #1
  # given: synopsis

  $args->stashed
    

  unnamed() : ArrayRef

The unnamed method returns an arrayref of values which have not been named using the "named" attribute.

unnamed example #1
  package main;

  use Data::Object::Args;

  local @ARGV = qw(--help execute --format markdown);

  my $args = Data::Object::Args->new(
    named => { flag => 0, command => 1 }
  );

  $args->unnamed # ['--format', 'markdown']
    
unnamed example #2
  package main;

  use Data::Object::Args;

  local @ARGV = qw(execute phase-1 --format markdown);

  my $args = Data::Object::Args->new(
    named => { command => 1 }
  );

  $args->unnamed # ['execute', '--format', 'markdown']
    

Al Newkirk, "awncorp@cpan.org"

Copyright (C) 2011-2019, Al Newkirk, et al.

This is free software; you can redistribute it and/or modify it under the terms of the The Apache License, Version 2.0, as elucidated in the "license file" <https://github.com/iamalnewkirk/data-object-args/blob/master/LICENSE>.

Wiki <https://github.com/iamalnewkirk/data-object-args/wiki>

Project <https://github.com/iamalnewkirk/data-object-args>

Initiatives <https://github.com/iamalnewkirk/data-object-args/projects>

Milestones <https://github.com/iamalnewkirk/data-object-args/milestones>

Contributing <https://github.com/iamalnewkirk/data-object-args/blob/master/CONTRIBUTE.md>

Issues <https://github.com/iamalnewkirk/data-object-args/issues>

2020-05-14 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.