I have a script that takes files / files that are too old (as defined through user input) and deletes them. I want to list each directory separately and ask for confirmation to delete old files in each directory.
So, I have an array (@oldDirs) that contains several arrays (each directory) that store strings (full path names).
@oldDirs = (@AirDefense,@Arcsight,@Avocent,@BlueCoat,@Checkpoint,@Cisco,@Crossbeam,@FireE ye,@lostAndFound,@rancid,@Riverbed,@Symantec,@Wiki,@WLAN) if($oldPathsSize != 0) { my $dirNamesCounter = 0; my @dirNames = ('/AirDefense','/Arcsight','/Avocent','/BlueCoat','/Checkpoint','/Cisco','Crossbeam','FireE ye','/lost+found','/rancid-2.3.8','/Riverbed','/Symantec','/Wiki','/WLAN'); foreach my @direc (@oldDirs) { my $size = @direc; print "Confirm Deletion of $size Old files in $dirNames[$dirNamesC]: \n"; $dirNamesCounter++; foreach my $pathname (@direc) { print "\t$pathname\n"; } print "\nDelete All?(y/n): "; my $delete = <STDIN>; chomp($delete); if($delete eq "y") {
My problem is with the first foreach statement. Both arrays and @direc are not allowed, because I need to have a scalar value in this part of foreach ... but they are all arrays! How should I do this, if possible?
source share