Hi Gurus,
I'm facing some issues with multiple conditions in my if statement.
if (!($InputLine=~/^Date/)) && (!($fields[6] eq "VEN")) {
Above is the line troughing some syntax errors.
I am trying to avoid the below creteria lines to process in my logic.
- Records starting with "Date"
- Valie "VEN" in field 6
Syntaxually the above code looks correct. But not sure why it is giving copilation errors...
Could someone advice if i'm doing anything wrong pls?
Thanks
Venkat
Is this part of a homework assignment?
What utility are you using to process this statement?
What diagnostic is it printing when you try to compile or run this code?
How are the variables $InputLine
and $fields[]
defined?
It is part of a filtering records from a file using a perl sub routine
I'm getting below syntax error while running the sub routine
26th line is that IF statement...
$InputLine is taking the records in my input file.
Please find the below my sub routime...
open (FILENAME,"RAV_20150403_060000.dat");
$InputLine1=<FILENAME>;
while ($InputLine1 ne "") {
# print $InputLine1;
my $result = &derfun($InputLine1);
#print %$result;
$InputLine1=<FILENAME>;
}
sub derfun {
my ($InputLine) = @_ ;
my $vol;
my @fields;
my $sId;
chomp($InputLine);
@fields = split /\t/,$InputLine;
$vol = $fields[7];
$sId = $fields[1];
If (!($InputLine=~/^Date/)) && ($fields[6] eq "VEN") {
my $refA = {
"c_id" => "1234",
"src_ast" => "RAV-" . $sId,
"vol" => $vol
} ;
return $refA;
}
}
You will need to put the condition into parenthesis:
if ((!($InputLine=~/^Date/)) && ($fields[6] eq "VEN")) {
Thanks Masir for the reply...
if ((!($InputLine=~/^Date/)) && (!($fields[6] eq "MYR"))) {
I need to un-filter the VEN records... hence i used above... It worked now...
Thanks everyone...