How can you do different things on certain lines in a text filedivided by separators?

Discussion in 'Perl Misc' started by hans, Mar 1, 2011.

  1. hans

    hans Guest

    How can you do different things on lines in a file divided in rages,
    for example:

    aaa
    ..
    ..
    .. insert "aaa" on every line between aaa and bbb
    ..
    bbb
    ..
    ..
    .. insert "bbb" on every line between bbb and ccc
    ..
    ..
    ccc
    ..
    .. etc.
    ..
    hans, Mar 1, 2011
    #1
    1. Advertising

  2. hans

    J. Gleixner Guest

    hans wrote:
    > How can you do different things on lines in a file divided in rages,
    > for example:


    What do you have so far?

    perldoc -f open
    perldoc perldocfaq6
    J. Gleixner, Mar 1, 2011
    #2
    1. Advertising

  3. hans

    J. Gleixner Guest

    J. Gleixner wrote:
    > hans wrote:
    >> How can you do different things on lines in a file divided in rages,
    >> for example:

    >
    > What do you have so far?
    >
    > perldoc -f open
    > perldoc perldocfaq6


    Make that perldoc perlfaq6
    J. Gleixner, Mar 1, 2011
    #3
  4. Re: How can you do different things on certain lines in a text file divided by separators?

    "hans" <> wrote in message
    news:...
    > How can you do different things on lines in a file divided in rages,
    > for example:
    >
    > aaa
    > .
    > .
    > . insert "aaa" on every line between aaa and bbb
    > .
    > bbb
    > .
    > .
    > . insert "bbb" on every line between bbb and ccc
    > .
    > .
    > ccc
    > .
    > . etc.
    > .




    while(<DATA>)
    {
    if ( /aaa/ .. /bbb/ ) {
    print "line between aaa and bbb : $_" }

    if ( /bbb/ .. /ccc/ ) {
    print "line between bbb and ccc : $_" }
    }


    __DATA__
    aaa
    hello1
    hello2
    hello3
    bbb
    world1
    world2
    world3
    ccc
    George Mpouras, Mar 2, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Edward Grosso via .NET 247

    Save a Recordset to an ASCII file with custom field separators

    Edward Grosso via .NET 247, Jun 11, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    457
    David Browne
    Jun 11, 2004
  2. =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=

    vs2005 publish website doing bad things, bad things

    =?Utf-8?B?V2lsbGlhbSBTdWxsaXZhbg==?=, Oct 25, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    596
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=
    Oct 25, 2006
  3. Martin Wells

    First things you check for when you've got errors

    Martin Wells, Oct 6, 2007, in forum: C Programming
    Replies:
    15
    Views:
    466
    Old Wolf
    Oct 8, 2007
  4. PerlFAQ Server
    Replies:
    0
    Views:
    162
    PerlFAQ Server
    Jan 14, 2011
  5. PerlFAQ Server
    Replies:
    0
    Views:
    149
    PerlFAQ Server
    Apr 19, 2011
Loading...

Share This Page