srikrishnan:

I'm sorry, but I'm unfamiliar with both Image::ExifTool and the internals of .pdf files. I'm writing just to offer a suggestion or two.

First, I notice that you restrict your variable names to 8 characters. While I'm a fan of shorter variable names, I'm surprised that you're wasting three of your characters by using a suffix of 'Val' on (nearly) all variables. I'd drop that habit like a hot rock. It's much more important to make your variable names clear than short.

For example, suppose you have a variable to represent a store owners Social Security Number. If you're a Java programmer, you might wind up with StoreOwnersSocialSecurityNumber or some such, which is much too long for my comfort. It looks like you might try to pack it down to $StOSSVal. I tend to use standardized abbreviations in my code to shorten variable names. In any industry, you'll have a particular set of frequently-used terms, and you should have (or create) a set of standard abbreviations for those terms. For example, a very common contraction of Social Security Number is SSN, so I'd use that throughout the application. So I'd shorten the variable to $StoreOwnerSSN, which is short and clear.

Secondly, it appears that the majority of those variables are used only once. Looking at how you're using them suggests the use of a hash, something like:

use strict; use warnings; use Image::ExifTool ':Public'; my @PDFAuthors = ( "Michael L. Oldham", "Dheeraj Khare", "Florante A. Quiocho", "Amy L. Davidson", "Jue Chen" ); my %StdPDFattrs = ( Description => "XXX 450, 515 (2007). doi:10.1038/XXX06264", Format => "application/pdf", Publisher => "XXX Publishing Group", Rights => " 2007 XXX Publishing Group", Charset => 'Latin', Title => "Crystal structure of a catalytic intermediate of the mal +tose transporter", Producer => "Acrobat Distiller 6.0.1 (Windows)", Cpyrt => " 2007 XXX Publishing Group", Identifier => "10.1038/XXX06264", EIssn => "1476-4687", EndingPage => "521", <<<SNIP>>> ); <<<SNIP>>> my $exifTool = new Image::ExifTool ':Public'; $exifTool->SetNewValue(); for my $Author (@PDFAuthors) { ($success, $errStr) = $exifTool->SetNewValue('Creator'=> $Author, +AddValue => 1); #print "Success: $success\n"; #print "Error $errStr\n"; } for my $Attribute (keys %StdPDFattrs) { $exifTool->SetNewValue( $Attribute, $StdPDFattrs{$Attribute} ); } <<<SNIP>>>

One last suggestion--Don't blindly double-space all your code. Whitespace has a single function: to make the program easy to read/understand. So use indentation and whitespace to make program structure clear.

Good luck with your problem!

...roboticus

P.S. As I was editing your code, I notice that you use 'XMP-RDF' in one place and 'XMP' elsewhere, perhaps your problem with XAP vs. XMP might be a consistency issue?

Update: Repaired CPAN link for module Image::ExifTool.

Update: Fixed %StdPDFattrs definition: I had square brackets instead of parenthesis. ++ to moritz for the catch!


In reply to Re: Adding xmp metadata using exiftool module by roboticus
in thread Adding xmp metadata using exiftool module by srikrishnan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.