I know there is a simple answer to this, but I can't seem to find it. I'm self taught so don't burn me too bad.
Basically, I need to pass a variable from one sub to another. Here's a simpler sample of what I am trying to do (the actual is large).
#!/usr/bin/perl -wT
use strict;
use CGI qw/:standard/;
$ENV{PATH} = "/cgi-bin";
# untaint and return value
sub IP_check {
my $_info2 = $ENV{'REMOTE_ADDR'};
my $info;
if (!$_info2) {
$info2 = "No IP address available";
return $info2;
}elsif ($_info2 !~ /[\%]+/ && $_info2 =~ /^(\d{1,3}\.{1})(\d{1,3}\.{1}
+)(\d{1,3}\.{1})(\d{1,3})$/) {
# my $info2 = "$1$2$3$4"; sorry, forgot to delete the "my"
# from the original posting
$info2 = "$1$2$3$4";
return $info2;
}else {
# my info2 = "Bad IP address submitted"; same "my" problem
#here
$info2 = "Bad IP address submitted";
return $info2;
}
}
if (param()) {
# do other stuff here before if statement
if (IP_check()) {
# do some stuff here before calling sub
&mailoff;
exit;}
}
# html form stuff is located here
sub mailoff {
# open mail handler stuff - omitted for simplicity
print MAIL "here is the ip address $info2";
# now the closing stuff
}
Can someone point me in the right direction?
Thanks,
Dave
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.