man page


ProjectBuilder::Base, part of the - module dealing with generic functions suitable for perl project development


This module provides generic functions suitable for perl project development


  use ProjectBuilder::Base;

  # Create a directory and its parents

  # Remove recursively a directory and its children

  # Encapsulate the system call for better output and return value test
  pb_system("ls -l", "Printing directory content");

  # Analysis a URI and return its components in a table
  my ($scheme, $account, $host, $port, $path) = pb_get_uri("svn+ssh://");

  # Gives the current date in a table
  @date = pb_get_date();

  # Manages logs of the program
  pb_log(1,"Message to print\n");

  # Manages content of a file
  my $cnt = pb_get_content("/etc/passwd");



Internal mkdir -p function. Forces mode to 755. Supports multiple parameters.

Based on File::Path mkpath.


Internal rm -rf function. Supports multiple parameters.

Based on File::Path rmtree.


Encapsulate the "system" call for better output and return value test. Needs a $ENV{'PBTMP'} variable which is created by calling the pb_mktemp_init function. Needs pb_log support, so pb_log_init should have been called before.

The first parameter is the shell command to call. This command should NOT use redirections. The second parameter is the message to print on screen. If none is given, then the command is printed. The third parameter prints the result of the command after correct execution if value is "verbose". If value is "noredir", it avoids redirecting outputs (e.g. for vi). If value is "quiet", doesn't print anything at all. If value is "mayfail", failure of the command is ok even if $Global::pb_stop_on_error is set, because the caller will be handling the error. A "verbose" can be added to mayfail to have it explain why it failed. If value is verbose_PREF, then every output command will be prefixed with PREF. This function returns as a result the return value of the system command.

If no error reported, it prints OK on the screen, just after the message. Else it prints the errors generated.


This function returns a list of 6 parameters indicating the protocol, account, password, server, port, and path contained in the URI passed in parameter.

A URI has the format protocol://[ac@]host[:port][path[?query][#fragment]].

Cf man URI.


This function returns a list of 9 parameters indicating the seconds, minutes, hours, day, month, year, day in the week, day in the year, and daylight saving time flag of the current time.

Cf: man ctime and description of the struct tm.


This function initializes the global variables used by the pb_log function.

The first parameter is the debug level which will be considered during the run of the program? The second parameter is a pointer on a file descriptor used to print the log info.

As an example, if you set the debug level to 2 in that function, every call to pb_log which contains a value less or equal than 2 will be printed. Calls with a value greater than 2 won't be printed.

The call to pb_log_init is typically done after getting a parameter on the CLI indicating the level of verbosity expected.


This function logs the messages passed as the second parameter if the value passed as first parameter is lesser or equal than the value passed to the pb_log_init function.

Here is a usage example:

  pb_log(1,"Hello World 1\n");
  pb_log(2,"Hello World 2\n");
  pb_log(3,"Hello World 3\n");

  will print:
  Hello World 1
  Hello World 2

This function prints the content of the file passed in parameter. If a second parameter is given, this is the descriptor of the logfile to write to in addtion to STDOUT. If a third parameter is given, this is the prefix providing it's writen as verbose_PREF. In which case the PREF string will be added before the line output.

This is a cat equivalent function.


This function returns the content of the file passed in parameter.


This function put the content of a variable passed as second parameter into the file passed as first parameter.


Fundtion to call before exiting pb so cleanup is done


This function initializes the global variable used by the pb_syntax function.

The parameter is the message string which will be printed when calling pb_syntax


This function prints the syntax expected by the application, based on pod2usage, and exits. The first parameter is the return value of the exit. The second parameter is the verbosity as expected by pod2usage.

Cf: man Pod::Usage


This function initializes the environemnt variable PBTMP to a random value. This directory can be safely used during the whole program, it will be removed at the end automatically.


This function returns the release of our operating system


This function returns the architecture of our local environment and standardize on i386 for those platforms.


This function checks that the commands needed for the subsystem are indeed present. The required commands are passed as a comma separated string as first parameter. The optional commands are passed as a comma separated string as second parameter.


This function checks existence of a command and return its full pathname or undef if not found. The command name is passed as first parameter. The second parameter should be 0 if the command is mandatory, 1 if optional. It returns the full path name of the command if found, undef otherwise and dies if that was a mandatory command


Expand out a path by environment variables as ($ENV{'ENVVAR'}) and ~


Return the number of files in a directory


The main Web site of the project is available at Bug reports should be filled using the trac instance of the project at


None exists for the moment.


The team lead by Bruno Cornec

COPYRIGHT is distributed under the GPL v2.0 license described in the file COPYING included with the distribution. man page