[30658] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1903 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 6 16:09:47 2008

Date: Mon, 6 Oct 2008 13:09:15 -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           Mon, 6 Oct 2008     Volume: 11 Number: 1903

Today's topics:
    Re: Data File <hirenshah.05@gmail.com>
    Re: Data File <glex_no-spam@qwest-spam-no.invalid>
    Re: How it works?(about while loop and regex as conditi <rvtol+news@isolution.nl>
    Re: How to escape single quotes inside fields but not t sln@netherlands.com
    Re: How to escape single quotes inside fields but not t sln@netherlands.com
    Re: How to escape single quotes inside fields but not t <cwilbur@chromatico.net>
    Re: How to escape single quotes inside fields but not t sln@netherlands.com
    Re: How to escape single quotes inside fields but not t sln@netherlands.com
    Re: How to escape single quotes inside fields but not t <tank209209@yahoo.com>
    Re: How to escape single quotes inside fields but not t <tank209209@yahoo.com>
    Re: How to escape single quotes inside fields but not t <rvtol+news@isolution.nl>
        How to sort and how to show cgi output into an iframe? <vsrawat@gmail.com>
    Re: How to sort and how to show cgi output into an ifra <vsrawat@gmail.com>
    Re: Problems flushing my buffer! (perl) <nigel@bouteyres.com>
    Re: trouble parsing "kind of" comma-delimited text <cartercc@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 6 Oct 2008 12:35:25 -0700 (PDT)
From: "friend.05@gmail.com" <hirenshah.05@gmail.com>
Subject: Re: Data File
Message-Id: <84a4e67c-8605-464a-8f5d-7c81c82dec4f@t41g2000hsc.googlegroups.com>

On Oct 6, 12:52=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> [Forwarded from CLP.Modules]
>
> "friend...@gmail.com" <hirenshah...@gmail.com> wrote:
> >I have a large file in following format:
>
> >ID | Time | IP | Code
>
> >I want to cluster the file by IP address and count total number of ID
> >for each IP address.
>
> split() each line at '|' into its components.
> Use the IP address as the key in a hash and increment a counter in that
> hash to count the total for that IP address.
>
> To create the clusters there are basically 2 different approaches,
> depending upon how large the file is, how much RAM you got, and how many
> IP addresses there are.
> Efficient, but needs lots of RAM: in addition to the counter also store
> each line in the hash for that key as a array. Then, after reading the
> whole file once, just walk through the whole hash key by key and print
> the array for each IP.
> Slow, but needs virtually no RAM: After reading the whole file once and
> creating all the hash keys walk through all the keys and for each key
> read the whole file again and print those lines, that have the same IP
> as the current key.
>
> jue
>
> memory =A0
>
>
>
>
>
> >I am new to perl.
>
> >Thanks.- Hide quoted text -
>
> - Show quoted text -

Hi,

Thanks for your reply.

I am trying to split with delimeter ' | ' But I am not sure what am I
doing wrong. It is not getting split. Below is example code.

open(INFO, $file);
@lines =3D <INFO>;
@line =3D split('|', $lines[0]);

print $line[3];



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

Date: Mon, 06 Oct 2008 15:01:01 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Data File
Message-Id: <48ea6e7d$0$89872$815e3792@news.qwest.net>

friend.05@gmail.com wrote:
[...]
> I am trying to split with delimeter ' | ' But I am not sure what am I
> doing wrong. It is not getting split. Below is example code.
> 

use strict;

> open(INFO, $file);

What if it fails?

open( my $info, '<', $file )
	or die "Can't open $file: $!";

> @lines = <INFO>;

You're sure you want to slurp the entire file?

my @lines = <$info>;
close $info;

> @line = split('|', $lines[0]);

It's a regular expression, so use '//' to remind yourself.

my @line = split( /\|/, $lines[0] );

> 
> print $line[3];
> 

The first argument to split is a regular expression
(see perldoc -f split).  The '|' is a metacharacter
in regular expressions and you need to escape it using '\'.

See metacharacter in perldoc perlretut too.





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

Date: Mon, 6 Oct 2008 20:52:09 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How it works?(about while loop and regex as condition)
Message-Id: <gcdu1s.1l4.1@news.isolution.nl>

Jürgen Exner schreef:

> The whole
> perlop man page is about 2000 lines long. That is way too long and
> complex. It is almost impossible to find anything there or to point
> people to specific part of it. Is someone already working on breaking
> it down into more managable chunks?


You could generate something like

-------------------------
=head2 TABLE OF CONTENTS

=over 2

=item L</Operator Precedence and Associativity>

=item L</Terms and List Operators (Leftward)>

=item L</The Arrow Operator>

=item etc. etc.

=back

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

before the "=head1 DESCRIPTION" line,

and use

perldoc -oHtml perlop | lynx -stdin

to have a viewer that is easier to navigate.

Something like "info" would also be nicer than the default man view.

Or use http://perldoc.perl.org/perlop.html

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Mon, 06 Oct 2008 18:25:07 GMT
From: sln@netherlands.com
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <p3lke490vi7m4k4f36ouhjbk24gh8d0hjk@4ax.com>

On Mon, 6 Oct 2008 08:16:38 -0700 (PDT), "Henry J." <tank209209@yahoo.com> wrote:

>Need to escape single quotes ( i.e., ' -> '' ) in a data file before
>sending to DB as part of insert SQLs.
>
>       Example 1):
>
>           it's mine, it's yours, 12, 42, 2008/10/06   => it''s mine,
>it''s yours, 12, 42, 2008/10/06
>
>       Example 2):
>
>           'it's mine', 'it's yours', 12, 42, '2008/10/06'  => 'it''s
>mine', 'it''s yours', 12, 42, '2008/10/06'
>
>The tricky part is that the data file may or may not have the string
>fields wrapped in single quotes.  In Example 1), it is not and single
>quotes around fields will be added by another script before sending to
>DB, in Example 2), its fields are already enclosed in single quotes
>and will be sent to DB as is.
>
>Does anybody have handy perl one-liner or script that tackles this?
>Thanks!


I don't think this can be a one liner, maybe.
In esscence this does it all:

sln

#############
# Delim Regex
#############

use strict;
use warnings;

my $str = "
it's mine, it's yours, 12, 42, 2008/10/06, 'it's mine', 'it's yours', 12, 42, '2008/10/06',
it's wants it's gets ";


while ($str =~ /([^,\n]+)/g)
{
	my $val = $1;
	$val =~ s/^[\s'"]+//; $val =~ s/[\s'"]+$//;
	$val =~ s/'/''/g;
	$val = "'$val'";
	print "val = $val\n";
}


__END__

output:

val_a = 'it''s mine'
val_a = 'it''s yours'
val_a = '12'
val_a = '42'
val_a = '2008/10/06'
val_a = 'it''s mine'
val_a = 'it''s yours'
val_a = '12'
val_a = '42'
val_a = '2008/10/06'
val_a = 'it''s wants it''s gets'





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

Date: Mon, 06 Oct 2008 18:39:59 GMT
From: sln@netherlands.com
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <nnmke49oo9c9toifjk4vg7vagrgf3a3fsf@4ax.com>

On Mon, 06 Oct 2008 18:25:07 GMT, sln@netherlands.com wrote:

>On Mon, 6 Oct 2008 08:16:38 -0700 (PDT), "Henry J." <tank209209@yahoo.com> wrote:
>
>>Need to escape single quotes ( i.e., ' -> '' ) in a data file before
>>sending to DB as part of insert SQLs.
>>
>>       Example 1):
>>
>>           it's mine, it's yours, 12, 42, 2008/10/06   => it''s mine,
>>it''s yours, 12, 42, 2008/10/06
>>
>>       Example 2):
>>
>>           'it's mine', 'it's yours', 12, 42, '2008/10/06'  => 'it''s
>>mine', 'it''s yours', 12, 42, '2008/10/06'
>>
>>The tricky part is that the data file may or may not have the string
>>fields wrapped in single quotes.  In Example 1), it is not and single
>>quotes around fields will be added by another script before sending to
>>DB, in Example 2), its fields are already enclosed in single quotes
>>and will be sent to DB as is.
>>
>>Does anybody have handy perl one-liner or script that tackles this?
>>Thanks!
>
>
>I don't think this can be a one liner, maybe.
>In esscence this does it all:
>
>sln
>
>#############
># Delim Regex
>#############
>
>use strict;
>use warnings;
>
>my $str = "
>it's mine, it's yours, 12, 42, 2008/10/06, 'it's mine', 'it's yours', 12, 42, '2008/10/06',
>it's wants it's gets ";
>
>
>while ($str =~ /([^,\n]+)/g)
>{
>	my $val = $1;
>	$val =~ s/^[\s'"]+//; $val =~ s/[\s'"]+$//;

# just for grins, reconstitute partial fixes.
# there goes that one-liner possibility

	$val =~ s/'+/'/g;
#

>	$val =~ s/'/''/g;
>	$val = "'$val'";
>	print "val = $val\n";
>}
>
>
>__END__
>
>output:
>
>val_a = 'it''s mine'
>val_a = 'it''s yours'
>val_a = '12'
>val_a = '42'
>val_a = '2008/10/06'
>val_a = 'it''s mine'
>val_a = 'it''s yours'
>val_a = '12'
>val_a = '42'
>val_a = '2008/10/06'
>val_a = 'it''s wants it''s gets'
>
>



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

Date: Mon, 06 Oct 2008 14:53:02 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <86myhheesx.fsf@mithril.chromatico.net>

>>>>> "HJ" == Henry J <tank209209@yahoo.com> writes:

    HJ> Need to escape single quotes ( i.e., ' -> '' ) in a data file
    HJ> before sending to DB as part of insert SQLs.

Use placeholders in your SQL statement, and let the database driver
handle escaping as necessary.   perldoc DBI

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Mon, 06 Oct 2008 19:48:13 GMT
From: sln@netherlands.com
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <ehqke49kujop8365eh12a57llalmvbqgtf@4ax.com>

On Mon, 6 Oct 2008 11:55:02 -0700 (PDT), "Henry J." <tank209209@yahoo.com> wrote:

>On Oct 6, 2:25 pm, s...@netherlands.com wrote:
>> On Mon, 6 Oct 2008 08:16:38 -0700 (PDT), "Henry J." <tank209...@yahoo.com> wrote:
>> >Need to escape single quotes ( i.e., ' -> '' ) in a data file before
>> >sending to DB as part of insert SQLs.
>>
>> >       Example 1):
>>
>> >           it's mine, it's yours, 12, 42, 2008/10/06   => it''s mine,
>> >it''s yours, 12, 42, 2008/10/06
>>
>> >       Example 2):
>>
>> >           'it's mine', 'it's yours', 12, 42, '2008/10/06'  => 'it''s
>> >mine', 'it''s yours', 12, 42, '2008/10/06'
>>
>> >The tricky part is that the data file may or may not have the string
>> >fields wrapped in single quotes.  In Example 1), it is not and single
>> >quotes around fields will be added by another script before sending to
>> >DB, in Example 2), its fields are already enclosed in single quotes
>> >and will be sent to DB as is.
>>
>> >Does anybody have handy perl one-liner or script that tackles this?
>> >Thanks!
>>
>> I don't think this can be a one liner, maybe.
>> In esscence this does it all:
>>
>> sln
>>
>> #############
>> # Delim Regex
>> #############
>>
>> use strict;
>> use warnings;
>>
>> my $str = "
>> it's mine, it's yours, 12, 42, 2008/10/06, 'it's mine', 'it's yours', 12, 42, '2008/10/06',
>> it's wants it's gets ";
>>
>> while ($str =~ /([^,\n]+)/g)
>> {
>>         my $val = $1;
>>         $val =~ s/^[\s'"]+//; $val =~ s/[\s'"]+$//;
>>         $val =~ s/'/''/g;
>>         $val = "'$val'";
>>         print "val = $val\n";
>>
>> }
>>
>> __END__
>>
>> output:
>>
>> val_a = 'it''s mine'
>> val_a = 'it''s yours'
>> val_a = '12'
>> val_a = '42'
>> val_a = '2008/10/06'
>> val_a = 'it''s mine'
>> val_a = 'it''s yours'
>> val_a = '12'
>> val_a = '42'
>> val_a = '2008/10/06'
>> val_a = 'it''s wants it''s gets'- Hide quoted text -
>>
>> - Show quoted text -
>
>Thanks a lot!  I'm able to adapt it a bit to solve my problem (e.g., I
>cannot add or remove enclosing single quotes).

Without at least removeing enclosing quotes, the inner quote would be hard to
substitute. Not impossible, but harder. Its easy to test if there is enclosing
quote (then add it back later), but it still has to be removed before doing the
inner quote substitution.

Either way it can be done. How did you do it?

Thanks!

sln



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

Date: Mon, 06 Oct 2008 20:06:32 GMT
From: sln@netherlands.com
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <1mrke4hae9ib1ggdc3hu4dqkb7co7r149e@4ax.com>

On Mon, 6 Oct 2008 12:58:14 -0700 (PDT), "Henry J." <tank209209@yahoo.com> wrote:

>On Oct 6, 3:48 pm, s...@netherlands.com wrote:
>> On Mon, 6 Oct 2008 11:55:02 -0700 (PDT), "Henry J." <tank209...@yahoo.com> wrote:
>> >On Oct 6, 2:25 pm, s...@netherlands.com wrote:
>> >> On Mon, 6 Oct 2008 08:16:38 -0700 (PDT), "Henry J." <tank209...@yahoo.com> wrote:
>
>I replace it with a string and then replace it back.
>
>BTW, i cannot use the placeholders to handle strings because this is a
>generic function in a perl lib that works like bcp in sybase (i.e.,
>loading a given data file into any given table in DB).

Ok, workarounds are acceptable.. good luck.
Btw, I used to do alot of ADO back in the day. In need of a job if you know of any.

sln



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

Date: Mon, 6 Oct 2008 11:55:02 -0700 (PDT)
From: "Henry J." <tank209209@yahoo.com>
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <468625a3-4f20-464d-b92c-94797ff9e909@x41g2000hsb.googlegroups.com>

On Oct 6, 2:25=A0pm, s...@netherlands.com wrote:
> On Mon, 6 Oct 2008 08:16:38 -0700 (PDT), "Henry J." <tank209...@yahoo.com=
> wrote:
> >Need to escape single quotes ( i.e., ' -> '' ) in a data file before
> >sending to DB as part of insert SQLs.
>
> > =A0 =A0 =A0 Example 1):
>
> > =A0 =A0 =A0 =A0 =A0 it's mine, it's yours, 12, 42, 2008/10/06 =A0 =3D> =
it''s mine,
> >it''s yours, 12, 42, 2008/10/06
>
> > =A0 =A0 =A0 Example 2):
>
> > =A0 =A0 =A0 =A0 =A0 'it's mine', 'it's yours', 12, 42, '2008/10/06' =A0=
=3D> 'it''s
> >mine', 'it''s yours', 12, 42, '2008/10/06'
>
> >The tricky part is that the data file may or may not have the string
> >fields wrapped in single quotes. =A0In Example 1), it is not and single
> >quotes around fields will be added by another script before sending to
> >DB, in Example 2), its fields are already enclosed in single quotes
> >and will be sent to DB as is.
>
> >Does anybody have handy perl one-liner or script that tackles this?
> >Thanks!
>
> I don't think this can be a one liner, maybe.
> In esscence this does it all:
>
> sln
>
> #############
> # Delim Regex
> #############
>
> use strict;
> use warnings;
>
> my $str =3D "
> it's mine, it's yours, 12, 42, 2008/10/06, 'it's mine', 'it's yours', 12,=
 42, '2008/10/06',
> it's wants it's gets ";
>
> while ($str =3D~ /([^,\n]+)/g)
> {
> =A0 =A0 =A0 =A0 my $val =3D $1;
> =A0 =A0 =A0 =A0 $val =3D~ s/^[\s'"]+//; $val =3D~ s/[\s'"]+$//;
> =A0 =A0 =A0 =A0 $val =3D~ s/'/''/g;
> =A0 =A0 =A0 =A0 $val =3D "'$val'";
> =A0 =A0 =A0 =A0 print "val =3D $val\n";
>
> }
>
> __END__
>
> output:
>
> val_a =3D 'it''s mine'
> val_a =3D 'it''s yours'
> val_a =3D '12'
> val_a =3D '42'
> val_a =3D '2008/10/06'
> val_a =3D 'it''s mine'
> val_a =3D 'it''s yours'
> val_a =3D '12'
> val_a =3D '42'
> val_a =3D '2008/10/06'
> val_a =3D 'it''s wants it''s gets'- Hide quoted text -
>
> - Show quoted text -

Thanks a lot!  I'm able to adapt it a bit to solve my problem (e.g., I
cannot add or remove enclosing single quotes).


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

Date: Mon, 6 Oct 2008 12:58:14 -0700 (PDT)
From: "Henry J." <tank209209@yahoo.com>
Subject: Re: How to escape single quotes inside fields but not the ones around  fields?
Message-Id: <c3bc602c-2c07-4b4d-9f64-107285c2ff69@k13g2000hse.googlegroups.com>

On Oct 6, 3:48=A0pm, s...@netherlands.com wrote:
> On Mon, 6 Oct 2008 11:55:02 -0700 (PDT), "Henry J." <tank209...@yahoo.com=
> wrote:
> >On Oct 6, 2:25=A0pm, s...@netherlands.com wrote:
> >> On Mon, 6 Oct 2008 08:16:38 -0700 (PDT), "Henry J." <tank209...@yahoo.=
com> wrote:
> >> >Need to escape single quotes ( i.e., ' -> '' ) in a data file before
> >> >sending to DB as part of insert SQLs.
>
> >> > =A0 =A0 =A0 Example 1):
>
> >> > =A0 =A0 =A0 =A0 =A0 it's mine, it's yours, 12, 42, 2008/10/06 =A0 =
=3D> it''s mine,
> >> >it''s yours, 12, 42, 2008/10/06
>
> >> > =A0 =A0 =A0 Example 2):
>
> >> > =A0 =A0 =A0 =A0 =A0 'it's mine', 'it's yours', 12, 42, '2008/10/06' =
=A0=3D> 'it''s
> >> >mine', 'it''s yours', 12, 42, '2008/10/06'
>
> >> >The tricky part is that the data file may or may not have the string
> >> >fields wrapped in single quotes. =A0In Example 1), it is not and sing=
le
> >> >quotes around fields will be added by another script before sending t=
o
> >> >DB, in Example 2), its fields are already enclosed in single quotes
> >> >and will be sent to DB as is.
>
> >> >Does anybody have handy perl one-liner or script that tackles this?
> >> >Thanks!
>
> >> I don't think this can be a one liner, maybe.
> >> In esscence this does it all:
>
> >> sln
>
> >> #############
> >> # Delim Regex
> >> #############
>
> >> use strict;
> >> use warnings;
>
> >> my $str =3D "
> >> it's mine, it's yours, 12, 42, 2008/10/06, 'it's mine', 'it's yours', =
12, 42, '2008/10/06',
> >> it's wants it's gets ";
>
> >> while ($str =3D~ /([^,\n]+)/g)
> >> {
> >> =A0 =A0 =A0 =A0 my $val =3D $1;
> >> =A0 =A0 =A0 =A0 $val =3D~ s/^[\s'"]+//; $val =3D~ s/[\s'"]+$//;
> >> =A0 =A0 =A0 =A0 $val =3D~ s/'/''/g;
> >> =A0 =A0 =A0 =A0 $val =3D "'$val'";
> >> =A0 =A0 =A0 =A0 print "val =3D $val\n";
>
> >> }
>
> >> __END__
>
> >> output:
>
> >> val_a =3D 'it''s mine'
> >> val_a =3D 'it''s yours'
> >> val_a =3D '12'
> >> val_a =3D '42'
> >> val_a =3D '2008/10/06'
> >> val_a =3D 'it''s mine'
> >> val_a =3D 'it''s yours'
> >> val_a =3D '12'
> >> val_a =3D '42'
> >> val_a =3D '2008/10/06'
> >> val_a =3D 'it''s wants it''s gets'- Hide quoted text -
>
> >> - Show quoted text -
>
> >Thanks a lot! =A0I'm able to adapt it a bit to solve my problem (e.g., I
> >cannot add or remove enclosing single quotes).
>
> Without at least removeing enclosing quotes, the inner quote would be har=
d to
> substitute. Not impossible, but harder. Its easy to test if there is encl=
osing
> quote (then add it back later), but it still has to be removed before doi=
ng the
> inner quote substitution.
>
> Either way it can be done. How did you do it?
>
> Thanks!
>
> sln- Hide quoted text -
>
> - Show quoted text -

I replace it with a string and then replace it back.

BTW, i cannot use the placeholders to handle strings because this is a
generic function in a perl lib that works like bcp in sybase (i.e.,
loading a given data file into any given table in DB).


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

Date: Mon, 6 Oct 2008 21:23:35 +0200
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: How to escape single quotes inside fields but not the ones around fields?
Message-Id: <gcdvl0.18k.1@news.isolution.nl>

Henry J. schreef:

> Need to escape single quotes ( i.e., ' -> '' ) in a data file before
> sending to DB as part of insert SQLs.

No, you don't. 

-- 
Affijn, Ruud

"Gewoon is een tijger."


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

Date: Tue, 07 Oct 2008 01:04:53 +0530
From: V S Rawat <vsrawat@gmail.com>
Subject: How to sort and how to show cgi output into an iframe?
Message-Id: <gcdp8v$okh$1@aioe.org>

I have put a website search form on my home page. it has just a textarea 
in which the term(s) to be searched are entered and then submit button 
calls the perlscript that is finding that term in all files in the 
website and showing the links of those files in which the term is 
present. It is working correctly.

Two issues:

1. Perl is either checking files in the order of their filenames or in 
the order in which it finds them in the folder, so the results are not 
coming sorted. One menu branch items are coming scattered within other 
menu branches items.

How can I sort it out so that at least one menu branch comes together?

2. The submit button is on the main home page.

all other links on the homepage are showing their results into an iframe 
in the middle, using target="iframe"

but perl generated page comes standalone.

How can I show the results of this submit into the iframe?

thanks.
-- 
V


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

Date: Tue, 07 Oct 2008 01:14:24 +0530
From: V S Rawat <vsrawat@gmail.com>
Subject: Re: How to sort and how to show cgi output into an iframe?
Message-Id: <gcdpqn$rhf$1@aioe.org>

On 10/7/2008 1:04 AM India Time, _V S Rawat_ wrote:

> I have put a website search form on my home page. it has just a textarea 
> in which the term(s) to be searched are entered and then submit button 
> calls the perlscript that is finding that term in all files in the 
> website and showing the links of those files in which the term is 
> present. It is working correctly.
> 
> Two issues:
> 
> 1. Perl is either checking files in the order of their filenames or in 
> the order in which it finds them in the folder, so the results are not 
> coming sorted. One menu branch items are coming scattered within other 
> menu branches items.
> 
> How can I sort it out so that at least one menu branch comes together?
> 
> 2. The submit button is on the main home page.
> 
> all other links on the homepage are showing their results into an iframe 
> in the middle, using target="iframe"
> 
> but perl generated page comes standalone.
> 
> How can I show the results of this submit into the iframe?
> 
> thanks.


my gawd. So simple. And I spent so long thinking out what to do.

form target="iframe" shows the result of perl into iframe.

The company of this ng made me wise. :-) thanks.
--

That sorting part is still holding me.

-- 
V


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

Date: Mon, 6 Oct 2008 12:29:34 -0700 (PDT)
From: Nigel <nigel@bouteyres.com>
Subject: Re: Problems flushing my buffer! (perl)
Message-Id: <bf7e8596-f7b5-4c0a-842f-5448656efcb0@p49g2000hsd.googlegroups.com>

On Oct 5, 2:40=A0pm, Martijn Lievaart <m...@rtij.nl.invlalid> wrote:
> 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 th=
e
> >bufferwould 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 an=
d
> > 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

On Oct 5, 2:40 pm, Martijn Lievaart <m...@rtij.nl.invlalid> wrote:
> 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 th=
e
> >bufferwould 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 an=
d
> > 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

Thank you all for your input. In the end I decided to adapt the
solution suggested by Jim Gibson:

>You need the "client-pull" refresh feature of HTTP that causes your
>browser to periodically request a page (or CGI):

<http://www.stonehenge.com/merlyn/LinuxMag/col39.html>

My needs are rather specific as I'm developing a web front-ended
database for a company not a website for use by the public. Anyway my
approach may interest some others: I have a program that collects the
parameters with which the User wishes to run the batch process in
question. Once their input is validated I open a new window with the
URL of my batch program + the parameters. The batch program in turns
runs some intitialisation processing before sending a page back to the
browser. In that page I have an automatic redirect back to my batch
program with slightly amend parameters so that it now starts to
process the required records. After a predetermined number of records
or a period of time (as yet undecided about that) it again sends a
page to the browser - again with an automatic redirect. This cycle
continues until the processing is complete at which point the Batch
Program sends a last page to the browser (without the automatic
redirect!) to tell the user the result of the process. I use some
parameters to store information between iterations of the batch
process to avoid it having to repeat too much processing each time it
is invoked. I also store some information in cookies so the function
that 'submits' the batch process can keep track of its progress. If
the batch process fails or the window is closed, the cookies expire
and the next time the user runs the submission function it tidies up
any submitted process(es) that no longer have a cookie i.e. have
failed in one way or another.

So in conclusion - I am using the Client-Pull method, but I'm not
keeping the batch process active all the time with the use of a fork
as described in the article above. Why? Purely pragmatic reasons - I'm
a completely self taught perl programer and the article gets into
aspects of perl and server side prcessing that are well outside my
level of understanding. The processing time is not critical and I
don't think it will be huge anyway. In any case the architecture of
the program is pretty similar to that outlined in the article so if it
becomes necessary I could change it in the future.

One particular point about the article that I couldn't get my head
around is how, when the batch program is re-invoked by the client-
pull, one avoids that simply starting up another instance of the
program instead of interupting the existing instance to get an update
on its progress. Can anyone enlighten me?

Thanks again for the input!

Nigel


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

Date: Mon, 6 Oct 2008 11:13:09 -0700 (PDT)
From: cartercc <cartercc@gmail.com>
Subject: Re: trouble parsing "kind of" comma-delimited text
Message-Id: <b67b916b-f82d-452c-8b7f-4ccece6cc1fc@t41g2000hsc.googlegroups.com>

On Oct 6, 9:41=A0am, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> Which only replaces Scylla with Charybdis, because now your target file
> will have double quotes around every value that contains a pipe symbol.

Except that my data files do not contain pipe symbols, and I can rely
on the fact that pipe symbols will not be in the file.

> Why not just use a standard CSV-parser to read the data? Simple,
> straight forward, no fuss, no problems, no pre-processing, and most
> important correct.

TIMTOWTDI. I have to do a lot of preprocessing, and it's easier for me
to incorporate as much of the proprocessing into one function as I
can. I agree that we are usually better off using a module that has
been time tested, but there are times when the reverse is true.

CC


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

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 1903
***************************************


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