in reply to gathering of some elements of a list

Hi steph_bow,

Your code, as presented, isn't working for me.

For one thing, $file isn't defined (should it be "ALL_FT"?).  You should really use strict and warnings all the time in your programs, to catch these types of errors.

Secondly, you appear to be looking for the string "REGULATION ALERTS", but it doesn't appear in your input file.  Hence, the entire block beginning with if (/REGULATION ALERTS/..eof(INFILE)){ is never getting executed.

Thirdly, I'm not sure exactly what you want for output.  It might be more helpful if you could show an example of the exact output you're looking for.  That way, we'll have a target to aim for.


s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

Replies are listed 'Best First'.
Re^2: gathering of some elements of a list
by steph_bow (Pilgrim) on Jul 30, 2007 at 14:17 UTC

    Dear Liverpole
    Thanks for your remarks
    I have updated with what you said. (the : "use warnings"; "use strict"; and the entry file : you can give the name you would like)

    in this case, I do not need : "REGULATION ALERTS" : sorry for the error
      Okay, that's definitely an improvement.

      Now you're assigning to $file (which doesn't need quotes around it):

      my $file = "$ARGV[0]"; # Better: (my $file = $ARGV[0]) or die "Syntax error ...\n";

      Why not use the same variable thereafter?:

      open(INFILE,"$ARGV[0]") or die "Can't open $ARGV[0]: $!"; # Better: open(INFILE, $file) or die "Can't open '$file': $!\n";

      But I still think you should specify the exact output you're looking for.  I suspect that the solution to get you from input data to output data may be easier than you think, and knowing what output you require will help us to modify your program to generate that output correctly.


      s''(q.S:$/9=(T1';s;(..)(..);$..=substr+crypt($1,$2),2,3;eg;print$..$/

        Dear liverpole,

        Thanks a lot I would like that my outfile looks like :
        0601|3|NORM|2|ALLO|XLF753|U|0045|0050| 0603|5|NORM|2|ALLO|ADR2CG||0430|0438| 0604|6|NORM|2|ALLO|AF681VC|i U|0500|0510| 0605|7|NORM|2|ALLO|AF651PQ|i|0515|0523| 0606|8|NORM|2|ALLO|AF713BR|i|0445|0453| 0607|9|NORM|2|ALLO|AFR100M|i|0520|0533| 0609|11|NORM|2|ALLO|GJT775|i E|2300|2315| 0610|12|NORM|2|ALLO|AF661WN|i|0450|0500|0500

        So that there is a unique column for i, E, and U and if two both appear on the same line, that they are in the same column. (the separator can be "|" or ";")