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

I'm a novice perl programmer and am having huge troubles with pattern matching. I am trying to scan through a HTML form I have pulled from the Web using LWP::UserAgent and fill in the fields with info entered into a form on my site. This boils down to replacing value="" with value"whatever", but I can;t seem to do it using substitution. Any help would be appreciated. Thanks

Replies are listed 'Best First'.
Re: Pattern Matching Hell.
by davorg (Chancellor) on Apr 04, 2001 at 15:28 UTC

    Why not show us what you've got and tell us what problems you're having. We'd far rather help you to solve the problem yourself than do your work for you.

    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me

Re: Pattern Matching Hell.
by jeroenes (Priest) on Apr 04, 2001 at 15:37 UTC
    Take a look into HTML::Parser to break down your pulled HTML, make some code to change the parameters and try CGI to rebuild it.

    Jeroen
    "We are not alone"(FZ)

      Or maybe something built around HTML::TreeBuilder and HTML::Element might be more appropriate in this case.

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

        Thanks for all of the suggestions. I don't have any problems with my code...I just needed suggestions to start writing the part where it reads the file and I couldn't understand how to just search between <start><end>. I'll look in to your suggestions. Thanks a lot. xf86
Re: Pattern Matching Hell.
by azatoth (Curate) on Apr 04, 2001 at 15:29 UTC

      tr is for replacing single characters with other single characters (or, maybe, deleting characters). The substitution operator s/// is much more likely to be useful here.

      --
      <http://www.dave.org.uk>

      "Perl makes the fun jobs fun
      and the boring jobs bearable" - me

Re: Pattern Matching Hell.
by orbital (Scribe) on Apr 05, 2001 at 07:49 UTC
    If you don't mind giving up control of your values you can avoid regular expressions by using a simple test case.

    if ($value eq "") { $value="whatever"; }