List in a different file used in the *.pl
Okay, I have read this a few times, I have tried it more.
I can't seem to get past that last detail that will help me understand how to call to an external file in a perl script, open the sucker, refer to it and use it.
Now I am clear on how to refer to it:
$list[0] or $list[$i] in a loop, $list[0][0] for lists with more bits to them, but how do I read it into the script in the first place, and what do I need to CHMOD the list in order to do it?
I think I need to CHOMP the list, too?
I don't know why I am stuck on this -- it seems so clear and yet I can't quite break the mental impasse that will make it ACTUALLY clear to me how it works and what I need to do to make it work.
Advice, sub-routines, tips, hints and links to tutorials all desparately welcome.
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
Orpheus posted this at 06:30 — 2nd April 2000.
They have: 568 posts
Joined: Nov 1999
So you just want to know what chomp does?
it removes the \n (line break) from the end of each element.
tazman posted this at 06:53 — 2nd April 2000.
They have: 99 posts
Joined: May 1999
Suzzane,
I am not clear on what you are referring to...
Do you have a text file that contains data you need to parse.....
If so, then use IO::File
$fh2 = IO::File->new("$listname", O_RDONLY);
while (<$fh2> ) {
$temp=$_;
chomp($temp); ##Strip that nasty \n
@templist = split(/;/, $temp); ### split line and assign to temp list
@templist2 = @cumlist;
@cumlist = (@templist2,@templist); #### add current to cumulative list
}
This example is to read from a text file a line at a time, split the line (assumes that you deliminate w/ ";" if not sub as necessary), and add to your cumulative list.
Hope this is what you were needing....if not, please post a clarification..
Tazman
PS: chmod the file in question to allow access for read rights by whatever class of user your server view a web process as....
Normally 444 is adequate.
[This message has been edited by tazman (edited 02 April 2000).]
fairhousing posted this at 07:48 — 2nd April 2000.
They have: 1,587 posts
Joined: Mar 1999
that makes 3 of us, what did u say???
------------------
CLICK 4 some tested resources for making money $, hosting, and web promotions.
My Site got hacked, but i'm coming back?
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
Suzanne posted this at 17:24 — 2nd April 2000.
She has: 5,507 posts
Joined: Feb 2000
Strangely enough, I had to leave my beast (computer) last night and so I picked up the book...
Okay, here goes...
I have a multi-dimensional list that I need to access. It has two dimensions.
This is my solution, please post yea/nay!
Suzanne posted this at 02:49 — 3rd April 2000.
She has: 5,507 posts
Joined: Feb 2000
In an effort to troubleshoot what I thought was a problem with another part of the script, I printed @images and it returns this:
Rob Pengelly posted this at 12:24 — 3rd April 2000.
They have: 850 posts
Joined: Jul 1999
Can you show us what the text file looks like?
------------------
L34RN |-|0\/\/ T0 5P34K L33T JU5T L1K3 4N 40L |-|4X0R
http://www.wiredstart.com : The Technology Start Page
http://www.thehungersite.com - http://www.therainforestsite.com
http://www.ratemymullet.com - Beauty is only mullet deep.
japhy posted this at 12:31 — 3rd April 2000.
They have: 161 posts
Joined: Dec 1999
tazman - there's NO need to use IO::File and cause a whole load of indirection. Filehandles are the preferred means of dealing with files.
Suzanne - your code is nearly correct.
Suzanne posted this at 18:03 — 3rd April 2000.
She has: 5,507 posts
Joined: Feb 2000
You ever read someone's post and make that gutteral 'oh, my god, I finally get it!' sound that comes out like 'unk!'??
Thanks, that makes a BIG difference. As usual, it's the little details I trip over.
Much obliged, Japhy,
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
Suzanne posted this at 04:11 — 4th April 2000.
She has: 5,507 posts
Joined: Feb 2000
Okay, The file doesn't open and can't seem to be found...
Sigh.
The file is a text file -- formatted like this:
stuff|other stuff|more stuff|end of stuff
stuff1|other stuff 1|more stuff 1|end of stuff 1
Do I need to make it required file? Do I need to have it end with 1;?
Argh.
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
fairhousing posted this at 08:51 — 4th April 2000.
They have: 1,587 posts
Joined: Mar 1999
the split function?
i must say i'm just about totally lost on this one, i just don't understand and i'm confused, but what's new.
------------------
CLICK 4 some tested resources for making money $, hosting, and web promotions.
My Site got hacked, but i'm coming back?
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
japhy posted this at 11:47 — 4th April 2000.
They have: 161 posts
Joined: Dec 1999
The file's obviously not where you think it is. Check to make sure you're giving it the right path to the file.
A file doesn't need to end with a "1;" unless you're including the file via require() or use(). If you're merely opening it to read from or write to, it doesn't need to conform to any rules.
------------------
--
MIDN 4/C PINYAN, NROTCURPI, US Naval Reserve
Suzanne posted this at 17:46 — 4th April 2000.
She has: 5,507 posts
Joined: Feb 2000
Okay, so how do I tell the silly thing that it's in the same damn folder as the pl file?
Gddmn it I am going to get this included file thing straight, I know I will, but I am SO bloody frustrated. To test the rest of the script, I am just listing the whole list in the actual .pl file but I don't want to have it that way -- I want it separate.
Fairhousing -- split just breaks the file down into parts and feeds it into a list. So splitting fun|stuff|basketball|baseball would create @sports = ('fun', 'stuff', 'basketball', 'baseball'). I think. I hope.
What I want is to take:
fun|stuff|basketball|baseball
sad|stuff|funerals|death
happy|stuff|kittens|roses
and make one list:
@moods = (['fun', 'stuff', 'basketball', 'baseball'], ['sad', 'stuff', 'funerals', 'death'], ['happy', 'stuff', 'kittens', 'roses']);
But I have .gif and numbers in there, too, so I don't know if I need something extra to sort it out, because in my book, it says that actual numbers shouldn't be quoted, and I don't think anything is being quoted because I keep getting weird errors about the .gif which means I don't have 'something.gif' but just something.gif, which is wrong.
Ack!
Suzanne
------------------
Zero Cattle
Suzanne
Tables DeMystified
[This message has been edited by Suzanne (edited 04 April 2000).]
fairhousing posted this at 20:56 — 4th April 2000.
They have: 1,587 posts
Joined: Mar 1999
this is the reason i try to make my own scripts when i can. because when i try to hack up one of those free ones it can be harder than making my own because i've got no idea what the other person was thinking when they made the script, hehe.
don't worry Suzanne, i'm confused here too.
------------------
CLICK 4 some tested resources for making money $, hosting, and web promotions.
My Site got hacked, but i'm coming back?
Traffic-Website.com free traffic, affiliate programs, hosting, & domain names.
My Site got hacked, but i'm coming back?
Suzanne posted this at 18:03 — 9th April 2000.
She has: 5,507 posts
Joined: Feb 2000
Okay, I hate to leave anyone hanging (like everyone here is just waiting for me to explain what I am doing -- ha!)
This is what finally worked:
What I did was type in the first couple of lines of the database into the script (list), work out the rest of the script, then generate the .txt file that I will be using for the database using this code:
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.