Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Help required in find command.

by maestromani (Initiate)
on Apr 16, 2014 at 14:30 UTC ( [id://1082518]=note: print w/replies, xml ) Need Help??


in reply to Re: Help required in find command.
in thread Help required in find command.

Don';t like to use $flag, looking for best option. my piece of code looks like $file_name is command line parameter.
while (<DATA_FILE>) { $str = $_ ; if ($str =~ /include/) { if ($str =~ /\b$file_name\b/) { $flag = "TRUE" ; } } if ($flag eq "TRUE") { if ($str =~ /View Name/) { print $str ; ($junk,$view_name) = split(\->\,$str) ; print $view_name ; $flag = "FALSE" ; } } #print "$_\n"; }

Replies are listed 'Best First'.
Re^3: Help required in find command.
by kcott (Archbishop) on Apr 17, 2014 at 06:06 UTC

    Your OP is virtually unreadable so I don't actually know what your problem is.

    The only place in the entire thread that the string 'View Name' appears is in your regex (i.e. '/View Name/'). Therefore, $str =~ /View Name/ will always be FALSE and that if block will never be entered. Perhaps that relates to whatever your problem is. Have you shown a representative sample of your data?

    From the code fragment you've shown here, you're using package global variables exclusively. Perhaps that relates to your problem. For instance, there could be another global $flag elsewhere in your code.

    -- Ken

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1082518]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-06-15 23:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.