Solved

Simple Code Change Needed

Posted on 1998-08-13
3
205 Views
Last Modified: 2012-05-04
I do not know perl however I need help making an ajustment to a cgi...

First, take a look at this log file:
http://library.advanced.org/10867/new/cgi-bin/stats/log.txt

This is the cgi file that writes it (I made a txt so you could see it):
http://library.advanced.org/10867/new/cgi-bin/stats/ax.txt

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:
|http://library.advanced.org/10867/new/home.shtml|

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:
http://library.advanced.org/10867/

With the changes made, the partial string would be:
|new/home.shtml|


Thanks,
jeffrey
0
Comment
Question by:jkelly061597
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 

Author Comment

by:jkelly061597
ID: 1209285
Edited text of question
0
 
LVL 5

Accepted Solution

by:
b2pi earned 200 total points
ID: 1209286
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(
                  http://library.advanced.org/10867/ 
                  http://library.advanced.com/1919/
                 );
# CUSTOM2-End
#### 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:


0
 
LVL 84

Expert Comment

by:ozo
ID: 1209287
#you may want to say
 s|\Q$_\E||;
#instead of
 s|$_||;
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
instmodsh - listing perl modules 2 97
Linux rename files by reordering dates in the file name 6 40
Perl Untar File 1 77
Create an automated page index 9 109
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question