in reply to Return a value

Hi Bhushan,

I lost enough tiny little 1;s that I now write it with a comment to myself like this:

package Foo; 1; # return true to end package Foo

A little harder to accidentally delete like that!

Remember: Ne dederis in spiritu molere illegitimi!

Replies are listed 'Best First'.
Re^2: Return a value
by bhushanQA (Sexton) on Jul 06, 2015 at 10:11 UTC
    Hi, I am stuck with one more problem here:
    [Section1] SQL1=select * from <tablename> SQL2=insert into table <table name>
    I have written below code to read the each section of .ini file and its working perfect. I have to use below subroutine in my main file, I want to call it and pass the each value in each section into the hash over there and do the database operations. below is code:
    sub Read_INI_files_get_initialData { my ( %ini_file, $ini_sect ); tie %ini_file, 'IniFiles',( -file => "/home/testtool/config/Initia +lData.ini" ); for $ini_sect ( keys %ini_file ) { %$ini_sect = %{ $ini_file{$ini_sect} }; } print "$Section1{SQL1}\n"; # output prints the 1st SQL1 statement + return in .ini file. return (\%Section1); }
    When I call this subroutine from main file, I don't get any return value which I could use for further database operations ( I want those SQL queries in hash so I could pass them to insert into my database using another program)

      How do you call it and how do you try to extract the returned value(s)?

      Please show us the code where you call the subroutine.

        Sure.. below is the code, where I am trying to call the subroutine written in the module.
        #!/usr/bin/perl use DBI; use DBD::Sybase; use strict; #use Config::IniFiles; require Read_INI_files; require IniFiles; #my %Section1; #Connect to the PP_DB my $dbh = DBI->connect( "dbi:Sybase:server=ctp-1-zone157; database=PP_ +DB; port=5000","sa", "password" ) or die "can not connect to the DB"; Read_INI_files_get_initialData_PP_DB(); print "$Section1{SQL1}\n";
      A reply falls below the community's threshold of quality. You may see it by logging in.