T
toomanyjoes
Hello,
I'm brand new to perl. I need to delete newlines from a text file but
only in the case that the line does not begin with a number. Then write
the results into a new text file.
For instance my text file looks like this.
1sampletextsampletextsamplet22tsampletextsampletextsampletext
2sampletextsampletextsampletextsam56etextsampletextsampletext
3sampletextsampletextsampletextsampletextsampletextsampletext
8sampletextsampletextsampletex765mpletextsampletextsampletext
9sampletextsampletextsampletextsampletextsampletextsampletext
15sampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletextsampletextsample324tsampletextsampletext
18sampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletext566pletextsampletextsampletextsampletext
22sampletextsampletextsampletextsampletextsampletextsampletext
1sampletextsampletextsamplete467ampletextsampletextsampletext
As you can see I would like every line to START with a number.
Also after this is done I need another script that will grab the number
at the beginning and put it in a database field and then grab all the
"sampletext" up until the next number and put that in another database
field. This taking into account that there could be numbers within the
sampletext that are not found at the beginning of a line. These numbers
should be taken as part of the sample text and not confused with the
numbers at the beginning of the line.(A little harder I'm sure) Any
questions you guys can help me with I'll appreciate.
Thanks!
Joe
I'm brand new to perl. I need to delete newlines from a text file but
only in the case that the line does not begin with a number. Then write
the results into a new text file.
For instance my text file looks like this.
1sampletextsampletextsamplet22tsampletextsampletextsampletext
2sampletextsampletextsampletextsam56etextsampletextsampletext
3sampletextsampletextsampletextsampletextsampletextsampletext
8sampletextsampletextsampletex765mpletextsampletextsampletext
9sampletextsampletextsampletextsampletextsampletextsampletext
15sampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletextsampletextsample324tsampletextsampletext
18sampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletextsampletextsampletextsampletextsampletext
sampletextsampletext566pletextsampletextsampletextsampletext
22sampletextsampletextsampletextsampletextsampletextsampletext
1sampletextsampletextsamplete467ampletextsampletextsampletext
As you can see I would like every line to START with a number.
Also after this is done I need another script that will grab the number
at the beginning and put it in a database field and then grab all the
"sampletext" up until the next number and put that in another database
field. This taking into account that there could be numbers within the
sampletext that are not found at the beginning of a line. These numbers
should be taken as part of the sample text and not confused with the
numbers at the beginning of the line.(A little harder I'm sure) Any
questions you guys can help me with I'll appreciate.
Thanks!
Joe