"Synh Vo" <[EMAIL PROTECTED]> wrote in message news:1779CE9992706F45BDC9575124A5AAE51BFC41@;a0001-xpo0114-s.hodc.ad.allstate .com... > Hi, > > I'm trying to read from a file and based on the some of the matched info, > print out certain statements. This is probably very easy for the folks here. >
See inline coments: > > open(FILE, "< obj.list") or die "can't open file : $! " ; > open(NEW, "> new.list"); # check rv of EVERY open!!!! > > chomp(@lines = <FILE>); > foreach my $item (@lines) { ^^^^^^^^ here you are assigning the value of each element to $item for each iteration. > if (/ADB/) { ^^^^^^ but here you look for the string "ADB" in $_ instead of $item. try: if ($item =~ /ADB/) { same thing for the other regex in the conditional below. > print "grant select , update, delete, insert on " $item " user;" ; this print will go to STDOUT. Dont you want it to go to NEW? try: print NEW "grant select , update, delete, insert on " $item " user;" ; same thing for the other prints > print " grant select on " $item " to tcmesg_select ;" ; > if (/p_/) { > print " grant execute on " $item" to tcmesg_admin; " ; > } > } > > close(FILE); > close(NEW); Paranoid programmers (like me) even check the rv of close. close(NEW) or warn("new.list probably corrupted: $!"); Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]