Dear Perl experts,
I have created my first Perl script (I am a complete novice): it searches for certain files on a network disks according to the data from the parsed XML-file and then copies them to the working folder. Since it has to browse a lot of folders the waiting period is up to 1 minute. I would like to have a text cursor rotating while the process is going on.
Here is my subprogram:
sub spin { my ($arg) = @_; $|++; for (my $x = 0; $x <= $arg; ++$x){ foreach (("-", "\\", "|", "/")){ print $_; Time::HiRes::sleep (0.1); print "\b"; } } print " \n"; }
It works perfectly well by itself.
And here are the pieces of code themselves:
my $dir; my $pattern = $version; OUTER: foreach ( @list_level_top ) { my $name = "$_" . "/*"; my @list_level_current_version = (glob ($name)); foreach (@list_level_current_version) { if ($_ =~ /\Q$pattern/) { $dir = $_; last OUTER +; } } }
and this:
copy ("$source", "$destination") or die "Failed to copy setup file\n";
Is there any way to use the spin function while the process of searching and/or copying is going on? I have checked all the solutions both here and on other sites and could neither understand how it works nor implement: way too much complicated and fail to produce what I expect (or I do it the wrong way). I would like to find a simple and, which is more important, working solution.
Thank you in advance.
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |