Nyimi Jose wrote: > > I need some explanation on following: > > 1. my skill of perl tells me so far to handle exceptions and write : > open(FH,$file) || die "can not open $file : $! \n"; > I've tried your code with a wrong file_name and got following message: > "Can't open in.txt1: No such file or directory at parser2.pl line 22." > How do you magically handle exception without writting any code for that ? :-) > > 2. where are you reading here : while(<>) ? > There is no file handle ? > Link to perldoc appreciated...
When the null filehandle is used to read files named on the command line the files are opened implicitly and a warning is issued for any open failure. Take a look at perldoc perlop (search for 'null filehandle') > 3. why did you put the main loop into a lexical scope ? > > { > local @ARGV = $ARGV[0]; > while (<>) { > } > } So that I could use 'local' to save the original command-line parameters. I'm discarding all parameters after the first, which will be replaced at the end of the scope in case later code requires anything else from the command line. > 4. why have you added the 'x' at > / (\d{2}-\d{2}-\d{4}:\d{3}) \s+ \d\d (.+) /x For the same reason you put spaces in the 'unpack' format. The /x modifier makes whitespace irrelevant within the regex so that it can be used for layout. If you need to match real spaces you have to use \x20 (or \s which will match any whitespace character including space). > 5. the $format from your code is : > 'A1 A6 A3 A1 A5 A1 A5 A1 A5 A1 A5 A1 A5 A1 A5 A1 A5 A1 A5 A1 A5' > > What i want is : > 'A1 A6 A3 x1 A5 x1 A5 x1 A5 x1 A5 x1 A5 x1 A5 x1 A5 x1 A5 x1 A5' > Skip the delimeter! > Could you make the change here please ? Sorry, I missed that. Try this. my $format = join ' ', map "A$_", (INDEX_LEN, NAME_LEN, WAY_LEN); $format = join ' x ', $format, map "A$_", (MEAS_LEN) x NOF_MEAS; I've used 'x' instead of 'x1' as the '1' isn't needed. HTH, Rob -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]