On Wed, 20 Aug 2003, john z wrote: > hi: > when i bring in a gif or jp file from http with a get, the headers come > along with the file. ive been trying to strip them and noticed that the reg > exp seems to fail under perl 806. > > the following should (imho) work but dont. > $got_gif=~s[^http(.*?)\n\n][]i; > or > $got_gif=~s[^http.*?\n\n][]i; > > the strange part is if i replace all the \n with something else, like \|, > then it works. or course, i cant do the sub for a real image since its > highly likely that \| is one of the bytes in the image file.
Then perhaps you don't understand the format of an URL (the http: stuff or the HTTP headers. Perhaps _I_ don't understand the format of the data you are working on. I would think that am appropriate regex to capture the image file name would be: ($got_gif)=$got_gif=~m!http://.+/([-\w]+\.(?=gif|jpg|jpeg))\b!i; Of course this regex might need to be adjusted if you need the full path to the file rather than just the base name. Your substitution replaced every thing starting with http: (but only at the beginning of a line) through the end of the header(s) with a null string. If you really have the http headers it is likely that they start with: Content-Type: text/html. If on the other hand you are trying to strip off all the header information up through the end-of-headers then an appropriate substiturion operator would be: $got_gif=~s/^.*\n\n/s; **** [EMAIL PROTECTED] <Carl Jolley> **** All opinions are my own and not necessarily those of my employer **** _______________________________________________ Perl-Win32-Users mailing list [EMAIL PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs