| 1 | #ABSTRACT: Pragma qbit | ||
| 2 | |||
| 3 | =head1 Name | ||
| 4 | |||
| 5 | qbit - Setup envirement to development modern perl applications and add some functions. | ||
| 6 | |||
| 7 | =head1 Description | ||
| 8 | |||
| 9 | Using this pragma is equivalent: | ||
| 10 | |||
| 11 | use strict; | ||
| 12 | use warnings FATAL => 'all'; | ||
| 13 | use utf8; | ||
| 14 | use open qw(:std utf8); | ||
| 15 | |||
| 16 | use Scalar::Util qw(set_prototype blessed dualvar isweak readonly refaddr reftype tainted weaken isvstring looks_like_number); | ||
| 17 | use Data::Dumper qw(Dumper); | ||
| 18 | use Clone qw(clone); | ||
| 19 | |||
| 20 | use qbit::Exceptions; | ||
| 21 | use qbit::Log; | ||
| 22 | use qbit::Array; | ||
| 23 | use qbit::Hash; | ||
| 24 | use qbit::GetText; | ||
| 25 | use qbit::Packages; | ||
| 26 | use qbit::StringUtils; | ||
| 27 | use qbit::Date; | ||
| 28 | use qbit::File; | ||
| 29 | |||
| 30 | =head1 Synopsis | ||
| 31 | |||
| 32 | use qbit; | ||
| 33 | |||
| 34 | sub myfunc { | ||
| 35 | my ($a1, $a2) = @_; | ||
| 36 | |||
| 37 | throw Exception::BadArguments gettext('First argument must be defined') | ||
| 38 | unless defined($a1); | ||
| 39 | |||
| 40 | return .... | ||
| 41 | } | ||
| 42 | |||
| 43 | try { | ||
| 44 | my $data = myfunc(@ARGV); | ||
| 45 | ldump($data); | ||
| 46 | } catch Exception::BadArguments with { | ||
| 47 | l shift->as_string(); | ||
| 48 | }; | ||
| 49 | |||
| 50 | =head1 Internal packages | ||
| 51 | |||
| 52 | =over | ||
| 53 | |||
| 54 | =item B<L<qbit::Exceptions>> - realize base classes and functions to use exception in perl; | ||
| 55 | |||
| 56 | =item B<L<qbit::Log>> - there're some function to simple logging; | ||
| 57 | |||
| 58 | =item B<L<qbit::Array>> - there're some function to working with arrays; | ||
| 59 | |||
| 60 | =item B<L<qbit::Hash>> - there're some function to working with hashes; | ||
| 61 | |||
| 62 | =item B<L<qbit::GetText>> - there're some function to internationalization your's software; | ||
| 63 | |||
| 64 | =item B<L<qbit::Packages>> - there're some function to access package internals; | ||
| 65 | |||
| 66 | =item B<L<qbit::StringUtils>> - there're some function to working with strings; | ||
| 67 | |||
| 68 | =item B<L<qbit::Date>> - there're some function to working with dates; | ||
| 69 | |||
| 70 | =item B<L<qbit::File>> - there're some function to manage files. | ||
| 71 | |||
| 72 | =back | ||
| 73 | |||
| 74 | =cut | ||
| 75 | |||
| 76 | package qbit; | ||
| 77 | $qbit::VERSION = '2.5'; | ||
| 78 | 8 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 79 | 8 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 80 | 8 | ▶ | use utf8; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 81 | 8 | ▶ | use open(); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 82 | 8 | ▶ | use Scalar::Util (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 83 | 8 | ▶ | use Data::Dumper (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 84 | 8 | ▶ | use Clone (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 85 | |||
| 86 | 8 | ▶ | use qbit::Exceptions (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 87 | 8 | ▶ | use qbit::Log (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 88 | 8 | ▶ | use qbit::Array (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 89 | 8 | ▶ | use qbit::Hash (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 90 | 8 | ▶ | use qbit::GetText (); |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 91 | 8 | ▶ | use qbit::Packages (); |
|
Subroutine
BEGIN: called CC=1 SCAR=2.6
| |||
| 92 | use qbit::StringUtils (); | ||
| 93 | use qbit::Date (); | ||
| 94 | use qbit::File (); | ||
| 95 | |||
| 96 | sub import { | ||
| 97 | $^H |= $utf8::hint_bits; | ||
| 98 | $^H |= 0x00000002 | 0x00000200 | 0x00000400; | ||
| 99 | |||
| 100 | ${^WARNING_BITS} |= $warnings::Bits{'all'}; | ||
| 101 | ${^WARNING_BITS} |= $warnings::DeadBits{'all'}; | ||
| 102 | |||
| 103 | my $pkg = caller; | ||
| 104 | my $pkg_sym_tbl = qbit::Packages::package_sym_table($pkg); | ||
| 105 | |||
| 106 | { | ||
| 107 | no strict 'refs'; | ||
| 108 | *{"${pkg}::TRUE"} = sub () {1}; | ||
| 109 | *{"${pkg}::FALSE"} = sub () {''}; | ||
| 110 | } | ||
| 111 | |||
| 112 | Scalar::Util->export_to_level( | ||
| 113 | 1, undef, | ||
| 114 | @{ | ||
| 115 | qbit::Array::arrays_difference( | ||
| 116 | [ | ||
| 117 | qw(set_prototype blessed dualvar isweak readonly refaddr reftype tainted weaken isvstring looks_like_number) | ||
| 118 | ], | ||
| 119 | [keys(%$pkg_sym_tbl)] | ||
| 120 | ) | ||
| 121 | } | ||
| 122 | ); # Don't export functions, if they were imported before | ||
| 123 | |||
| 124 | Data::Dumper->export_to_level(1, qw(Dumper)); | ||
| 125 | |||
| 126 | Clone->export_to_level(1, undef, qw(clone)); | ||
| 127 | |||
| 128 | qbit::Exceptions->export_to_level(1); | ||
| 129 | qbit::Log->export_to_level(1); | ||
| 130 | qbit::Array->export_to_level(1); | ||
| 131 | qbit::Hash->export_to_level(1); | ||
| 132 | qbit::Packages->export_to_level(1); | ||
| 133 | qbit::GetText->export_to_level(1); | ||
| 134 | qbit::StringUtils->export_to_level(1); | ||
| 135 | qbit::Date->export_to_level(1); | ||
| 136 | qbit::File->export_to_level(1); | ||
| 137 | |||
| 138 | @_ = qw(open :std :utf8); | ||
| 139 | goto &open::import; | ||
| 140 | } | ||
| 141 | |||
| 142 | 1; | ||