[30659] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1904 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 7 00:09:49 2008

Date: Mon, 6 Oct 2008 21:09:11 -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: 1904

Today's topics:
    Re: "AUTOLOAD" for variables? <u8526505@gmail.com>
    Re: <Help> How to use routines from another perl script (fidokomik\)
    Re: <Help> How to use routines from another perl script <tim@burlyhost.com>
    Re: Data File <jurgenex@hotmail.com>
        freezoosex - Free porn wbdismalgoldstein@gmail.com
    Re: How it works?(about while loop and regex as conditi <havel.zhang@gmail.com>
    Re: How to escape single quotes inside fields but not t <tank209209@yahoo.com>
    Re: How to sort and how to show cgi output into an ifra <vsrawat@gmail.com>
    Re: How to sort and how to show cgi output into an ifra <smallpond@juno.com>
    Re: How to sort and how to show cgi output into an ifra <vsrawat@gmail.com>
    Re: How to sort and how to show cgi output into an ifra sln@netherlands.com
    Re: How to sort and how to show cgi output into an ifra <jurgenex@hotmail.com>
    Re: Problems flushing my buffer! (perl) <nospam-abuse@ilyaz.org>
    Re: Problems flushing my buffer! (perl) <jimsgibson@gmail.com>
    Re: sysread <tadmc@seesig.invalid>
    Re: sysread <dontmewithme@got.it>
    Re: sysread <ben@morrow.me.uk>
    Re: sysread sln@netherlands.com
    Re: sysread xhoster@gmail.com
    Re: trouble parsing "kind of" comma-delimited text <nun@yahoo.com>
        update XML file with perl or other...? <inetquestion@hotmail.com>
    Re: update XML file with perl or other...? <inetquestion@hotmail.com>
    Re: update XML file with perl or other...? xhoster@gmail.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 6 Oct 2008 18:15:53 -0700 (PDT)
From: cyl <u8526505@gmail.com>
Subject: Re: "AUTOLOAD" for variables?
Message-Id: <4b764100-2736-4f1b-97fb-cd088a29666f@p10g2000prf.googlegroups.com>

On 10$B7n(B2$BF|(B, $B>e8a(B11$B;~(B36$BJ,(B, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth cyl <u8526...@gmail.com>:> On 10$B7n(B1$BF|(B, $B2<8a(B7$B;~(B05$BJ,(B, Ben Morrow
> > <b...@morrow.me.uk> wrote:
>
> In any case, you can do something like
>
>     package TestB;
>
>     use TestA;
>
>     for (keys %TestA::) {
>         no strict 'refs';
>         *$_ = \*{"TestA::$_"};
>     }
>
> to alias everything from TestA to TestB.
>

This way is so cool. It does work. Thanks very much. May I ask an
additional question? When there is a package in TestA, say
TestA::SubPackageA, I can see a key "SubPackageA::" in %TestA but I
can not use "new TestB::SubPackageA;" to do the same alias mapping. Is
there a way to work this out? Thanks.


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

Date: Tue, 7 Oct 2008 01:37:40 +0200
From: "Petr Vileta \(fidokomik\)" <stoupa@practisoft.cz>
Subject: Re: <Help> How to use routines from another perl script
Message-Id: <gce7h0$s5s$1@aioe.org>

baiyanhuang@gmail.com wrote:
> Hi, All,
> 
> I am just a novice to perl, I want to reuse a routine wrote in one
> perl script to all other perl scripts, just like c, c++ do, but I
> don't know how to "include" another perl script into current perl
> script to utilize the routines. would anyone give some tips on it?
> 
> Thanks so much.
> 
> Baiyan

A simplest way is to write routines into separate files

--- example (/var/myroutines/ex1.pl) ---
1;
sub myfunc1 {
my ($param1,$param2) = @_;
my $to_return='';
# some code here
return $to_return;
}
--- example ---

and "include" it in main program like this:

#!/usr/bin/perl
use strict;
require "/var/myroutines/ex1.pl;
my $val = myfunc1(1, 'abc');

-- 
Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail.
Send me your mail from another non-spammer site please.)
Please reply to <petr AT practisoft DOT cz>



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

Date: Mon, 06 Oct 2008 20:12:14 -0700
From: Tim Greer <tim@burlyhost.com>
Subject: Re: <Help> How to use routines from another perl script
Message-Id: <jsAGk.856$1Z4.52@newsfe01.iad>

Petr Vileta (fidokomik) wrote:

> baiyanhuang@gmail.com wrote:
>> Hi, All,
>> 
>> I am just a novice to perl, I want to reuse a routine wrote in one
>> perl script to all other perl scripts, just like c, c++ do, but I
>> don't know how to "include" another perl script into current perl
>> script to utilize the routines. would anyone give some tips on it?
>> 
>> Thanks so much.
>> 
>> Baiyan
> 
> A simplest way is to write routines into separate files
> 
> --- example (/var/myroutines/ex1.pl) ---
> 1;

^ Down there, maybe --> ?

> sub myfunc1 {
> my ($param1,$param2) = @_;
> my $to_return='';
> # some code here
> return $to_return;
> }

1;

> --- example ---
> 
> and "include" it in main program like this:
> 
> #!/usr/bin/perl

use warnings;

> use strict;
> require "/var/myroutines/ex1.pl;

|| die, or die, or use eval.


-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!


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

Date: Mon, 06 Oct 2008 15:01:12 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Data File
Message-Id: <p52le41qijf022n7qfnu0vko244qhjt6kl@4ax.com>

"friend.05@gmail.com" <hirenshah.05@gmail.com> wrote:
>On Oct 6, 12:52 pm, Jürgen 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 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);

Always check if the open was successful. Also, the 3 argument form of
open is preferable as are lexical filehandles:
	open ($info, '<', $file) 
		or die ("Couldn't open $file because $!\n");

>@lines = <INFO>;

There is no need to slurp in the whole file if afterwards you are
processing the file line by line anyway.
On the other hand, if the file _is_ small enough to be slurped in, then
you can just sort() the array in memory for your clustering and thus
save quite some work.

	while (<$info>) {

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

The vertical bar is special in REs, you need to escape it:
	($id, $time, $ip, $code) = split /\|/;

>print $line[3];
	print $code;

jue


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

Date: Mon, 6 Oct 2008 19:27:26 -0700 (PDT)
From: wbdismalgoldstein@gmail.com
Subject: freezoosex - Free porn
Message-Id: <fcbb8f99-0a96-4714-a3b0-c355ed884e0c@v72g2000hsv.googlegroups.com>

freezoosex
 .
 .
 .
*******CLICK HERE********
http://vids365.cn/freezoosex
*****************************
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
freezoosex


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

Date: Mon, 6 Oct 2008 19:19:46 -0700 (PDT)
From: "havel.zhang" <havel.zhang@gmail.com>
Subject: Re: How it works?(about while loop and regex as condition)
Message-Id: <6a7f937e-af5a-4fde-bb10-dad14f4bef53@f77g2000hsf.googlegroups.com>

On Oct 6, 9:34=A0pm, J=FCrgen Exner <jurge...@hotmail.com> wrote:
> "havel.zhang" <havel.zh...@gmail.com> wrote:
>
> [...]
>
> >This program works well, but i can't understand the =A0while loop with
> >regex:
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"$html =3D~ m{a\b([^>]+)(.*?)</a>}ig"
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^^^^^^^^^^^^^^^^^^^^^^^
> >it's works fine, and so amazing:) everytime, it's pick out patten "<a
> >href=3D...></a>" =A0and get right result. But HOW does it work? I think =
it
> >will always pick out the first matched patten.
>
> >Can any perl guru give me answer?
>
> The documentation can. See 'perldoc perlop', section 'Quote and
> quote-like operators', the two paragraphs beginning with
> "The "/g" modifier specifies global pattern matching--that is, ..."
>
> However, it is not surprising that you didn't find it. 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?
>
> jue

Thank you jue:
    After I post my question on news group, I found answer in a perl
book. That book point out the function which a regex with /g modifier
as condition in while loop, as you point out above. It's so easy and
amazing:)
    Thank you again:)

Havel


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

Date: Mon, 6 Oct 2008 20:37:35 -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: <16d74ab4-931d-4281-bab2-f3195c89148e@p49g2000hsd.googlegroups.com>

On Oct 6, 4:06=A0pm, s...@netherlands.com wrote:
> On Mon, 6 Oct 2008 12:58:14 -0700 (PDT), "Henry J." <tank209...@yahoo.com=
> wrote:
> >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...@yah=
oo.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 kn=
ow of any.
>
> sln

Sorry I'm in NYC and you know how rough it is around here.  Good luck.


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

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

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

> 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.
> 

Further, how to find whether my server supports SSI or not?

to avoid generating entire html through perl, I have created an html 
file of the header part that remains common across the perl script results.

I want to include it in my result and then add whatever perl generates 
along with footer.

How to give that command in my perlscript?

I have added in my perlscript
print "<!--#include file=\"index_search_include.txt\"-->\n";
where index_search_include.txt is the header file that I have made.

but server is giving 500 internal server error and error logs are showing

malformed header from script. Bad header=<!--#include file="index_searc: 
/home/username/public_html/cgi-bin/search.cgi

where to put that index_search_include.txt file? in cgi-bin or in 
public_html or where, and what name to include? just the file name or 
even the path /home/username/public_html/index_search_include.txt

there was also some issue that .html is to be renamed to .shtml for ssi 
to work. I couldn't understand which .html file to rename.

if server doesn't support html, I would need to generate entire thing 
line by line through perl or to read from that file and write thru perl.

Thanks.
-- 
V


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

Date: Mon, 6 Oct 2008 13:55:49 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: How to sort and how to show cgi output into an iframe?
Message-Id: <56fb9d15-cc52-4997-a889-f7339c79797d@m73g2000hsh.googlegroups.com>

On Oct 6, 3:44 pm, V S Rawat <vsra...@gmail.com> wrote:
> 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

You are getting the files in the order in which they appear in
the directory.  To sort them:

1. read all the filenames into an array @filenames
2. to send the output to your page, loop thru the array using foreach
foreach (sort {$a cmp $b} @filenames)
3. to modify the order of the output, change {$a cmp $b} to a
different function.

To put all of the subdirectories first, for example, you will want to
test using '-d' and change the result of the comparison accordingly.

--S


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

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

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

> On 10/7/2008 1:14 AM India Time, _V S Rawat_ wrote:
> 
>> 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.
>>
> 
> Further, how to find whether my server supports SSI or not?

ok, when I upload the following in a file to my server, and open in 
browser, I do see Monday. that means SSI is working for me. but not in 
html file. it worked in shtml file.

<HTML>
<TITLE>Test File</TITLE>

<!--#config timefmt="%A" --> <!--#echo var="DATE_LOCAL" -->

</HTML>

--

good enough. Now, the remaining parts are to be attended.

> 
> to avoid generating entire html through perl, I have created an html 
> file of the header part that remains common across the perl script results.
> 
> I want to include it in my result and then add whatever perl generates 
> along with footer.
> 
> How to give that command in my perlscript?
> 
> I have added in my perlscript
> print "<!--#include file=\"index_search_include.txt\"-->\n";
> where index_search_include.txt is the header file that I have made.
> 
> but server is giving 500 internal server error and error logs are showing
> 
> malformed header from script. Bad header=<!--#include file="index_searc: 
> /home/username/public_html/cgi-bin/search.cgi
> 
> where to put that index_search_include.txt file? in cgi-bin or in 
> public_html or where, and what name to include? just the file name or 
> even the path /home/username/public_html/index_search_include.txt
> 
> there was also some issue that .html is to be renamed to .shtml for ssi 
> to work. I couldn't understand which .html file to rename.
> 
> if server doesn't support html, I would need to generate entire thing 
> line by line through perl or to read from that file and write thru perl.
> 
> Thanks.



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

Date: Mon, 06 Oct 2008 22:02:38 GMT
From: sln@netherlands.com
Subject: Re: How to sort and how to show cgi output into an iframe?
Message-Id: <oluke4dnvo650dkur4jgeelr7hjt67rq6v@4ax.com>

On Tue, 07 Oct 2008 01:58:15 +0530, V S Rawat <vsrawat@gmail.com> wrote:

>On 10/7/2008 1:14 AM India Time, _V S Rawat_ wrote:
>
>> 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.
>> 
>
>Further, how to find whether my server supports SSI or not?
>
>to avoid generating entire html through perl, I have created an html 
>file of the header part that remains common across the perl script results.
>
>I want to include it in my result and then add whatever perl generates 
>along with footer.
>
>How to give that command in my perlscript?
>
>I have added in my perlscript
>print "<!--#include file=\"index_search_include.txt\"-->\n";
>where index_search_include.txt is the header file that I have made.
>
>but server is giving 500 internal server error and error logs are showing
>
>malformed header from script. Bad header=<!--#include file="index_searc: 
>/home/username/public_html/cgi-bin/search.cgi
>
>where to put that index_search_include.txt file? in cgi-bin or in 
>public_html or where, and what name to include? just the file name or 
>even the path /home/username/public_html/index_search_include.txt
>

If you generate, or get some portion of your html with perl, then pass
it on, you can do any sort of amalgomation you wan't.

It seams as though you are forcing the html through a processor that
won't take incomplete html.

You many need a perl script that joins html fragments into a whole
before sending it to the renderer.

You can do it one of two ways, insert the placeholder in the constant html
or insert it into the dynamic part, substitute, then send it to the renderer.

This avoids generating html because you are using constant html as the substitute,
and just printing out the joined parts. Since this is by design, there should be no
errors as long as the reconstituted whole does not have errors (which can be checked
before the renderer gets it).

This can be done by hand like mail merge substitution or you can use a reliable
capture parser (or do it all in ASP?):

=========================
use strict;
use warnings;

use RXParse; # VERSIN 2

my $p = new RXParse();
$p->setMode( 'html' => 1, 'resume_onerror'=> 1 );
$p->setHandlers('start' => \&starth, 'end' => \&endh);

sub starth
{
	my ($obj, $el, $term, @attr) = @_;
	my $buffer = lc($el);
	if ($buffer eq 'substitutebody' || $buffer eq 'substitutefooter')
	{
		$obj->CaptureOn( $buffer );
	}
}
sub endh
{
	my ($obj, $el, $term) = @_;
	my $buffer = lc($el);
	if ($buffer eq 'substitutebody' || $buffer eq 'substitutefooter')
	{
		$obj->CaptureOff( $buffer, 1 );
	}
}

open my $fh, 'c:\temp\header_footr.html' or die "can't open header_footr.html...";

$p->CaptureOn('ALL');
$p->parse($fh);
$p->CaptureOff('ALL');

close $fh;

$p->DumpCaptureBuffs();

# generate dynamic html
# ...

# substitute the capture sequence body for the dynamic html generated.
# the sequence is just the index into the main capture array.
# this is all 'raw' html. functions are provided for this though.
# ....

# write/send out the entire sequence now as complete html
# ...



__END__



BUFFER: all
=====================================
index	seqence
-----	--------
[0]	1	<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html lang="en"><head><title>CNN.com - Breaking News, U.S., World, Weather,
Entertainment & Video News</title>      
<meta http-equiv="refresh" content="1800;url=?refresh=1">
<meta name="Description" content="CNN.com delivers the latest breaking news and information on the latest top stories, weather, business, entertainment, politics, and more. For in-depth coverage,
CNN.com provides special reports, video, audio, photo galleries, and interactive guides.">
<meta name="Keywords" content="CNN, CNN news, CNN.com, CNN TV, news, news online, breaking news, U.S. news, world news, weather, business, CNN Money, sports, politics, law, technology, entertainment,
education, travel, health, special reports, autos, developing story, news video, CNN Intl">
</head>
[1]	-2	
[2]	3	undefined
[3]	-4	
[4]	5	</html>


BUFFER: substitutebody
=====================================
index	seqence
-----	--------
[0]	2	<substitutebody DROP YOUR BODY IN THIS SEQUENCE></substitutebody>


BUFFER: substitutefooter
=====================================
index	seqence
-----	--------
[0]	4	<substitutefooter DROP YOUR FOOTER IN THIS SEQUENCE></substitutefooter>



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

Date: Mon, 06 Oct 2008 15:06:12 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to sort and how to show cgi output into an iframe?
Message-Id: <qo2le4delrgrfl0ofvjoekbofbcrhhh4re@4ax.com>

V S Rawat <vsrawat@gmail.com> wrote:

>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.

Perl simply uses whatever the operating system returns. If the OS
returns them in random sequence, then Perl will just use that sequence. 

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

If you want file names to be sorted by some criteria, then you need to
sort them yourself. See "perldoc -f sort".

jue


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

Date: Mon, 6 Oct 2008 20:49:48 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Problems flushing my buffer! (perl)
Message-Id: <gcdtlc$1ttm$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 <slrngekj4b.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...
> 
> Not the version I have here (2.8.7dev9) which appears to be almost the
> newest developer version (there's a 2.8.7dev10 on lynx.isc.org). So I
> wouldn't expect the stable release (2.8.6) to be incremental, either.

Mine is lynx2-8-5-pre4.  Maybe you are not aware that lynx will behave
as you ask it?  My config file is about 3K large...  E.g., I have

    # Set the threshold # of lines Lynx must render before it
    # redraws the screen in PARTIAL mode.  Anything < 0 implies
    # use of the screen size.
    PARTIAL_THRES:6

Hope this helps,
Ilya


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

Date: Mon, 06 Oct 2008 17:04:05 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Problems flushing my buffer! (perl)
Message-Id: <061020081704057639%jimsgibson@gmail.com>

In article
<bf7e8596-f7b5-4c0a-842f-5448656efcb0@p49g2000hsd.googlegroups.com>,
Nigel <nigel@bouteyres.com> wrote:

> 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 the
> > >bufferwould be
> > > flushed each time I printed instead of waiting until the program
> > > terminates. But I can't
> > > get it to work.

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


> 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?

The program uses the session id to indicate that a request is a
follow-up for a previous new request. The first request does not have a
session id, so param('session') in line 9 of the sample program returns
false (undef). Each subsequent refresh request contains the 'session'
parameter, and the value of that parameter is used to fetch the results
so far, as in line 11.

Good luck!

-- 
Jim Gibson


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

Date: Mon, 6 Oct 2008 09:44:48 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: sysread
Message-Id: <slrngek930.67p.tadmc@tadmc30.sbcglobal.net>

Larry <dontmewithme@got.it> wrote:

> what is buffered IO ??


   Suffering from Buffering?

      http://perl.plover.com/FAQs/Buffering.html


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Mon, 06 Oct 2008 23:09:31 +0200
From: Larry <dontmewithme@got.it>
Subject: Re: sysread
Message-Id: <dontmewithme-2D279E.23093106102008@news.tin.it>

In article <slrngek930.67p.tadmc@tadmc30.sbcglobal.net>,
 Tad J McClellan <tadmc@seesig.invalid> wrote:

> http://perl.plover.com/FAQs/Buffering.html

Thanks, I read that. Too bad my system (Mac OS X) doesn't support: 
setvbuf();


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

Date: Mon, 6 Oct 2008 22:23:18 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: sysread
Message-Id: <67cqr5-454.ln1@osiris.mauzo.dyndns.org>


Quoth Larry <dontmewithme@got.it>:
> In article <slrngek930.67p.tadmc@tadmc30.sbcglobal.net>,
>  Tad J McClellan <tadmc@seesig.invalid> wrote:
> 
> > http://perl.plover.com/FAQs/Buffering.html
> 
> Thanks, I read that. Too bad my system (Mac OS X) doesn't support: 
> setvbuf();

Modern perls (as of 5.8) use PerlIO instead of stdio, so what your
system supports is irrelevant. 

Ben

-- 
        I must not fear. Fear is the mind-killer. I will face my fear and
        I will let it pass through me. When the fear is gone there will be 
        nothing. Only I will remain.
ben@morrow.me.uk                                          Frank Herbert, 'Dune'


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

Date: Mon, 06 Oct 2008 23:38:04 GMT
From: sln@netherlands.com
Subject: Re: sysread
Message-Id: <e08le45il582uilg013qtdfqjqt4tp0hdg@4ax.com>

On 06 Oct 2008 15:47:16 GMT, xhoster@gmail.com wrote:

>Larry <dontmewithme@got.it> wrote:
>> In article <20081005192912.762$Lz@newsreader.com>, xhoster@gmail.com
>> wrote:
>>
>> > It might be possible, but extremely unlikely, that this could return
>> > early after reading less than 4 bytes, even in the absence of an error
>> > condition. If I had to use sysread, I'd probably take that chance,
>> > myself.  But why not just use read?  That will restart as needed until
>> > it gets 4 bytes, unless there are errors.
>>
>> this is something I forgot to tell you about:
>>
>> "sysread bypasses buffered IO, so mixing this with other kinds of reads,
>> print, write, seek, tell, or eof can cause confusion because the perlio
>> or stdio layers usually buffers data."
>>
>> what is buffered IO ??
>
>IO that is buffered by perl or by C on behalf of perl.
>
I would think that Perl calls level II i/o functions on its own, does it not?
>> how size is this buffer ??
>
>That depends on your system.
Does it? Do you have an example?

>  Why do you care?  The point of using
>high-level languages is that you usually don't need to worry about such
>things.
>
Freedom of information. I have the freedom to ask if you know what your talking about.

sln



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

Date: 07 Oct 2008 01:59:06 GMT
From: xhoster@gmail.com
Subject: Re: sysread
Message-Id: <20081006215910.147$vM@newsreader.com>

sln@netherlands.com wrote:
> On 06 Oct 2008 15:47:16 GMT, xhoster@gmail.com wrote:
>
> >Larry <dontmewithme@got.it> wrote:
> >> In article <20081005192912.762$Lz@newsreader.com>, xhoster@gmail.com
> >> wrote:
> >>
> >> > It might be possible, but extremely unlikely, that this could return
> >> > early after reading less than 4 bytes, even in the absence of an
> >> > error condition. If I had to use sysread, I'd probably take that
> >> > chance, myself.  But why not just use read?  That will restart as
> >> > needed until it gets 4 bytes, unless there are errors.
> >>
> >> this is something I forgot to tell you about:
> >>
> >> "sysread bypasses buffered IO, so mixing this with other kinds of
> >> reads, print, write, seek, tell, or eof can cause confusion because
> >> the perlio or stdio layers usually buffers data."
> >>
> >> what is buffered IO ??
> >
> >IO that is buffered by perl or by C on behalf of perl.
> >
> I would think that Perl calls level II i/o functions on its own, does it
> not?

I have no idea what a level II i/o function is.  The man pages don't seem
to break them down into that classification.  Is this a standard usage
or are you just making crap up?


> >> how size is this buffer ??
> >
> >That depends on your system.
> Does it? Do you have an example?

perl -e 'print "asdfsfsfdsldfjlskdfjlsjflsadjflsdfsadfsf" foreach
(1..3e5)'\
   | truss perl -le '<STDIN>'

shows "read" system calls of size 5120 on SunOS 5.9.  The same
thing but with strace rather than truss gives ones of 4096 bytes on
Linux 2.6.16.54-0.2.5-smp.  An old Irix system I no longer have access
to used 10240 bytes.  At least Perl for Windows uses 512 bytes, but since
it doesn't have a "strace" equivalent I don't remember how I deduced that.


>
> >  Why do you care?  The point of using
> >high-level languages is that you usually don't need to worry about such
> >things.
> >
> Freedom of information. I have the freedom to ask if you know what your
> talking about.

Coming from you, that is rather rich.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 06 Oct 2008 21:45:17 -0400
From: nun <nun@yahoo.com>
Subject: Re: trouble parsing "kind of" comma-delimited text
Message-Id: <gceevc$1amp$1@news.ett.com.ua>

Jürgen Exner wrote:
> 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.
> 
> Sounds like a normal CSV file to me.
> 
> [...]
>> 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.
> 
> Why not just use the Text::CSV module or one of its relatives to parse
> that file?
> 
> jue


Thanks - that worked great :)

DB


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

Date: Mon, 6 Oct 2008 19:25:48 -0700 (PDT)
From: inetquestion <inetquestion@hotmail.com>
Subject: update XML file with perl or other...?
Message-Id: <03f41898-81c9-4384-9476-5600f1afc952@p49g2000hsd.googlegroups.com>

I have an XML document which I would like to modify based on the
results of a test.  A subset of information contained in the XML file
is shown below.  If a 'test' to each server:port were to fail, then
the xml file should be modified such that the attribute 'off' is set
to a value of 1.    I was thinking of doing this in perl, but would
like to get some suggestions based on ease of modifying files, etc...
I've written some basic perl scripts to read an xml file before, but
ran into some confusion when trying to write them back out.  Any
suggestions or pointers?


 ...
 ...
<app name="hokiepokie">
    <instance host="server01" port="8080" Off="0"/>
    <instance host="server02" port="8081" Off="0"/>
    <instance host="server03" port="8082" Off="0"/>
</app>
 ...
 ...




-Inet







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

Date: Mon, 6 Oct 2008 19:46:33 -0700 (PDT)
From: inetquestion <inetquestion@hotmail.com>
Subject: Re: update XML file with perl or other...?
Message-Id: <23fab402-8213-4f2d-836f-f600141def41@u46g2000hsc.googlegroups.com>

On Oct 6, 10:25 pm, inetquestion <inetquest...@hotmail.com> wrote:
> I have an XML document which I would like to modify based on the
> results of a test.  A subset of information contained in the XML file
> is shown below.  If a 'test' to each server:port were to fail, then
> the xml file should be modified such that the attribute 'off' is set
> to a value of 1.    I was thinking of doing this in perl, but would
> like to get some suggestions based on ease of modifying files, etc...
> I've written some basic perl scripts to read an xml file before, but
> ran into some confusion when trying to write them back out.  Any
> suggestions or pointers?
>
> ...
> ...
> <app name="hokiepokie">
>     <instance host="server01" port="8080" Off="0"/>
>     <instance host="server02" port="8081" Off="0"/>
>     <instance host="server03" port="8082" Off="0"/>
> </app>
> ...
> ...
>
> -Inet


for example, lets say the test on server02 failed, what procedure
would need to occur to change the xml file as follows?  If possible I
would prefer to do this via traditional xml methods and not text file
parsing.  I'm just a little lost as to how to do it...

 <app name="hokiepokie">
    <instance host="server01" port="8080" Off="0"/>
    <instance host="server02" port="8081" Off="1"/>
    <instance host="server03" port="8082" Off="0"/>
</app>


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

Date: 07 Oct 2008 02:53:34 GMT
From: xhoster@gmail.com
Subject: Re: update XML file with perl or other...?
Message-Id: <20081006225338.151$8z@newsreader.com>

inetquestion <inetquestion@hotmail.com> wrote:
> I have an XML document which I would like to modify based on the
> results of a test.

You will almost certainly have to rewrite the entire file.  Modifying
an XML file in place, except in some highly rigid contexts, would be quite
an adventure.


>  A subset of information contained in the XML file
> is shown below.  If a 'test' to each server:port were to fail, then
> the xml file should be modified such that the attribute 'off' is set
> to a value of 1.    I was thinking of doing this in perl, but would
> like to get some suggestions based on ease of modifying files, etc...
> I've written some basic perl scripts to read an xml file before, but
> ran into some confusion when trying to write them back out.  Any
> suggestions or pointers?

If the file isn't large compared to your RAM, I'd probably start by trying
XML::Simple, which despite the name isn't all that simple and it really
pays to read the docs pretty thoroughly.

>
> ...
> ...
> <app name="hokiepokie">
>     <instance host="server01" port="8080" Off="0"/>
>     <instance host="server02" port="8081" Off="0"/>
>     <instance host="server03" port="8082" Off="0"/>
> </app>

Useful options for XML::Simple might be
ForceArray=>1, KeyAttr=>{app=>'name', instance=>'host'}

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

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


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