#!/usr/bin/perl use strict; use warnings; use CGI::Fast; while ( my $q = CGI::Fast->new ) { my $client_ip = $q->http('X-Forwarded-For') || $q->remote_addr || 'unknown'; print $q->header("text/plain; charset=utf-8"); print "$client_ip\n"; }