I am writing a perl script to extract a integer from a file and for each line generated, the integer is increased by 1.0.
I am not sure how to imbed the awk command within my perl script, as I get a lot of error messages.
At the top of the code, I included the files the script is extracting info from.
Can I get some pointers to get (line 22) the awk line to work?
Thanks RCP
#!perl ## comp_prim_loc file > Location: X:75.4634 Y:15.875 Side: +1 Rotation:0 ## comp_locs file> Reference Designator: C1000 ## comp_locs file> Reference Designator: C1002 ## comp_locs file> Reference Designator: C1004 open(MYOUTFILE, ">align_comp_cc.txt"); open (FILEH, "comp_prim_loc"); while (<FILEH>) { chomp; if ( /Location:/i ) { tr/:)(/ /; ($xloc,$yloc,$rot) = (split)[2,4,8]; open(MYOUTFILE, ">>align_comps_cc.txt"); $count = $yloc; open (FILEH, "comp_locs"); while (<FILEH>) { chomp; if ( /Reference Designator:/i ) { ($name) = (split)[2]; my $count="`awk -v x=$count -v y=1.0 'BEGIN{ printf "%3f\n", x+y}'`"; print "\$\place_component_by_reference_with_mrf('$name', [['$xloc', '$ +count', 'BO\$board'], 0, 0], 0, \@NoRepeat);\n"; } } } } close(MYOUTFILE);
The results should look like this:
$place_component_by_reference_with_mrf('C1000', ['70.4469', '16.875', 'BO$board', 0, 0], 0, @NoRepeat);
$place_component_by_reference_with_mrf('C1002', ['70.4469', '17.875', 'BO$board', 0, 0], 0, @NoRepeat);
$place_component_by_reference_with_mrf('C1004', ['70.4469', '18.875', 'BO$board', 0, 0], 0, @NoRepeat);

In reply to awk issues by RCP

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.