Changeset 1378 for trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm
- Timestamp:
- 08/13/15 18:07:55 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Utils.pm
r1151 r1378 21 21 22 22 @ISA = qw(Exporter); 23 @EXPORT = qw(to_ascii exec_command switch_user run_via_sudo );24 @EXPORT_OK = qw(to_ascii exec_command switch_user run_via_sudo );23 @EXPORT = qw(to_ascii exec_command switch_user run_via_sudo yesno); 24 @EXPORT_OK = qw(to_ascii exec_command switch_user run_via_sudo yesno); 25 25 26 26 =head2 to_ascii($text) … … 248 248 } 249 249 250 =head2 genpassword 250 =head2 genpassword(%options) 251 252 Generate a random password, options are: 253 254 =over4 255 256 =item length 257 258 The minimum password length (default is 6) 259 260 =item nonalpha 261 262 Include non alpha-numeric caracters 263 264 =item syllables 265 266 Use a set of syllables instead letter 267 268 =back 251 269 252 270 =cut … … 296 314 } 297 315 316 =head2 yesno($value, $default) 317 318 Check is a paramter mean yes or no 319 320 =cut 321 322 sub yesno { 323 my ($value, $default) = @_; 324 325 if ($value =~ /^(yes|1|true)$/i) { 326 return 1; 327 } 328 if ($value =~ /^(no|0|false)$/i) { 329 return 0; 330 } 331 if ($value =~ /^\d+$/ and $value != 0) { 332 return 1; 333 } 334 return $default || $value; 335 } 336 298 337 1; 299 338
Note: See TracChangeset
for help on using the changeset viewer.