Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Linux Ask!

Dec 202010
 

How can I comment out a large block of Perl code?

Answer:

Perl does not support multi-line comments like C++ or Java. If you want to comment out a large block of Perl code, there is still a trick.

package Foo;

=pod
This is a multi-line comments 
more...
more...
=cut

print "Hello";
Dec 182010
 

How do I find the current module name in Python?

Answer:

The easiest way is to look at the look at the predefined global variable __main__. If it has the value "__main__", it means the program is run as a script (not as imported module).

E.g.

def main():
    print 'Running test...'


if __name__ == '__main__':
    main()
Dec 172010
 

How to change the nginx log format?

Answer:

Firstly, you need to define a valid log format for nginx, e.g.

log_format foo '$remote_addr - $remote_user [$time_local]  '
                '"$request" $status $bytes_sent '
                '"$http_referer" "$http_user_agent"';

Then, you need to link that format with your log file:

access_log /var/logs/nginx-test-access.log foo;

Dec 162010
 

What is the PHP's short_open_tag

Answer:

PHP's short_open_tag is a way to use PHP in a PHP script without the normal PHP tag, e.g.

Instead of

# <?php echo "hello world"; ?>

You can use a simplified version.

# <? echo "hello world"; ?>

Although it is not recommended, if you want to set it, you can enable it by editing the php.ini

vi /etc/php.ini

Locate and set

short_open_tag = On

Also, remember to restart web server such as Apache if needed.