MDK::Common::Various man page on Mageia

Man page or keyword search:  
man Server   17783 pages
apropos Keyword Search (all sections)
Output format
Mageia logo
[printable version]

MDK::Common::Various(3User Contributed Perl DocumentatiMDK::Common::Various(3)

NAME
       MDK::Common::Various - miscellaneous functions

SYNOPSIS
	   use MDK::Common::Various qw(:all);

EXPORTS
       first(LIST)
	   returns the first value. "first(XXX)" is an alternative for
	   "((XXX)[0])"

       second(LIST)
	   returns the second value. "second(XXX)" is an alternative for
	   "((XXX)[1])"

       top(LIST)
	   returns the last value. "top(@l)" is an alternative for $l[$#l]

       to_bool(SCALAR)
	   returns a value in { 0, 1 }

       to_int(STRING)
	   extracts the number from the string. You could use directly "int
	   "11 foo"", but you'll get Argument "11 foo" isn't numeric in int.
	   It also handles returns 11 for "foo 11 bar"

       to_float(STRING)
	   extract a decimal number from the string

       bool2text(SCALAR)
	   returns a value in { "true", "false" }

       bool2yesno(SCALAR)
	   returns a value in { "yes", "no" }

       text2bool(STRING)
	   inverse of "bool2text" and "bool2yesno"

       chomp_(STRING)
	   non-mutable version of chomp: do not modify the argument, returns
	   the chomp'ed value. Also works on lists: "chomp_($a, $b)" is
	   equivalent to "chomp($a) ; chomp($b) ; ($a,$b)"

       backtrace()
	   returns a string describing the backtrace. eg:

	       sub g { print "oops\n", backtrace() }
	       sub f { &g }
	       f();

	   gives

	       oops
	       main::g() called from /tmp/t.pl:2
	       main::f() called from /tmp/t.pl:4

       internal_error(STRING)
	   another way to "die" with a nice error message and a backtrace

       noreturn()
	   use this to ensure nobody uses the return value of the function.
	   eg:

	       sub g { print "g called\n"; noreturn }
	       sub f { print "g returns ", g() }
	       f();

	   gives

	       test.pl:3: main::f() expects a value from main::g(), but main::g() doesn't return any value

SEE ALSO
       MDK::Common

perl v5.18.1			  2011-09-14	       MDK::Common::Various(3)
[top]

List of man pages available for Mageia

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Tweet
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
Vote for polarhome
Free Shell Accounts :: the biggest list on the net