[16334] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3746 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 19 11:05:31 2000

Date: Wed, 19 Jul 2000 08:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964019115-v9-i3746@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 19 Jul 2000     Volume: 9 Number: 3746

Today's topics:
        AND in regexp?? <vwcorrado@my-deja.com>
    Re: AND in regexp?? <aqumsieh@hyperchip.com>
        ANN: yapc::Europe Call For Participation <gellyfish@gellyfish.com>
    Re: CGI.pm question <tony_curtis32@yahoo.com>
    Re: DB_File question. <sumus@aut.dk>
        Event Calendar Script suggestions? <deja@skaught.com>
    Re: Event Calendar Script suggestions? <webslave@NOSPAMfatbones.com>
        french characters <ledruide@fac-simile.com>
    Re: french characters <hump@katz.cc.univie.ac.at>
    Re: HELP: Pattern Match (Keith Calvert Ivey)
    Re: how to delete )) tvn007@my-deja.com
    Re: how to delete )) <bart.lateur@skynet.be>
    Re: How to limit the size of an input field <tony_curtis32@yahoo.com>
    Re: How to limit the size of an input field <wmonk@documentsolutions.com>
    Re: Making a Perl module (M.J.T. Guy)
        Matching a block of data <samara_biz@hotmail.com>
    Re: NEW: AI::NeuralNetwork - idea, comments <newspost@coppit.org>
        Newbie Question - about calendars <laf@gameonline.co.uk>
    Re: Newcomer question on Multithreading In Active Perl  <care227@attglobal.net>
    Re: Newcomer question on Multithreading In Active Perl  nso@manbw.dk
    Re: Perl RTE ? <red_orc@my-deja.com>
        Perl/DBI Select Question amerar@my-deja.com
    Re: Perl/DBI Select Question <gellyfish@gellyfish.com>
    Re: Perl/DBI Select Question newsposter@cthulhu.demon.nl
    Re: Problem with reading values out of an ascii file <buggerm@de.ibm.com>
    Re: Problem with reading values out of an ascii file <foo@bar.va>
    Re: Problem with reading values out of an ascii file (Bernard El-Hagin)
    Re: Problem with reading values out of an ascii file <buggerm@de.ibm.com>
    Re: Problem with reading values out of an ascii file <buggerm@de.ibm.com>
        Read&Modify a Sql File ? rajg@rocketmail.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 19 Jul 2000 13:58:50 GMT
From: VW Corrado <vwcorrado@my-deja.com>
Subject: AND in regexp??
Message-Id: <8l4c6f$lg7$1@nnrp1.deja.com>

Hello,

I am trying to match on multiple keywords and am having trouble with the
regexp to do so.  Let's say the user typed in "vase white", I want to
retrieve all records that contain both vase & white in any order.  I
have tried various things including this:

while (<FILE>) {
  if (m/(vase)+.*(white)+/i) {
    #...do something...
  }
}

This will get the results ONLY if the record contains "vase" and then
"white".  Almost there, but not quite.


--
TIA!
  Richard


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 19 Jul 2000 14:38:29 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: AND in regexp??
Message-Id: <7avgy2i3rt.fsf@merlin.hyperchip.com>


VW Corrado <vwcorrado@my-deja.com> writes:

> I am trying to match on multiple keywords and am having trouble with the
> regexp to do so.  Let's say the user typed in "vase white", I want to
> retrieve all records that contain both vase & white in any order.  I
> have tried various things including this:
> 
> while (<FILE>) {
>   if (m/(vase)+.*(white)+/i) {
>     #...do something...
>   }
> }
> 
> This will get the results ONLY if the record contains "vase" and then
> "white".  Almost there, but not quite.

The simplest solution would be to use two regexps:

	if (/vase/ and /white/) {
		# do stuff
	}

--Ala


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

Date: 19 Jul 2000 17:13:19 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: ANN: yapc::Europe Call For Participation
Message-Id: <8l4k2v$3om$1@orpheus.gellyfish.com>


			       European
		     Yet Another Perl Conference
			  YAPC::Europe 19100

		     http://www.yapc.org/Europe/

	       Friday to Sunday, September 22-24, 2000
				at the
		    Institute of Contemporary Arts
			      London, UK

	     *** Abstract Deadline : August 11, 2000 ***

YAPC::Europe is an inexpensive (40 pounds/person) Perl users and
developers conference, with tutorials and technical talks. The
conference is set in central London, down the road from Buckingham
Palace, although we are reliably informed that Her Royal Highness will
"probably not" attend.  The theme of the conference is "The Art of
Perl", with a track on Saturday dedicated to the topic of creating old
media and new with Perl, as well as looking at Perl as an art form.

All are welcome to this grassroots conference, to learn and share in
the benefits of belonging to the Perl community.

Many well-known Perl developers and authors will be there:

 - Randal Schwartz: co-author of "Learning Perl" and professional trainer.
 - Graham Barr: author of the IO::* and Net::* modules, including
   Net::LDAP.
 - Tim Bunce: author of "Programming the Perl DBI" and the DBI database
   interface module.
 - Andreas Koenig: one of the CPAN wizards.
 - Nick Ing-Simmons: author of the Perl/Tk system.

  ... and YOU!

We are looking for tutors and speakers at YAPC::Europe.  Presentations
will be:

  TUTORIALS: 3 hours (half-day) or 6 hours (full-day).
  LONG TALKS: 40 minutes.
  SHORT TALKS: 25 minutes.
  LIGHTNING TALKS: 5 minutes.

If you wish to make a presentation, we will need to know:

  Type of talk (tutorial, long, short, or lightning)
  Title
  A 200-300 word abstract
  One or two sentences on you and your affiliation
  Whether you will have course notes or other materials if
    you are proposing a tutorial
  Any special presentation needs (e.g., you can only talk in
    Hindi Sign Language with the aid of a UN-trained fruitbat)

Mail this to:

  euro-speakers@perltoys.com

in plain ASCII text (strictly no Microsoft Word or HTML) by August 11,
2000.  We would like that your materials be available online, but it
is not required.

Topics are unlimited, but some suggestions include:

 * ART!  (Music, dance, poetry, mime, ...)
 * Text processing (XML, regular expressions)
 * Perl and the Web (CGI, HTML, mod_perl)
 * Databases (DBI, Access, replication, administration)
 * Graphics (Tk, GTk, controlling 3rd party software)
 * Scientific computing (PDL, distributed computation)
 * Practical Perl Programming
 * Module guts and usage of any particular module
 * Visionary or position papers on Perl
 * Anything cool :)

Because YAPC::Europe is about producing the biggest communal bang for
smallest attendee buck, there is no financial compensation for
presenting.  Tutors and speakers will, however, be richly rewarded
with the appreciation of their fellow Perl programmers which the
canny will be able to convert into beer.

Any questions about the conference should be directed to:
  european-yapc@othersideofthe.earth.li
-- 
yapc::Europe in assocation with the Institute Of Contemporary Arts
   <http://www.yapc.org/Europe/>   <http://www.ica.org.uk>


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

Date: 19 Jul 2000 09:48:00 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: CGI.pm question
Message-Id: <87ya2yfa73.fsf@limey.hpcc.uh.edu>

>> On Wed, 19 Jul 2000 03:18:13 GMT,
>> joelnet1@my-deja.com said:

> I need to take the variables from a submitted form and
> create formatted html output from those vars.

> I don't want to have to translate let them like this:
> $firstname = param("firstname");

> in order to use them because there are over 100 vars on
> the form I'm working with.

Use param() (no argument) to get the list of all
parameters in the form and then iterate over them.

    perldoc CGI

Or use the import methods.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: 19 Jul 2000 15:34:06 +0200
From: Jakob Schmidt <sumus@aut.dk>
Subject: Re: DB_File question.
Message-Id: <1z0qgs6o.fsf@macforce.sumus.dk>

Nico Zigouras <zigouras@mail.med.upenn.edu> writes:

> As far as I know, you can't use data structures in a tied DB_file hash,
> right?  You can only use strings, right?  When I tried to use an array as
> a value strict gave me an error.

That's right. Reference values wil be stringified by any of the DBM modules.

MLDBM from CPAN is a wellknown and well tested module for storing multi level
data structs in DBM.

My own DWH_File (also from CPAN) is more powerful than MLDBM, but it's quite
unknown and not thouroughly tested. If you try it I'd like to hear any comments
you might have. But don't use it for anything critical - it's very beta...

> dbmopen( my %db, "test.db", 0666 ) || die($!);
> $db{name} = "john";
> dbmclose %db;

The dbmopen() interface to DBM still works but is somewhat deprecated. Use
tie() in stead:

use DB_File;
tie( %db, 'DB_File' ) or die "$!"; # see docs for more option
 ...
untie %db;

Check out

perldoc -f tie
and
man DB_File

-- 
Jakob


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

Date: Wed, 19 Jul 2000 13:49:10 GMT
From: Scott <deja@skaught.com>
Subject: Event Calendar Script suggestions?
Message-Id: <8l4bkf$l0j$1@nnrp1.deja.com>

I'm looking for a script that will let users (preferrably authorized
users) add events to a monthly calendar.  Does anyone have any
suggestions?

Thanks, I appreciate your help.  If you could email me too in case I
miss the public post that would be great.

Scott




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 19 Jul 2000 14:17:06 GMT
From: "Carson" <webslave@NOSPAMfatbones.com>
Subject: Re: Event Calendar Script suggestions?
Message-Id: <CLid5.3$Fw.855@typhoon-news1.southeast.rr.com>

Scott,
I use
http://www.mattkruse.com/scripts/calendar/index.html
its a but fussy getting all the subdirectories with the appropriate
authorities, (on some hosts even though I changed it with ftp, I still had
to get the unix admin to change it) but once that was all worked out it
seems pretty bulletproof.
one word of caution, once you install it, write down the password &
username, even if you're just trying it out, it is tedious to reset it
later.
HTH
Carson
www.ccstools.com


"Scott" <deja@skaught.com> wrote in message
news:8l4bkf$l0j$1@nnrp1.deja.com...
> I'm looking for a script that will let users (preferrably authorized
> users) add events to a monthly calendar.  Does anyone have any
> suggestions?
>
> Thanks, I appreciate your help.  If you could email me too in case I
> miss the public post that would be great.
>
> Scott
>
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.




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

Date: Wed, 19 Jul 2000 10:35:20 -0400
From: "Hervé ledruide Ségard" <ledruide@fac-simile.com>
Subject: french characters
Message-Id: <q_id5.5589$EA1.329232@news.total.net>

    We have an application which use perl to talk to an Oracle database.
All our french characters are weirdly translated.
é becomes i
è becomes h ....and so on.

Talking to the database via sqlplus works great....Are we missing something
in the perl cgi or configuration ?




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

Date: 19 Jul 2000 14:43:23 GMT
From: Peter Marksteiner <hump@katz.cc.univie.ac.at>
Subject: Re: french characters
Message-Id: <8l4eqb$37pa$1@www.univie.ac.at>

"Hervé ledruide Ségard" <ledruide@fac-simile.com> wrote:
:     We have an application which use perl to talk to an Oracle database.
: All our french characters are weirdly translated.
: é becomes i
: è becomes h ....and so on.

: Talking to the database via sqlplus works great....Are we missing something
: in the perl cgi or configuration ?

Probably $ENV{NLS_LANG} = 'AMERICAN_AMERICA.WE8ISO8859P1';

   Peter

-- 
Peter Marksteiner
Vienna University Computer Center


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

Date: Wed, 19 Jul 2000 12:25:17 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: HELP: Pattern Match
Message-Id: <39779dc3.36513145@news.newsguy.com>

I wrote, without sufficient testing:

>  $address =~ s/\bstr?(?:\b|\.)/Street/gi;

Make that

   $address =~ s/\bstr?\b\.?/Street/gi;

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)


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

Date: Wed, 19 Jul 2000 13:33:49 GMT
From: tvn007@my-deja.com
Subject: Re: how to delete ))
Message-Id: <8l4ans$ke3$1@nnrp1.deja.com>

No, it does not work because I use

$/=")";

Also, I am not allow to use "chomp"

Please let me know if can you come up with any other solution.

Thanks,

In article <8l3nuh$3jjcp$1@ID-36965.news.cis.dfn.de>,
  "mike solomon" <mike.solomon@eps.ltd.uk> wrote:
> would this work for you ?
>
> my $foo = "aaa))ggg";
>
> $foo =~ s/\)\)//;
>
> print "$foo\n";
>
> this strips the ))
>
> Regards
>
> Mike Solomon
>
> <tvn007@my-deja.com> wrote in message
news:8l3gtl$2bd$1@nnrp1.deja.com...
> > Hi,
> >
> > I have tried so many way but I cannot delete this characters ))
> >
> > Example: I have the file as shown below:
> >
> >
> >
> > (ab
> >   c)
> > (xyx)
> > (zzz)
> > ))
> >
> > #my script has:
> >
> > $/ =")";
> >
> > How can I delete the )) in the file above. The )) is always
> > at the end of file.
> >
> > Thanks in advance
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 19 Jul 2000 14:11:35 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: how to delete ))
Message-Id: <d3cbns8gn62r95hcgmccd8rvfqsk8crh45@4ax.com>

tvn007@my-deja.com wrote:

>I have tried so many way but I cannot delete this characters ))

>#my script has:
>
>$/ =")";
>
>How can I delete the )) in the file above. The )) is always
>at the end of file.

The reason why you're having trouble, is because of $/ that is set to
")". This means that your "))" data will be spread of two "lines".

It looks like your parentheses will have to be balanced anyway. Why not
make use of that?

	$/ = ")";
	my $nest = 0;
	while(<DATA>) {
	    s!([\(\)])!
	        if($1 eq "(") {
	            $nest++;
	            $1;
	        } else {
	            --$nest >= 0 and $1;
	        }
	      !ge;
	    print;
	}

-- 
	Bart.


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

Date: 19 Jul 2000 09:50:52 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How to limit the size of an input field
Message-Id: <87vgy2fa2b.fsf@limey.hpcc.uh.edu>

>> On Wed, 19 Jul 2000 20:12:40 +0800,
>> "Harry" <harris@rock.upnaway.com> said:

> in a post form is there a way to get a script to give an
> error msg if the entry is to long

Yes, if you suitably define "too long".

perldoc -f length

but the perl relevance is tangential at best.  I'd try the
comp.infosystems.www.authoring.cgi newsgroup for more
info.

hth
t
-- 
"With $10,000, we'd be millionaires!"
                                           Homer Simpson


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

Date: Wed, 19 Jul 2000 07:59:45 -0700
From: "Monk" <wmonk@documentsolutions.com>
Subject: Re: How to limit the size of an input field
Message-Id: <snbghi4q6tt99@corp.supernews.com>


"Young" <noemail@noemail.com> wrote in message
news:3975A521.274BF060@noemail.com...
> In a HTML text box, you can use the MAXLENGTH property. You can't type
beyond
> the specified number of characters.
>
> Example: <INPUT TYPE="text" NAME="variablename" MAXLENGTH=15>
>

You may also want to try:

$CGI::POST_MAX at the beginning of the cgi script. Check out this link

http://stein.cshl.org/~lstein/


> Harry wrote:
>
> > in a post form is there a way to get a script to give an error msg if
the
> > entry is to long
>




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

Date: 19 Jul 2000 13:26:12 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Making a Perl module
Message-Id: <8l4a9k$171$1@pegasus.csx.cam.ac.uk>

Alex T. <samara_biz@hotmail.com> wrote:
>
>I'm having troubles getting a function in a module work. I've read
>perldocs, but it didn't help me. I thought I did everything what perldoc
>tells to do to make a module. Here's my code:

Try again using -w.    It'll tell you several things that are wrong.

For example, where is $response set?


Mike Guy


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

Date: Wed, 19 Jul 2000 10:02:13 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Matching a block of data
Message-Id: <3975B4E5.C4E183C7@hotmail.com>

Hi,

I need to match the following block of data (inside the delimiters).
I need $1 to hold what's in name field, $2 - filename, and $3 - some
data.

-------------------------------------------------
Content-Disposition: form-data; name="my_file";
filename="C:\WINNT\Profiles\ecpjm\Desktop\delete_this.txt"
Content-Type: text/plain

Some data
--------------------------------------------------

Could anyone help me?

Thanks!!!

Alex



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

Date: Wed, 19 Jul 2000 09:42:36 -0400
From: David Coppit <newspost@coppit.org>
Subject: Re: NEW: AI::NeuralNetwork - idea, comments
Message-Id: <Pine.GSO.4.21.0007190940100.2094-100000@mamba.cs.Virginia.EDU>

On 19 Jul 2000, Ilmari Karonen wrote:

> In article <8l3moa$7b2$1@nnrp1.deja.com>, peterhi@my-deja.com wrote:
> >AI::NeuralNetwork::BackProp perhaps and then we can extend the base name
> 
> That's not going to win a golf contest.  Surely something shorter
> would work just as well..
> 
>   AI::NeuralNet::BackProp?
>   AI::Neural::BackProp?
>   AI::Neural::BP?

Please, NOOO! Most of the lifetime of software is spent in maintenance. That
is, more people will be reading code that writing it. Make the little
investment of typing the extra characters so that people later on will know
what the heck you're talking about.

David (who's tired trying to decipher variables with names like "x", "xx",
"Decl", "Obstack", and "cov_lst".)



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

Date: Wed, 19 Jul 2000 15:56:52 +0100
From: "Neil Lathwood" <laf@gameonline.co.uk>
Subject: Newbie Question - about calendars
Message-Id: <964018930.15862.0.nnrp-10.c246f12b@news.demon.co.uk>

Hi Folks, I know this is being covered in a different post but I have a bit
of a different question.

In my cgi script if I run:

#!/usr/bin/perl

print "content-type:text/html\n\n";

@fini = `cal 12 2000`;

print "@fini";

it prints out the date's fine but what I want to do is format the date into
a table, the problem I have is that the output produced by the calendar
contains a lot of spaces, how do I go about removing those spaces but still
keeping the dates in the correct order. Hope I have explained myself
correctly and many thanks to anyone that responds back.

Neil







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

Date: Wed, 19 Jul 2000 09:53:44 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Newcomer question on Multithreading In Active Perl MSWin32
Message-Id: <3975B2E8.F7BF1B5B@attglobal.net>

Alexei P Lisitsa wrote:
> 
> 
> I run   "perl ttt.pl" where ttt.pl is as follows( simple example from a
> tutorial on threads):
> ---------------------------------------------------------------------------------
> 
> use Thread;
> $thr = new Thread \&sub1;
>  sub sub1 {
>         print "In the thread\n";
>     }
> ------------------------------------------------------------------------------------
> 
> I've got a diganostic: "No threads in this perl at ttt.pl line 2".
> 

IIRC, threading is not included in the perl build by default.  That 
feature is a build time option.  Since you probably got a binary, 
you probably got the defaults only.


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

Date: 19 Jul 2000 16:52:33 +0200
From: nso@manbw.dk
Subject: Re: Newcomer question on Multithreading In Active Perl MSWin32
Message-Id: <uem4qnpe6.fsf@S4RA.i-did-not-set--mail-host-address--so-shoot-me>

Drew Simonis <care227@attglobal.net> writes:

> IIRC, threading is not included in the perl build by default.  That 
> feature is a build time option.  Since you probably got a binary, 
> you probably got the defaults only.

Are there any prebuilt binaries out there with 5.005 threading enabled?

ActivePerl seems to have interpreter threads enabled. How is this feature
accessed?

Thanks,
-- 
Niels Skou Olsen, M.Sc.
Intelligent Engine, R&D
MAN B&W Diesel A/S
mailto://nso@manbw.dk


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

Date: Wed, 19 Jul 2000 13:30:48 GMT
From: Rodney Engdahl <red_orc@my-deja.com>
Subject: Re: Perl RTE ?
Message-Id: <8l4ai8$k5e$1@nnrp1.deja.com>

In article <8l3vpu$bpb$1@gxsn.com>,
  "James Goodwill" <james@goodwill.globalnet.co.uk> wrote:

>
> How can I install just the bits I need to get Perl up-and-running,
> i.e. a runtime environment? Or am I looking at compiling the Perl
> code?
>


Check out perl2exe from dynamicstate.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 19 Jul 2000 14:21:45 GMT
From: amerar@my-deja.com
Subject: Perl/DBI Select Question
Message-Id: <8l4dh4$mop$1@nnrp1.deja.com>



Hello,

Simple question here.  I cannot figure out how to return multiple
results.  If my select statement returns 5 rows, how can I check each
value that is being returned?  Do they get returned into an array or do
I execute multiple selects??  I need an example....

Please cc a copy of amerar@ci.chi.il.us

Thanks,

Arthur
amerar@ci.chi.il.us


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Wed, 19 Jul 2000 14:42:17 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Perl/DBI Select Question
Message-Id: <d7jd5.455$Px6.44604@news.dircon.co.uk>

On Wed, 19 Jul 2000 14:21:45 GMT, amerar@my-deja.com Wrote:
> 
> 
> Hello,
> 
> Simple question here.  I cannot figure out how to return multiple
> results.  If my select statement returns 5 rows, how can I check each
> value that is being returned?  Do they get returned into an array or do
> I execute multiple selects??  I need an example....
> 

The usual idiom is something like :

while ( my $row = $sth->fetch )
{
   # do something with reference to array of single row
}

> Please cc a copy of amerar@ci.chi.il.us

Nah, you put it in the reply-to address for that.

/J\


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

Date: 19 Jul 2000 14:41:14 GMT
From: newsposter@cthulhu.demon.nl
Subject: Re: Perl/DBI Select Question
Message-Id: <8l4ema$4ah$1@internal-news.uu.net>

amerar@my-deja.com wrote:

> Simple question here.  I cannot figure out how to return multiple
> results.  If my select statement returns 5 rows, how can I check each
> value that is being returned?  Do they get returned into an array or do
> I execute multiple selects??  I need an example....

Check the documentation for DBI. Somewhere around line 225 under the
'Outline Usage' section.

Erik



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

Date: Wed, 19 Jul 2000 15:15:11 +0200
From: Sven <buggerm@de.ibm.com>
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <3975A9DE.EBA12FB6@de.ibm.com>

Bernard El-Hagin wrote:

> On Wed, 19 Jul 2000 12:49:26 GMT, Bernard El-Hagin
> <bernard.el-hagin@lido-tech.net> wrote:
> >On Wed, 19 Jul 2000 14:18:06 +0200, Sven <buggerm@de.ibm.com> wrote:
> >>Hi !
> >>I want to extract a formula out of a ascii file end evaluate it:
> >>something like this:
> >>#
> >>saddwefwef fwefewrrr 3+4 fsdre wfefa
> >>#
> >>i want to extrakt 3+4 into a variable and print out the result: 7
> >
> >$_ = "saddwefwef fwefewrrr 3+4 fsdre wfefa";
> >($a) = $_ =~ m/^D*(\d+\s*.\s*\d+)\D*$/;
>                 ^^^
> Typo. That "D" should be "\D".
>
> Bernard
> --
> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'

Thanks for the answer,
in fact i'm having little trouble in understanding what it means !
and it won't work either!




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

Date: Wed, 19 Jul 2000 15:23:02 +0200
From: Marco Natoni <foo@bar.va>
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <3975ABB6.60AFD71E@bar.va>

Anno,

Anno Siegel wrote:
>> lets say the formula begins with a keyword like %3+4% i tried 
>> eval and it works fine for a variable like $var=3+4; but how can 
>> i take it out of the string ?
> Well, that's what Marcus 

  "Marcus"? :)

> was driving at with his remark about having to "know the pattern" 
> of the formula.  Only you can tell what sorts of formulas can 
> appear and how they can be separated from the background noise.

 ...and the immediate consequence is that he will be able to retrieve the
pattern and thus, with a fast reading of the manual, he will also be
able to solve his problem. ;)


	Best regards,
		Marco


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

Date: Wed, 19 Jul 2000 13:32:04 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <slrn8nbb5t.6r.bernard.el-hagin@gdndev25.lido-tech>

On Wed, 19 Jul 2000 15:15:11 +0200, Sven <buggerm@de.ibm.com> wrote:
>Bernard El-Hagin wrote:
>
>> On Wed, 19 Jul 2000 12:49:26 GMT, Bernard El-Hagin
>> <bernard.el-hagin@lido-tech.net> wrote:
>> >On Wed, 19 Jul 2000 14:18:06 +0200, Sven <buggerm@de.ibm.com> wrote:
>> >>Hi !
>> >>I want to extract a formula out of a ascii file end evaluate it:
>> >>something like this:
>> >>#
>> >>saddwefwef fwefewrrr 3+4 fsdre wfefa
>> >>#
>> >>i want to extrakt 3+4 into a variable and print out the result: 7
>> >
>> >$_ = "saddwefwef fwefewrrr 3+4 fsdre wfefa";
>> >($a) = $_ =~ m/^D*(\d+\s*.\s*\d+)\D*$/;
>>                 ^^^
>> Typo. That "D" should be "\D".
>>
>> Bernard
>> --
>> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
>> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
>
>Thanks for the answer,
>in fact i'm having little trouble in understanding what it means !
>and it won't work either!

It worked for me. Make sure you copied it correctly (copy and paste is
your friend) and make the change as above and it will work.

Bernard
--
perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'


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

Date: Wed, 19 Jul 2000 15:36:35 +0200
From: Sven <buggerm@de.ibm.com>
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <3975AEE3.412915B0@de.ibm.com>

Anno Siegel wrote:

> Sven  <buggerm@de.ibm.com> wrote in comp.lang.perl.misc:
> >Marco Natoni wrote:
> >
> >> Sven,
> >>
> >> Sven wrote:
> >> > I want to extract a formula out of a ascii file end evaluate
> >> > it: something like this:
> >> > #
> >> > saddwefwef fwefewrrr 3+4 fsdre wfefa
> >> > #
> >> > i want to extrakt 3+4 into a variable and print out the result: 7
> >>
> >>   You must know the pattern of the formula or how to recognize it in the
> >> given text.  Then, you can use the /eval/ subroutine.
> >>
> >>         perldoc perlre
> >>         perldoc -f eval
> >>
> >>         Best regards,
> >>                 Marco
> >
> >Thanks for the answer
> >lets say the formula begins with a keyword like %3+4%
> >i tried eval and it works fine for a variable like $var=3+4;
> >but how can i take it out of the string ?
>
> Well, that's what Marcus was driving at with his remark about having to
> "know the pattern" of the formula.  Only you can tell what sorts of
> formulas can appear and how they can be separated from the background noise.
> A single, made-up example just isn't enough to tell.
>
> Anno
> --
> "Its not bad design, its a cgi script!"

Thanks, i'll try to be more precisly
it's a file full of text
and anywhere can stand a formula within %formula%
i can read strings out of the file and parse them find the keyword
then reassemble the words to a formula and use the eval function.
Problem: my perl knowledge is not that big and coding the above
will take many lines for me i just wanted to know if there is a easy way
to take out the formula and evaluate it.

Best Regards,
Sven




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

Date: Wed, 19 Jul 2000 15:43:08 +0200
From: Sven <buggerm@de.ibm.com>
Subject: Re: Problem with reading values out of an ascii file
Message-Id: <3975B06C.80928E6A@de.ibm.com>

Bernard El-Hagin wrote:

> On Wed, 19 Jul 2000 15:15:11 +0200, Sven <buggerm@de.ibm.com> wrote:
> >Bernard El-Hagin wrote:
> >
> >> On Wed, 19 Jul 2000 12:49:26 GMT, Bernard El-Hagin
> >> <bernard.el-hagin@lido-tech.net> wrote:
> >> >On Wed, 19 Jul 2000 14:18:06 +0200, Sven <buggerm@de.ibm.com> wrote:
> >> >>Hi !
> >> >>I want to extract a formula out of a ascii file end evaluate it:
> >> >>something like this:
> >> >>#
> >> >>saddwefwef fwefewrrr 3+4 fsdre wfefa
> >> >>#
> >> >>i want to extrakt 3+4 into a variable and print out the result: 7
> >> >
> >> >$_ = "saddwefwef fwefewrrr 3+4 fsdre wfefa";
> >> >($a) = $_ =~ m/^D*(\d+\s*.\s*\d+)\D*$/;
> >>                 ^^^
> >> Typo. That "D" should be "\D".
> >>
> >> Bernard
> >> --
> >> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
> >> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'
> >
> >Thanks for the answer,
> >in fact i'm having little trouble in understanding what it means !
> >and it won't work either!
>
> It worked for me. Make sure you copied it correctly (copy and paste is
> your friend) and make the change as above and it will work.
>
> Bernard
> --
> perl -e '${qq=\x22=}=qq=\053=;$_="BeJUST_ANOTHERnaPERL_HACKERd\n";
> ${qq=\x2c=}=qq=\x72=;print split /[AC-Z_]$"/;'

Thanx worked fine
i got your reply with the typo correction to late (should refresh more
often)





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

Date: Wed, 19 Jul 2000 13:34:42 GMT
From: rajg@rocketmail.com
Subject: Read&Modify a Sql File ?
Message-Id: <8l4apg$keh$1@nnrp1.deja.com>

Hi,

   I have a Sqlfile which creates tables/Indexes  and the
file has statements like this:

*****
create table EMP_TAB {
            OID int not null,
            Name varchar(255) null,
            ....
        }
        storage (initial 5 m  next 1 m pctincrease 50) tablespace
empdata;
*****

    (There are over 200 create table statements in this file).

    The problem i have is to change the  values(initial, next ..) of the
"storage" statement  for each  Table.  I need
to read a config file and pick up the values for initial, next
and pctincrease for each table and then change it in the sql script.

For eg:  the config file would be typically like this:
TABLE_NAME    Initial    Next    PctIncrease
---------------------------------------------
EMP_TAB       10 m       5 m       10
 ....  ......


 Any hints on the perl script?  I have been trying to work it out as
follows ..

****
open(SQLFILE, "sqlfilename") || die "cannot open sqlfile \n"; open
(CFGFILE, "configfilename") || die "cannot open config file \n"; while
(<SQLFILE>)
{
  chomp;
  if (/create \s+ table/)
  {
      my $tab = $_ ;
      $line = <SQLFILE>  until ( ($line =~ /storage/) || ($line =~ /;/)
);       if ($line =~ /storage/)
      {
        $line =~ /storage \s+ initial (\d+) k next (\d+) k pctincrease
(\d+))/;         my $initial = $1;
        my $next = $2;
        my $pcti = $3;
        $tab =~ /create table (\w+) \(/ ;
        my $TABLE_NAME = $1 ;
        @table_data = `grep $TABLE_NAME tbdata` ;
        chomp(@table_data);
        ($tblname,$initial_new,$next_new,$pcti_new,$junk) = split(/
\s+/,@table)

*****

    And here is where i am wondering how do i write the new values back
into the file.  That is how do i modify the values in the file on fly?
Also, is the above approach correct at all?

thanks
raj


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3746
**************************************


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