# Problem with Perl script that creates directories with names

Status
Not open for further replies.

#### vlsi_fanatic

##### Junior Member level 1
Help with perl

Hi,
i am new to perl. I got a problem. I am writing a script to create a
directory whose name will be generated in the script. for example one
of the directory name I need to create will be 9.1.3C I am getting
this value in a variable ($dirname) and I am using print mkdir C:/perl/$dirname command to create it. Since the value
includes a Charecter perl is giving me syntax error. If the value is
just 9.1.3 the print line is working fine. But with that charecter at
the end I am getting problems. Can anyone solve my problem?

Thanks

#### nand_gates

Re: Help with perl

Code:

hope this helps.

#### disney

##### Member level 1
Re: Help with perl

have it in quotes

#### kovalja

##### Junior Member level 2
Re: Help with perl

Hi,

when I see your code, I'm really a little bit confused. Shouldn't you use back-slash instead of slash in Win directory path?

Let me know if windows changed the command line behaviour

BTW. If you want to create the directory structure similar you presented, try this:
Code:
system( "mkdir C:\\perl\\$dirname" ); HTH, kovalja #### jarodz ##### Full Member level 1 #### vlsi_fanatic ##### Junior Member level 1 Re: Help with perl kovalja said: Hi, when I see your code, I'm really a little bit confused. Shouldn't you use back-slash instead of slash in Win directory path? Let me know if windows changed the command line behaviour BTW. If you want to create the directory structure similar you presented, try this: Code: system( "mkdir C:\\perl\\$dirname" );

HTH,
kovalja

Windows didn't change the command line behavior. In this way you don't need to escape the backslash in the path. Try using it. It works.

jammed said:
make sure your directory name is enclosed in quotes.

\$dirname = "9.1.3C";

hope this helps.

If I put it in Quotes it works.

Thanks.

Status
Not open for further replies.