6 Replies - 781 Views - Last Post: 05 November 2015 - 12:36 AM

#1 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Perl question(directories)

Posted 04 November 2015 - 11:09 PM

hi everyone

i am need to write a script that ask the user to input a directory path and make that directory.

i mean the path must be asked the user and after that a directory must be created by that path

so can you help me
Is This A Good Question/Topic? 0
  • +

Replies To: Perl question(directories)

#2 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,580
  • Joined: 13-June 14

Re: Perl question(directories)

Posted 04 November 2015 - 11:43 PM

You're going to need to show an attempt at solving the problem and tell us where you're stuck. Have you looked at the documentation for Perl's core modules? There's one in particular that will be very helpful here - look for one containing the word "File".
Was This Post Helpful? 0
  • +
  • -

#3 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Re: Perl question(directories)

Posted 05 November 2015 - 12:19 AM

ok this is my code

my $dir = readline STDIN;
chomp $dir;

if($dir =~/the path/) {

    mkdir( $dir );
     print"the directory is made successfully";

}else {
     print"your syntax is wrong\n";
}




and my problem is, it will not make the directory
Was This Post Helpful? 0
  • +
  • -

#4 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,580
  • Joined: 13-June 14

Re: Perl question(directories)

Posted 05 November 2015 - 12:24 AM

What is the purpose of the match on line 4? Think about what you're saying there.
Was This Post Helpful? 0
  • +
  • -

#5 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Re: Perl question(directories)

Posted 05 November 2015 - 12:28 AM

it is like this


if($dir =~/['a'..'z'][:][/]['a'..'z']/gi)




i want it to like (D:/test/perl)
Was This Post Helpful? 0
  • +
  • -

#6 ndc85430  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 611
  • View blog
  • Posts: 2,580
  • Joined: 13-June 14

Re: Perl question(directories)

Posted 05 November 2015 - 12:31 AM

I'm not too familiar with Perl's regex syntax, so you'll have to look that up. My point was that the check in your original code would only ever match one thing (i.e. the string "the path").
Was This Post Helpful? 0
  • +
  • -

#7 Yya09  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 19
  • Joined: 22-October 15

Re: Perl question(directories)

Posted 05 November 2015 - 12:36 AM

ok thanks
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1