FAQ
Hi all,

I have a problem in combining the nested/multiple patterns. The input of the file is as follows:

Input:-
<f1>
A
B
C
</f1=c>

D
E
F

<f1=c>
G
H
</f1=c>

I
J
<f1=c>

K

</f1=c>
L
M
<f1=c>

N
O
</f1>


and i would like to convert in to the following manner

Output:
<f1>
A
B
C
G
H
K
N
O
</f1>
D
E
F

I
J

L
M

I have got the file contents as showed in the input. I am trying to combine the matter between <f1=c>and </f1=c> in to single <f1>…….</f1>

Can anyone help in how to combine these nested/multiple patterns

Thanks in advance for the help

Regards
Anand


---------------------------------
Jiyo cricket on Yahoo! India cricket
Yahoo! Messenger Mobile Stay in touch with your buddies all the time.

Search Discussions

  • Xavier Noria at Mar 29, 2006 at 7:14 am

    On Mar 29, 2006, at 8:10, anand kumar wrote:

    Hi all,

    I have a problem in combining the nested/multiple
    patterns. The input of the file is as follows:
    The problem to answer this message is that looks like the example is
    a simplification of the real input data, and thus it is difficult to
    come with a specific solution because you don't know which
    assumptions taken from the example actually apply.

    Anyway, I think the point here is that you know the flip-flop
    operator, which is .. in scalar context (search perlop for "flip").
    This is a program that outputs what you want modulus blank lines to
    depict its usage, so you can adapt it if it indeed does the job:

    @inside = ();
    @outside = ();
    while (<>) {
    next unless /\S/;
    my $inside = m{^<f1} .. m{^</f1};
    next if m{^</?f1=};
    print, next if $inside;
    push @outside, $_;
    }
    print @outside;

    If the flip-flop operator does not make sense in the actual input
    data please write again.

    -- fxn

    % perl foo.pl input
    <f1>
    A
    B
    C
    G
    H
    K
    N
    O
    </f1>
    D
    E
    F
    I
    J
    L
    M
  • Anand kumar at Mar 29, 2006 at 8:28 am
    Hi all

    Sorry for not posting the question clearly, Please find the attachment of the sample file. The matter enclosed in <f1>….</f1=c>, <f1=c>…..</f1=c>….<f1=c>……</f1> are all the foot notes that are spanning on various pages, now what I am trying to do is that to combine all the related footnotes that are spanned in various pages and place them at on place. Here <f1> indicates the starting of the footnotes, <f1=c> indicates that the footnote continues from previous page, the </f1=c> indicates that the foot notes continues in next page and </f1> indicates the end of the footnotes

    Note :- please open the attached file in DOS or Linux environment

    please help in this matter

    Thanks in advance for the help

    Regards
    Anand

    anand kumar wrote:
    Hi all,

    I have a problem in combining the nested/multiple patterns. The input of the file is as follows:

    Input:-

    A
    B
    C


    D
    E
    F


    G
    H


    I
    J


    K


    L
    M


    N
    O



    and i would like to convert in to the following manner

    Output:

    A
    B
    C
    G
    H
    K
    N
    O

    D
    E
    F

    I
    J

    L
    M

    I have got the file contents as showed in the input. I am trying to combine the matter between and in to single …….

    Can anyone help in how to combine these nested/multiple patterns

    Thanks in advance for the help

    Regards
    Anand


    ---------------------------------
    Jiyo cricket on Yahoo! India cricket
    Yahoo! Messenger Mobile Stay in touch with your buddies all the time.


    ---------------------------------
    Jiyo cricket on Yahoo! India cricket
    Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
  • Xavier Noria at Mar 29, 2006 at 8:38 am

    On Mar 29, 2006, at 10:28, anand kumar wrote:

    Sorry for not posting the question clearly, Please find the
    attachment of the sample file. The matter enclosed in <f1>….</
    f1=c>, <f1=c>…..</f1=c>….<f1=c>……</f1> are all the foot notes that
    are spanning on various pages, now what I am trying to do is that
    to combine all the related footnotes that are spanned in various
    pages and place them at on place. Here <f1> indicates the starting
    of the footnotes, <f1=c> indicates that the footnote continues from
    previous page, the </f1=c> indicates that the foot notes continues
    in next page and </f1> indicates the end of the footnotes
    Looks like the code I sent before is a good starting point. The only
    new relevant stuff I see are the "<fn>" tags, but you could adapt the
    script easily to deal with that correctly and to do what's needed
    with empty lines. If you understand the flip-flop operator you've got
    the script.

    -- fxn
  • Anand kumar at Mar 29, 2006 at 10:01 am
    Hi

    Yes, of course the code u have sent is very helpful and thanks for that. But the problem here is that in a single file there may be various number of foot notes i.e. <f1>,<f2><f3>………….so on. For all these the conventions are the same as told before. I am having problem in combining the relevant ones. Please help in this matter

    Thanks in advance for the help

    Regards
    Anand
    Xavier Noria wrote:
    On Mar 29, 2006, at 10:28, anand kumar wrote:

    Sorry for not posting the question clearly, Please find the
    attachment of the sample file. The matter enclosed in ….> f1=c>, …..….…… are all the foot notes that
    are spanning on various pages, now what I am trying to do is that
    to combine all the related footnotes that are spanned in various
    pages and place them at on place. Here indicates the starting
    of the footnotes, indicates that the footnote continues from
    previous page, the indicates that the foot notes continues
    in next page and indicates the end of the footnotes
    Looks like the code I sent before is a good starting point. The only
    new relevant stuff I see are the "" tags, but you could adapt the
    script easily to deal with that correctly and to do what's needed
    with empty lines. If you understand the flip-flop operator you've got
    the script.

    -- fxn



    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org






    ---------------------------------
    Jiyo cricket on Yahoo! India cricket
    Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
  • Xavier Noria at Mar 29, 2006 at 10:07 am

    On Mar 29, 2006, at 12:01, anand kumar wrote:

    Yes, of course the code u have sent is very helpful and thanks for
    that. But the problem here is that in a single file there may be
    various number of foot notes i.e. <f1>,<f2><f3>………….so on. For all
    these the conventions are the same as told before. I am having
    problem in combining the relevant ones. Please help in this matter
    I think we can go back to the simplification. Would you please send
    an analogous simplified example that contains sections f1, f2, f3,
    following the same structure as in the original data?

    -- fxn
  • Anand kumar at Mar 29, 2006 at 10:33 am
    Hi

    Please find the file as an attachment with this mail

    Regards
    Anand

    Xavier Noria wrote:
    On Mar 29, 2006, at 12:01, anand kumar wrote:

    Yes, of course the code u have sent is very helpful and thanks for
    that. But the problem here is that in a single file there may be
    various number of foot notes i.e. ,………….so on. For all
    these the conventions are the same as told before. I am having
    problem in combining the relevant ones. Please help in this matter
    I think we can go back to the simplification. Would you please send
    an analogous simplified example that contains sections f1, f2, f3,
    following the same structure as in the original data?

    -- fxn



    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org






    ---------------------------------
    Jiyo cricket on Yahoo! India cricket
    Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
  • Xavier Noria at Mar 29, 2006 at 10:41 am

    On Mar 29, 2006, at 12:32, anand kumar wrote:

    Please find the file as an attachment with this mail
    Well, that didn't look like a simplification at all. I asked for
    another example with simplified notation because we already have an
    idea of the actual input and because you need to provide the
    *expected output* as well, which will be easier to produce and
    understand that way.

    -- fxn
  • Anand kumar at Mar 29, 2006 at 11:52 am
    Hi

    Please find the attached input.dat and output.dat

    Thanks in advance for the help

    Regards
    Anand

    Xavier Noria wrote:
    On Mar 29, 2006, at 12:32, anand kumar wrote:

    Please find the file as an attachment with this mail
    Well, that didn't look like a simplification at all. I asked for
    another example with simplified notation because we already have an
    idea of the actual input and because you need to provide the
    *expected output* as well, which will be easier to produce and
    understand that way.

    -- fxn


    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org






    ---------------------------------
    Jiyo cricket on Yahoo! India cricket
    Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
  • Anand kumar at Mar 29, 2006 at 11:55 am
    Hi

    Please find the attached input.dat and output.dat

    Thanks in advance for the help

    Regards
    Anand

    Xavier Noria wrote:
    On Mar 29, 2006, at 12:32, anand kumar wrote:

    Please find the file as an attachment with this mail
    Well, that didn't look like a simplification at all. I asked for
    another example with simplified notation because we already have an
    idea of the actual input and because you need to provide the
    *expected output* as well, which will be easier to produce and
    understand that way.

    -- fxn


    --
    To unsubscribe, e-mail: beginners-unsubscribe@perl.org
    For additional commands, e-mail: beginners-help@perl.org






    ---------------------------------
    Jiyo cricket on Yahoo! India cricket
    Yahoo! Messenger Mobile Stay in touch with your buddies all the time.
  • Xavier Noria at Mar 29, 2006 at 2:30 pm

    On Mar 29, 2006, at 13:55, anand kumar wrote:

    Please find the attached input.dat and output.dat
    I asked twice to go back to the simplified notation and that was
    twice ignored. Sorry, I can't spend more time on this thread.

    -- fxn

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupbeginners @
categoriesperl
postedMar 29, '06 at 6:10a
activeMar 29, '06 at 2:30p
posts11
users2
websiteperl.org

2 users in discussion

Anand kumar: 6 posts Xavier Noria: 5 posts

People

Translate

site design / logo © 2022 Grokbase