my @result; my @result1; my @result2; my $b; my $c; my $d; my $ifile51 = '../test.txt'; my $ofile51 = 'seq.txt'; open (my $ifh51, '<', $ifile51) or die $!; open (my $ofh51, '>', $ofile51) or die $!; while(my $line51 = <$ifh51>) { # my $line51 = $_ if /\bbist_mode\b/; @result = grep (/bist_mode/, $line51); @result1 = grep (/mode_sel/, $line51); @result2 = grep (/mem_type_sel/, $line51); $b = join("_",@result); $b =~ s/,([^,]*$)/$1/; $c = join("_",@result1); $c =~ s/,([^,]*$)/$1/; $d = join("_",@result2); $d =~ s/,([^,]*$)/$1/; print $b; print $c; print $d; } print $b; print $c; print $d;

This code prints the value of b,c,d inside while loop but not outside while loop , what may be the problem ?

The text file contains

bist_ctlr_clk_bistctlr,

bist_ctlr_rst_bistctlr_n,

bist_ctlr_serial_in_system,

bist_ctlr_serial_out_system,

bist_ctlr_shift_en_system,

bist_ctlr_global_bbad,

bist_ctlr_global_repairable,

bist_ctlr_bist_mode,

bist_ctlr_mem_type_sel,

bist_ctlr_mode_sel,

bist_ctlr_memsafe,

bist_ctlr_sif_reg_en_system,

bist_ctlr_sif_load_en_system,

bist_ctlr_sif_update_en_system,

bist_ctlr_mem_atpg_mode,

bist_ctlr_flash_data_select,

bist_ctlr_flash_repair_data,

bist_ctlr_bend,

Outside the loop it should print

bist_ctlr_bist_mode

bist_ctlr_mem_type_sel


In reply to Not printing the values outside the while loop by suvendra123

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.