hiw do i perform this extraction

Discussion in 'Perl Misc' started by kitcha, Aug 21, 2006.

  1. kitcha

    kitcha Guest

    i have a file of this format..

    ModelGen Info, Time 63425843 ps, Instance Device/Device_core
    00000084 E5810000 STR r0,[r1,#0]

    i want the script to print an output like this

    Time 63425843 ps

    00000084 E5810000 STR r0,[r1,#0]


    wht cmds shud i use?
     
    kitcha, Aug 21, 2006
    #1
    1. Advertising

  2. kitcha <> wrote:

    > wht cmds shud i use?



    -------------------------
    #!/usr/bin/perl
    use warnings;
    use strict;

    while ( <DATA> ) {
    if ( s/^\s\s+/ / ) {
    print;
    next;
    }
    s/^[^,]+,\s*//;
    s/,[^,]+$//;
    print "$_\n";
    }

    __DATA__
    ModelGen Info, Time 63425843 ps, Instance Device/Device_core
    00000084 E5810000 STR r0,[r1,#0]
    -------------------------


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Aug 21, 2006
    #2
    1. Advertising

  3. kitcha wrote:
    > i have a file of this format..
    >
    > ModelGen Info, Time 63425843 ps, Instance Device/Device_core
    > 00000084 E5810000 STR r0,[r1,#0]
    >
    > i want the script to print an output like this
    >
    > Time 63425843 ps
    >
    > 00000084 E5810000 STR r0,[r1,#0]
    >
    >
    > wht cmds shud i use?
    >


    I thk ul hv mr lck f u us ths 1s:

    /!perl
    use strict;
    use warnings;
    while (<$posting>) {
    s/wht/what/;
    s/cmds/commands/;
    s/shud/should/;
    s/i/I/;
    print;
    }

    bcz ts hrd 2 tl wt ppl rly mn whn ty us txt spk on usnt so i wdnt rcmnd t.
     
    RedGrittyBrick, Aug 21, 2006
    #3
  4. Re: -multiposted-

    wrote:
    > "kitcha" <> wrote:
    >>>[ snip multiposted message ]

    >
    > This message has been posted more than once as separate articles:
    > comp.lang.perl.misc
    > <news:>
    >
    > perl.beginners
    > <news:>
    >
    >
    > This practice, known as multiposting, is generally considered
    > impolite in Usenet newsgroups. For an explanation, please see:
    >
    > http://www.cs.tut.fi/~jkorpela/usenet/xpost.html


    *THIS* message has been posted more than once as separate articles:

    comp.lang.perl.misc
    <news:>

    comp.lang.perl.misc
    <news:>


    This practice, known as multiposting, is pissing some of us off.
     
    John W. Krahn, Aug 21, 2006
    #4
  5. Re: -multiposted-

    "John W. Krahn" <> writes:

    > *THIS* message has been posted more than once as separate articles:
    >
    > comp.lang.perl.misc
    > <news:>
    >
    > comp.lang.perl.misc
    > <news:>
    >
    >
    > This practice, known as multiposting, is pissing some of us off.


    ESPECIALLY as some of us have filtered out the offending multiposts in
    the first place -- now we also need to filter out the multiposted
    messages nagging the newsgroup at large about multiposting?

    Charlton


    --
    Charlton Wilbur
     
    Charlton Wilbur, Aug 21, 2006
    #5
  6. kitcha

    Guest

    Re: -multiposted-

    John W. Krahn wrote:

    > This practice, known as multiposting, is pissing some of us off.


    Sheesh - I tested this damn thing with over 100 test posts and I never
    saw this.

    OK, OK - I'm turning off the bot. I gotta figure out how to do
    effective "real world" testing without actually posting back to usenet.
    Maybe I'll have the bot send me an e-mail or something...

    --
    David Filmer (http://DavidFilmer.com)
     
    , Aug 21, 2006
    #6
  7. kitcha

    Dr.Ruud Guest

    Re: -multiposted-

    schreef:
    > John W. Krahn:


    >> This practice, known as multiposting, is pissing some of us off.

    >
    > Sheesh - I tested this damn thing with over 100 test posts and I never
    > saw this.
    >
    > OK, OK - I'm turning off the bot. I gotta figure out how to do
    > effective "real world" testing without actually posting back to
    > usenet. Maybe I'll have the bot send me an e-mail or something...


    That is how a bot of mine works: I have to reply to its email before it
    posts a message. I wrote it quite a while ago, in procmail+sed, and it
    is still operational (look for "newszilla-pmf" in google-groups for
    details), but is hardly ever used, because newszilla is just too good.

    I included in the source a way to skip the approval-by-email, but I
    never activated that, because that would open a spam-path (from a
    webpage almost directly to usenet). The bot can easily be adjusted to
    send the moderation email to multiple addresses, so more than just me
    can be involved in the approval/rejection procedure. In short, it is a
    moderated bot, and it transforms data coming from a web-form into a
    usenet posting.

    (It doesn't really solve a problem, I wrote it mainly to show that it
    could be done with what is available to an average client of my ISP.)

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Aug 22, 2006
    #7
  8. kitcha

    kitcha Guest

    Hi Tad ,
    Thanks for the script but it has some issues

    I have a 1000 line document like this...


    # ModelGen Info, Time 14088224 ps, Instance /tb_device/device_u1/
    # 00000098 E88B01FE STMIA r11,{r1-r8}
    # ModelGen Info, Time 14318056 ps, Instance /tb_device/device_u1/
    # Data Write FFFFFE08
    00000010
    # ModelGen Info, Time 14344356 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE0C
    000000A0
    # ModelGen Info, Time 14370656 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE10
    00000000
    # ModelGen Info, Time 14396956 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE14
    00000060
    # ModelGen Info, Time 14423256 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE18
    00000000
    # ModelGen Info, Time 14449556 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE1C
    00008050
    # ModelGen Info, Time 14475856 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE20
    00000080
    # ModelGen Info, Time 14502156 ps, Instance /tb_device/device_u1/
    # (seq) FFFFFE24
    00000020
    # ModelGen Info, Time 14509024 ps, Instance /tb_device/device_u1/
    # 0000009C E3A01008 MOV r1,#8
    # ModelGen Info, Time 14719424 ps, Instance /tb_device/device_u1/
    # 000000A0 E3A02E1A MOV r2,#0x1a0
    # ModelGen Info, Time 14929824 ps, Instance /tb_device/device_u1/
    # 000000A4 E59F303C LDR r3,0xe8
    # ModelGen Info, Time 15343756 ps, Instance /tb_device/device_u1/
    # Data Read 000000E8
    FFFFFE00
    # ModelGen Info, Time 15363774 ps, Instance /tb_device/device_u1/
    # 000000A8 E8830006 STMIA r3,{r1,r2}
    # ModelGen Info, Time 15593606 ps, Instance /tb_device/device_u1/
    # Data Write FFFFFE00
    00000008


    the problem is that all the characters that come after {} rnt
    printed...it would be thankful if u cud explain the script to me as i m
    not able to understand it..

    thanks and regards,
    kitcha
     
    kitcha, Aug 23, 2006
    #8
  9. kitcha <> wrote:

    > Hi Tad ,



    Do not send stealth-Cc emails. It is rude.


    > Thanks for the script but it has some issues



    It works perfectly for the data that you gave me.


    > I have a 1000 line document like this...



    If you change the specification, then the solution is likely to change!


    > the problem is that all the characters that come after {} rnt
    > printed...



    The problem was that you gave virtually no specification for
    what you wanted.

    My program does exactly what you asked for.

    If you want something else, then specify something else.


    > it would be thankful if u cud explain the script to me as i m



    It is spelled "you", not "u".

    It is spelled "could", not "cud".

    It is spelled "am", not "m".

    Do not use "cutsie" spellings, it is rude to people for whom
    English is not a first language.


    > not able to understand it..



    Programs are much easier to understand if you write them yourself.

    Try that first, then post here if you get stuck.


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
     
    Tad McClellan, Aug 23, 2006
    #9
    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. ALuPin
    Replies:
    13
    Views:
    6,592
    mouna
    Nov 27, 2008
  2. z0mb1e_fr
    Replies:
    2
    Views:
    757
    z0mb1e_fr
    Dec 3, 2003
  3. CoX
    Replies:
    3
    Views:
    501
  4. Martin Feuersteiner
    Replies:
    0
    Views:
    3,047
    Martin Feuersteiner
    Jul 19, 2004
  5. HNguyen
    Replies:
    4
    Views:
    2,458
    HNguyen
    Dec 21, 2004
Loading...

Share This Page