i have two array in my perl and i want to grep one array from other array my code in perl is as follows.
#!/usr/bin/perl
open (han5, "idstatus.txt");
open (han4, "routename.txt");
@array3 = <han4>;
@array4 = <han5>;
foreach (@array3) {
@out = grep(/$_/, @array4);
print @out; }
file routename.txt
strvtran
fake
globscr
file idstatus.txt
strvtran online
strvtran online
strvtran online
globscr online
globscr online
globscr online
globscr online
globscr online
Xtech dead
Xtech dead
fake online
fake online
fake connecting
walkover123 online
walkover123 online
Now what i want to grep globscr element from idstatus.txt and output should be like:
globscr online
globscr online
globscr online
globscr online
globscr online
and i dont want to use any system command. please help me here