On Sun, May 14, 2006 7:51 pm, Ryan A wrote: > ------------------------------ > $stdin = fopen('php://stdin', 'r'); > > while ($line = fgets($stdin)) > { > $line=trim($line); > ryan_debug_write_to_file('In while(),STDIN, > Start..'.$line.'---End '); You *DO* see this bit in the log right?... And is $line what you expect it to be, newlines and all?... > $pattern="/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/"; It's NOT your problem, but... \ has an awful lot of different meanings inside of " marks in PHP. I'd recommend using \\ to get a single \ embedded in a string. If tomorrow you need \t for the PCRE, you'll get REAL confused if you just follow your current practice... One thing to try is to make the SIMPLEST regex you can first by adding this line AFTER your curent $pattern = "..."; line: $pattern = '/(.*)/'; Then, piece by piece, build it up to what you think you want, adding only one expression at a time. This will help focus the problem down to a specific pattern syntax in PCRE instead of one big mess. You might also want to make some of the \\d parts be more like \\d{1,3} since an IP quad has to be 0..255 to be kosher. > if (preg_match($pattern,$line,$m)) > /*\|(.+)\|(.+)*/ > { > ryan_debug_write_to_file('Now in Preg match!'); > /* This does not execute for some reason....ARRRRGH*/ > ....more code here > } > ------------------------------ > > The problem is I never get the "Now in Preg match" > message... I have checked the preg_match by taking the > data and putting it in a file and reading it from > there like this: > > > ----------------------------------- > > <pre> > <?php > > $stdin = fopen("test.txt", "r"); > while ($line = fgets($stdin)) > { > $line=trim($line); > echo '<b>In while(),Start..'.$line.'---End of > stdin<br></b>'; > > > $pattern="/^(\d+\.\d+\.\d+\.\d+)\|(.+)\|(\d+)\|([\d-]+)\|(.+)\|(.+)$/"; > if (preg_match($pattern,$line,$m)) > /*\|(.+)\|(.+)*/ > { > > > echo 'Now in Preg match!<br>'; > } > } > ?> > </pre> > > ----------------------------------- > > and it works perfectly, so wheres the damn problem on > top? Spent the better part of 3 hours trying to find > the problem. Just for [bleeps] and giggles, take out the $ bit. Perhaps the stdin EOL character is not being returned the way you/PCRE expects by fgets? That seems like the only place anything COULD go wrong given your testing... -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php