Gossamer Forum
Home : General : Perl Programming :

Interesting Concatenation Problem - Require Help

Quote Reply
Interesting Concatenation Problem - Require Help
HI All ,

I am facing an interesting problem

Please help me resolve the same.

I have two functions. The main function reads the machine name from an input config file , passes it on to sub_main() function .
In the sub_main() function , I need to concatenate this machine name with ".world" .

However the concatenated string is wierd. However both the inpus to the concatenation are OK , the result is not

Please Help

Attaching code for your reference.



#!/usr/bin/perl

main();

sub main () {

my %config_hash=();
my @machines=();
my $i=0;
open(CONFIG, "<config_details.cfg") || die "I/O Success - Cannot process get_max_ri.sql file";

while (<CONFIG>)
{
my @config_line=split(/=/,$_);
print "$config_line[0]\n";
$config_hash{$config_line[0]}=$config_line[1];
}

@machines=split(/,/,$config_hash{"MACHINE NAMES"});
my $NUM_MACHINES=@machines;

for ($i=0;$i<$NUM_SMF_MACHINES;$i++)
{
chomp($machines[$i]);
sub_main($i+1,$machines[$i]);
}

}


sub sub_main()

{
my $mac2=shift();
my $mac3=$mac2.'.world';
print $mac3;
print "\n";

}
Subject Author Views Date
Thread; hot thread Interesting Concatenation Problem - Require Help gpta_varun 13322 Jul 12, 2010, 11:03 PM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
gpta_varun 13119 Jul 12, 2010, 11:17 PM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13076 Jul 12, 2010, 11:58 PM
Thread; hot thread Re: [Andy] Interesting Concatenation Problem - Require Help
gpta_varun 13101 Jul 13, 2010, 12:14 AM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13062 Jul 13, 2010, 12:30 AM
Thread; hot thread Re: [Andy] Interesting Concatenation Problem - Require Help
gpta_varun 13112 Jul 13, 2010, 1:11 AM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13039 Jul 13, 2010, 1:13 AM
Thread; hot thread Re: [Andy] Interesting Concatenation Problem - Require Help
gpta_varun 13121 Jul 13, 2010, 1:34 AM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13069 Jul 13, 2010, 1:39 AM
Thread; hot thread Re: [Andy] Interesting Concatenation Problem - Require Help
gpta_varun 13102 Jul 13, 2010, 1:44 AM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13108 Jul 13, 2010, 1:47 AM
Thread; hot thread Re: [Andy] Interesting Concatenation Problem - Require Help
gpta_varun 13094 Jul 13, 2010, 2:05 AM
Thread; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13062 Jul 13, 2010, 2:07 AM
Thread; hot thread Re: [Andy] Interesting Concatenation Problem - Require Help
gpta_varun 13102 Jul 13, 2010, 3:09 AM
Post; hot thread Re: [gpta_varun] Interesting Concatenation Problem - Require Help
Andy 13025 Jul 13, 2010, 3:15 AM