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.

Jan 022011
 

Multi-line string in Perl

Answer:

To assign a multi-line string to a variable in Perl, is easy with the following trick:

my $html = <<END;
<p>
    This is HTML content.
</p>

END

print $html;
Dec 282010
 

Change the PHP's maximum upload file size

Answer:

The default maximum upload file size in PHP is only 2MB. If you want to change it, you need to edit the php.ini

vi /etc/php.ini

Locate and set (100M in the following example)

memory_limit = 100M;
post_max_size = 100M;
upload_max_filesize = 100M;

Try it with the number you need. (You might need to use a large value in post_max_size and memory_limit if you want to upload a file which is exactly 100M in size)

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

Dec 212010
 

How can I find out my current package in Perl?

Answer:

To find the current package in your Perl script, you can try something like the following:

package Foo;

my $current_package = __PACKAGE__;
print "I am in package $current_package\n";

1;

When executed:

# perl foo.pl

I am in package Foo
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";