Rathlar has asked for the wisdom of the Perl Monks concerning the following question:
i have file mdata.txt and inside the lines are like this:
number name
Here is what I need to do:
Pull the number and name from the txt file located at a user defined line number. Then split the 2 and assign them to variables.
splitting i can do... at least i think i have that part right...
I think that will split the line and assign the variables in one go unless I messed up there as well...my ($mnum,$mname) = split(/ /,$mdata,2);
Basically I just need to search a file for a specific line number and then assign the text on that line to $mdata
Would anyone be able to help me figure this out? I'd be forever grateful for help with this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Return full line from line number X
by CountZero (Bishop) on Oct 26, 2008 at 23:03 UTC | |
by Rathlar (Initiate) on Oct 26, 2008 at 23:23 UTC | |
by krusty (Hermit) on Oct 27, 2008 at 00:47 UTC | |
by Rathlar (Initiate) on Oct 27, 2008 at 02:51 UTC | |
|
Re: Return full line from line number X
by JavaFan (Canon) on Oct 26, 2008 at 22:39 UTC | |
by CountZero (Bishop) on Oct 26, 2008 at 22:58 UTC | |
|
Re: Return full line from line number X
by oko1 (Deacon) on Oct 27, 2008 at 03:19 UTC | |
|
Re: Return full line from line number X
by lightoverhead (Pilgrim) on Oct 27, 2008 at 02:08 UTC |