# A Perl question.

This topic is 4899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm using perl to create a list and parts of it worked perfect but there is one part of it i can get to work right. I am making a list and i need it to be in the following format "../res/ddr.asi", "../res/ddf.asi", "../res/ddd.asi", "../res/dds.asi", "../res/dda.asi", but its coming out in the format of \"../res/ddr.asi\", \"../res/ddf.asi\", \"../res/ddd.asi\", \"../res/dds.asi\", \"../res/dda.asi\", So i need to get rid of the left slashs. I tried removing them from my code but it gave an error.

else
{
print $point6;$fileExtension = ".asi";

for( $i = 0;$i < @musicList; $i++ ) { if($count == $ARGV[$NUM_MUSIC] )
{
last;
}
else
{
$output = "$output\\\"../res/$musicList[$i]$fileExtension\\\","; }$count++;
}

}


This may be a trival problem but i cant find the solution in me Perl book. Many Thanks, W

##### Share on other sites
You need to get rid of TWO backslashes in each set of three. The first two encode a literal backslash within the quoted string. The third, and the subsequent double-quote, encode a literal double-quote. It's exactly the same as in C, C++ or Java (or Python, or any other language I can think of at the moment that actually uses double-quoted strings).

By the way, your control flow logic is needlessly complex. Just compare $i to both the @musicList length and the$ARGV[$NUM_MUSIC] limit in the for condition; no need to manage two separate variables for it. (unless you deliberately use$count elsewhere? o_O)

##### Share on other sites
As a side note, you can also use foreach insead of a for loop.

Cheers
Chris

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 14
• 14
• 10
• 9
• 11
• ### Forum Statistics

• Total Topics
634096
• Total Posts
3015492
×