Marius van Witzenburg "Learned my lesson in life, now setting my action to stay in life."

8Jun/100

Upgrading Perl 5.8.x to 5.10.x on FreeBSD.

In the ports collection you can find /usr/ports/UPDATING. Here you can read how to upgrade Perl 5.8.x to the new release 5.10.x.

The description below is copied from the updating file.

Note: you might need to manually upgrade some ports after this. For example, I had to recompile APR, Apache and Subversion.

Portupgrade users:
0) Fix pkgdb.db (for safety):

	pkgdb -Ff

1) Reinstall perl with new 5.10:

	env DISABLE_CONFLICTS=1 portupgrade -o lang/perl5.10 -f perl-5.8.\*

2) Reinstall everything that depends on Perl:

	portupgrade -fr perl

Portmaster users:

	env DISABLE_CONFLICTS=1 portmaster -o lang/perl5.10 lang/perl5.8
	portmaster -r perl-

Note: If the "perl-" glob matches more than one port you will need to
specify the name of the perl directory in /var/db/pkg explicitly.

7Jun/100

How to use the exec() and system() function and capture the returned output.

When you want to execute a program you sometimes want to use the result of the program you executed.

exec(PROGRAM);
$result = system(PROGRAM);

Both Perl's exec() function and system() function execute a system shell command. The big difference is that system() creates a fork process and waits to see if the command succeeds or fails - returning a value. exec() does not return anything, it simply executes the command. Neither of these commands should be used to capture the output of a system call. If your goal is to capture output, you should use the backtick operator:

$result = `PROGRAM`;

Found this information in a post by Kirk Brown.

10Mar/100

List only directories on the command-line or in your scripts

Here you have some different ways of showing only the directories on a path you specify.
This can be used in different other languages such as PHP with shell_exec for example.

ls -l /shares/ | grep "^d" | awk '{ print $9 }'
find /shares/ -maxdepth 1 -mindepth 1 -type d | sed 's/.\///g'
find /shares/ -maxdepth 1 -mindepth 1 -type d | perl -pi -e 's/.\///g'
find /shares/ -maxdepth 1 -mindepth 1 -type d | grep -v '^\./\.'

I hope you find them useful on some way :-)
Of course comments are more than welcome!