OK, here are some general pointers:

  1. use CGI qw(:param) to process your form data; handrolled stuff is messy, hard to maintain, and insecure. See use CGI or die; for more about why.
  2. use strict always and run under -w, the latter especially when you're developing. Perl will catch all sorts of errors you won't. As things stand, your script could fail for lots of reasons in lots of places and you'd never know why.

our own Ovid has written a CGI tutorial guide, check his homenode for the link (follow the link in this paragraph)

Now, some specifics:

What your ifs are doing is done more maintainably with a hash. I like to do this at the top of complex scripts:

my %actions = ( option1 => \&process_option1, option2=>\&processoption2 ); my $option = param('option'); $action{$option}->() or default_action(); exit;

And so forth. That nasty-looking \& thing creates references to subroutines, which are called by the $action{$option} line. Here, what you should do is create a hash whose keys are as you have them, and whose values are the files that each kind of action works on:

my %file_hash = ( a=>'notiagro.html', d=>'notideportes.html' # and so on ); my $catfile = $file_hash{$cat} || 'default value';

I know that doesn't get you everything you need. You have a start on the harder parts, but get this part working first and then come back to those.

For finding the link to extract and replace, you need to think about how your file looks. I can't help you with that with the information I have now, but I've gone on long enough so far. Hope this gets you over a hurdle or two.

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


In reply to Re: Re: Re: My vacation depends on it by arturo
in thread My vacation depends on it by aletz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.