.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "if 3perl" .TH if 3perl "2018-11-29" "perl v5.24.1" "Perl Programmers Reference Guide" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" if \- "use" a Perl module if a condition holds (also can "no" a module) .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use if CONDITION, MODULE => ARGUMENTS; \& no if CONDITION, MODULE => ARGUMENTS; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" The \f(CW\*(C`if\*(C'\fR module is used to conditionally load or unload another module. The construct .PP .Vb 1 \& use if CONDITION, MODULE => ARGUMENTS; .Ve .PP will load \s-1MODULE\s0 only if \s-1CONDITION\s0 evaluates to true. The above statement has no effect unless \f(CW\*(C`CONDITION\*(C'\fR is true. If the \s-1CONDITION\s0 does evaluate to true, then the above line has the same effect as: .PP .Vb 1 \& use MODULE ARGUMENTS; .Ve .PP The use of \f(CW\*(C`=>\*(C'\fR above provides necessary quoting of \f(CW\*(C`MODULE\*(C'\fR. If you don't use the fat comma (eg you don't have any \s-1ARGUMENTS\s0), then you'll need to quote the \s-1MODULE.\s0 .SS "\s-1EXAMPLES\s0" .IX Subsection "EXAMPLES" The following line is taken from the testsuite for File::Map: .PP .Vb 1 \& use if $^O ne \*(AqMSWin32\*(Aq, POSIX => qw/setlocale LC_ALL/; .Ve .PP If run on any operating system other than Windows, this will import the functions \f(CW\*(C`setlocale\*(C'\fR and \f(CW\*(C`LC_ALL\*(C'\fR from \s-1POSIX\s0. On Windows it does nothing. .PP The following is used to deprecate core modules beyond a certain version of Perl: .PP .Vb 1 \& use if $] > 5.016, \*(Aqdeprecate\*(Aq; .Ve .PP This line is taken from Text::Soundex 3.04, and marks it as deprecated beyond Perl 5.16. If you \f(CW\*(C`use Text::Soundex\*(C'\fR in Perl 5.18, for example, and you have used warnings, then you'll get a warning message (the deprecate module looks to see whether the calling module was \f(CW\*(C`use\*(C'\fR'd from a core library directory, and if so, generates a warning), unless you've installed a more recent version of Text::Soundex from \s-1CPAN.\s0 .PP You can also specify to \s-1NOT\s0 use something: .PP .Vb 1 \& no if $] ge 5.021_006, warnings => "locale"; .Ve .PP This warning category was added in the specified Perl version (a development release). Without the \f(CW\*(Aqif\*(Aq\fR, trying to use it in an earlier release would generate an unknown warning category error. .SH "BUGS" .IX Header "BUGS" The current implementation does not allow specification of the required version of the module. .SH "SEE ALSO" .IX Header "SEE ALSO" Module::Requires can be used to conditionally load one or modules, with constraints based on the version of the module. Unlike \f(CW\*(C`if\*(C'\fR though, Module::Requires is not a core module. .PP Module::Load::Conditional provides a number of functions you can use to query what modules are available, and then load one or more of them at runtime. .PP provide can be used to select one of several possible modules to load, based on what version of Perl is running. .SH "AUTHOR" .IX Header "AUTHOR" Ilya Zakharevich . .SH "COPYRIGHT AND LICENCE" .IX Header "COPYRIGHT AND LICENCE" This software is copyright (c) 2002 by Ilya Zakharevich. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.