print variable after closing the file in perl : Below code works fine but I want $ip to be printed after closing the file.

    use strict;
    use warnings;
    use POSIX;

    my $file = "/tmp/example";
    open(FILE, "<$file") or die $!;
    while (<FILE>) {
    my $lines = $_;
    if ($lines =~ m/address/){
    my($string, $ip) = (split ' ', $lines);
    print "IP address is:$ip\n";
     }
    }
    close(FILE);
