in reply to Regex Parsing

I see what you're trying to accomplish (I think), but I can't see what you've tried...

How is it giving you trouble? What code do you have that is not working?

Replies are listed 'Best First'.
Re^2: Regex Parsing
by toadi (Chaplain) on Mar 27, 2005 at 17:04 UTC
    Did not really have any code. Did not have a idea howto do it.
    But after some more pondering:
    my @array = (split/\n/, $data); my $firstmatch = $array[3]; my $secondmatch = $array[4];

    But is this the best/fastes way. Got lots of files with this kind of data.

    This happens over and over:

    Open the file split the records parse this data insert it into db close file


    --
    My opinions may have changed,
    but not the fact that I am right

      I think you have an excellent solution using split and array access. There is no reason to use a regex when other solutions will work equally well. Often, a regex will be more complicated or more fragile.

      Now, there are some parsing problems that are better solved with a regex, but this isn't one of them. And, personally, I only use a regex when I cannot use other solutions.

      Being right, does not endow the right to be rude; politeness costs nothing.
      Being unknowing, is not the same as being stupid.
      Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
      Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

        solution using split

        There is no reason to use a regex

        Technically speaking, a split uses a regex O:-)