Author: obnox Date: 2007-07-04 23:21:51 +0000 (Wed, 04 Jul 2007) New Revision: 23711
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=23711 Log: Refactor the actual creation of object into its own small function. Michael Modified: branches/SAMBA_3_0/examples/scripts/users_and_groups/createdomobj.pl Changeset: Modified: branches/SAMBA_3_0/examples/scripts/users_and_groups/createdomobj.pl =================================================================== --- branches/SAMBA_3_0/examples/scripts/users_and_groups/createdomobj.pl 2007-07-04 22:30:25 UTC (rev 23710) +++ branches/SAMBA_3_0/examples/scripts/users_and_groups/createdomobj.pl 2007-07-04 23:21:51 UTC (rev 23711) @@ -116,7 +116,7 @@ exit 1; } -# rpc open/close functions: +# utility functions: sub open_rpc_pipe { print "opening rpc pipe\n"; @@ -129,20 +129,22 @@ close(IPC); } +sub do_create { + my $target_name = shift; + print "creating $target_type $target_name\n"; + print IPC "$rpc_cmd $target_name\n"; +} + # main: open_rpc_pipe(); if ("x$startnum" eq "x") { - my $target_name = $prefix; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; + do_create($prefix); } else { for (my $num = 1; $num <= $num_targets; ++$num) { - my $target_name = sprintf "%s%.05d", $prefix, $startnum + $num - 1; - print "creating $target_type $target_name\n"; - print IPC "$rpc_cmd $target_name\n"; + do_create(sprintf "%s%.05d", $prefix, $startnum + $num - 1); if (($num) % 500 == 0) { printf("500 ".$target_type."s created\n"); close_rpc_pipe(); @@ -151,5 +153,6 @@ } } } + close_rpc_pipe();