Hi -- Disclaimer: I'm very new to Perl. Please forgive any offensive coding practices.
I'm working through a file parse. The first few lines of the file are below the "***". Note that the first 2 lines of the file have blank spaces after the visible text, whereas on the following lines there are no spaces after the last visible character. (You'll have to trust me on that; I'm not sure it'll be obvious in this post.)
This is all happening in a subroutine to which I pass in the array containing the file contents. When I shift through the array and get to the 4th line (" Year 2019") and print it, I get ("Year 201"). I've confirmed the same phenomenon further down in the file, where the last character is dropped when it's the last character on the line.
Thanks in advance,
Carol
Code is as follows:
sub read_gage_header { my ($data, $header, @headers, $ettb_no, $year); $data = shift; #Now get ettb_no $header = $data->[0]; @headers = split / /, $header; #NOTE: this print yields expected results print "HEADERS before ettb_no @headers\n" if defined ($debug); #NOTE: this gets the proper ettb_no $ettb_no = $headers[4]; #Skip to get to Year shift @$data; shift @$data; shift @$data; $header = shift @$data; #NOTE: this gives me "Year 201" print "HEADER before year $header\n" if defined ($debug); ... more code ...
****************** FILE STARTS HERE ********************************
Gage Information - 240CN - 240 FEEDER CANAL SUPPLY TO 240 FEEDER FROM BELEN HIGH LINE CANAL + Year 2019 Month Day Time Height Discharge (mst) (HP ft) (QR cfs) ----- --- ---- ------ --------- July 29 1230 5.54 80 ... more data ...
In reply to Perl appears to be dropping last character of line by cmarra
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |