Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Help required in find command.

by CountZero (Bishop)
on Apr 16, 2014 at 13:43 UTC ( [id://1082510]=note: print w/replies, xml ) Need Help??


in reply to Help required in find command.

Please give us a few more blocks, exactly as they appear in your file (you can change names and other sensitive info if required) and put this information in <code> ... </code> tags.

It is very important to see the exact structure, delimiter, number of lines, ...

Also give us an example of the output you expect from the data you provide.

Update: changed <quote> to <code> (thanks choroba)

CountZero

A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

My blog: Imperial Deltronics

Replies are listed 'Best First'.
Re^2: Help required in find command.
by maestromani (Initiate) on Apr 16, 2014 at 14:30 UTC
    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"; }

      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://1082510]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2024-04-23 07:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found