I am need of your assistance, I need to look through a file and read it line by line. And this is the tricky bit (for me at least). Whilst reading the first character on line A which should begin with an E and then search through the lines until I find a line beginning with G.
But if we hit a line beginning with h<lower case> we've gone to far and the script should produce an error. Now I though maybe using a FOR loop to loop through the lines one at a time however I've never done this in perl so here was my crack at it:UPDATE: I forgot to add the type on data...#!/usr/bin/perl use strict; my @lines; my $file = <quoteout.dat>; open my $in, '<', $file; open my $out, '>', "ERR"; @lines = split('', $_); for(my $i; $i < 9; $i++) { if($line[$i] eq 'E') { #add one until finds a G or h } }
Could someone help as I'm not sure if this is right.Q165HWN0X001 Q165HWN0X002 Q165HWN0X003 E99HEADER|006|001 E99INSSCH|052| E99POLCOM|1||IIL|62|35119849249024||||| E99INSFAC2|C00124||||||XAJX0727,YGAX0000,ZAAJ0203,VABA0018,WJZA1800| G35119849249024 h189SMA2
Thanks
JimIn reply to Reading file and matching lines by Jalcock501
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |