[19891] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2086 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 7 18:06:29 2001

Date: Wed, 7 Nov 2001 15:05:11 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1005174310-v10-i2086@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 7 Nov 2001     Volume: 10 Number: 2086

Today's topics:
    Re: ActivePearl in Win2k closes window immediately <dae_alt3@juno.com>
    Re: ActivePerl can't open file...sometimes <brian_helterline@hotmail.com>
    Re: Best language for low IQ programmers? (dmason)
    Re: Calling a script via SSI to access MySQL <mbudash@sonic.net>
    Re: Code Review Needed! <mbudash@sonic.net>
    Re: Code Review Needed! (Tad McClellan)
    Re: Code Review Needed! <mbudash@sonic.net>
    Re: Code Review Needed! (Damian James)
        Dealing with Data::Dumper lvirden@cas.org
        force stack dump  after die (Reza Rob)
        Help with my FreeShell service <esn@ematic.com>
    Re: Help with my FreeShell service <jessica.bull@broadwing.com>
    Re: Help with my FreeShell service (Tad McClellan)
        nmake / dmake Windows 98 <rbbdsb@earthlink.net>
    Re: nmake / dmake Windows 98 <jeff@vpservices.com>
    Re: Opening/creating files <mbudash@sonic.net>
        RE for SQL columns (Nan)
    Re: RE for SQL columns <mbudash@sonic.net>
    Re: RE for SQL columns (Tad McClellan)
    Re: Reading series of files on Client's computer with l <brian_helterline@hotmail.com>
    Re: split into words, find in table <jurgenex@hotmail.com>
    Re: split into words, find in table <mbudash@sonic.net>
    Re: split into words, find in table <jeff@vpservices.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Nov 2001 13:29:02 -0800
From: dougedmunds <dae_alt3@juno.com>
Subject: Re: ActivePearl in Win2k closes window immediately
Message-Id: <Xns915289016AF4DDougEdmunds@209.20.130.129>

> Use a smarter text editor than notepad (ugh!), one that allows you to

Try Jens' File Editor (free!).
It is easy to set up a toolbar to one-touch open a DOS window,
or to run perl in DOS with your file, or redirect
output of your perl program to a window in the program.

Use a DOS window if your program requires input.  The
redirect window doesn't handle input.


Here's the link:
http://home.t-online.de/home/Jens.Altmann/jfe_eng.htm

-- 
Doug Edmunds
Vancouver, Washington USA
edmunds::at::pacifier::dot::com


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

Date: Wed, 7 Nov 2001 12:08:11 -0800
From: "Brian Helterline" <brian_helterline@hotmail.com>
Subject: Re: ActivePerl can't open file...sometimes
Message-Id: <9sc4bg$19g$1@hpcvnews.cv.hp.com>


"Ron Reidy" <rereidy@indra.com> wrote in message
news:3BE972ED.32B61156@indra.com...
> Gil Vautour wrote:
> >
> > Hello,
> >
> > I'm running ActivePerl on a Windows2000 machine and I have a script will
> > run fine when when double-clicked or run from a command prompt like (ie.
> > c:\>perl script.pl)  However, when I specify the path to Perl.exe and
> > specify the path to the
> > script it spits an error saying that it cannot open the file ("No such
> > file or directory at...") that exists in the same place as the script.
> > The same error occurs when running it from the command prompt like
> > C:\Perl\bin>c:\script.pl
> >
> > Why would this be happening?  Is the script run with different
> > permissions
> > when invoked that way?  Below is the script.
> >
> > #!/usr/local/bin/perl -w
> >
> > open(CRSOUTFILE,">coursesnew.txt") || die "cannot open the file $!";
> > open(CRSINFILE,"COURSES.TXT") || die "cannot open the file $!";
> > while(<CRSINFILE>){
> >
> >            if (/\(.*?\)/) {
> >            $_ =~ s/\(.*?\)//g;
> >            print (CRSOUTFILE "$_");
> >            } else {
> >            print (CRSOUTFILE "$_");
> >            }
> > }
> > close CRSINFILE;
> > close CRSOUTFILE;
> >
> > Thanks,
> I am not sure is sh-bang works in windows (search the FAQs).  But this
> error indicates that Perl is not found at the location specified in the
> sh-bang line (at least in UNIX), or the current directory is not in your
> %PATH% variable.

It has nothing to do with sh-bang or finding perl.  It can't find the
"COURSES.TXT" file to open since the script assumes it is the current
working directory which is different than the location of the script (in the
cases where it failed)


> --
> Ron Reidy
> Oracle DBA
> Reidy Consulting, L.L.C.




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

Date: 7 Nov 2001 14:27:46 -0800
From: dylmason@hotmail.com (dmason)
Subject: Re: Best language for low IQ programmers?
Message-Id: <bb69ecbe.0111071427.35ba38c8@posting.google.com>

 ...I can't believe how many people actually took this seriously....


BrianMetc@aol.com (Brian Metc) wrote in message news:<1004990076967295@aol.com>...
> I would like to get into the programing field. My problem is that I have low IQ due to
> early childhool learning deprivation and TV overdose. Simply said I am stuped, I am 
> pretty good amongst my friends, but not solving problems. You know what I
> mean. Anyways, I want to go into computor programing because of money
> issue. I now need to choose languege for programming, simple enough
> for me.
> 
> My friend wh does C plus plus recommended that I learn either Visual Basic or Eiffel.
> My ex girlfriend who is a sys admin who did perl, sugested that I learn Ada because
> it has "serious type system" which is fool proof.
> 
> She dis couraged me from using Eiffel because itr was  a language going out of the
> market, no longer used by any serious corporation, She said the same thing for Ada.
> 
> Java is simple compared to c plus plus but a scam language, based on hype.
> 
> This only leaves visual basic. Especally because it is used under Windows, Microsoft
> stuff is always easier.
> 
> Would any one sugest the best language for me.
> 
> Brian


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

Date: Wed, 07 Nov 2001 20:22:52 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Calling a script via SSI to access MySQL
Message-Id: <mbudash-7D6879.12225507112001@news.sonic.net>

In article <slrn9ui9of.ec1.tadmc@tadmc26.august.net>, 
tadmc@augustmail.com wrote:

> Alex Shi <chpshi@stonix.com> wrote:
> >
> 
[snip]
> 
> 
> Why are you processing *two* query results per loop iteration?

good question. obviously he wants to present the results in a two-column 
table, but he has set himself up for editing errors later. as a bare 
minimum, and all global variable concerns aside, this would be better:

while (@aRow = $sth->fetchrow()) {
    print "<tr>\n";
    print_row();
    print_row() if (@aRow = $sth->fetchrow());
    print "</tr>\n";
}

sub print_row {
    print "$td1$sp1\$$aRow[4]$asp<br>\n";
    print "$sp2<b>$aRow[3]</b><br>\n";
    print "$aRow[6]<br>\n";
    print "[<a href=\"prdinfo.php3?code=$aRow[1]\">Order</a>]$asp";
    print $atd;
}
 
hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Wed, 07 Nov 2001 20:59:26 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Code Review Needed!
Message-Id: <mbudash-446714.12592907112001@news.sonic.net>

In article <m13d3qpflu.fsf@halfdome.holdit.com>, merlyn@stonehenge.com 
(Randal L. Schwartz) wrote:

> >>>>> "Uri" == Uri Guttman <uri@stemsystems.com> writes:
> 
> Uri> the dispatch table is a also style to protect against potential
> Uri> changes in the future as well. the OP never said that the list of sub
> Uri> was fixed or would be permanently hardwired. i prefer to make the
> Uri> assumption the code will change as we all know code does change.
> 
> But until it changes, you can do this:
> 
>   BEGIN {
>     my %table;
>     @table{qw(email_zip email_txt cp_zip cp_txt)} = ();
> 
>     sub call_send {
>       my $func = shift;
>       die "invalid func $func" unless exists $table{$func};
>       ($table{$func} ||= do {
>         no strict 'refs';
>         \&{"_send_$func"};
>       })->(@_);
>     }
>   }
> 
> That restricts the names that can be used, and caches the result of
> the symbol-table lookup.  I think that should satisfy all parties now.

ok, i'll [take an intermediate-programmer's-] bite... how (where?) does 
it do the cacheing?
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Wed, 07 Nov 2001 21:37:59 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Code Review Needed!
Message-Id: <slrn9uj79u.g5d.tadmc@tadmc26.august.net>

Michael Budash <mbudash@sonic.net> wrote:
>In article <m13d3qpflu.fsf@halfdome.holdit.com>, merlyn@stonehenge.com 
>(Randal L. Schwartz) wrote:
>
>> >>>>> "Uri" == Uri Guttman <uri@stemsystems.com> writes:
>> 
>> Uri> the dispatch table is a also style to protect against potential
>> Uri> changes in the future as well. the OP never said that the list of sub
>> Uri> was fixed or would be permanently hardwired. i prefer to make the
>> Uri> assumption the code will change as we all know code does change.
>> 
>> But until it changes, you can do this:
>> 
>>   BEGIN {
>>     my %table;
>>     @table{qw(email_zip email_txt cp_zip cp_txt)} = ();
>> 
>>     sub call_send {
>>       my $func = shift;
>>       die "invalid func $func" unless exists $table{$func};
>>       ($table{$func} ||= do {
>>         no strict 'refs';
>>         \&{"_send_$func"};
>>       })->(@_);


If $table{$func} is true, deref and call it.

If $table{$func} is false, evaluate the do-block which evals
to a reference, store the ref in $table{$func}, _then_
deref and call it.


>>     }
>>   }
>> 
>> That restricts the names that can be used, and caches the result of
>> the symbol-table lookup.  I think that should satisfy all parties now.
>
>ok, i'll [take an intermediate-programmer's-] bite... how (where?) does 
>it do the cacheing?


In the %table hash.


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


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

Date: Wed, 07 Nov 2001 21:50:29 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Code Review Needed!
Message-Id: <mbudash-D3D470.13503207112001@news.sonic.net>

In article <slrn9uj79u.g5d.tadmc@tadmc26.august.net>, 
tadmc@augustmail.com wrote:

> Michael Budash <mbudash@sonic.net> wrote:
> >In article <m13d3qpflu.fsf@halfdome.holdit.com>, merlyn@stonehenge.com 
> >(Randal L. Schwartz) wrote:
> >
> >> >>>>> "Uri" == Uri Guttman <uri@stemsystems.com> writes:
> >> 
> >> Uri> the dispatch table is a also style to protect against potential
> >> Uri> changes in the future as well. the OP never said that the list of 
> >> sub
> >> Uri> was fixed or would be permanently hardwired. i prefer to make the
> >> Uri> assumption the code will change as we all know code does change.
> >> 
> >> But until it changes, you can do this:
> >> 
> >>   BEGIN {
> >>     my %table;
> >>     @table{qw(email_zip email_txt cp_zip cp_txt)} = ();
> >> 
> >>     sub call_send {
> >>       my $func = shift;
> >>       die "invalid func $func" unless exists $table{$func};
> >>       ($table{$func} ||= do {
> >>         no strict 'refs';
> >>         \&{"_send_$func"};
> >>       })->(@_);
> 
> 
> If $table{$func} is true, deref and call it.
> 
> If $table{$func} is false, evaluate the do-block which evals
> to a reference, store the ref in $table{$func}, _then_
> deref and call it.
> 
> 
> >>     }
> >>   }
> >> 
> >> That restricts the names that can be used, and caches the result of
> >> the symbol-table lookup.  I think that should satisfy all parties now.
> >
> >ok, i'll [take an intermediate-programmer's-] bite... how (where?) does 
> >it do the cacheing?
> 
> 
> In the %table hash.


thanks, tad. makes sense to me now. very elegant...
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 7 Nov 2001 21:56:34 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Code Review Needed!
Message-Id: <slrn9ujb8u.nvg.damian@puma.qimr.edu.au>

On Wed, 07 Nov 2001 20:59:26 GMT, Michael Budash said:
>In article <m13d3qpflu.fsf@halfdome.holdit.com>, merlyn@stonehenge.com 
>(Randal L. Schwartz) wrote:
>> ...
>>   BEGIN {
>>     my %table;
>>     @table{qw(email_zip email_txt cp_zip cp_txt)} = ();
>> 
>>     sub call_send {
>>       my $func = shift;
>>       die "invalid func $func" unless exists $table{$func};
>>       ($table{$func} ||= do {
>>         no strict 'refs';
>>         \&{"_send_$func"};
>>       })->(@_);
>>     }
>>   }
>> 
>> That restricts the names that can be used, and caches the result of
>> the symbol-table lookup.  I think that should satisfy all parties now.
>
>ok, i'll [take an intermediate-programmer's-] bite... how (where?) does 
>it do the cacheing?

   $table{$func} ||= \&coderef;

The 'cache' here is really a dispatch table built on the fly from
the symrefs! Nifty, Randal :-)

Cheers,
Damian
-- 
@:=grep!(m!$/|#!..$|),split//,<DATA>;@;=0..$#:;while($:=@;){$;=rand
$:--,@;[$;,$:]=@;[$:,$;]while$:;push@|,shift@;if$;[0]==@|;select$,,
$,,$,,1/80;print qq x\bxx((@;+@|)*$|++),@:[@|,@;],!@;&&$/}  __END__
Just another Perl Hacker,### http://home.pacific.net.au/~djames.hub


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

Date: 7 Nov 2001 20:30:47 GMT
From: lvirden@cas.org
Subject: Dealing with Data::Dumper
Message-Id: <9sc5ln$2dn$1@srv38.cas.org>

I am seeing the following behavior:

 $ perl -e "use Data::Dumper"
Data::Dumper object version 2.103 does not match $Data::Dumper::VERSION 2.12 at /volws/lwv26/ldatae/lib/perl5/5.7.2/sun4-solaris-stdio/XSLoader.pm line 97.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
lwv26awu (45242) $ cpan
Undefined value assigned to typeglob at (eval 9) line 12.
Warning [/home/lwv26/.inputrc line 2]:
  Invalid variable `show-all-if-ambiguous'

cpan shell -- CPAN exploration and modules installation (v1.59_56)
ReadLine support enabled

cpan> install Data::Dumper
CPAN: Storable loaded ok
Going to read /home/lwv26/.cpan/Metadata
  Database was generated on Wed, 07 Nov 2001 12:12:04 GMT
Data::Dumper is up to date.

cpan> quit
Lockfile removed.



Since it appears that Data::Dumper is up to date, how do I deal with the
version mis-match?  Thanks!
-- 
"I know of vanishingly few people ... who choose to use ksh." "I'm a minority!"
<URL: mailto:lvirden@cas.org> <URL: http://www.purl.org/NET/lvirden/>
Even if explicitly stated to the contrary, nothing in this posting
should be construed as representing my employer's opinions.


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

Date: 7 Nov 2001 13:30:10 -0800
From: google_news@linisoft.com (Reza Rob)
Subject: force stack dump  after die
Message-Id: <af17817c.0111071330.7a54693f@posting.google.com>

Can someone tell me how I can force a stack dump after each die command?
Do I have to recompile perl  5.6.1?


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

Date: Wed, 07 Nov 2001 20:12:52 GMT
From: Sebastian <esn@ematic.com>
Subject: Help with my FreeShell service
Message-Id: <3BE99588.BFD12778@ematic.com>

Hi all i'm looking for some 1 that's good with Perl and can plz creat
mi a Perl script to AutoAdd users to my FreeBSD Box when i recive
a email like this.

eMail---Start
Below is the result of your feedback form. It was submitted by
() on Wednesday, November 7, 2001 at 09:51:11
---------------------------------------------------------------------------

Your Name: Real name

E-Mail Address: avem@hotmail.com

UserName: mav

Passwd: superme

Use: to teripts i have to make for school

submit: Submit

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

REMOTE_HOST: ncasse02.telenet-ops.be
REMOTE_ADDR: 213.224.83.46
HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)

eMail---End


Ok so this is how i whant it to work

The user fills out the form, when user Submits the form is sends the
form
info to a local email like this email.the perl script runs crontab every
5min
and it checks the local eMail and extracts the form fillds Your Name:, 
UserName: and Passwd: and creats the user. 
_________________________
Username:mav
Real name:Real name
Passwd:superme

Shell: /usr/local/bin/bash
Home directory: /home/fshell/mav
Group: fshell
--------------------------------------------------


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

Date: Wed, 07 Nov 2001 20:21:51 GMT
From: "Jessica Bull" <jessica.bull@broadwing.com>
Subject: Re: Help with my FreeShell service
Message-Id: <zJgG7.92529$tb2.7319422@bin2.nnrp.aus1.giganews.com>

is this an offer for contract work?  otherwise, this newsgroup is to HELP
solve problems, not do them for you.


"Sebastian" <esn@ematic.com> wrote in message
news:3BE99588.BFD12778@ematic.com...
> Hi all i'm looking for some 1 that's good with Perl and can plz creat
> mi a Perl script to AutoAdd users to my FreeBSD Box when i recive
> a email like this.
>
> eMail---Start
> Below is the result of your feedback form. It was submitted by
> () on Wednesday, November 7, 2001 at 09:51:11
> --------------------------------------------------------------------------
-
>
> Your Name: Real name
>
> E-Mail Address: avem@hotmail.com
>
> UserName: mav
>
> Passwd: superme
>
> Use: to teripts i have to make for school
>
> submit: Submit
>
> --------------------------------------------------------------------------
-
>
> REMOTE_HOST: ncasse02.telenet-ops.be
> REMOTE_ADDR: 213.224.83.46
> HTTP_USER_AGENT: Mozilla/4.0 (compatible; MSIE 5.01; Windows 98)
>
> eMail---End
>
>
> Ok so this is how i whant it to work
>
> The user fills out the form, when user Submits the form is sends the
> form
> info to a local email like this email.the perl script runs crontab every
> 5min
> and it checks the local eMail and extracts the form fillds Your Name:,
> UserName: and Passwd: and creats the user.
> _________________________
> Username:mav
> Real name:Real name
> Passwd:superme
>
> Shell: /usr/local/bin/bash
> Home directory: /home/fshell/mav
> Group: fshell
> --------------------------------------------------
>




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

Date: Wed, 07 Nov 2001 21:38:01 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Help with my FreeShell service
Message-Id: <slrn9uj7dl.g5d.tadmc@tadmc26.august.net>

Jessica Bull <jessica.bull@broadwing.com> wrote:
>is this an offer for contract work?  otherwise, this newsgroup is to HELP
>solve problems, not do them for you.
>
>
>"Sebastian" <esn@ematic.com> wrote in message
>news:3BE99588.BFD12778@ematic.com...
>> Hi all i'm looking for some 1 that's good with Perl and can plz creat
>> mi a Perl script to AutoAdd users to my FreeBSD Box when i recive
>> a email like this.


And your cutsie English is likely to turn away people too.


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


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

Date: Wed, 07 Nov 2001 21:47:22 GMT
From: "Russell Brooks" <rbbdsb@earthlink.net>
Subject: nmake / dmake Windows 98
Message-Id: <KZhG7.21873$S4.2040415@newsread1.prod.itd.earthlink.net>

Hi,
  I'm running Perl v5.6.1 build 629 on a Windows 98 platform.  I am unable
to successfully run nmake or dmake against some of the modules.  I am trying
to install modules from CPAN via
  perl -MCPAN -e shell
though I am getting similar results from running nmake or dmake manually.
Nmake was pulled from nmake15.exe.  Running nmake on module List::Util I
get:

Microsoft (R) Program Maintenance Utility   Version 1.50
Copyright (c) Microsoft Corp 1988-94. All rights reserved.

cp lib/List/Util.pm blib\lib\List\Util.pm
cp lib/Scalar/Util.pm blib\lib\Scalar\Util.pm
        D:\Perl\bin\Perl.exe -ID:\Perl\lib -ID:\Perl\lib
D:\Perl\lib\ExtUtils/xs
ubpp   -typemap D:\Perl\lib\ExtUtils\typemap -typemap typemap Util.xs >
Util.c




    cl -c  -nologo -O1 -MD -DNDEBUG -DWIN32 -D_CONSOLE -DNO_STRICT -DHAVE_DE
S_FCRYPT -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -DPERL_MSVCRT_READFIX -
O1 -
MD -DNDEBUG    -DVERSION=\"1.06\"  -DXS_VERSION=\"1.06\"  -ID:\Perl\lib\CORE
Util.c
NMAKE : fatal error U1081: 'cl' : program not found
Stop.

To get around it I pulled down dmake.  If I run it against the same module I
get:

DMAKE.EXE:  makefile:  line 778:  Error -- Expecting macro or rule defn,
found neither

I don't have access to a C compiler.  nmake does appear to successfully
compile some modules.  Does anyone have any suggestions?

TIA,
RB




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

Date: Wed, 07 Nov 2001 14:38:09 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: nmake / dmake Windows 98
Message-Id: <3BE9B7D1.279AFBED@vpservices.com>

Russell Brooks wrote:
> 
> Hi,
>   I'm running Perl v5.6.1 build 629 on a Windows 98 platform.  I am unable
> to successfully run nmake or dmake against some of the modules.  I am trying
> to install modules from CPAN via
>   perl -MCPAN -e shell
> though I am getting similar results from running nmake or dmake manually.
> Nmake was pulled from nmake15.exe.  Running nmake on module List::Util I
> get:
> ...
> ubpp   -typemap D:\Perl\lib\ExtUtils\typemap -typemap typemap Util.xs >

In other words, the module has an XS component, i.e. a C componenet.

> I don't have access to a C compiler.  nmake does appear to successfully
> compile some modules.

That's correct.  If the module has XS (C) components, you need a
compiler to make it.  Nmake works only for modules (of which there are
many) without XS components.

-- 
Jeff



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

Date: Wed, 07 Nov 2001 22:02:50 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Opening/creating files
Message-Id: <mbudash-FA9AE7.14025307112001@news.sonic.net>

In article <slrn9ujb1p.1on.mgjv@verbruggen.comdyn.com.au>, 
mgjv@tradingpost.com.au wrote:

> On Wed, 07 Nov 2001 18:10:39 GMT,
> 	Tad McClellan <tadmc@augustmail.com> wrote:
> > G Harper <g.vox@verizon.net> wrote:
> > 
> >>How can I open a file to read from, without truncating it, and creating 
> >>it
> >>if necessary?
> > 
> > 
> > What would be the point of creating an empty file to read from?
> > 
> > You're not going to read much from an empty file.
> > 
> > Anyway (untested):
> > 
> >    unless ( -e $file ) {  # doesn't exist, need to create it...
> >       open FILE, ">$file" or die "could not create '$file' $!";
> >    }
> >    open FILE, $file or die "could not open '$file' for reading  $!";
> 
> Which maybe needs the warning that this contains a race condition, if
> multiple processes could be doing this same thing.
> 
> I'd rather like to see some more explanation on the why of this before
> commetning any further.

good point. i think i would've gone this route:
 
open FILE, "+>>$file"

and then repositioned the file cursor using seek...
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: 7 Nov 2001 13:00:37 -0800
From: nandagopalj@hotmail.com (Nan)
Subject: RE for SQL columns
Message-Id: <8193246.0111071300.39e1a2a5@posting.google.com>

Hello:

Here is a sample perl that I need some help...


$sql =<<EOF;
select 
emp_name, emp_salary,
emp_id
from employee_table where
emP_id = :1
EOF

I need a regular expression to retain the
text from {select} through {from} in the above string. 
Basically the resultant string (after the regular expression)contains
only the columns (i.e. emp_name,emp_salary,empId).

I can have upper and lower cases in select and from while
trying to match them.

Thanks for any help/suggestions..

Nan


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

Date: Wed, 07 Nov 2001 21:23:45 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: RE for SQL columns
Message-Id: <mbudash-36426C.13234807112001@news.sonic.net>

In article <8193246.0111071300.39e1a2a5@posting.google.com>, 
nandagopalj@hotmail.com (Nan) wrote:

> Hello:
> 
> Here is a sample perl that I need some help...
> 
> 
> $sql =<<EOF;
> select 
> emp_name, emp_salary,
> emp_id
> from employee_table where
> emP_id = :1
> EOF
> 
> I need a regular expression to retain the
> text from {select} through {from} in the above string. 
> Basically the resultant string (after the regular expression)contains
> only the columns (i.e. emp_name,emp_salary,empId).
> 
> I can have upper and lower cases in select and from while
> trying to match them.
> 
> Thanks for any help/suggestions..
> 
> Nan

for your data ($sql), plus some safety precautions:

($columns) = $sql =~ /^select\s*\n\s*(.+?)\s*\n\s*from /isg;
# if you really want no spaces in the resultant string:
$columns =~ s/\s//sg;
 
hth-
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Wed, 07 Nov 2001 21:38:02 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: RE for SQL columns
Message-Id: <slrn9uj7l2.g5d.tadmc@tadmc26.august.net>

Nan <nandagopalj@hotmail.com> wrote:
>
>
>$sql =<<EOF;
>select 
>emp_name, emp_salary,
>emp_id
>from employee_table where
>emP_id = :1
>EOF
>
>I need a regular expression to retain the
>text from {select} through {from} in the above string. 


   $sql =~ s/select(.*?)from.*/$1/is;


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


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

Date: Wed, 7 Nov 2001 12:34:52 -0800
From: "Brian Helterline" <brian_helterline@hotmail.com>
Subject: Re: Reading series of files on Client's computer with loop
Message-Id: <9sc5tg$25p$1@hpcvnews.cv.hp.com>


"Etal" <colorful_98@yahoo.com> wrote in message
news:370bfd7.0111070628.ceb0e7d@posting.google.com...
> I want to be able to upload a series of small icons from the client's
> computer. Each file is named icon1.gif, icon2.gif...
>
> A multipart form asks the user to locate the file "icon" on their
> drive (without extension), then a loop ads the "1.gif, 2.gif..." to
> the file.
>
> By Perl does not accept the file name as a valid file on the client's
> drive. Any idea of how to do that?
>
> Here is the script I use:
>
> use CGI qw/:standard/;
> use CGI::Carp qw/fatalsToBrowser/;
> my $file = param('file');
> my $fn = $file;
> $fn =~ s,^.*(\\|/)(.+)$,$2,; # Extract filename from client path.
> if($fn ne "icon") { die "'$fn' is NOT the file I need here.";}
>
> # Assign name to files on Client machine
> for ($a = 1; $a < 13; $a++) {
> $file_up = "$file$a.gif";
> $fn_up = "$fn$a.gif";
>
> if (ref $file_up) {

$file_up is not a reference so this test always fails

>              # read file
>   } else {
>      # error reading file
>         }
> }
>
> I get error reading file...




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

Date: Wed, 7 Nov 2001 11:45:18 -0800
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: split into words, find in table
Message-Id: <3be98f61$1@news.microsoft.com>

"Pokerface" <paul@xpand.nl> wrote in message
news:3bea255f.774427147@news.zwoll1.ov.nl.home.com...
> I'm tryng to find / make a script that does the following, but can't
> figure out what to do....
>
> I'd like to compare words in a string (from a DB record) to another
> table (word, description). If a word from the first record equals a
> word in the second table, it has to retrun the description.
>
> The sencentences from the first string have to splitted into words.

Rough and untested:
%description =
               (word1 => 'descr1',
                 word2 => 'descr2',
                 word3 => 'descr3',
                 .....);
$_ =  $mystring;
foreach (split) { #look at each word from the original string individually
    # you may want to do some normalization of $_ here,
    # e.g. make all characters lower case, remove digits and special
characters, etc.
    if exists(%description{$_}) { #If there is a description for this word
        return "Word $_ found, description is $description{$_}\n";
    } else { # if there is no description for this word
        return "Word $_ not found\n";
    }

jue




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

Date: Wed, 07 Nov 2001 20:54:49 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: split into words, find in table
Message-Id: <mbudash-B64125.12545107112001@news.sonic.net>

In article <3BE96AE8.14876664@vpservices.com>, Jeff Zucker 
<jeff@vpservices.com> wrote:

> Pokerface wrote:
> > 
> > Hi,
> > 
> > I'm trying to find / make a script that does the following, but can't
> > figure out what to do....
> > 
> > I'd like to compare words in a string (from a DB record) to another
> > table (word, description). If a word from the first record equals a
> > word in the second table, it has to return the description.
> > 
> > The sentences from the first string have to split into words.
> > 
> > First table:
> > Content
> > -----------
> > Content_Id
> > Content_text
> > 
> > Second table:
> > WordsDescription
> > --------------------
> > WD_Id
> > WD_Word
> > WD_Desc
> > 
> 
> use DBI;
> #... connect to the db
> my $sth = $dbh->prepare(qq~
>     SELECT Content_text, WD_Desc
>       FROM Content, WordsDescription
>      WHERE Content.Content_text = WordsDescription.WD_Desc
> ~);

this does not do what the o.p. asked. this comes closer, at least in 
mysql:

my $sth = $dbh->prepare(qq~
  SELECT Content_text, WD_Word, WD_Desc
    FROM Content c, WordsDescription w
   WHERE c.Content_text
         REGEXP CONCAT('(^|[[:space:]])', w.WD_Word, '([[:space:]]|$)')
~);

but still doesn't take care of multiple occurences of a word in a 
record, words surrounded by punctuation, etc.
 
i doubt it can be done using only sql, but i'd love to be proven wrong!
 
hth-
michael
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Wed, 07 Nov 2001 14:55:24 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: split into words, find in table
Message-Id: <3BE9BBDC.D766AAA7@vpservices.com>

Michael Budash wrote:
> 
> In article <3BE96AE8.14876664@vpservices.com>, Jeff Zucker
> <jeff@vpservices.com> wrote:
> 
> > Pokerface wrote:
> > >
> > > I'm trying to find / make a script that does the following, but can't
> > > figure out what to do....
> > >
> > > I'd like to compare words in a string (from a DB record) to another
> > > table (word, description). If a word from the first record equals a
> > > word in the second table, it has to return the description.
> > >
> > > The sentences from the first string have to split into words.
> > >
>
> > [snip my poor example]
>
> this does not do what the o.p. asked.

Ooops, right, I missed the line about splitting the string into words.
(admitedly a rather major thing to miss :-))

> i doubt it can be done using only sql, but i'd love to be proven wrong!

Well, a combo of perl and SQL.  Given two CSV tables:

  Content_Id,Content_text
  1,Just Another Perl Hacker

  WD_Id,WD_Word,WD_Desc
  1,Perl,thanks Larry
  2,Hacker,not a guru

The script below prints out:

  Just Another Perl (thanks Larry) Hacker (not a guru) 

# connect to db
# ...
my $sth1 = $dbh->prepare(qq~
    SELECT Content_text FROM Content
~);
my $sth2 = $dbh->prepare(qq~
    SELECT WD_Desc FROM WordsDescription WHERE WD_Word = ?
~);
$sth1->execute;
while (my $row = $sth1->fetch) {
    for my $word( split /\s+/, $row->[0] ) {
        $sth2->execute($word);
        my $desc = '';
        while ( my $r = $sth2->fetch ) { $desc = '('.$r->[0].') ' }
        print "$word $desc"
    }
}
__END__

As with your example, the getting of words is quite basic and a better
regex is left as an exercise.

-- 
Jeff



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

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


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