Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Reading entire file.

by cLive ;-) (Prior)
on May 04, 2001 at 10:23 UTC ( #77884=note: print w/replies, xml ) Need Help??

in reply to Reading entire file.

"I am not able to post the actual file due to the nature of my work.."

So, why not make up a few lines of fake data to give us some idea of structure. And tell us what you are putting in $this and $that?

My money's on a dodgy regexp :)

cLive ;-)

Replies are listed 'Best First'.
Re: Re: Reading entire file.
by stuffy (Monk) on May 04, 2001 at 11:47 UTC
    I do have some sample text in my origional post. That is simular to what can be found in my text file, except there are 26 of one type of tool, 20 of another type, and 10 of another. I am only conserned with the first 26. My actual code is:

    while (<PD_FILE>){ if (/$tool_number/) $continue = 1; } if (/$end_tool/) $continue = 0; } if ($continue){ print $_; } }

    the value for $tool_number is Tool01 which will and does give $end_tool a value of Tool02. Everything that I have checked up to this point seems to work except the loop. I tried some code that was posted as a reply to another question.
    while (<^(*?)$tool_number(.*)$/) {

    that did not seem to work either.

      Hmmm, maybe this will make sense? (adding the braces you missed (typo :)
      my $tool_number = 1; # (say - perhaps you're looping through them, hen +ce... $tool_number = sprintf(%02d,$tool_number); # add leading zero, if need +ed while (<PD_FILE>){ if (/^Tool$tool_number/) { $continue = 1; } if (/^Tool/ && !(/^Tool$tool_number/)) { $continue = 0; } if ($continue){ print $_; } }

      FYI - ^ matches the beginning of a string (line in this case).

      cLive ;-)

      Yes, but is the sample text output or input. If input, what do you want output? ditto vice versa...

      cLive ;-)

        The sample is the input (the file that I want to read and cut into little pieces to output what the user wants to see.) The user inputs the tool name (Tool01,) and the date that they want to go back to (which is taken care of earlier in the script.) What the script does is gets rid of everything before the inputed date and keeps everything after. Then it is supposed to find every instance of the specified tool (Tool01) and print out any coments that have been written for that tool, stopping when it gets to the next tool, going to the next instance of that tool, printing untill it reaches the next tool.......The way it is set up the output to the reader should read:

        Tool01 - ran good
        Tool01 - Broke spindle temp transducer
        waitin on replacement

        once it is at that point, it is useable. Eventually I want to optomise the output to read:

        Apr 23 0630 - ran good
        Apr 24 2330 - Broke spindle temp transducer
        waiting on replacement

        I hope this clears up any confusion as to what I am asking, and what I am trying to do.


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (3)
As of 2021-12-09 07:09 GMT
Find Nodes?
    Voting Booth?
    R or B?

    Results (36 votes). Check out past polls.