|XP is just a number|
Re: telling script to read from next lineby andreychek (Parson)
|on Jul 08, 2001 at 05:19 UTC||Need Help??|
I'm going to offer a two part answer. I'll first answer the question you asked, then I'll answer what it looks like you're really trying to do with your code :-)
1. The question you asked -- how to read data from a newline -- I think you may be making this problem harder then it is. Perl will gladly work with you on this. In fact, by default, it does read line by line, unless you tell it differently. As an example, check out this code:
That code will loop through your data file, line by line. By the time it's finished executing, it will print the url from each line of your data file.
However, it doesn't appear that you need to do something with each line, it appears that you want to pick out a random line from your data file, and do something with it. And you're in luck, because it just so happens that this information is in the FAQ. All you have to do to get a random line from your file is this:
As a final note, I noticed that you were accessing elements in the @part array by using syntax like @array. Actually, the correct syntax to access a single element in an array is $array and $array. It's using the $, instead of the @. The @ is for referring to an entire array or array slice. The $ is used to refer to one, scalar value, such as a single element in an array.
Hope that helps!