Product SiteDocumentation Site

Handling String Array Tags

Not only is the date stored in a format that adds complication to your script. A number of tags are string arrays, not scalar strings. This means you may see output that is all mashed together.
To help deal with this, the following subroutine takes in an array of strings and returns a string that is built using a passed-in delimiter:
sub arrayToString {
my($sep) = shift;
my(@array) = @_;
my($str);
$str = $array[0];
for ( $i = 1; $i < $#array; $i++ )
{
$str = $str . $sep . $array[$i];
}
return $str;
}
Note
Show your Perl expertise and earn extra points by implementing the arrayToString subroutine as a single Perl statement that uses the join function.
The following list shows the tags that are an array of strings:
*BASENAMES
*CHANGELOGNAME
*CHANGELOGTEXT
*DIRNAMES
*FILEGROUPNAME
*FILELANGS
*FILELINKTOS
*FILEMD5S
*FILEUSERNAME
*OLDFILENAMES
*PROVIDENAME
*PROVIDEVERSION
*REQUIRENAME
*REQUIREVERSION
Cross Reference
Chapter 4, Using the RPM Database covers more on these tags.