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.


In reply to Re: writing all the strings between two particular substrings by FalseVinylShrub
in thread writing all the strings between two particular substrings by giridharreddy9

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.