Help !! perl open function

Help Please perl Gurus,

I am trying to add ungrouped passengers in a group and I creating a script however it fails on first step only I tried all the options it returns following error.

syntax error at junki line 4, near "open "
Execution of junki aborted due to compilation errors.
at junki line 14

Here is my code

#!/usr/bin/perl -w 
$bookid = 3456 
 
open (LSOUT, "res_list -avail -bookid $bookid |" ); 
while ($LINEINc = <LSOUT>) 
{ 
  chomp ($LINEINc); 
  if ( $LINEINc =~ "no/name") 
  { 
    print "$passid\n"; 
  } 
} 
close (LSOUT); 
exit; 

Usually I use following commands to do it manually.

# res_list -avail 
ID Availability Pass Name GroupName Total Pass 
0050 booked abc xyz no/name's 8 
0051 booked abc xyz roth 8 
0052 booked abc xyz no/name's 8 
0053 booked abc xyz no/name's 8 
0054 booked abc xyz bengal 9 
0055 booked abc xyz no/name's 9 
0056 booked abc xyz brown 9 
0057 booked abc xyz no/name's 9 
0058 booked abc xyz eagle 9 
0059 booked abc xyz no/name's 9 
005A booked abc xyz no/name's 9 

select only 3 ID's where group name is noname and list them in a comma saperated format like 0050,0052,0053....

then run following command to make sure they are not member any other groups.

#search_grp -passid 0050,0052,0053 

ID Group Name Pass. Count loc Count 
---- -------------------------------- ----- ----- 
0050 - - - 
0052 - - - 
0053 - - - 

if they are not member of any group then print in the following format in file - name grpid_class

create group ID 0050, class=leisure; 
copy id 0052 to group id 0050; 
copy id 0053 to group id 0050; 

once they are displayed to user run the file in following command

#create_group -f 0050_leisure 

succuessful display message.

  1. Whenever you post a code try to use "
" tags, it makes it easier to read. 

2. After writing every perl program, run perl -c <PROG_NAME> to make sure there are no obvious mistakes. 

3. You forgot to end 1st line with ";" which happens to be just above "open" function. 

#!/usr/bin/perl -w 
$bookid = 3456 ;

open (LSOUT, "res_list -avail -bookid $bookid |" ); 
while ($LINEINc = <LSOUT>) 
{ 
       chomp ($LINEINc); 
       if ( $LINEINc =~ "no/name") 
       { 
              print "$passid\n"; 
       } 
} 

close (LSOUT); 
exit; 
1 Like

WOW ! hawkeye.

Thank you zedex. that gets me moving. Appreciate it.