Catriona Pure Scents <[EMAIL PROTECTED]> wrote: : I think I understand what you are getting at.... : : I have no concept of "join" that you use.
run this from the command line: perldoc -f join Or read about join in the 'perlfunc' file that comes with perl's standard documentation. : But realising that this is a loop that I am attempting to : alter, not quite what I was trying to do no. : : so, @env_vars = keys(%ENV); this from all I have read, : takes the server dependant environment variables and holds : them in memory. Not exactly. They are already in memory in a hash named %ENV. This hash is created by and maintained by perl. "@env_vars = keys(%ENV);" copies the names of all keys of the ENV hash (in memory) and places them into an array (called @env_vars) which is also in memory. It sounds like you are maintaining someone else's code. Either the code was written long ago or the original programmer wasn't very good or both. : But the server I am using doesn't seem to have http_referrer : as a env variable. Doesn't show in the logs I am currently : receiving anyway. Your server may be configured not to show it. Check with your Sys Admin. : Therefore if the following stuff was a loop then I am presuming : that I need to add another line to the details that I want to : log, like.... : : $log_entry .="$ENV{http_referrer}\|"; While the correct spelling for referrer uses four R's, HTTP using only three: $log_entry .="$ENV{http_referer}|"; : then go on with the : : @env_vars = keys(%ENV); : : foreach $variable (@env_vars) : { : $log_entry .="$ENV{$variable}\|"; : } : : would this be better. Yes, but what if there is nothing in $ENV{http_referrer}. In its current state your script is probably not using warings, but as you become more proficient in programming with perl, you'll probably want to turn warnings on. If you try to use an undefined value with warnings turned on, you'll get a warning everytime you run the script. So, what you propose is better, but not much better. And you are also escaping '|' needlessly. If there was a value in $ENV{http_referrer}, then keys %ENV would have 'http_referrer' as one of its values. Otherwise it won't. What you could do is add a default value to the referrer: $ENV{http_referer} ||= 'no referrer'; @env_vars = keys(%ENV); foreach $variable ( @env_vars ) { $log_entry .= "$ENV{$variable}\|"; } This way you have still only added one line and you won't piss off the next person who has to maintain what looks like a small portion of spaghetti code. "$ENV{http_referer} ||= 'no referrer';" basically says "set $ENV{http_referer} to 'no referrer' if it has a value that evaluates to false. In perl, that would be: undef, '', or 0. Each of which is unlikely to actually be valid http referrers. : btw, I don't think apache is loaded on this server. Not sure : I didn't set it up, as a complete newbie you probably wouldn't : want me to either :-)) I have a tiny hosting service and you wouldn't want me configuring servers either. :) This script will give you a list of the keys in %ENV and their values, including the server name. Don't leave it on your server, though, it's a security risk. #!/usr/bin/perl $|++; use CGI; # find max key length my $max; foreach ( keys %ENV ) { $max = length if length > $max; } my $q = CGI->new(); print $q->header(), $q->start_html( 'env.pl' ), $q->pre( "\n", map { sprintf "%-*s = %s\n", $max, $_, $ENV{ $_ } } sort keys %ENV ), $q->end_html(), __END__ HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>