in reply to Splitting a string in Perl
Answers re split (and, as it happens, re join) can be found at perldoc -f split.
Working code (to your specs, except for using __DATA__ rather than a file as the data source):
#!/usr/bin/perl use strict; use warnings; my($memAddr, $data, $ascii, @lines, $line); # open(DATAFILE $filename) # while(<DATAFILE>) @lines = <DATA>; for $line(@lines) { chomp $line; ($memAddr, $data, $ascii) = split(/\s\s+/, $line); $data = join('', split(/\s/, $data)); print "$memAddr $data $ascii \n"; } __DATA__ -MEMADDR- ----HEX REPRESENTATION---- ---ASCII--- 0000 21 74 63 5f 37 5f 31 5f 36 !tc_7_1_6 1234 0f bb ac 11 a6 82 ff 5f 27 !xy_8_1
|
|---|