Jump to content
  • Advertisement
Sign in to follow this  
Woody FX

A Perl question.

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!