View Full Version : copyDir module???
I have a Dir with several sub-Dirs.
Using IO::Dir, I can read the Dirhandles and use them to supply variables. I want to be able to control which dirs, IO::Dir reads so, imagine this
the Dirs are named like this: a la Carte, Table DHote, Christmas Fayre.
I want to be able to click 'activate/deactivate' in an html page so that onclick, only the desired menus shall display. I can do this, sort of mechanically, if I copy the relevant dirs to a new Dir and list those. But I cant find a module to copy Dirs and there may well be a better way to do this.
I ask for some pointers please rather than code.
Thank you
Bazz
mlseim
07-19-2005, 08:26 PM
I think File::Copy does files and/or directories.
http://search.cpan.org/~nwclark/perl-5.8.7/lib/File/Copy.pm
FishMonger
07-19-2005, 08:37 PM
Rather than coping your directories and files back & forth, it would be more efficient to use File::Find instead if IO::Dir and pass the desired dir name.
http://search.cpan.org/~nwclark/perl-5.8.7/lib/File/Find.pm
http://search.cpan.org/~merlyn/File-Finder-0.53/lib/File/Finder.pm
Thank you guys.
I am out of my depth again :( or to (try), to be positive I'm at the beginning of another learning curve.
I can see how those modules work but I cant work out, (in my head firstly), how I can use them for this app. I want to add to my cms system, the ability to make different menus 'wanted'. The system may well have already inputted, all menus for a particular restaurant for the year but, I want it only to show those that the restaurateur has clicked to make 'live'. so he/she can make a menu, check it, but not make it live until he/she is happy with it.
I'll scratch my head some more and, see how I get on. :)
bazz
FishMonger
07-20-2005, 04:26 PM
I'm not sure if I understand what you're tring to accomplish. Can you post a link to the site so we can view what you have done and include more details of what it needs to do?
Based on your other questions I've looked at, I think you need to be using a database for keeping track of this info instead of tring to structure then restructure your directory structure to meet your search needs.
Thanks FishMonger.
heh heh, no directory structures changes have been necessary - yet :)
Not sure which link would help explain this so I shall show you link for a restaurant.
ON menus, you should see it pop out with a list of menus. A click on these in a day or so, will show you the actual menu. This nav menu is populated because there exists a dir, for each meal menu. I want to be able to let the customer have all thier menus stored and only those which are live to present in the nav menu. No point having a Christmas or Thanksgiving menu showing at Easter?
I had thought about this as the process:
1. All menus live in a dir called 'menuStore'
2. On the cms admin page which enables addition and soon, also, deletion of menus, there is to be a link to activate or de-activate the menu
3. point 2 will run a script which has the sub moveDir, and this 'copies and pastes' the speciifc meal menu Dir from menuStore to another dir called liveMenus.
4. The script which shows the flyout meal menu would be reading that liveMenus dir and so, would present a link to see the recently copied dir/menu, because it is live.
I have got so far with a click-only, automated admin system that I would like to finish it as such. :) don't like the thought of an admin-intensive accident-prone database.
if you need me to show you other links, perhaps to show the admin pages, I could send you an email.
Any help you can give me will be gratefully received.
Bazz
FishMonger
07-20-2005, 08:16 PM
I don't understand your reason for not wanting to use a database. For the size and complexity of the site you're building, it doesn't make sense not to use a database. Your prior problem of sorting the directories could have been solved with a single SQL query statement. After all, if you think about it, the solution we were working with created a "mini" database in memory by building a complex associative array then used a complex sorting routine to get it to the desired order.
Instead of moving the directories, create a "subscribed" file that holds the menu directory (or file) names that you want displayed. When the menu is activated/deactivated its name is added or removed from the "subscribed" file. This is the method used in our email program SquirrelMail. You can then read-in the "subscribed" file into an array and pass it to the File::Find subroutine to extract all the seperate menus.
mlseim
07-20-2005, 10:57 PM
Fishmonger,
I know that this whole project Bazz is doing was begun long ago and taken on sort of a life of it's own.
Bazz,
When you started this, you began with sort of an existing thing (skeleton) and evolved it from there ... working on it for over a year now, building it up into what I say is the most complex Perl thing I've seen in a long time.
In hindsight, you do wish you began with MySQL, but now are probably exasperated at the thought of converting it over?
Fishmonger is right ... you should use MySQL.
Maybe you can hire a programmer to begin the MySQL database portion and get everything in place for you. That would take some of the burden off of you (your sanity, etc.) and you could concentrate on the conversion.
If The Chris System really generates some good income, the whole MySQL thing would pay for itself quickly, and you would get some needed sleep. ;)
I myself, am not a MySQL expert ... but based on the complexity of your system, I know it would be best.
Thanks guys.
Please don't get me wrong. I don't disagree with you.
It's like this because, as mlseim says, I did start with a series of previous scripts, which I had had made for an earlier similar-but-smaller project. Then my demands from them grew significantly and so too, did the potential amount of data.
The urgency for completion increased as well, especially when the ISP made some changes and the scripts stopped working - only on my site not the full server. :( They still work elsewhere.
Now I am finishing off the addition of features that were never in the older ones and which really will, I believe, make a difference to the finished result.
When I have some paying customers, I can learn mySQL or pay someone else
depending on the time available.
I shall try the suggestions you guys made earlier and see how I get on.
Bazz
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.