perlhp has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am trying to open a read file path from properties file, but I am unable to do that. However, I have tried doing some hard-coded, it works fine.

Error: Could not open file '/home/ad/prod/logs/test.log' No such file or directory at binaryImageTransfer.pl In below code, when I try to use tempVar directly it works. I have also tried printing logFileName. It works

my $config = Config::Tiny->new; $config = Config::Tiny->read('myconfig_imagetransfer'); $logFileName = $config->{TRUNK}->{LOG_FILE}; chomp $logFileName; #my $tempVar = '/home/ad/prod/logs/test.log'; my $tempVar = $logFileName; open($logFile, '>>', $tempVar) or die "Could not open file $tempVar $ +!";
myconfig_imagetransfer [TRUNK] SOURCE_DIR = /home/ad/prod/war TARGET_DIR = /app/tomcat6/trunkcurrent/webapps LOG_FILE = '/home/ad/prod/logs/test.log'
Any help in this regard will be appreciated. Thank you in advance

Replies are listed 'Best First'.
Re: Files/Properties: Not able to open file from properties file
by Athanasius (Archbishop) on Jan 22, 2014 at 08:43 UTC

    Hello perlhp, and welcome to the Monastery!

    As I reconstruct it (please heed the advice of nithins and hdb and fix the formatting of your post), your config file myconfig_imagetransfer contains:

    TRUNK SOURCE_DIR = /home/ad/prod/war TARGET_DIR = /app/tomcat6/trunkcurrent/webapps LOG_FILE = '/home/ad/prod/logs/test.log'

    Two points:

    1. Config::Tiny requires section headings to be in square brackets, so you need to change TRUNK to [TRUNK].

    2. Remove the quotation marks from around the LOG_FILE entry.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: Files/Properties: Not able to open file from properties file
by nithins (Sexton) on Jan 22, 2014 at 07:41 UTC

    can u dump your code in between "code" tag, so that it can be more readable