in reply to writing all the strings between two particular substrings

Hi

I don't think I quite understand what you are aiming to do. Perhaps if you posted the desired output to go with the input data, it would be clearer.

But here are some notes on your code:

Taking a guess at what you want to do, try this for starters:

use strict; use warnings; use diagnostics; while (<>) { s/^\s*input\s*//; s/^\s*output\s*//; s/,/;/g; print; }

This simply strips 'input' and 'output' from the starts of the lines (with variable amounts of white space) and turns ',' into ';'. I have done it using <> so that it will act as a filter. You specify the input and output files on the command line e.g.

$ perl test.pl 5378_scan.v >data.txt $ cat data.txt CK; n3065gat; n3066gat; n3067gat; n3068gat; n3069gat; n3070gat;n3100ga +t; test_si; test_se; n3104gat; n3105gat; n3106gat; n3107gat; n3108gat; n3109gat; n3110gat;

If you decide to open the files within the script, look up using the 3-argument form of open, lexical file handles and checking the return value of open.

Come back and say if this helps, and any other questions you have.

Regards, F.V.S.

Replies are listed 'Best First'.
Re^2: writing all the strings between two particular substrings
by Anonymous Monk on Oct 28, 2009 at 06:47 UTC