Greenguy's Board

Greenguy's Board (http://www.greenguysboard.com/board/index.php)
-   Programming & Scripting (http://www.greenguysboard.com/board/forumdisplay.php?f=15)
-   -   perl help (http://www.greenguysboard.com/board/showthread.php?t=3599)

spacemanspiff 2004-01-03 10:55 AM

perl help
 
Ok, I'm trying to learn a little perl programming. I have an include file that I use in a bunch of different folders, and I want to be able to replace it without uploading it to each folder individually.

I can locate all the files from the command line. Can a perl program do this? I want to:

1. locate all the files.
2. replace the old files with the new one.

I'm just hoping one of you scripting gurus can shorten the learning curve for me. :)

Thanks
SS

amadman 2004-01-03 02:57 PM

Hmmm.... You mean you have the same include file in a bunch of folders? If so then you may want to consider having 1 include file for all of the folders. Then when you need to make changes you only need to change the one.

Or am I totally confused about what you are asking?|rasta|

spacemanspiff 2004-01-03 08:11 PM

Here's the way it's set up. I have the root folder, domain.com, that has an include file in it that's inserted on most of the html docs in the root. I also have a bunch of sub-folders, that need to have the same include file on the html docs in them. The way it's set up now, I have to upload the include file to all of the subfolders whenever I make a change to it.

I can (and probably will) upload the file to an aliased folder and change all the includes to virtual includes. I have a larger project I want to do, and this is the first step in learning to write programs.

More confused now? |jester|

amadman 2004-01-03 09:01 PM

Quote:

Originally posted by spacemanspiff

More confused now? |jester|

Yup... :)

But I think I got you. It sounds beyond me thought I am afraid.|sad|

spacemanspiff 2004-01-03 09:14 PM

I guess the simplest way to say it is how do you search a directory for a specific file, then upload a new version wherever it's found.

urb 2004-01-04 01:26 PM

If the file you are looking to alter is the same for each location, like a banner and supporting code, you can use a simple include file which all the pages can be pointed at.



Then to update every page which is linked into the include, you just edit one file.

I'm not sure if that's what you were asking, so forgive me if you already know this. :)

spacemanspiff 2004-01-04 02:51 PM

That works fine Urb. I'll do it that way. I suppose that's what you were talking about too Madman. Learned something new about virtual includes. Thanks guys.:)

I would still like to know the best way to accomplisg my original goal. I don't need the exact code. Just a general outline would be great.

vmp22 2004-01-15 02:11 AM

i think i kinda understand what you're looking for....

if you are using PHP, the easiest way would be set the include_path directive in your php.ini file.

if you are using Perl, set the path where your include file is located into the Perl include array; for example, if your include file is called "include.pl" which is located in "/some/location/", in each Perl script, do this:

push @INC,'/some/location/';
use "include.pl";

Urb's suggestion about using the SSI include will work too

hope that helps a bit... unless i am completely wrong about what you're looking for |sad|

spacemanspiff 2004-01-15 08:35 AM

It all helps vmp. Using the ssi is probably the correct way to do the job, and that's the way I ended up doing it. I wanted to do the search and replace method just to learn some perl. I learned enough doing that to modify another program that does some very useful things. I'm learning new stuff every day. It's really kind of fun.

Thanks again to all who helped.


All times are GMT -4. The time now is 01:26 PM.

Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc