Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^2: Checking value of an extracted variable

by r.biswas (Initiate)
on Dec 23, 2012 at 10:13 UTC ( #1010084=note: print w/replies, xml ) Need Help??


in reply to Re: Checking value of an extracted variable
in thread Checking value of an extracted variable

My code is shown below. After locating the keyword(stored in $first) I need to check the value of the variable stored in $first. $first = SEL_BLOCK. But I need to check the value of the SEL_BLOCK. How can it be done?

open(OUT,">Output.txt") or die "Can't open output.txt for writing:$!\n +"; open(IN, "<Input.txt") or die "Can't open input.txt for reading:$!\n"; @array = <IN>; foreach $line (@array) { chomp ($line); if ($line =~ /^OPT:/) { $var = $'; @param = split / /, $var; $first = $param[1]; print "$first\n"; if ($first==1) { # This is not working as desired $start = 1; } else { $skip = 1; } } elsif ($start == 1 || $skip==1) { if ($line =~ /^]/) { $start = 0; $skip = 0; } elsif ($skip == 0) { printf (OUT "$line\n"); } } else { printf (OUT "$line\n"); } }

Replies are listed 'Best First'.
Re^3: Checking value of an extracted variable
by r.biswas (Initiate) on Dec 23, 2012 at 10:22 UTC
    I also like to point out that in the input file the keyword will be declared as below
    Input.txt(input file) OPT: SEL_BLOCK [ some text to be copied to output file if SEL_BLOCK = 1 ]

    SEL_BLOCK will be defined in a config file which can be included in the perl script. The script will have visibilty of the value of SEL_BLOCK and take appropriate actions(copying contents from input to output file).

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1010084]
help
Chatterbox?
[Corion]: Oh yay. The (external, not guided by me) programmers have chosen Moose+DBIx::Class for some implementation, and now seem to do 1+n SELECT statements for each row, as is usual when using ORMs.
[Corion]: So maybe I should investigate how to plug in a cache in front of DBIx::Class so I can do a ->selectall_hashre f and then satisfy the "sub"-selects from that cached single SELECT statement ...
[erix]: then you might as well send that patch to the DBIC guys :)

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2017-09-25 11:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    During the recent solar eclipse, I:









    Results (279 votes). Check out past polls.

    Notices?