Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
[url=http://perldoc.perl.org/functions/use.html][black][b]use[/b][/black][/url] [green]Net::Telnet[/green] [red]([/red][red])[/red][red];[/red]
[black][b]use[/b][/black] [green]strict[/green][red];[/red]
[black][b]use[/b][/black] [green]warnings[/green][red];[/red]
[gray][i]# List of hosts for which to run command.[/i][/gray]
[url=http://perldoc.perl.org/functions/my.html][black][b]my[/b][/black][/url] [blue]@hosts[/blue] = [red]qw([/red][purple][/purple]
[purple] 192.168.0.2[/purple]
[purple] 192.168.0.3[/purple]
[purple][/purple][red])[/red][red];[/red]
[black][b]my[/b][/black] [blue]@childs[/blue][red];[/red]
[olive][b]foreach[/b][/olive] [black][b]my[/b][/black] [blue]$host[/blue] [red]([/red][blue]@hosts[/blue][red])[/red] [red]{[/red]
[black][b]my[/b][/black] [blue]$pid[/blue] = [url=http://perldoc.perl.org/functions/fork.html][black][b]fork[/b][/black][/url][red]([/red][red])[/red][red];[/red]
[olive][b]if[/b][/olive] [red]([/red][blue]$pid[/blue][red])[/red] [red]{[/red]
[gray][i]# Parent[/i][/gray]
[url=http://perldoc.perl.org/functions/print.html][black][b]print[/b][/black][/url] [red]"[/red][purple]Child [blue]$host[/blue] running under [blue]$pid[/blue], parent [blue]$$\[/blue]n[/purple][red]"[/red][red];[/red]
[url=http://perldoc.perl.org/functions/push.html][black][b]push[/b][/black][/url] [blue]@childs[/blue], [blue]$pid[/blue][red];[/red]
[red]}[/red] [olive][b]elsif[/b][/olive] [red]([/red][blue]$pid[/blue] == [fuchsia]0[/fuchsia][red])[/red] [red]{[/red]
[gray][i]# Child[/i][/gray]
[black][b]print[/b][/black] [red]"[/red][purple][blue]$host[/blue]: Connecting[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[black][b]my[/b][/black] [blue]$obj[/blue] = new [maroon]Net::Telnet[/maroon][red]([/red][blue]$host[/blue][red])[/red][red];[/red]
[black][b]print[/b][/black] [red]"[/red][purple][blue]$host[/blue]: More stuff here[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[url=http://perldoc.perl.org/functions/sleep.html][black][b]sleep[/b][/black][/url][red]([/red][fuchsia]1[/fuchsia] + [url=http://perldoc.perl.org/functions/rand.html][black][b]rand[/b][/black][/url] [fuchsia]6[/fuchsia][red])[/red][red];[/red]
[black][b]print[/b][/black] [red]"[/red][purple][blue]$host[/blue]: All Done[purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[url=http://perldoc.perl.org/functions/exit.html][black][b]exit[/b][/black][/url] [fuchsia]0[/fuchsia][red];[/red]
[red]}[/red] [olive][b]else[/b][/olive] [red]{[/red]
[url=http://perldoc.perl.org/functions/die.html][black][b]die[/b][/black][/url] [red]"[/red][purple]couldnt fork: [blue]$![/blue][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[red]}[/red]
[red]}[/red]
[gray][i]# Wait for all children to Finish[/i][/gray]
[olive][b]foreach[/b][/olive] [red]([/red][blue]@childs[/blue][red])[/red] [red]{[/red]
[black][b]my[/b][/black] [blue]$tmp[/blue] = [url=http://perldoc.perl.org/functions/waitpid.html][black][b]waitpid[/b][/black][/url][red]([/red][blue]$_[/blue], [fuchsia]0[/fuchsia][red])[/red][red];[/red]
[black][b]print[/b][/black] [red]"[/red][purple]done with pid [blue]$tmp[/blue][purple][b]\n[/b][/purple][/purple][red]"[/red][red];[/red]
[red]}[/red]