I have a script that will create a directory based on user input. The directories are named numerically. For example, some could be 210999 and others could be 2813220. I want to match anything that starts with a 2 but has only 6 digits to be created in a parent folder named 200. Anything that starts with 28 and has 7 digits like the example above to be created in the parent folder called 2800. Part of my lines look like:
elsif ($Proj =~ /2\d\d\d\d\d/)
mkdir ($p200.$Proj, 0777)
elsif ($Proj =~ /28\d\d\d\d\d/)
mkdir ($p2800.$Proj, 0777)
I left some of the symbols out for clarity. There are a lot of other folders with the same type of code as above and everything is working fine, except when I input 2813220 into the text box, the folder is created in the 200 and not the 2800 parent folder. How can I write it so that it matches the first two digits, 28, and then counts 5 digits. It seems to me that the number of digits are not matching. I hope this makes sense, please let me know if there's a better way for me to do this. thanks
elsif ($Proj =~ /2\d\d\d\d\d/)
mkdir ($p200.$Proj, 0777)
elsif ($Proj =~ /28\d\d\d\d\d/)
mkdir ($p2800.$Proj, 0777)
I left some of the symbols out for clarity. There are a lot of other folders with the same type of code as above and everything is working fine, except when I input 2813220 into the text box, the folder is created in the 200 and not the 2800 parent folder. How can I write it so that it matches the first two digits, 28, and then counts 5 digits. It seems to me that the number of digits are not matching. I hope this makes sense, please let me know if there's a better way for me to do this. thanks