On Dec 14, Lance Prais said: >I am using the following piece of code to check to see if online 23 the >word 'Running' appears between pos 11 and 19.
Whenever you have specific information like that, a regex is often not the best approach to take. >#open a file with the filehandle >open WORKFLOW, "+<..\\..\\workflow.txt" or die "Cannot open Workflow $!\n"; >my $data = <WORKFLOW> for (1..21); #Testing to make sure I am This discards lines 1 through 21. I thought you wanted to discard the first 22 lines. >seek(WORKFLOW, 22, 0); #This will put you at row 23.--- This is not what seek() does. seek FH, OFFSET, WHENCE; OFFSET is some number of bytes (not a line number), relative to WHENCE -- if WHENCE is 0, it's OFFSET bytes from the beginning of the file, if WHENCE is 1, it's OFFSET bytes from the current position in the file, and if WHENCE is 2, it's OFFSET bytes (you usually want OFFSET to be negative in this case) from the end of the file. Your call puts you 22 bytes from the beginning of the file. Not what you wanted. If you want to skip the first 22 lines of a file, just do: <FH> for 1 .. 22; >$_=<WORKFLOW>; >/("Running")/; #Now if you want, you can also check > #to make sure that this was found in > #the right column by checking @- and @+ >if($-[0] == 10 && $+[0] == 18) You don't need parens around "Running" in your regex. And instead of using a regex here, why not simply test like so: $_ = <WORKFLOW>; if (substr($_, 10, 8) eq '"Running"') { # ... } You should also never use a regex in void context -- if it fails, you'll get the results from the previous successful regex shining through: "jeff" =~ /(ef+)/; print $1; # "eff" "joe" =~ /(ef+)/; print $1; # "eff" -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]