Go Premium for a chance to win a PS4. Enter to Win

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 214
  • Last Modified:

Simple Code Change Needed

I do not know perl however I need help making an ajustment to a cgi...

First, take a look at this log file:

This is the cgi file that writes it (I made a txt so you could see it):

What I need to do is be able to leave out part of the url in the log file.

For example, Notice the first line of the log file contains this partial string:

What I want to do is to be able to specify part of this string to leave out, preferrably as a variable I can change. In this case I want to omit the:

With the changes made, the partial string would be:

1 Solution
jkelly061597Author Commented:
Edited text of question
Replace this line

# CUSTOM1-End (delete through this line if you delete)

with the following (yes, the first line is the same as that above)
Replacement ends at ####

# CUSTOM1-End (delete through this line if you delete)
# CUSTOM2-Begin (see below)
# Now we trim off parts of the url that, for some reason, we don't care about
# Add each chunk to be trimmed on a separate line below (I've included two
# as examples)
@trim = qw(
#### Replacement ends

Now, replace the line (I'm assuming you only want the HTTP_REFERER portion played with)

$ENV{'HTTP_REFERER'} =~ s/\|//g;

with the following (same caveats as before... first line is the same, replacement ends with ####

$ENV{'HTTP_REFERER'} =~ s/\|//g;
foreach (@trim) {
    $ENV{'HTTP_REFERER'} =~ s|$_||;
#### End of replacement

That's it.  I'm quite curious as to why you'd want to do this.  If you've any processes that parse this log file, this will confuse them no end.

$logline .= "export|" unless $ENV{'DOCUMENT_URI'};

with the following:

#you may want to say
#instead of

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now