#!/usr/bin/perl use strict; use warnings; use Tie::File; use Sensitive_Array; # this is the global var I am using $main::touched=0; my (@array, @watched_array); my $file='test_tie_file'; # First tie the array to the file tie @array, 'Tie::File', $file or die "cannot tie to $file: $!\n"; push @array, int (rand 1000) until $#array > 39; # fill it on the first pass # now tie it up to an array that will tell us when it was altered tie @watched_array, 'Sensitive_Array', \@array; print "array of length $#watched_array is now watched\n"; print "would you like to alter the file (y/n)\n"; my $ansa=; push @watched_array, 'touched' if $ansa =~/^y/; untie @array; if ($main::touched) { print "File has been altered\n" } else { print "File remains the same\n"; }