Perl loop to wait for adb devices array -


I hope someone can help me when I add two Android devices so why does my loop disappear?

With the help of some research, I have succeeded in combining the code given below, although I have added a loop for awhile to wait for the Android 'ADB Devices' command. I'm looking to sit at the moment while waiting for the loop to connect via the USO for two Android devices, or when the two connected devices are activated, my code just compiles, and when the loop is compiled Works, when the device is already activated and connected, but when I disconnect the script from USB cables with USB cables, and after a few seconds SB connection plug in my PC, the script is still sitting in the loop. I am running this script on the latest Strawberry Pearl on Windows 7.

Any guidance will be highly appreciated.

Here the code is ...

  Use strict; Use the warning qw (all); IPC :: use run 3; Use carp queues; Use data: Dumper; My @upewow = get_devices (); My $ devicesattached = ""; While (! @divis) {get_devices (); Print "."; Sleep (1); Last if @devices; } Print "\ n \ tTOTE 1 $ device [0]"; Print "\ n \ tTop2 devices are [1] \ n"; Sub get_devices {my $ adb_out; Run 3 ["ADB", "Devices"], undoubtedly, \ $ adb_out, undefined; $? And clack "WARNING: status of zero-zero exit ($?)"; My @trace = $ adb_out = ~ m / ^ ([[: xdigit:]] +) \ s + device $ / xmg; Want to come back? @res: \ @res; }  

Many thanks, MikG

> @devices Once you enter the loop the easiest to decide

  is changing (while! @devices) {get_devices ();  

to

  while (! @devices) {@devices = get_devices ();  

However, you can simplify your code further:

  my @devices; Until (@devices = get_devices ()) {print "."; Sleeping 1; }  

Note that there is a situation in Pearl which can help you in such a situation. Run it:

  perl -d / path / to / my / script  

Comments