Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

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.


In reply to Spinning cursor while waiting for search/copy process to be finished by Ingvar

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (3)
As of 2024-04-19 21:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found