#!/usr/bin/perl use strict; use warnings; use DBI; my $var1 = "dbname"; #Database Name my $var2 = "user"; #Username my $var3 = "pass"; #Password my $var4 = "select directory_path, keyword1, keyword2, keyword3 from +load_instance where rule_id = '1'"; sub db_conn1 { $dbh = DBI -> connect("DBI:Oracle:".$var1,$var2,$var3) || die ("not co +nnected:DBI::errstr"); my $sth = $dbh -> prepare($var4); $sth->execute(); while(@row=$sth->fetchrow_array()) #Fetch the number of rows { #returned by the query $values=$row[0]; print "@row\n"; } } ######db_conn1($var1,$var2,$var3,$var4); sub search_phrase { my ( $inFile, @phrases ) = @_; open my $inFH, q{<}, $inFile or die qq{open: $inFile: $!\n}; my $line; PHRASE: foreach my $phrase ( @phrases ) { my $rxPhrase = qr{\Q$phrase\E}; # keep reading down the file while ($line = <$inFH>) { # when one phrase matches, jump to the next next PHRASE if $line =~ /$rxPhrase/; } # end of file, and we haven't matched the last phrase } # We have just matched the last phrase. # The number we want is somewhere in $line. my ($number) = $line =~ /(\d+)/; return $number; } my $result = search_phrase(db_conn1($var1,$var2,$var3,$var4)); if (defined $result) { print "$result\n" } else { print "-1\n" }
Possible unintended interpolation of @row in string at comb1.pl line 1 +9. Global symbol "$dbh" requires explicit package name at comb1.pl line 1 +3. Global symbol "$dbh" requires explicit package name at comb1.pl line 1 +4. Global symbol "@row" requires explicit package name at comb1.pl line 1 +6. Global symbol "$values" requires explicit package name at comb1.pl lin +e 18. Global symbol "@row" requires explicit package name at comb1.pl line 1 +8. Global symbol "@row" requires explicit package name at comb1.pl line 1 +9. Execution of comb1.pl aborted due to compilation errors.
In reply to Re^2: functions and arguments
by mercuryshipz
in thread functions and arguments
by mercuryshipz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |