[22336] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4557 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 12 14:06:43 2003

Date: Wed, 12 Feb 2003 11:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 12 Feb 2003     Volume: 10 Number: 4557

Today's topics:
    Re: Accessing files in html folder from cgi script <nobull@mail.com>
    Re: Analyzing Columns of Data <bigj@kamelfreund.de>
        File-handles as variables <itatsumakiNO@SPAMhotmail.com>
    Re: File-handles as variables (Walter Roberson)
    Re: Finding multiple repititions of a pattern (with num (Venugopal)
    Re: grep with line number ? <krahnj@acm.org>
    Re: grep with line number ? <glex_nospam@qwest.net>
        how to safely substitute a "(", ")" or "[" <nospam@nospam.org>
    Re: how to safely substitute a "(", ")" or "[" (Tad McClellan)
    Re: how to safely substitute a "(", ")" or "[" (Walter Roberson)
    Re: how to safely substitute a "(", ")" or "[" <mpapec@yahoo.com>
    Re: how to safely substitute a "(", ")" or "[" <nospam@nospam.org>
    Re: Indented Text to Nested DataStructure[Tricky or Eas (valued customer)
    Re: Insecure Filehandle Dependencies <flavell@mail.cern.ch>
    Re: Minimalist Perl Interpreter for Windows 98 and XP? <noemail@nowhere.net>
    Re: Minimalist Perl Interpreter for Windows 98 and XP? <wsegrave@mindspring.com>
    Re: Minimalist Perl Interpreter for Windows 98 and XP? <jeff@vpservices.com>
    Re: PersistentPerl never resolves first time through (Todd Boss)
        PREFIX and LIB args for Makefile (Chas Friedman)
        problem with "piping" data from STDOUT into the PerlTK' (Vitali)
    Re: puzzling operator priorities <bkennedy@hmsonline.com>
    Re: Re Installing modules from CPAN <brian.smart@blueyonder.co.uk>
    Re: Saving/Editing SQL queries (Adam Hapworth)
    Re: Saving/Editing SQL queries <richard@zync.co.uk>
    Re: Scope of a global lexical (Greg)
    Re: strict and warnings <bkennedy@hmsonline.com>
    Re: Subs in external files? <nobull@mail.com>
        Syntax error (spyderscripts)
    Re: Syntax error <paanwa@hotmail.com>
    Re: Syntax error <tony_curtis32@yahoo.com>
        Win32::OLE GroupItems PPT <lance@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 12 Feb 2003 18:46:34 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Accessing files in html folder from cgi script
Message-Id: <u9lm0lz69h.fsf@wcl-l.bham.ac.uk>

craigdessoy@hotmail.com (Craig) writes:

> i am trying to send an email from a cgi script (in the cgi-bin), which
> attaches a csv file

What module are you using how?

> located in the html folder.

What is "the html folder"?

> for this i am using /mainwebsite_html/file.csv

Is the absolute file path '/mainwebsite_html' a valid directory name
for the entity you call  "the html folder"?

> when i run this script from the browser

Cough, cough, cough...

> or command line i get a software error: /mainwebsite_html/file.csv not
> readable.

This does not look like a native Perl error.  What software is
generating this error.

> i tried an absolute address and got the same error.

What do you mean by "absolute address"?

> permissions are set at 755.
> does anyone have any suggestions?

I suggest you are perhaps unclear about the distiction between file
names and URLs.  But it's rather hard to say without anything concrete
to go on.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 12 Feb 2003 16:41:08 +0100
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: Analyzing Columns of Data
Message-Id: <pan.2003.02.12.15.30.19.299493@kamelfreund.de>

On Wed, 12 Feb 2003 06:50:05 -0800, brice wrote:

> I have a comma-separated value file of the following format:
> 
> first_value,second_value,third_value
> 1,2,3
> 10,20,30
> 32,11,52
> 
> and so on...
> 
> I want to grab each column of data as it's own array. In other words,
> I want to have the first array be:
> 
> array1[0] = "first_value"
> array1[1] = "1"
> array1[2] = "10
> array1[3] = "32"
> 
> My script has to account for varying numbers of columns as I won't
> always have three columns to work with. Any ideas on this? I just need
> a little nudge on this to get going.

Half a year ago,
I had a similar problem.
I decided to write the module
Tie::CSV_File
available at CPAN.

Have a look to it.
You can tried a CSV file as an array with it :-)


Best Wishes,
Janek


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

Date: Wed, 12 Feb 2003 18:27:42 GMT
From: "Okey Laboratory" <itatsumakiNO@SPAMhotmail.com>
Subject: File-handles as variables
Message-Id: <HA7KM5.BDF@campus-news-reading.utoronto.ca>

Hi all,

This is a stupid question, because I remember reading the answer before and
just can't locate it in the perldocs.  I am parsing a tab-delimited file,
and depending on the value in the first element I'll either want to write to
one file or the other.  Because the rest of my parsing is identical except
for file-handle to which I print, I'd love to be able to dynamically set
file-handles.  This would save me huge blocks of parsing code (five
possibilities * 90 lines of code = 450 lines).  Any suggestions how could I
do this?

Thoughts much appreciated,
Tats

Sample code:

open(RGD, '>rgd.csv');
open(MGI, '>mgi.csv');

while (<IN>) {
     my @row = split("\t");

     if ($row[0] =~ /^rgd$/g) {# process with file-handle RGD}
    elsif ($row[0] =~ /^mgi$/g) {# process identically with file-handle MGI}

    }




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

Date: 12 Feb 2003 19:00:53 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: File-handles as variables
Message-Id: <b2e5l5$q2g$1@canopus.cc.umanitoba.ca>

In article <HA7KM5.BDF@campus-news-reading.utoronto.ca>,
Okey Laboratory <itatsumakiNO@SPAMhotmail.com> wrote:
:This is a stupid question, because I remember reading the answer before and
:just can't locate it in the perldocs.  I am parsing a tab-delimited file,
:and depending on the value in the first element I'll either want to write to
:one file or the other.  Because the rest of my parsing is identical except
:for file-handle to which I print, I'd love to be able to dynamically set
:file-handles.

If you use a scalar variable in a location that a FILEHANDLE is
expected, then the string value of the variable will be used as the
FILEHANDLE name.

Another approach to consider is to store your handles in a hash
and index the hash by a variable depending on your choice of output
streams. [But if that choice variable is extracted from an input line,
you really should validate it as being one of the valid choices
before you dereference the hash.]
-- 
This is not the same .sig the second time you read it.


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

Date: 12 Feb 2003 10:22:40 -0800
From: balasubv@hotmail.com (Venugopal)
Subject: Re: Finding multiple repititions of a pattern (with number of  repititions unknown)
Message-Id: <68041301.0302121022.2a44ef7e@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E49B3FE.68886F21@earthlink.net>...
> Venugopal wrote:
> > 
> > Hi,
> > 
> > I have a string of the form
> > .....PATTERN[num1]...PATTERN[num2]....PATTERN[numN]
> > 
> > PATTERN is fixed, but the number of repitions N is not.
> > I want to extract the variables num1,num2,...numN
> > 
> > How do I this in Perl?
> 
> my @nums = $data =~ /PATTERN\[(.*?)\]/g;
Thanks! That did the job! 
My sincere thanks for other responses also.


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

Date: Wed, 12 Feb 2003 19:01:28 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: grep with line number ?
Message-Id: <3E4A99D5.419C45FA@acm.org>

kamran wrote:
> 
> What I have is, I have read an entire text file into an array:
> open(FILE,"$FILE");
> @LINES = <FILE>;
> close(FILE);
> @LINES = <FILE>
> 
> and want to find the line number containg the expression "###CONTENT###"
> so I can split my @LINES into two parts, one from the beginning to
> the line number containing the expression and one for the remaining.

open FILE, $file or die "Cannot open $file: $!";
my ( @part1, @part2 );
push @{ 1 .. /###CONTENT###/ ? \@part1 : \@part2 }, $_ while <FILE>;



John
-- 
use Perl;
program
fulfillment


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

Date: Wed, 12 Feb 2003 13:04:17 -0600
From: Jeff D Gleixner <glex_nospam@qwest.net>
Subject: Re: grep with line number ?
Message-Id: <TSw2a.40$6c6.34616@news.uswest.net>

kamran wrote:

> But you are talking to an illiterate :)
> What I have is, I have read an entire text file into an array:
> open(FILE,"$FILE");
> @LINES = <FILE>;
> close(FILE);
> @LINES = <FILE>
> 
> and want to find the line number containg the expression "###CONTENT###"
> so I can split my @LINES into two parts, one from the beginning to
> the line number containing the expression and one for the remaining.

Why not split it as you read the file?  If you really only want to split
the file, do it while you read it and don't slurp the entire file into @LINES.

my (@top, @bottom);
open (FILE, "<$FILE") or die "...$!";
my $foundContent=0;
while(<FILE>)
{
	if (!$foundContent)
	{
		if ( /###CONTENT###/)
		{
			$foundContent=1;
			next;
		}
		push (@top, $_);
	}
	else
	{
		push(@bottom, $_);
	}
}
close(FILE) or die "...$!";

If you really care what line ###CONTENT### was found, then put an iterator in 
the loop.

More code, but IMHO easier to read & understand, especially for, as you say, 
"an illiterate".  It's also faster and uses less memory than slurp & grep 
techniques, which may/may not matter.



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

Date: Wed, 12 Feb 2003 11:17:48 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: how to safely substitute a "(", ")" or "["
Message-Id: <b2ds3c$ceb16@nrn2.NRCan.gc.ca>

Hi all,

this simple script is working nicely, except if I want to substitute a "(",
")" or "[".

#########################
#!/usr/local/bin/perl -w
use strict;

my $string = 'abd&6)31%34';
my $subs = 'abd';
my $new_string = $string;
$new_string  =~ s/$subs//;

print "$string has been substituted $subs:\n$new_string\n";
#########################
nrn1# perl test
abd&6)31%34 has been substituted abd:
&6)31%34

But now, if I replace $subs with ")", I get an error:

/")"/: unmatched () in regexp at test line 7.

How can I deal with this? I can escape it (make $subs = '\)'), but is there
another way? Any other characters I should be aware of?

I already tried:
nrn1> perldoc -q substitution
No documentation for perl FAQ keyword `substitution' found"

Thanks!

Christian





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

Date: Wed, 12 Feb 2003 10:40:33 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how to safely substitute a "(", ")" or "["
Message-Id: <slrnb4ku81.3tu.tadmc@magna.augustmail.com>

Christian Caron <nospam@nospam.org> wrote:

> this simple script is working nicely, except if I want to substitute a "(",
> ")" or "[".


> $new_string  =~ s/$subs//;


> I can escape it (make $subs = '\)'), but is there
> another way?


   $new_string  =~ s/\Q$subs//;

see also:

   perldoc -f quotemeta


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 12 Feb 2003 16:43:08 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: how to safely substitute a "(", ")" or "["
Message-Id: <b2dtis$man$1@canopus.cc.umanitoba.ca>

In article <b2ds3c$ceb16@nrn2.NRCan.gc.ca>,
Christian Caron <nospam@nospam.org> wrote:
:But now, if I replace $subs with ")", I get an error:

:/")"/: unmatched () in regexp at test line 7.

:How can I deal with this? I can escape it (make $subs = '\)'), but is there
:another way? Any other characters I should be aware of?

See the perlre man page for the \Q and \E modifiers. See also
the equivilent function, quotemeta .
-- 
Disobey all self-referential sentences!


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

Date: Wed, 12 Feb 2003 17:44:24 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: how to safely substitute a "(", ")" or "["
Message-Id: <59uk4vcjrq13uh1il4dc5f4c5a07vah73h@4ax.com>

X-Ftn-To: Christian Caron 

"Christian Caron" <nospam@nospam.org> wrote:
>print "$string has been substituted $subs:\n$new_string\n";
>#########################
>nrn1# perl test
>abd&6)31%34 has been substituted abd:
>&6)31%34
>
>But now, if I replace $subs with ")", I get an error:
>
>/")"/: unmatched () in regexp at test line 7.
>
>How can I deal with this? I can escape it (make $subs = '\)'), but is there
>another way? Any other characters I should be aware of?

\Q escapes chars for you, so you can:
$new_string  =~ s/\Q$subs\E//;
or just:
$new_string  =~ s/\Q$subs//;



-- 
Matija


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

Date: Wed, 12 Feb 2003 12:14:33 -0500
From: "Christian Caron" <nospam@nospam.org>
Subject: Re: how to safely substitute a "(", ")" or "["
Message-Id: <b2dvdp$ceb17@nrn2.NRCan.gc.ca>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrnb4ku81.3tu.tadmc@magna.augustmail.com...
> Christian Caron <nospam@nospam.org> wrote:
>
> > this simple script is working nicely, except if I want to substitute a
"(",
> > ")" or "[".
>
>    $new_string  =~ s/\Q$subs//;
>
> see also:
>
>    perldoc -f quotemeta
>
Thanks!

Christian




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

Date: 12 Feb 2003 10:01:21 -0800
From: scooterm@hotmail.com (valued customer)
Subject: Re: Indented Text to Nested DataStructure[Tricky or Easy?]
Message-Id: <1b347673.0302121001.41a85ae1@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E49C1B2.D6622CD1@earthlink.net>...
> valued customer wrote:
> > 
> > ==== Problem Input
> > Here is the problem, I start with something like
> > THIS:
> > 
> > SECTION 1
> >     Hello World Blah blah blah.
> >     Hello again, Blah blah blah.
> > 
> >     SECTION 1.1
> >         Here's more blah blah blah.
> >         Blahdy bladhy blay bloo foo.
> > 
> > ==== Desired Output
> > And I want to end up with something like
> > THIS:
> > 
> 
[snip]
> This was only tested on the sample data you gave... I hope that it works
> ok on your real data.

Thanks for the posting!

Acutally, the solution you posted is close, but it does not handle the
recursion properly. That is the part I am wrestling with myself. Look
closely at the <sub> tags and you may notice that what I am trying to
do is get them to enclose all "subsections" that have indents greater
than any section 'above' it. I know I am not the first person in the
world to try this, so I continue my search ...

Anyone else out there want to give it a shot?

==== Your code produces the following output
<root>
<txt>SECTION 1</txt>
    <sub>
    <txt>Hello World Blah blah blah.</txt>
    <txt>Hello again, Blah blah blah.</txt>
    </sub>
        <sub>
            <txt>SECTION 1.1</txt>
            <sub>
            <txt>Here's more blah blah blah.</txt>
            <txt>Blahdy bladhy blay bloo foo.</txt>
            </sub>
        </sub>
<root>

==== I am trying for THIS output (notice the nesting of the 'sub' tags

<root>
<txt>SECTION 1</txt>
    <sub>
    <txt>Hello World Blah blah blah.</txt>
    <txt>Hello again, Blah blah blah.</txt>
        <sub>
            <txt>SECTION 1.1</txt>
            <sub>
            <txt>Here's more blah blah blah.</txt>
            <txt>Blahdy bladhy blay bloo foo.</txt>
            </sub>
        </sub>
    </sub>
<root>


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

Date: Wed, 12 Feb 2003 17:21:20 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Insecure Filehandle Dependencies
Message-Id: <Pine.LNX.4.53.0302121710540.7803@lxplus073.cern.ch>

On Feb 12, Joel Konkle-Parker inscribed on the eternal scroll:

> Thanks for all the replies (and bickering).

"Bickering"??  I didn't see any bickering!!  (would you like the five
minute argument or ...?)

We had a collegial discussion of some relevant issues, and I thought
we reached a reasonable agreement about the issues discussed, and
might have helped some lurkers as a result (one can always hope).

It would be a nice coincidence if we had also happened to answer your
original question, but hey, this is Usenet.   ;-}

> The problem was with a system() call.

Was it?  I didn't see any system() call in what you had posted.

> I changed the one-argument call to a two-argument call,
> and everything was fine.

http://www.perldoc.com/perl5.8.0/pod/perlsec.html

 If you pass more than one argument to either system or exec, the
 arguments are checked for taintedness but the operation will still be
 attempted, emitting an optional warning. This will be fatal in a
 future version of perl so do not rely on it to bypass the tainting
 mechanism.

Was any of that relevant to your situation?  Unclear from the minimal
detail in your followup.

Good luck.



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

Date: 12 Feb 2003 16:42:07 GMT
From: nobody <noemail@nowhere.net>
Subject: Re: Minimalist Perl Interpreter for Windows 98 and XP?
Message-Id: <Xns9320776CDBAFFabccbaabc@129.250.170.100>

> So is it possible to copy all the files in /perl/bin to a CD-ROM or
> ZIP disk and run it as a minimalist Perl (without setup or
> installation)?

Yes (as someone else said). But you don't even need that much.
Start with your script, perl.exe, and perl56.dll (or maybe
all the dll's). That may be enough...


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

Date: Wed, 12 Feb 2003 12:07:59 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Minimalist Perl Interpreter for Windows 98 and XP?
Message-Id: <b2e3kh$jt3$1@slb3.atl.mindspring.net>

"Goh, Yong Kwang" <gohyongkwang@hotmail.com> wrote in message
news:354933d6.0302120508.5abbdf60@posting.google.com...
<snip>
> So is it possible to copy all the files in /perl/bin to a CD-ROM or
> ZIP disk and run it as a minimalist Perl (without setup or
> installation)?

Microweb, available at www.indigostar.com, can be run from a CD.

Bill Segraves




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

Date: Wed, 12 Feb 2003 10:26:59 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Minimalist Perl Interpreter for Windows 98 and XP?
Message-Id: <3E4A91F3.4080509@vpservices.com>

Goh, Yong Kwang wrote:

 
> So is it possible to copy all the files in /perl/bin to a CD-ROM or
> ZIP disk and run it as a minimalist Perl (without setup or
> installation)?


It doesn't need to be "a minimalist Perl" - my entire ActivePerl tree 
including /bin, /site, /lib (with *many* modules), even with /html and 
/eg directories is less than 50mb so would fit comfortably on a Zip 
disk.  It runs just by popping it into the zip drive on another machine 
without any installation or setup.

-- 
Jeff



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

Date: 12 Feb 2003 08:41:29 -0800
From: toddboss@yahoo.com (Todd Boss)
Subject: Re: PersistentPerl never resolves first time through
Message-Id: <3fddd6bb.0302120841.1f1ed96b@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E49C24B.56BAC210@earthlink.net>...
> Todd Boss wrote:
> > 
> > Hello.
> > 
> > we're using PersistentPerl (formerly known as SpeedyCGI) to help speed
> > up a large perl-based web app.  Solaris box, Iplanet webserver,
> > connecting to an Oracle database via DBI::Oracle.
> [snip]
> 
> I've no idea why your problem is happening, *but* I've an idea for a
> sort-of workaround:
> 
> How much of your site has been adapted to use perperl?  Is it to late
> for you to consider fastcgi instead?

Well, because as I Understand, FastCGI doesn't support Iplanet.  Or does it?
The documentation for FastCGI that i've found online isn't very clear
as to which web servers it currently works on.  Does anyone know?

We've done nothing other than change the perl call to perperl, in terms of
"adapting" our code to run persistently.

boss


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

Date: Wed, 12 Feb 2003 16:26:58 +0000 (UTC)
From: friedman@math.utexas.edu (Chas Friedman)
Subject: PREFIX and LIB args for Makefile
Message-Id: <b2dski$12f$1@geraldo.cc.utexas.edu>

(Note: I posted the following as a response to a posting a few days ago,
but I think it may not have been very visible. Please excuse the repeat
if this was already seen.)

Something that's confused me for some time: I've seen recommendations
in various texts to use 

perl Makefile.PL PREFIX=... and sometimes just(!) perl Makefile.PL LIB=...

when creating a Makefile used to install a module in a local 
(i.e. not the standard) directory.
In fact, it seems that the PREFIX=... version usually seems to be the one
that is satisfactory, and the LIB=... isn't what is wanted
but in a few cases I seem to recall that I needed to use both the PREFIX=... and LIB=... together in the command to use the resulting Makefile without 
errors/problems. To understand the difference, I tried various combinations
and compared the resulting Makefiles, and there certainly was a difference, but
the effect of the differences was hard to understand - Makefiles produced
by Makefile.PL tend to be rather long and difficult (for me) to read.

 Anyone know what the effect of each of these settings is and when the LIB=
is useful? 
 (Note: I do realize that "use lib" is something different and often
necessary when using modules located in nonstandard places.)
 Thanks for any comments or info!
                       chas





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

Date: 12 Feb 2003 08:47:34 -0800
From: v.proutski@organon.co.uk (Vitali)
Subject: problem with "piping" data from STDOUT into the PerlTK's Text widget - blocking pipe
Message-Id: <69fcf697.0302120847.1a9ca616@posting.google.com>

I've writen an application with GUI written in PerlTk. I have lots of
"print" statements throughout the program and I would like to collect
whatever they print into STDOUT and display it in the Text area of a
dedicated window of MonitorW.pm widget I have also written:
#=======================================================================#
package MonitorW;
use vars qw($VERSION);
$VERSION='1.0';
use base (Tk::Toplevel);
use Tk::widgets qw(Frame Button ROText);
Construct Tk::Widget 'MonitorW';
use IO::Handle;
sub Populate{
  my ($w,$args) = @_;
  $w->SUPER::Populate($args);
  if(defined $args->{parent}){$w->{parent}=$args->{parent};}
  my $Fr1 = $w->Frame(-relief=>"raised", -borderwidth=>2);
  $Fr1->pack(-side=>"top", -fill=>"both",-expand=>"yes");
  my $TextField=$Fr1->Scrolled('Text',-wrap=>'none',-scrollbars=>'osow',
                                     
-width=>75,-height=>20,-bg=>'white');
  $TextField->pack(-side=>"top",-padx=>1,-expand=>'yes',-fill=>'both');
  $w->Advertise("TextField"=>$TextField);
  my $Fr2 = $w->Frame(-relief=>"raised", -borderwidth=>2);
  #->Frame(-relief=>"raised", -borderwidth=>4);
  $Fr2->pack(-side=>"bottom",-fill=>"both");#,-expand=>"yes");
  my $Close=$Fr2->Button(-text=>'Close',-default=>"active",
                         -command=>sub{ $w->Close();});
  my $StopRestart=$Fr2->Button(-text=>'Stop',-default=>"active",
                               -command=>sub{ $w->StopRestart()});
  $w->Advertise("StopRestart"=>$StopRestart);
  my $Clear=$Fr2->Button(-text=>'Clear',-default=>"active",
                         -command=>sub{ $w->Clear();});
  my $Save=$Fr2->Button(-text=>'Save',-default=>"active",
                        -command=>sub{ $w->Save();});
  my $pady=5;
  $Close->grid(-row=>0,-column=>3,-padx=>20,-pady=>$pady,-sticky=>'n');
  $StopRestart->grid(-row=>0,-column=>0,-padx=>20,-pady=>$pady,-sticky=>'n');
  $Clear->grid(-row=>0,-column=>1,-padx=>20,-pady=>$pady,-sticky=>'n');
  $Save->grid(-row=>0,-column=>2,-padx=>20,-pady=>$pady,-sticky=>'n');
  $w->ConfigSpecs(
    -parent=>['PASSIVE',undef,undef,undef],  # 
  );
  #------------------------------------------------------#
  # create a pipeline between two handles
  pipe(STDINNN, STDOUTTT);
  #------------------------------------------------------#
  # make STDOUTTT work like STDOUT
  my $oldH=select(STDOUTTT); 
  #-1-----------------------------------------------------#
  # set autoflush to 1 (unbuffer output)
  $|=1; # $|=0;
  #------------------------------------------------------#
  # define action on fileevent - respons to changes in STDINNN handle
into
  # which data are supposed to be piped from STDOUTTT
  $args->{-parent}->fileevent(\*STDINNN,'readable'=>sub{$w->PutInMonitor(\*STDINNN,0);});
}
#============================================================#
# method reads from HANDLE and inserts string in to $TextField
sub PutInMonitor{
  my ($w, $handle, $STOP)=@_;
  my $data;
  if(sysread($handle, $data, 4096)) {
    if($STOP==1){ return;}
    if($data){
      my $TextField=$w->Subwidget('TextField');
      $TextField->insert('end',$data);
      $TextField->yview('end');
    }
  }
#$|=1; 
#$|=0;
}
#============================================================#
#============================================================#
Unfortunaly this does not quite work. Specifically, data are printed
in $TextField when the total number of bytes is upto 4096 (Linux
PIPE_SIZE = 4096), but even single extra byte causes some kind of
blocking: nothing appears in the TextField and whole GUI become
unresponsive. Interestingly, when I attempt to "print" fewer that 4096
bytes, all of them apper in TextField at once, as if they were
buffered (despite $|=1 in ). If I set $| to 0 in #-1 (see sub
Populate{}) then only first 4096 bytes of the total print-out are
displayed in TextField. If I also add
$|=1; 
$|=0;
at the end of sub PutInMonitor{} - I can "print" up to twice the
amount bytes (2x4096 ) and I can see that sub PutInMonitor{} is called
twice, but again every extra byte in addition to 2x4096 causes
blockage and GUI becomes "numb". Furhtermore, when the amount of data
I print is > 2x4096 I do not see sub PutInMonitor{} to be called at
all.
Can anybody help and explain to me what happens and how can I unblock
input and output handles when they are used by "print" and "syswrite"
or maybe I need to use something else to bypass stdio?

Vitali


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

Date: Wed, 12 Feb 2003 12:39:27 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: puzzling operator priorities
Message-Id: <AQGdnUMJ5JX5GtejXTWcqw@giganews.com>


"ebchang" <chang0@adelphia.net> wrote in message
news:Xns9320694C7EFF9chang0adelphia.net@24.48.107.53...
> Looking at the expression $x = 5 && $y = 7,  I thought it would be
> parenthesized as either ($x = (5 && $y)) = 7 or as $x = (5 && $y)) = 7)
> since && has higher priority than assignment.

If I had to guess, perhaps the interpreter doing some optimization:

$x = 5 && $y = 7

Becomes via the precedence rules:

$x = (5 && $y) = 7

perl sees (5 && $y), realizes this will *always* return simply $y, and
substitutes $y instead:

$x = $y = 7

which produces the behavior your are seeing.  In experimenting, I noticed
that:

$x = rand() && $y = 7

produces a compile time error, saying "Can't modify logical and (&&) in
scalar assignment".  Without the value '5' which is known at compile time,
perl cannot optimize the && out of the picture, and thus producess the error
related to the assignment operator.  This is just a guess, perhaps someone
with more internals experience can comment.

--Ben Kennedy




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

Date: Wed, 12 Feb 2003 16:58:09 -0000
From: "Brian Smart" <brian.smart@blueyonder.co.uk>
Subject: Re: Re Installing modules from CPAN
Message-Id: <EVu2a.8969$217.5687@news-binary.blueyonder.co.uk>

Hello Randy,
I followed your advice to reconfigure using
cpan> o config init
and tried again.
Unfortunately I still seem to have the same problem. The text I got was as
follows:
************
  There's a new CPAN.pm version (v1.65) available!
  You might want to try
    install Bundle::CPAN
    reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...

Fetching with LWP:
  ftp://cpan.teleglobe.net/pub/CPAN/modules/03modlist.data.gz
Going to read n/sources/modules/03modlist.data.gz
Running make for I/IL/ILYAZ/modules/Math-Pari-2.010305.tar.gz
Fetching with LWP:

ftp://cpan.teleglobe.net/pub/CPAN/authors/id/I/IL/ILYAZ/modules/Math-Pari-2.
010305.tar.gz
CPAN: MD5 loaded ok
Fetching with LWP:
  ftp://cpan.teleglobe.net/pub/CPAN/authors/id/I/IL/ILYAZ/modules/CHECKSUMS
Could not gzopen
n/sources/authors/id/I/IL/ILYAZ/modules/Math-Pari-2.010305.tar.gz at
/usr/lib/perl5/5.00503/CPAN.pm line 4159.
[bsmart Net-SSH-Perl-1.23]$
***********

I get the feeling I must be doing something stupid but I don't want to give
up! If you have any further thoughts I will welcome them with open arms.

Regards

Brian Smart





"Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
news:slrnb4koke.4up.randy@theoryx5.uwinnipeg.ca...
> On Wed, 12 Feb 2003 12:18:06 -0000,
>    Brian Smart <brian.smart@blueyonder.co.uk> wrote:
> >Could I ask another question. When I tried to install a different
> >module all went well until the message
> >
> >Fetching with LWP:
> >  ftp://ftp.demon.co.uk/pub/CPAN/modules/03modlist.data.gz
> >Going to read y/sources/modules/03modlist.data.gz
> >Running make for I/IL/ILYAZ/modules/Math-Pari-2.010305.tar.gz
> >CPAN: MD5 loaded ok
> >Could not gzopen
> >y/sources/authors/id/I/IL/ILYAZ/modules/Math-Pari-2.010305.tar.gz at
> >/usr/lib/perl5/5.00503/CPAN.pm line 4159.
> >[bsmart Net-SSH-Perl-1.23]$'
>
> It's trying to read a file in a directory 'y', which most likely
> you don't have. This is probably due to a stray 'y' getting
> written to CPAN.pm's Config.pm - either edit this file
> (or $HOME/.cpan/CPAN/MyConfig.pm, if you use that) to get
> rid of the 'y', or else reconfigure things via
>   bash$ perl -MCPAN -e shell
>   cpan> o conf init
>
> --
> best regards,
> randy kobes




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

Date: 12 Feb 2003 09:55:38 -0800
From: hap@mikomi.org (Adam Hapworth)
Subject: Re: Saving/Editing SQL queries
Message-Id: <a6cb04db.0302120955.4c325d20@posting.google.com>

guymal@hotmail.com (Guy) wrote in message news:<8c80bc84.0302120041.528ae3f6@posting.google.com>...
> Hi,
> I'm working on a web application (written in Perl, duh!) that allows users
> to execute SQL queries on a relational database (and save/edit these
> queries).
> Since the users have no knowledge of either the db scheme or SQL, my
> application lets them create queries using a web based GUI according to
> terms that the users know (an abstraction of the db scheme).
> 
> I'm looking for a way to translate a given data structure (that represents
> what the user wants in their query) to actual SQL (so I can run it) and to
> save this query in order to edit it later.
> 
> Here is a typical scenario:
> A user creates a query using the GUI, their query is translated into SQL and
> executed. The user can save this query (somehow) and edit it later in the
> GUI (and then save it again).
> 
> Any suggestions/ideas?
> 
> TIA,
> Guy



You might want to look into DBIx::Abstract. This allows you to pass
hashes or arrays to the where statement and if I remember correctly to
the coloumns that are selected and the tables. It was desgined with
MySQL and I think it now supports Oracle as well. As for storign their
data why not set up a table in the database to track fields, tables,
query's for given user.

Adam


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

Date: Wed, 12 Feb 2003 17:56:38 +0000
From: "Richard Gration" <richard@zync.co.uk>
Subject: Re: Saving/Editing SQL queries
Message-Id: <20030212.175623.680466996.20961@richg.zync>

Hi,

I also write database driven web apps in Perl, and this has come up
before. What you're talking about is known as a "query-by-form" interface.
They're not simple beasts. Here is some general advice from someone who in
the past has always convinced his boss that "there really is no need for a
QBF solution here, lets ask the users what reports they'd like to see" :-)

If I were to _have_ to write one, I'd start with the syntax definition for
the select statement and design my UI around that. I'd implement very
simple queries first and make sure they worked. I'd start with

SELECT field FROM table;

and leave it at that. Table names in a drop down, which then populated the
field dropdown "onChange();". I'd store it exactly as it appears to the
user ie dropdown1 has value1, dropdown2 has value2, etc. Then you have a
complete solution for simple SELECTs. Then allow more than one field to be
selected, perhaps by having an "Add" button, which appended the current
value of the dropdown to a list. Then I'd add a simple WHERE clause: " ...
WHERE field = value". Then add a choice of operator (=,<,>,etc). Then
extend the WHERE clause to allow " ... AND field2 = value2". Then allow
other conjunctions besides AND, allow NOTs, etc, etc. Just build it up
piece by piece. Then I'd release it to CPAN :-)

Just a few thoughts, you're free to disagree :-)
Rich


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: 12 Feb 2003 08:11:29 -0800
From: gdsafford@hotmail.com (Greg)
Subject: Re: Scope of a global lexical
Message-Id: <a8f367ed.0302120811.72ca84f9@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3E4934D7.5659834E@earthlink.net>...
> Greg wrote:
> > eric wrote:
> > > Greg wrote:
> > > > use strict;
> > > > use warnings;
> > > >
> > > > smith();
> > > >
> > > > my $global = 3;
> > > >
> > > > sub smith{
> > > >    print $global || 'undef', "\n";
> > > > }
> > > >
> > > > This prints 'undef' when run in my local Perl 5.6 installation.
> > > > How can the body of smith() be interpreted without the assignment
> > > > of 3 to $global having taken place?
> > >
> > > the line
> > > my $global = 3;
> > > causes $global to be recognized at compile time, and set to 3 at run
> > > time.
> > > the compile-time recognition means that sub smith can access $global
> > > without generating a compile-time error under strict 'vars'.
> > > the run-time assignment does not happen until after the call to sub
> > > smith, so $global is undefined when sub smith runs.
>  [snip]
> > I see. So, the statement my $global = 3; is executed both at compile
> > time and run time. I should have seen this.
> 
> Well, part of it is executed at compile time, and part is executed at
> run time.
> 
> > I'm used to C behavior.
> 
> Out of curiousity, when you do, in C:
> 
>    static int foo = 3;
> 
> Does the '3' get stored in the memory for 'foo' at compile time, or at
> _start() time (before main() is called), or somewhere in between?
> 
> In other words, if I have a function which is called from _start, will
> the 'foo' variable be initialized?

Sorry. I'm no expert. I don't even know anything about _start() time.
I just know that when I initialize a file-scope global in a C or C++
program, the value is available at any point subsequent to the
initialization in the file, e.g.,

/* test.c */

#include <stdio.h>

void smith();

int main(){
   smith();
}

int global = 3;

void smith(){
   printf("smith: %d\n", global); /* prints '3' */
}

I wouldn't think that the 'static' keyword would affect the
compilation of a file when applied to a file-scope variable, but, as I
said, I'm no expert.

Greg


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

Date: Wed, 12 Feb 2003 11:27:36 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: strict and warnings
Message-Id: <I6OcnUZVid4Q69ejXTWcpQ@giganews.com>


"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:jb9k4vop7u8ksasfarc9dgs2fsbvciekd3@4ax.com...

> Not so. For example, I use XML::Writer, to er, generate XML --
> obviously, and *it* produces warnings internally if *my* data I pass it
> is undefined. I should not do that. It would have been better still if
> it used Carp for that, and pointed to the place in *my* script where I
> call XML::Writer's methods in an unclean way. But still, this is
> something, indicating *something* is wrong with my data, somewhere.

I don't think warnings should act as a substitute for parameter validation,
this is not what they were designed for.  Warnings are there to alert the
developer that "hey you need to change your code to validate that parameter,
dummy".  Warning messages should only be consumed by users who have found a
bug.  I would say modules that produce warning through normal use have some
kind of flaw since the entire point of warnings is to help find flaws in
code.  Now perhaps the XML::Writer author assumed that the calling code
would just not send undefined values so his module is in fact functioning
exactly as designed, but my personal defintion of "normal use" includes code
sending bogus or otherwise malformed input.

--Ben Kennedy





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

Date: 12 Feb 2003 18:50:33 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Subs in external files?
Message-Id: <u9heb9z62u.fsf@wcl-l.bham.ac.uk>

Joel Konkle-Parker <j.j.konkle-parker@larc.nasa.gov> writes:

> Joel Konkle-Parker wrote:
> 
> > How do I call a sub from an external file? Or sould I need to create
> > a module to do that?
> > - Joel
> >
> 
> I just answered my own question. For future reference:
> 
> just use a require "path/sub.pl"; then call the sub like normal

Yes you _can_ still use/write Perl4-style libraries in Perl5 but
unless you have a particular reason to do so then I would council
against it.

One particular problem is that if two or more Perl5-style modules all
require the same Perl4-style library then all but the fist will fail
silently.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 12 Feb 2003 10:14:28 -0800
From: sulfericacid@qwest.net (spyderscripts)
Subject: Syntax error
Message-Id: <32b6332f.0302121014.4338564c@posting.google.com>

I get the error: Bad name after 'username' when using:  
   my @unverified_emails=('$form{'usermail'}', '$ID');

Anyone have suggestions on how to correct the problem?


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

Date: Wed, 12 Feb 2003 13:30:44 -0500
From: "Paanwa" <paanwa@hotmail.com>
Subject: Re: Syntax error
Message-Id: <3e4a7625$0$99451$a04e5680@nnrp.fuse.net>

Have you tried:

my @unverified_emails=("$form{'usermail'}", "$ID");

PAW

"spyderscripts" <sulfericacid@qwest.net> wrote in message
news:32b6332f.0302121014.4338564c@posting.google.com...
> I get the error: Bad name after 'username' when using:
>    my @unverified_emails=('$form{'usermail'}', '$ID');
>
> Anyone have suggestions on how to correct the problem?




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

Date: Wed, 12 Feb 2003 12:32:41 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Syntax error
Message-Id: <873cmtmjsm.fsf@limey.hpcc.uh.edu>

>> On 12 Feb 2003 10:14:28 -0800,
>> sulfericacid@qwest.net (spyderscripts) said:

> I get the error: Bad name after 'username' when using:
> my @unverified_emails=('$form{'usermail'}', '$ID');

> Anyone have suggestions on how to correct the problem?

Well, "username" doesn't appear anywhere in the code you
show, so I assume you mean "usermail".

The problem can be seen by counting matched quote
characters (i.e. where do your strings end?).  And I
expect most of them are spurious, unless you really want
the strings matched literally.

hth
t


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

Date: Wed, 12 Feb 2003 10:08:32 -0600
From: Lance Hoffmeyer <lance@augustmail.com>
Subject: Win32::OLE GroupItems PPT
Message-Id: <Xns9320672613730lanceaugustmailcom@216.166.71.236>

Help with syntax:

$shape =  $p2->Slides(1)->Shapes(6);
my $text = $shape->ShapeRange->GroupItems(Index=>6)->
   TextFrame->TextRange->{Text};


Win32::OLE(0.1502) error 0x80020003: "Member not found"
    in METHOD/PROPERTYGET "" at test.pl line 67
Can't call method "GroupItems" on an undefined value at test.pl line 67.



I imagine it is my (Index=>6) but I have tried a number
of different things and nothing seems to work. Any suggestions?

Lance




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

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.  

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 V10 Issue 4557
***************************************


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