Loading ...
Sorry, an error occurred while loading the content.
 

get URL

Expand Messages
  • Scott
    I m still a perl beginner. I m wanting to do a (I m not sure how to say it) backdoor get method URL to have a part of the script execute only when the get
    Message 1 of 4 , Dec 5, 2003
      I'm still a perl beginner. I'm wanting to do a (I'm not sure how to
      say it) backdoor get method URL to have a part of the script execute
      only when the get value is met.
      I'm thinking something like this:

      my $reindex = 0;

      sub start {
      # Force a reindex
      $reindex = 1 if (CGI:aram('reindex'));
      return 1;
      }
      ...

      I've tried some things but it always runs the whole script no matter
      what I do. I want to exclude this portion of the script under normal
      operations.

      The URLs that I'm thinking of:
      Normal URL = http://domain.com/cgi-bin/script.cgi
      Backdoor Get URL = http://domain.com/cgi-bin/script.cgi?reindex=y
      (or would it be ...?reindex=1)

      Should I be thinking an if/else? Or can a sub do it? (I'm not well
      versed in subroutines) The reason I'm wanting to do this (besides to
      learn more perl) is to lower CPU time. By needing to do a (could be
      massive) File::Find, I can cache the results to a flat file so the
      file is accessed every time the script runs, but the File::Find scan
      only occurs with the "secret" URL when directories and files are updated.
    • Ben Maynard
      Hi Scott I am not sure if I get your meaning right, but are you saying if you recieve a parameter reindex you want to run a sub or if you don t recieve the
      Message 2 of 4 , Dec 5, 2003
        Hi Scott

        I am not sure if I get your meaning right, but are you
        saying if you recieve a parameter reindex you want to
        run a sub or if you don't recieve the parameter you
        want to exit? If it is the second I would do
        something like:

        my $cgi = CGI->new();
        my $reindex = $cgi->param("reindex") || 0;

        if ($reindex) {
        start();
        other_subs();
        }

        So if any value is passed via the parameter reindex it
        will take that value if not it will be a false (0) the
        if statement is boolean, if (true) then else exit is
        assumed unless you have something underneath that
        isn't in a subroutine

        HTH

        Ben

        --- Scott <mike_nhl@...> wrote: > I'm still a
        perl beginner. I'm wanting to do a (I'm
        > not sure how to
        > say it) backdoor get method URL to have a part of
        > the script execute
        > only when the get value is met.
        > I'm thinking something like this:
        >
        > my $reindex = 0;
        >
        > sub start {
        > # Force a reindex
        > $reindex = 1 if (CGI:aram('reindex'));
        > return 1;
        > }
        > ...
        >
        > I've tried some things but it always runs the whole
        > script no matter
        > what I do. I want to exclude this portion of the
        > script under normal
        > operations.
        >
        > The URLs that I'm thinking of:
        > Normal URL = http://domain.com/cgi-bin/script.cgi
        > Backdoor Get URL =
        > http://domain.com/cgi-bin/script.cgi?reindex=y
        > (or would it be ...?reindex=1)
        >
        > Should I be thinking an if/else? Or can a sub do it?
        > (I'm not well
        > versed in subroutines) The reason I'm wanting to do
        > this (besides to
        > learn more perl) is to lower CPU time. By needing to
        > do a (could be
        > massive) File::Find, I can cache the results to a
        > flat file so the
        > file is accessed every time the script runs, but the
        > File::Find scan
        > only occurs with the "secret" URL when directories
        > and files are updated.
        >
        >
        > ------------------------ Yahoo! Groups Sponsor
        >
        > Unsubscribing info is here:
        > http://help.yahoo.com/help/us/groups/groups-32.html
        >
        > Your use of Yahoo! Groups is subject to
        > http://docs.yahoo.com/info/terms/
        >
        >

        ________________________________________________________________________
        Download Yahoo! Messenger now for a chance to win Live At Knebworth DVDs
        http://www.yahoo.co.uk/robbiewilliams
      • Scott
        ... Not to exit. I want the whole script to run every time it s called, except the parameter reindex will only run when it s (true). ... Is this where I d put
        Message 3 of 4 , Dec 5, 2003
          --- In perl-beginner@yahoogroups.com, Ben Maynard <liliafan@y...> wrote:
          > Hi Scott
          >
          > I am not sure if I get your meaning right, but are you
          > saying if you recieve a parameter reindex you want to
          > run a sub or if you don't recieve the parameter you
          > want to exit?

          Not to exit. I want the whole script to run every time it's called,
          except the parameter reindex will only run when it's (true).

          > If it is the second I would do
          > something like:
          >
          > my $cgi = CGI->new();
          > my $reindex = $cgi->param("reindex") || 0;
          >
          > if ($reindex) {

          Is this where I'd put the code that is dependant on '?reindex=y' ?

          > start();
          > other_subs();
          > }

          And put the rest of the script here? that's not a subroutine?

          Are there some keywords that I can go search google or cpan for this
          type of thing? I'm not sure what the best words are that would
          describe this situation.

          >
          > So if any value is passed via the parameter reindex it
          > will take that value if not it will be a false (0) the
          > if statement is boolean, if (true) then else exit is
          > assumed unless you have something underneath that
          > isn't in a subroutine
          >
          > HTH
          >
          > Ben
          >
          > --- Scott <mike_nhl@y...> wrote: > I'm still a
          > perl beginner. I'm wanting to do a (I'm
          > > not sure how to
          > > say it) backdoor get method URL to have a part of
          > > the script execute
          > > only when the get value is met.
          > > I'm thinking something like this:
          > >
          > > my $reindex = 0;
          > >
          > > sub start {
          > > # Force a reindex
          > > $reindex = 1 if (CGI:aram('reindex'));
          > > return 1;
          > > }
          > > ...
          > >
          > > I've tried some things but it always runs the whole
          > > script no matter
          > > what I do. I want to exclude this portion of the
          > > script under normal
          > > operations.
          > >
          > > The URLs that I'm thinking of:
          > > Normal URL = http://domain.com/cgi-bin/script.cgi
          > > Backdoor Get URL =
          > > http://domain.com/cgi-bin/script.cgi?reindex=y
          > > (or would it be ...?reindex=1)
          > >
          > > Should I be thinking an if/else? Or can a sub do it?
          > > (I'm not well
          > > versed in subroutines) The reason I'm wanting to do
          > > this (besides to
          > > learn more perl) is to lower CPU time. By needing to
          > > do a (could be
          > > massive) File::Find, I can cache the results to a
          > > flat file so the
          > > file is accessed every time the script runs, but the
          > > File::Find scan
          > > only occurs with the "secret" URL when directories
          > > and files are updated.
          > >
          > >
          > > ------------------------ Yahoo! Groups Sponsor
          > >
          > > Unsubscribing info is here:
          > > http://help.yahoo.com/help/us/groups/groups-32.html
          > >
          > > Your use of Yahoo! Groups is subject to
          > > http://docs.yahoo.com/info/terms/
          > >
          > >
          >
          > ________________________________________________________________________
          > Download Yahoo! Messenger now for a chance to win Live At Knebworth DVDs
          > http://www.yahoo.co.uk/robbiewilliams
        • Ben Maynard
          Scott ... Yes it is if ($reindex) { reindex_specific_stuff; } The stuff in that statement will only execute if $reindex is true, therefore any value that isn t
          Message 4 of 4 , Dec 5, 2003
            Scott

            > > if ($reindex) {
            >
            > Is this where I'd put the code that is dependant on
            > '?reindex=y' ?

            Yes it is

            if ($reindex) {
            reindex_specific_stuff;
            }

            The stuff in that statement will only execute if
            $reindex is true, therefore any value that isn't null
            or 0.

            Ben



            ________________________________________________________________________
            Download Yahoo! Messenger now for a chance to win Live At Knebworth DVDs
            http://www.yahoo.co.uk/robbiewilliams
          Your message has been successfully submitted and would be delivered to recipients shortly.