Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Concatenate Issue

Status
Not open for further replies.

mashidas

IS-IT--Management
Oct 30, 2008
2
CA
Hi guys,

I wrote this perl script to create thousand of folders by reading from a text file a number, for instance for the numbers 12123131212 * 3238233272 , I need to create the folder 1/2/1/2/12123131212/US_English and 3/2/3/8/3238233272/US_English. The problem is that the last part is not being concatenated properly. Please take a look on the code and output. For some reason, only the last number in my txt is getting concatenated correctly. Please advise :)

Thanks alot.

---------------------------------------------------------------------

Output:

1\2\1\2\12123131212
\8000\US_English
3\2\3\8\3238233533
\8000\US_English
5\4\5\6\5456546456
\8000\US_English
4\5\3\3\4533535355\8000\US_English

----------------------------------------------------------

#!/usr/local/bin/perl
#
# Program to do the obvious
#

open FILE, "ali.txt" or die $!;

while (my $line = <FILE>)

{
$foldername=$line;
$FirstVar = substr($line,0, 1);
$SecondVar = substr($line,1, 1);
$ThirdVar = substr($line,2, 1);
$FourthVar = substr($line,3, 1);
$FifthVar="8000\\US_English";

$NewDirectory =$FirstVar."\\".$SecondVar."\\".$ThirdVar."\\".$FourthVar."\\".$line."\\".$FifthVar;

print ($NewDirectory);
print"\n";
}
 
I would 'chomp' your input.

There's a newline character at the end of $line .


I hope that helps.

Mike
 
Hi Mike,

Thx for replying. Chomps works :)...Really appreciate it

Thanks :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top