[30655] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 1900 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 5 09:09:43 2008

Date: Sun, 5 Oct 2008 06:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 5 Oct 2008     Volume: 11 Number: 1900

Today's topics:
    Re: Basic pattern matching - baffled sln@netherlands.com
        Download files script. <internetpowerfultools@gmail.com>
    Re: Download files script. <internetpowerfultools@gmail.com>
    Re: Help: Process many files at the same time sln@netherlands.com
    Re: how to replace $1, $2, $3 ... sln@netherlands.com
    Re: how to replace $1, $2, $3 ... sln@netherlands.com
    Re: how to replace $1, $2, $3 ... sln@netherlands.com
    Re: is Win32::GUI thread safe? <starbuck42+newsgroup@gmail.com>
        new CPAN modules on Sun Oct  5 2008 (Randal Schwartz)
    Re: pack and hex <bart.lateur@pandora.be>
    Re: Problems flushing my buffer! (perl) <nospam-abuse@ilyaz.org>
    Re: Problems flushing my buffer! (perl) <whynot@pozharski.name>
    Re: Problems flushing my buffer! (perl) <m@rtij.nl.invlalid>
    Re: trouble parsing "kind of" comma-delimited text sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 04 Oct 2008 22:23:21 GMT
From: sln@netherlands.com
Subject: Re: Basic pattern matching - baffled
Message-Id: <pnofe45ljalmakj6pcldjdi45v7l2pb566@4ax.com>

On Fri, 03 Oct 2008 01:54:11 -0700, Xainin <63f2-oyik@dea.spamcon.org> wrote:

>xhoster@gmail.com wrote:
>
>>Xainin <63f2-oyik@dea.spamcon.org> wrote:
>>> Help!  I don't understand why this script:
>>>
>>> #!perl -w
>>>
>>> $a = 'C:\WINDOWS';
>>> $b = 'C:\WINDOWS';
>>>
>>> if ( $a =~ /^$b$/i ) {
>>>     print "matched '$a' to '$b'\n";
>>> }
>>> else {
>>>     print "UNMATCHED '$a' vs. '$b'\n";
>>> }
>>
>>\W is special in a regex.
>>
>>>
>>> $ta = quotemeta "$a";
>>
>>$a is not used as a regex, it is treated as a literal string.  Protecting
>>characters special to regexes in something not used that way is
>>counterproductive.
>>
>>Xho
>
>Thanks to all - I added strict/warnings and declared with "my", but the
>key per your last comment was to change "$ta" to "$a" in my last test and
>it works.


I'm not sure if you are getting the point.

The regular expression is on the right, what your testing is on the left:

$a = 'C:\WINDOWS';

if ($a =~ /do/i) {	# i modifier means case insensitive matching
#   regexp ^^
	print "matched $a to 'do'\n";
}

if ($a =~ /wi/i) {
	print "matched $a to 'wi'\n";
}

if ($a !~ /c:\windows/i) {
# escape seq ^^  
	print "did NOT match $a to 'c:\windows'\n";

	# in this case the regular expression had a \w in it
        # which is shorthand for all the letters, and all the 
        # numbers that can be matched in that single character position.
        # the regexp now looks for:
	# c, :, then
        # any char or number (because of \w), then
        # i, n, d, o, w, s
        # however, in that character position in $a, the literal object
        # of comparison, is '\' and it fails
}

# to fix that, the regular expression needs to escape '\' the escape character.
# this results in '\\'w instead of '\w'. there is no '\\' substitution (shorthand)
# in the regex parser, so '\\' is treated as a single '\' when the regular expression
# is parsed. thus '\\w' becomes the literal search pattern "\w" within $a.

if ($a =~ /c:\\windows/i) {
	print "did match $a to 'c:\windows'\n";
}

Be sure not to confuse yourself with the constructs you have listed.
It does not seam like you are distinguishing the string you want to test with
the regular expression you use to test it with.

sln





------------------------------

Date: Sun, 5 Oct 2008 02:18:11 -0700 (PDT)
From: mathaios <internetpowerfultools@gmail.com>
Subject: Download files script.
Message-Id: <f757de19-fd9f-440d-b1a7-be2da8ab2d48@q9g2000hsb.googlegroups.com>

Hi.
I want to install a script in my website  for the visitors to be able
to download files.
Is there anyone who can replace the variables  needed to be changed in
the
script  below for base downloads folder, downloads log file name,
allowed file types
 with highlighted example text? I mean:
in this line for example:
<span style=3D"background-color:ff0000;">
define('BASE_DIR','/home/user/downloads/'); </span>there is a variable
to be entered.Where should i enter this variable?

---------------------------------------------------------------------------=
=AD---------------------------------------------------------------
// Allow direct file download (hotlinking)?
// Empty - allow hotlinking
// If set to nonempty value (Example: example.com) will only allow
downloads when referrer contains this text
define('ALLOWED_REFERRER', '');


// Download folder, i.e. folder where you keep all files for
download.
// MUST end with slash (i.e. "/" )
define('BASE_DIR','/home/user/downloads/');


// log downloads?  true/false
define('LOG_DOWNLOADS',true);


// log file name
define('LOG_FILE','downloads.log');


// Allowed extensions list in format 'extension' =3D> 'mime type'
// If myme type is set to empty string then script will try to detect
mime type
// itself, which would only work if you have Mimetype or Fileinfo
extensions
// installed on server.
$allowed_ext =3D array (


  // archives
  'zip' =3D> 'application/zip',


  // documents
  'pdf' =3D> 'application/pdf',
  'doc' =3D> 'application/msword',
  'xls' =3D> 'application/vnd.ms-excel',
  'ppt' =3D> 'application/vnd.ms-powerpoint',


  // executables
  'exe' =3D> 'application/octet-stream',


  // images
  'gif' =3D> 'image/gif',
  'png' =3D> 'image/png',
  'jpg' =3D> 'image/jpeg',
  'jpeg' =3D> 'image/jpeg',


  // audio
  'mp3' =3D> 'audio/mpeg',
  'wav' =3D> 'audio/x-wav',


  // video
  'mpeg' =3D> 'video/mpeg',
  'mpg' =3D> 'video/mpeg',
  'mpe' =3D> 'video/mpeg',
  'mov' =3D> 'video/quicktime',
  'avi' =3D> 'video/x-msvideo'
);
---------------------------------------------------------------------------=
=AD---------------------------------------------------------------


I  would be greatful.






------------------------------

Date: Sun, 5 Oct 2008 02:07:11 -0700 (PDT)
From: mathaios <internetpowerfultools@gmail.com>
Subject: Re: Download files script.
Message-Id: <df65484f-7003-4730-8074-dbfe7256a005@t65g2000hsf.googlegroups.com>

On Sep 30, 2:46=A0am, Rich Grise <r...@example.net> wrote:
> On Sun, 28 Sep 2008 03:29:26 -0700, mathaios wrote:
> > Hi.
> > I want to install a script in my website =A0for the visitors to be able
> > to download files.
>
> Why not just link to it, and let them click "save to disk"?
>
> Cheers!
> Rich

How do i do that?


------------------------------

Date: Sat, 04 Oct 2008 23:29:47 GMT
From: sln@netherlands.com
Subject: Re: Help: Process many files at the same time
Message-Id: <41vfe4dk81tqcue16g0mno4dtba9pv8oj2@4ax.com>

On Tue, 30 Sep 2008 08:57:35 -0500, Tad J McClellan <tadmc@seesig.invalid> wrote:

>Amy Lee <openlinuxsource@gmail.com> wrote:
>
>
>> foreach $file (@ARGV)
>
>
>Why do you think you need this foreach loop?
>
>(hint: where does your program make use of the $file variable?)
>
>
>> {
>>   while (<>)
>
>
>The diamond operator (<>) opens a file (for reading) for you.
>
>
>>   {
>>     chomp;
>>     if (/(\d+)\s+dG = (-?[\d.]+)\s+(.*)/)
>>     {
>>       $total = $1;
>>       $name = $3; 
>>       s/.*//;
>
>
>What is in $_ at this point in your program?
>
>(hint: print it out here.)
>
>
>>     }
>>     $g += tr/C//;
>>     $c += tr/G//;
>
>
>What string is the tr/// operator operating on here? (Answer: the string in $_).
>
>What is in $_ at this point? (Answer: either the empty string or a newline).
>
>How many "C" characters are there in $_ (Answer: zero).
>
>Repeatedly adding zero to a number will not likely lead to useful results...
>
>
>>   }
>>   $gc = $g+$c;
>>   $GC = $gc/$total;
>
>
>I anticipate that you will run into yet another Frequently Asked Question,
>so let's get that out of the way right now:
>
>   perldoc -q 999
>
>        Why am I getting long decimals (eg, 19.9499999999999) instead 
>        of the numbers I should be getting (eg, 19.95)?
>
>and
>
>   perldoc -q round
>
>        Does Perl have a round() function?  What about ceil() and floor()?  
>        Trig functions?
>
>
>>   print "$name\t$GC\n";
>
>
>Since you have not provided a filehandle to print(), all of the output
>will go to the default stream (STDOUT).
>
>If you want to write to a file, you must open() it for writing,
>and use the filehandle that the open() set up for you, eg:
>
>    open my $OUTFILE, '>', "$file.new" or die "could not open '$file.new' $!";
>then
>    print $OUTFILE "$name\t$GC\n";
>
>
>> }
>> Then I hope I can get a list of the result because I use "foreach" to
>> process many files I gave at the same time. However, It just output one
>> file and the output variable $CG is wrong. If I run this to process one
>> file, it could work well.
>
>
>perl will handle all of the reading from one file then writing to
>another file for you.
>
>See the -i switch in perlrun.pod and the $^I variable in perlvar.pod.

You are the atypical prototype ball buster ain't ya?

sln


------------------------------

Date: Sun, 05 Oct 2008 00:00:18 GMT
From: sln@netherlands.com
Subject: Re: how to replace $1, $2, $3 ...
Message-Id: <hn0ge4lrpdi58m1eoupj7uaomfd1l2e9e9@4ax.com>

On Tue, 30 Sep 2008 17:06:14 +0200, Peter Makholm <peter@makholm.net> wrote:

>Marten Lehmann <lehmannmapson@cnm.de> writes:
>
>> I have a regular expression, which returns several values in $1, $2,
>> $3 and so on. How can I simplify an assignment like this:
>>
>> ($one, $two, $three) = ($1, $2, $3);
>
>Quite obfuscated and only almost equivalent:
>
>$var =~ m/$re/;
>($one, $two, @rest) = map { substr($var, $-[$_], $+[$_] - $-[$_]) } 1 .. $#-;
>
>Some extra work may make it more equivalent with the original (test
>for definedness of $-[$_]) but this only makes it even more obscure
>nad I'm not convinced taht it doesn't contains other quirks.
>
>I guess there is a special level of hell reserved for people using
>this in production code.
>
>//Makholm

Talk about obfuscated ^. Map/substr, holy christ.

@aaa = ($str =~ /"+\s*([^"]*?)\s*"+|\s*([^,\n]+)\s*/g);

Works fine for me. Up to the author to test for defined'ness...

sln


------------------------------

Date: Sun, 05 Oct 2008 00:16:32 GMT
From: sln@netherlands.com
Subject: Re: how to replace $1, $2, $3 ...
Message-Id: <aj1ge4t6f0mc4c148p0b5rc1tijbncugao@4ax.com>

On Tue, 30 Sep 2008 17:06:14 +0200, Peter Makholm <peter@makholm.net> wrote:

>Marten Lehmann <lehmannmapson@cnm.de> writes:
>
>> I have a regular expression, which returns several values in $1, $2,
>> $3 and so on. How can I simplify an assignment like this:
>>
>> ($one, $two, $three) = ($1, $2, $3);
>
>Quite obfuscated and only almost equivalent:
>
>$var =~ m/$re/;
>($one, $two, @rest) = map { substr($var, $-[$_], $+[$_] - $-[$_]) } 1 .. $#-;
>
>Some extra work may make it more equivalent with the original (test
>for definedness of $-[$_]) but this only makes it even more obscure
>nad I'm not convinced taht it doesn't contains other quirks.
>
>I guess there is a special level of hell reserved for people using
>this in production code.
>
>//Makholm

Of course no sane person would try to generalize the results. The regular expression
is designed with the results in mind, not the inverse.

Have a nice day...

/(?:<(?:(?:(\/*)($Name)\s*(\/*))|(?:($Name+)(\s+(?:(?:(?:".*?")|(?:'.*?'))|(?:[^>]*?))+)\s*(\/?))|(?:\?(.*?)\?)|(?:!(?:(?:DOCTYPE(.*?))|(?:\[CDATA\[(.*?)\]\])|(?:--(.*?)--)|(?:ATTLIST(.*?))|(?:ENTITY(.*?))|(?:ELEMENT(.*?)))))>)|(.+?)/

sln




------------------------------

Date: Sun, 05 Oct 2008 00:37:38 GMT
From: sln@netherlands.com
Subject: Re: how to replace $1, $2, $3 ...
Message-Id: <bn2ge4lqm2e7gbomhra1f9j8i00k4qj94j@4ax.com>

On Sun, 05 Oct 2008 00:00:18 GMT, sln@netherlands.com wrote:

>On Tue, 30 Sep 2008 17:06:14 +0200, Peter Makholm <peter@makholm.net> wrote:
>
>>Marten Lehmann <lehmannmapson@cnm.de> writes:
>>
>>> I have a regular expression, which returns several values in $1, $2,
>>> $3 and so on. How can I simplify an assignment like this:
>>>
>>> ($one, $two, $three) = ($1, $2, $3);
>>
>>Quite obfuscated and only almost equivalent:
>>
>>$var =~ m/$re/;
>>($one, $two, @rest) = map { substr($var, $-[$_], $+[$_] - $-[$_]) } 1 .. $#-;
>>
>>Some extra work may make it more equivalent with the original (test
>>for definedness of $-[$_]) but this only makes it even more obscure
>>nad I'm not convinced taht it doesn't contains other quirks.
>>
>>I guess there is a special level of hell reserved for people using
>>this in production code.
>>
>>//Makholm
>
>Talk about obfuscated ^. Map/substr, holy christ.
>
>@aaa = ($str =~ /"+\s*([^"]*?)\s*"+|\s*([^,\n]+)\s*/g);
>
>Works fine for me. Up to the author to test for defined'ness...
>
>sln

Actually, I would never do this because it will always embed undef's on the
non-matching $# if more than one capture definition per match. But for single's
its is fine, any more its not fine.

sln




------------------------------

Date: Sat, 04 Oct 2008 19:16:58 -0400
From: "Tom F." <starbuck42+newsgroup@gmail.com>
Subject: Re: is Win32::GUI thread safe?
Message-Id: <gc8thh$4hu$1@aioe.org>

zentara wrote:
>> zentara wrote:
> 
>>> I would bet that you can solve the problem by :
>>>
>>> 1. Create the thread first in the program, before any gui code is
>>> invoked.  For instance, you cannot reliably launch threads from
>>> a gui callback. Threads get a copy of the parent when spawned,
>>> so you want to spawn early before gui code statements are used.

> You don't share the GUI widgets as shared variables, Perl only allows
> scalars in shared vars. In Gtk2 ,you can pass in a widget reference in
> the threads->new(\&codeblock, $somewidget), and then access the widget
> by a Glib->Idle_add() statement. Does Win32::Gui have something like
> Idle_add? Adds a callback at first idle moment in the event loop. 

Thanks, I think I am just going to have to use shared variables as flags and 
whatnot. Dang, I had this thing written 5 times over if only it was friggin' 
thread safe.


------------------------------

Date: Sun, 5 Oct 2008 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Sun Oct  5 2008
Message-Id: <K8912r.rLr@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Catalyst-Authentication-Store-Htpasswd-1.003
http://search.cpan.org/~bobtfish/Catalyst-Authentication-Store-Htpasswd-1.003/
Authen::Htpasswd based user storage/authentication. 
----
Catalyst-Plugin-Cache-Memcached-Fast-0.1
http://search.cpan.org/~vasilus/Catalyst-Plugin-Cache-Memcached-Fast-0.1/
Catalyst Plugin for Cache::Memcached::Fast 
----
Cogwheel-0.03
http://search.cpan.org/~stypnow/Cogwheel-0.03/
A Client/Server Networking Framework based on Moose and Sprocket 
----
Crypt-NSS-0.01_04
http://search.cpan.org/~claesjac/Crypt-NSS-0.01_04/
Perl bindings to NSS (Netscape Security Services) 
----
Data-Rx-0.003
http://search.cpan.org/~rjbs/Data-Rx-0.003/
perl implementation of Rx schema system 
----
Data-Rx-0.004
http://search.cpan.org/~rjbs/Data-Rx-0.004/
perl implementation of Rx schema system 
----
Data-Rx-Type-MooseTC-0.001
http://search.cpan.org/~rjbs/Data-Rx-Type-MooseTC-0.001/
experimental / proof of concept Rx types from Moose types 
----
Data-Rx-Type-MooseTC-0.002
http://search.cpan.org/~rjbs/Data-Rx-Type-MooseTC-0.002/
experimental / proof of concept Rx types from Moose types 
----
Data-Rx-Type-PCRE-0.001
http://search.cpan.org/~rjbs/Data-Rx-Type-PCRE-0.001/
PCRE string checking for Rx (experimental) 
----
Devel-Declare-0.002001
http://search.cpan.org/~flora/Devel-Declare-0.002001/
----
Device-USB-0.23
http://search.cpan.org/~gwadej/Device-USB-0.23/
Use libusb to access USB devices. 
----
FLV-Info-0.21
http://search.cpan.org/~cdolan/FLV-Info-0.21/
Extract metadata from Macromedia Flash Video files 
----
File-Find-Closures-1.09
http://search.cpan.org/~bdfoy/File-Find-Closures-1.09/
functions you can use with File::Find 
----
Foorum-0.2.8
http://search.cpan.org/~fayland/Foorum-0.2.8/
forum system based on Catalyst 
----
Git-FastExport-0.05
http://search.cpan.org/~book/Git-FastExport-0.05/
A module to parse the output of git-fast-export 
----
Gitosis-Config-0.0.3
http://search.cpan.org/~perigrin/Gitosis-Config-0.0.3/
Parse and Write gitosis config files 
----
Gtk2-Ex-PodViewer-0.18
http://search.cpan.org/~gbrown/Gtk2-Ex-PodViewer-0.18/
a Gtk2 widget for displaying Plain old Documentation (POD). 
----
Lingua-DE-Wortschatz-1.26
http://search.cpan.org/~schroeer/Lingua-DE-Wortschatz-1.26/
wortschatz.uni-leipzig.de webservice client 
----
Mail-Builder-1.12
http://search.cpan.org/~maros/Mail-Builder-1.12/
Easily create plaintext/html e-mail messages with attachments and inline images 
----
Net-IP-Match-Regexp-1.01
http://search.cpan.org/~cdolan/Net-IP-Match-Regexp-1.01/
Efficiently match IP addresses against ranges 
----
Net-Laconica-0.08
http://search.cpan.org/~haggai/Net-Laconica-0.08/
Perl extension for fetching from, and sending notices/messages to Laconica instances 
----
ODG-Record-0.28
http://search.cpan.org/~ctbrown/ODG-Record-0.28/
Perl extension for efficient and simple manipulation of row based records. 
----
Perlwikipedia-1.3.5
http://search.cpan.org/~dcollins/Perlwikipedia-1.3.5/
a Wikipedia bot framework written in Perl 
----
Scalar-Util-Ref-0.01
http://search.cpan.org/~gfuji/Scalar-Util-Ref-0.01/
A selection of general-utility reference subroutines 
----
Sub-ParamFrame-0.03
http://search.cpan.org/~schoejo/Sub-ParamFrame-0.03/
Supply key alias and defaults of named arguments. 
----
TM-1.44
http://search.cpan.org/~drrho/TM-1.44/
Topic Maps, Base Class 
----
TM-Easy-0.02
http://search.cpan.org/~drrho/TM-Easy-0.02/
Topic Maps, Easy Usage 
----
Test-More-Behaviours-v0.0.3
http://search.cpan.org/~rija/Test-More-Behaviours-v0.0.3/
Group Test::More assertions into behaviours 
----
Test-More-Behaviours-v0.0.4
http://search.cpan.org/~rija/Test-More-Behaviours-v0.0.4/
Group Test::More assertions into behaviours 
----
Win32-MSI-HighLevel-1.0003
http://search.cpan.org/~grandpa/Win32-MSI-HighLevel-1.0003/
Perl wrapper for Windows Installer API 
----
Yahoo-Marketing-APT-1.02
http://search.cpan.org/~shenj/Yahoo-Marketing-APT-1.02/
an interface for Yahoo! Search Marketing's APT Web Services. 
----
warnings-unused-0.021
http://search.cpan.org/~gfuji/warnings-unused-0.021/
Produces warnings when unused variables are detected 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


------------------------------

Date: Sat, 04 Oct 2008 22:24:30 +0200
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: pack and hex
Message-Id: <e0kfe4t9hmivfks7ua4j80ibeo8jv4e2k3@4ax.com>

Larry wrote:

>Right now I cannot figure outhow come they came up with the b7 
>thing...If I were to use the following as a b8:
>
>0xFF 0xFF 0xFF 0xFF
>
>I could numbers from 0 to 4294967295, with the b7 is a lesser.

It's because for MP3, bytes with the high bit set are considered
special: they're treated as the start of a new audio frame. In
principle, bytes with the high bit set are illegal in meta tags.

And then, of course somebody screwed up and put raw Unicode (including
BOM, which is a 0xFF and a 0xFE byte, indicating byte endianness) in
ID3v2 meta tags. I know Winamp dares to do that. And now, we're stuck
with the consequences.

-- 
	Bart.


------------------------------

Date: Sat, 4 Oct 2008 21:18:34 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Problems flushing my buffer! (perl)
Message-Id: <gc8mja$9n7$1@agate.berkeley.edu>

[A complimentary Cc of this posting was NOT [per weedlist] sent to
Peter J. Holzer
<hjp-usenet2@hjp.at>], who wrote in article <slrngefera.etl.hjp-usenet2@hrunkner.hjp.at>:
> Right. Although that's extremely rare these days. All the major
> graphical HTML rendering engines (IE, Gecko, KHTML, ...) are able to
> render a page incrementally. However, many text based browsers (e.g.,
> lynx, w3m) aren't - if Nigel is using one of them that might be the
> problem.

lynx is incremental as well...

Yours,
Ilya





------------------------------

Date: Sun, 05 Oct 2008 12:21:41 +0300
From: Eric Pozharski <whynot@pozharski.name>
Subject: Re: Problems flushing my buffer! (perl)
Message-Id: <5idmr5x9ju.ln2@carpet.zombinet>

Ilya Zakharevich <nospam-abuse@ilyaz.org> wrote:
> [A complimentary Cc of this posting was NOT [per weedlist] sent to
> Peter J. Holzer <hjp-usenet2@hjp.at>], who wrote in article
> <slrngefera.etl.hjp-usenet2@hrunkner.hjp.at>:
>> Right. Although that's extremely rare these days. All the major
>> graphical HTML rendering engines (IE, Gecko, KHTML, ...) are able to
>> render a page incrementally. However, many text based browsers (e.g.,
>> lynx, w3m) aren't - if Nigel is using one of them that might be the
>> problem.
> lynx is incremental as well...

elinks too...

-- 
Torvalds' goal for Linux is very simple: World Domination


------------------------------

Date: Sun, 5 Oct 2008 14:40:15 +0200
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Problems flushing my buffer! (perl)
Message-Id: <pan.2008.10.05.12.40.15@rtij.nl.invlalid>

On Fri, 03 Oct 2008 02:57:24 -0700, Nigel wrote:

> Hi there,
> 
> I hope you can help - I'm writing a perl program and I want it report
> back to the browser
> on its progress. I read the perl faq and saw that by setting $| true the
> buffer would be
> flushed each time I printed instead of waiting until the program
> terminates. But I can't
> get it to work.
> 
> I'm expecting the web page to say that it's on the job, then every
> second (for 10 seconds) to say Please Wait and then at the end to say
> it's finished. But what happens is I wait ten seconds for a response and
> the whole lot appears at once. Any advice would be VERY welcome.

Some versions (all?) of IE needs 256 characters before they will behave 
correctly. Try to print 256 spaces somewhere. I wrote scripts that did 
behave like what you told until I added the spaces.

HTH,
M4


------------------------------

Date: Sat, 04 Oct 2008 20:24:42 GMT
From: sln@netherlands.com
Subject: Re: trouble parsing "kind of" comma-delimited text
Message-Id: <6oife45lqmurcr2hmopciskmm8c9dnvur3@4ax.com>

On Fri, 03 Oct 2008 13:37:01 -0400, nun <junk@yahoo.com> wrote:

>I need to process a text file of product data that's supplied to me by a
>vendor. This data is "kind of" comma-delimited.... some of the rows
>contain commas within the "description" field, and in these cases (and
>only in these cases) that field's data is enclosed by double quotes.
>Here is some sample data:
>
>SKU,DESCRIPTION,PRICE
>12345,CABLE,21.25
>56789,"CONNECTOR, LARGE",13.50
>
>Rows which do not have the double-quote-enclosed comma issue can be
>processed correctly using this code:
>
>#################################
># reading data in from file
>my (@AoA);
> while ( <> ) {

	my @tmpa = ();
	while (/"+\s*([^"]*?)\s*"+|\s*([^,\n]+)\s*/g) # trims 
	{
		my $val = defined $1 ? $1 : $2;
		push @tmpa, $val;
	}
	push @AoA, \@tmpa;

	# or ...

	push @AoA, [(/("+[^"]*?"+|[^,\n]+)/g)];  # does not trim
> }
>#################################
>
>but of course the rows which do have that issue don't parse as desired.
>
>So far I've been unable to come up with a good way to handle this, so I
>thought I'd ask for suggestions from the gurus. Any ideas would be
>appreciated.
>
>DB

If you don't want to bring in a bunch of code, do it the easy way.
sln


use strict;
use warnings;

my $str = '
SKU,DESCRIPTION,PRICE
12345,	CABLE ,  21.25
56789,"CONNECTOR, LARGE"",13.50
';


while ($str =~ /("+[^"]*?"+|[^,\n]+)/g)
{
	my $val = $1;
	$val =~ s/^[\s'"]+//; $val =~ s/[\s'"]+$//;
	print "val_a = $val\n";
	# ... push @ary, $val;
}
print "\n\n\n";

## or ...

while ($str =~ /"+\s*([^"]*?)\s*"+|\s*([^,\n]+)\s*/g)
{
	my $val = defined $1 ? $1 : $2;
	print "val_b = $val\n";
	# ... push @ary, $val;
}

print "\n\n\n";

## or ...

my @ary = ($str =~ /("+[^"]*?"+|[^,\n]+)/g); # but gets all the crap as well

print "@ary\n";

__END__

output:

val_a = SKU
val_a = DESCRIPTION
val_a = PRICE
val_a = 12345
val_a = CABLE
val_a = 21.25
val_a = 56789
val_a = CONNECTOR, LARGE
val_a = 13.50



val_b = SKU
val_b = DESCRIPTION
val_b = PRICE
val_b = 12345
val_b = CABLE
val_b = 21.25
val_b = 56789
val_b = CONNECTOR, LARGE
val_b = 13.50



SKU DESCRIPTION PRICE 12345     CABLE    21.25 56789 "CONNECTOR, LARGE"" 13.50




------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 1900
***************************************


home help back first fref pref prev next nref lref last post