icg has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I wan't to parse a tag-delimited file and store the result as a hash having keys as the tag and the values as the string following the tag. The input file consists of multiple lines with no line breaks. The tags are two letter alphabets. Can anyone help? Thank you, Gowtham

Replies are listed 'Best First'.
Re: Parse tag-delimited input file
by Joost (Canon) on May 27, 2005 at 12:51 UTC
Re: Parse tag-delimited input file
by dragonchild (Archbishop) on May 27, 2005 at 12:56 UTC
    In addition to Joost's excellent pointers, a sample would go a long way in receiving help. Even better would be what you tried to do to solve your problem and why you think it's not working. We, as a community, prefer to edit than to create, at least when answering questions.

    • In general, if you think something isn't in Perl, try it out, because it usually is. :-)
    • "What is the sound of Perl? Is it not the sound of a wall that people have stopped banging their heads against?"
Re: Parse tag-delimited input file
by holli (Abbot) on May 27, 2005 at 13:19 UTC
    like this?

    If not, show us sample input.


    holli, /regexed monk/
      Input file looks like this: AN 0005 SR SI CO Me GH EL ub.com UR http://www.xxx.com MA Me Gm Output should be like this: AN 0005 SR CO Me GH ... ...
        use strict; use warnings; my $input = "AN 0005 SR SI CO Me GH EL ub.com UR http://www.xxx.com MA + Me Gm"; my @input = split / +/, $input; print "@input[0..2,4..6] ... ..."; #AN 0005 SR CO Me GH ... ...


        holli, /regexed monk/