Recent Notes

Displaying keyword search results 1 - 3
Created by jk34 on April 19, 2011 15:42:24    Last update: April 19, 2011 15:42:24
Check the __name__ variable to see if the Python module was invoked from the command line. The line prints when the Python script is called from the command line, but doesn't print when it is imported by another Python module with import MyModule . if __name__ == '__main__': print 'Invoked f...
Created by Dr. Xi on February 09, 2011 13:27:51    Last update: February 09, 2011 13:27:51
By the perldoc , use Module LIST; is exactly equivalent to: BEGIN { require Module; Module->import( LIST); } Because of the BEGIN block, use is executed immediately. Therefore, it is not suitable for lazy loading of modules at runtime. use does not work with a runtime variable: C:\>perl $cgi = "CGI"; require $cgi; prin... require works: C:\>perl $cgi = 'CGI'; require "${cgi}.pm"; ... Also, file extension is required if require is not passed a bareword: // this works require CGI; // so does th...
Created by Dr. Xi on December 04, 2009 04:33:05    Last update: December 04, 2009 04:33:05
Variable Meaning $_ The default or implicit variable. @_ Within a subroutine the array @_ contains the parameters passed to that subroutine. $a, $b Special package variables when using sort() $<digit> Contains the subpattern from the corresponding set of capturing parentheses from the last pattern match, not counting patterns matched in nested blocks that have been exited already. $. Current line number for the last filehandle accessed. $/ The input record separator, newline by default. $| If set to nonzero, forces a flush right away and after every write or print on the currently selected output channel. Default is 0 (regardless of whether the channel is really buffered by the system or not; $| tells you only whether you've asked Perl explicitly to flush after...