Hi Balli, On Mon, 18 Jun 2012 23:23:19 -0700 (PDT) balli sudan <sudan.ba...@gmail.com> wrote:
> ####this is my sample code friends### > sub swap > { > ($rule1,$rule2=@_; > my $old_rule="iptables -A INPUT -s 0/0 -i eth0 -d 192.168.2.1 -p TCP -j > ACCEPT"; > $temp = $old_rule; > my $new_str=iptables -D INPUT rule_no > #now here we will add the desired rule number > my $new_rule=iptables -I INPUT rulenumber-s 202.96.0.0/12 -j DROP > $old_str=$new_str > $new_str = $temp > # if we have to swap rules we will simply delete the previous rule in the > chain and add a new rule > This code is invalid and won't compile. Where is your real code? For how to write code properly see: http://perl-begin.org/tutorials/bad-elements/ In order to swap the contents of two variables in Perl, you can simple do: ($x, $y) = ($y, $x); No need for temporary variables. Regards, Shlomi Fish > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Interview with Ben Collins-Sussman - http://shlom.in/sussman Emacs is a nice operating system, but what it lacks, in order to compete with Linux, is a good text editor. — based on http://en.wikiquote.org/wiki/Emacs Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/