[22390] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4611 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Feb 23 11:05:53 2003

Date: Sun, 23 Feb 2003 08:05:06 -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           Sun, 23 Feb 2003     Volume: 10 Number: 4611

Today's topics:
        $SIG{__DIE__} and modules <webmaster@neverseenbefore.com>
    Re: Change a variable <barryk2@SPAM-KILLER.mts.net>
    Re: Chucking up text on word boundaries? (Robert Nicholson)
    Re: compiling perlcc generated c code with gcc <nospam_stigerikson@yahoo.se>
    Re: Creating a variable from 3 other variables (descrip <PleaseDontThrowSpam@Me.com>
    Re: Creating a variable from 3 other variables (descrip <jurgenex@hotmail.com>
    Re: having PERL respond to a key press <usenet_poster_a@tranzoa.com>
        HTML::TokeParser: How to detect a <br> (Francesco Moi)
    Re: map two lists <ubl@schaffhausen.de>
    Re: Need recommendation for e-card program/engine <abigail@abigail.nl>
    Re: parens () <Juha.Laiho@iki.fi>
    Re: parens () <abigail@abigail.nl>
        Problem installing Perl dbd::mysql in Windows XP. Pleas <eleos111@hotmail.com>
    Re: Problems comparing strings <barryk2@SPAM-KILLER.mts.net>
    Re: Religious question: commenting <afterthefall@entropy.muc.muohio.edu>
    Re: Religious question: commenting <peakpeek@purethought.com>
    Re: Simple Pattern Problem? <REMOVEsdnCAPS@comcast.net>
    Re: Simple Pattern Problem? <barryk2@SPAM-KILLER.mts.net>
    Re: Simple Pattern Problem? (Tad McClellan)
    Re: Switch order of sprintf conversions (Gunnar Hjalmarsson)
        Updating a MS Access DB with Perl (casper44)
    Re: Use or not to use modules [was: How do I ...] <abigail@abigail.nl>
    Re: Use or not to use modules (Gunnar Hjalmarsson)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 23 Feb 2003 11:33:33 +0100
From: "Dieter D'Hoker" <webmaster@neverseenbefore.com>
Subject: $SIG{__DIE__} and modules
Message-Id: <b3a82g$1jlhca$1@ID-155251.news.dfncis.de>

I have this perl-gameserver ,
now sometimes it craches and I want autorestart it then ,
so I definded

$SIG{__DIE__} = \&SigDIE;

and in sub SigDIE there is code to restart it if it is an unknow error ,
if $@ =~ some text I use in all MY die statements , it still dies ...

problem is that sig die catches ALL die statement , also those in
eval-blocks ,
in my server I don't use eval blocks that much , and they are only used in a
way i can write my onw die text ,
so I can handle it in sub SigDie ,
but how about the modules I use , is it safe to use this in combination with
those modules  ?

use Config::IniFiles;
use English;
use IO::Select;
use IO::Socket;
use POSIX qw();
use strict;
use Time::HiRes;

Or maybe there is a beter way to do this ?

Would it be safe to eval{} my entire mainloop ? :

sub mainloop {

 while (1) {
   eval{ #mainloopfucntions };
   &Serverrestart() if $@;
 }
}

Can you nest eval's ?

eval{ #blabla eval{#blabbla};  #blabla};

if not that would be a problem cause I use it to make $SIG{ALRM} work in all
cases ...



-- 
Dieter D'Hoker
http://dieter.dhoker.com/
news:free.nl.dieter.dhoker & news:alt.nl.fan.dieter.dhoker
Tetrinet SeRVer : TSRV.COM




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

Date: Sun, 23 Feb 2003 08:24:23 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Change a variable
Message-Id: <MPG.18c2959261f7c98398970f@news.mts.net>


In article <b385fk$t80$1@slb2.atl.mindspring.net>, Lt. 
(LTZ@wewantmore.com) says...
> 
> My apologies, I am very new to this.
> 
> I am trying to stip out the first two
> characters in a variable which is supplied
> in a web form.  Example:
> 
> $Form{'refid'}  would return a value of HK1234567
> I would like to strip out the HK, or the first two
> characters, the result would create another variable,
> and use the new variable for the rest of my script.
> 
> How do I do this?
> 
> Sorry to be such a newbie.
> 
> --
> LTZ
> 
> 

One way to do this is :
    $Form{"refid"} =~ s/^..//;  # strip 1st 2 chars


-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: 23 Feb 2003 07:14:13 -0800
From: robert@elastica.com (Robert Nicholson)
Subject: Re: Chucking up text on word boundaries?
Message-Id: <24a182bd.0302230714.db386a9@posting.google.com>

Well you'd think so wouldn't you. I just commented out the following
lines and try it in a list context.

# get rid of hotmail signature
        s/_{65,}.*//g;
        # get rid of previous message
        s/----- Original Message -----.*//g;
        # get rid of comments
        s/\[\[HTML.*//g;
        push(@text, $_);
        #$lines = wrap('','',@text);
        #@wrappedLines = split(/\n/,$lines);
        @wrappedLines = wrap('','',@text);
        $partIndex = 1;
        foreach $line (@wrappedLines) {
                &emailPart($line,$partIndex);
                $partIndex++;
        }

As far as I'm concerned that doesn't work like the docs describe.

When I do this $wrappedLines[0] has the entire @text in it and
strangely
enough $#wrappedLines = 0

Only when I use the approach that's commented out does it work for me.

Martien Verbruggen <mgjv@tradingpost.com.au> wrote in message news:<slrnb5g2up.2fm.mgjv@martien.heliotrope.home>...
> On 22 Feb 2003 07:03:57 -0800,
> 	Robert Nicholson <robert@elastica.com> wrote:
> 
> [about Text::Wrap::wrap]
> 
> > I haven't checked the source but I thought if you called wrap in a
> > list context that it would return an array.
> 
> Well, the documentation suggest that it does. Quote:
> 
>     @lines = wrap($initial_tab, $subsequent_tab, @text);
> 
> Martien


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

Date: Sun, 23 Feb 2003 10:46:50 +0100
From: stig <nospam_stigerikson@yahoo.se>
Subject: Re: compiling perlcc generated c code with gcc
Message-Id: <b3a5d1$7o4$1@oden.abc.se>

Benjamin Goldberg wrote:

> stig wrote:
> [snip]
>> as gcc begins to parse the c file it generates 4-5 lines of warnings
>> per line c code, and ends in error
>> 
>> this is how the errors and warnings begin
>> myprogram.c:1:20: EXTERN.h: No such file or directory
>> myprogram.c:2:18: perl.h: No such file or directory
>> myprogram.c:3:18: XSUB.h: No such file or directory
> 
> You need to have the perl source installed on your machine to be able to
> compile the output of perlcc... that is where those headers are.
> 
> 


hi again. it seems like the sources solved some of the problems.
an object file is now created, however then gcc complains again.

myprogram.o: In function `perl_init_aaaa':
myprogram.c:3278: undefined reference to `Perl_Gthr_key_ptr'

and so on for other function, spits out a couple of hundred rows

any further hints?

thanks
stig



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

Date: Sun, 23 Feb 2003 13:10:41 -0000
From: "Mikey" <PleaseDontThrowSpam@Me.com>
Subject: Re: Creating a variable from 3 other variables (description of initial errors)
Message-Id: <b3ah7g$4n3$1@wisteria.csv.warwick.ac.uk>

"Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
news:slrnb5g2fl.2fm.mgjv@martien.heliotrope.home...
> On Sat, 22 Feb 2003 13:53:29 -0000,
> Mikey <PleaseDontThrowSpam@Me.com> wrote:
> >
> > "Matija Papec" <mpapec@yahoo.com> wrote in message
> > news:dhue5v44gv4i4gpamcjmgl86vtolr89avp@4ax.com...
> >> X-Ftn-To: Mikey
> >>
> >> "Mikey" <PleaseDontThrowSpam@Me.com> wrote:
> >> >
> >> >If I try the following, I will get errors:
> >> >my $date = "$year$month$day";
> >>
> >> Which error exactly? This should work but as alternative you can use
> >> my $date = $year . $month . $day;
> >> or:
> >> my $date = "${year}${month}${day}";
> >
> >:)
> >
> > Thanks,
>
> You forgot to answer the question posed: Which error do you get when
> using "$year$month$day"?
>

Code used:

my $date = $year$month$day;

Errors given:

Scalar found where operator expected at league line 94, near
"$year$month$day"
    (Missing operator before $month?)
Scalar found where operator expected at league line 94, near
"$year$month$day"
    (Missing operator before $day?)
syntax error at league line 94, near "$year$month$day"
Execution of  aborted due to compilation errors.


On a seperate issue, how can I output these errors to a file so I don't have
to copy them out from my dos-prompt?

Hope you find these errors interesting\confusing!

Thanks,

Mikey


> You should not be getting any error when using that construction, so if
> you do get one, you have a broken perl, and you should fix that.
> Starting to use unnecessarily verbose code because you have a broken
> installation of Perl, or because you don't understand what's going on,
> is silly.
>
> Martien
> --
>                         |
> Martien Verbruggen      | That's not a lie, it's a terminological
>                         | inexactitude.
>                         |




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

Date: Sun, 23 Feb 2003 15:41:20 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Creating a variable from 3 other variables (description of initial errors)
Message-Id: <AY56a.4890$ES3.653@nwrddc04.gnilink.net>

Mikey wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrnb5g2fl.2fm.mgjv@martien.heliotrope.home...
>> You forgot to answer the question posed: Which error do you get when
>> using "$year$month$day"?
> Code used:
> my $date = $year$month$day;

This is not the same code as you showed us in your first posting:

>>>>If I try the following, I will get errors:
>>>>    my $date = "$year$month$day";

The code you showed us in your first posting works fine. That's why everyone
was rather mystified about why you would get an error message at all and
insisted on seeing that error message.
Can you see how is essential it is to copy(!) and paste the exact, actual(!)
code and not to retype it?

> Errors given:
>
> Scalar found where operator expected at league line 94, near
> "$year$month$day"
>     (Missing operator before $month?)
> Hope you find these errors interesting\confusing!

Enlighting and clarifying would be a more accurate term. If you would have
shown us those messages earlier then probably we would have guessed that you
are not showing us the real code.
Thanks for sending everyone on a fool's errand.

jue




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

Date: Sun, 23 Feb 2003 00:40:45 -0800
From: Alex <usenet_poster_a@tranzoa.com>
Subject: Re: having PERL respond to a key press
Message-Id: <mT2dnRf7XY98FMWjXTWc-g@speakeasy.net>

Martien Verbruggen wrote:
> On Sat, 22 Feb 2003 18:27:10 -0800,
> And, if you state that a module, which most people here normally
> recommend, is not doing a good job for you, you should probably justify
> it a bit more than you've done until now. Maybe someone else can confirm
> or deny that Term::ReadKey doesn't work on win98 (within the
> restrictions mentioned in the README file that comes with the module)?
> 
> Do you maybe have some odd installation of Perl?
> 
> Martien

Sorry for the confusion.

Again, on a Win98 system, a newly PPM'd TermReadKey under Active State Perl 
5.6.1 build 633, Term::ReadKey seems to be fine, just fine.

I've no idea why Term::ReadKey did not work back when I needed Term::ReadKey to 
work. But, in my first posting in this thread, I just guessed that the OP may 
have had the same problem that I had had. So, the same solution seemed a likely 
thing to try.

Alex



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

Date: 23 Feb 2003 06:46:07 -0800
From: francescomoi@europe.com (Francesco Moi)
Subject: HTML::TokeParser: How to detect a <br>
Message-Id: <5b829932.0302230646.1e22cedd@posting.google.com>

Hello.

I've got this HTML to parse:

-------------//----------
<A href=foo.html class=title1>
This story<BR>It is the text
</A>
-------------//----

My Perl code:
--------//--------
my $url = $attr->{'href'};
my $class = $attr->{'class'};
my $text = $parser->get_trimmed_text("/a");
--------/----------

And I get:
url = foo.html   [OK]
class = title1   [OK]
text = This storyIt is the text

And I want to get rid of 'This story' or detect <br> in order to 
remove some part of the text.

Is this possible?

By the way, is there any mailing list or forum devoted to 
HTML::TokeParser??

Thank you very much.


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

Date: Sun, 23 Feb 2003 15:34:19 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: map two lists
Message-Id: <b3apca$6s6$1@news.dtag.de>

Malte Ubl wrote:
> my @result = map2 { print "1 -> $_1, 2 -> $_2\n" } @array1, @array2;
> @result = map3 { print "1 -> $_1, 2 -> $_2\n" } (1,1), (2,2);

Obviously, @result will be empty in both cases. Feel free to adopt my 
code, so it will actually return something :)



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

Date: 23 Feb 2003 14:52:05 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Need recommendation for e-card program/engine
Message-Id: <slrnb5ho0l.1au.abigail@alexandra.abigail.nl>

Dave Lahoti (Dave@Lahoti.com) wrote on MMMCDLXIII September MCMXCIII in
<URL:news:ylV5a.2795$uD3.226672803@newssvr21.news.prodigy.com>:
@@  
@@  Hello,
@@  
@@  Does anyone know of a good e-card engine that would work well in a Linux
@@  environment?

This is not the right place to ask for that. This is a news group
about a language, not a group about finding random applications.

@@  Is Perl the best language for this?  Or PHP?

Define "best language". For some people, Perl will be best language.
For most, Perl will not. And some wise people will say "it depends".

@@  It should be comparable to www.JustSayWow.com.

Did you contact them for the code?


Abigail
-- 
$" = "/"; split $, => eval join "+" => 1 .. 7;
*{"@_"} = sub  {foreach (sort keys %_) {print "$_ $_{$_} "}};
%{"@_"} = %_ = (Just => another => Perl => Hacker); &{%{%_}};


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

Date: Sun, 23 Feb 2003 08:27:01 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: parens ()
Message-Id: <b3a0kf$tfu$1@ichaos.ichaos-int>

abigail@abigail.nl said:
>Robert Krueger (racsw@frontiernet.net) wrote on MMMCDLXII September
>MCMXCIII in <URL:news:v5frr523k2r71@corp.supernews.com>:
>][  Robert Krueger wrote:
>][  
>][ >   Why does this work:
>][ >      print (( 2 * 3 ) * 8 );
>][ > 
>][ >   and this doesn't?
>][ >      print ( 2 * 3 ) * 8;
>][  
>][  I receive this warning:
>][  
>][  "Useless use of integer multiplication (*) in void context at
>][  <line #>"
>][  
>][  In C or C++, I would never get a warning for this syntax, but
>][  regardless, the order of precedence remains the same with or
>][  without the parens(), so why does Perl take issue with this?
>
>    $ cat hmm.c
>    # include <stdlib.h>
>    # include <stdio.h>
>
>    int main (int argc, char * argv []) {
>        printf ("%d\n", (2 * 3)) * 8;
>        exit (0);
>    }
>    $ gcc -Wall -o hmm hmm.c
>    $ ./hmm
>    6
>    $
>
>
>So, yeah, gcc isn't giving you a warning. But it isn't printing 48 either.

I must wonder which version of gcc you are using, since your exact code
does give me the warning "hmm.c:5: warning: value computed is not used" -
which is pretty much what I expected to see.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: 23 Feb 2003 14:46:39 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: parens ()
Message-Id: <slrnb5hnmf.1au.abigail@alexandra.abigail.nl>

Juha Laiho (Juha.Laiho@iki.fi) wrote on MMMCDLXIII September MCMXCIII in
<URL:news:b3a0kf$tfu$1@ichaos.ichaos-int>:
,,  abigail@abigail.nl said:
,, >Robert Krueger (racsw@frontiernet.net) wrote on MMMCDLXII September
,, >MCMXCIII in <URL:news:v5frr523k2r71@corp.supernews.com>:
,, >][  Robert Krueger wrote:
,, >][  
,, >][ >   Why does this work:
,, >][ >      print (( 2 * 3 ) * 8 );
,, >][ > 
,, >][ >   and this doesn't?
,, >][ >      print ( 2 * 3 ) * 8;
,, >][  
,, >][  I receive this warning:
,, >][  
,, >][  "Useless use of integer multiplication (*) in void context at
,, >][  <line #>"
,, >][  
,, >][  In C or C++, I would never get a warning for this syntax, but
,, >][  regardless, the order of precedence remains the same with or
,, >][  without the parens(), so why does Perl take issue with this?
,, >
,, >    $ cat hmm.c
,, >    # include <stdlib.h>
,, >    # include <stdio.h>
,, >
,, >    int main (int argc, char * argv []) {
,, >        printf ("%d\n", (2 * 3)) * 8;
,, >        exit (0);
,, >    }
,, >    $ gcc -Wall -o hmm hmm.c
,, >    $ ./hmm
,, >    6
,, >    $
,, >
,, >
,, >So, yeah, gcc isn't giving you a warning. But it isn't printing 48 either.
,,  
,,  I must wonder which version of gcc you are using, since your exact code
,,  does give me the warning "hmm.c:5: warning: value computed is not used" -
,,  which is pretty much what I expected to see.


3.0.4


Abigail
-- 
perl -we '$_ = q ?4a75737420616e6f74686572205065726c204861636b65720as?;??;
          for (??;(??)x??;??)
              {??;s;(..)s?;qq ?print chr 0x$1 and \161 ss?;excess;??}'


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

Date: Sun, 23 Feb 2003 11:43:08 +0200
From: CM <eleos111@hotmail.com>
Subject: Problem installing Perl dbd::mysql in Windows XP. Please help!
Message-Id: <3m5h5vgt2s97mkdfd9di2n2a09839mtqh3@4ax.com>

Hi.

I have tried to install Perl (ActivePerl 5.8.0 and 5.6.1) in Windows
XP with IIS and mysql 4. I also added DBI module with the command
install DBI 
and added dbd-mysql with command:
install
ftp://ftp.de.uu.net/pub/CPAN/authors/id/JWIED/DBD-mysql-1.2212.x86.ppd

But when I try to run a specific script I always get the follow error:

[Sat Feb 22 23:49:01 2003]
C:\Inetpub\wwwroot\cgi\phpBBusers2nukeusers.pl: install_driver(MySQL)
failed: Can't load 'C:/Perl/site/lib/auto/DBD/mysql/mysql.dll' for
module DBD::mysql: load_file:The specified module could not be found
at C:/Perl/lib/DynaLoader.pm line 206.
[Sat Feb 22 23:49:01 2003]
C:\Inetpub\wwwroot\cgi\phpBBusers2nukeusers.pl: Compilation failed in
require at (eval 2) line 3.
[Sat Feb 22 23:49:01 2003]
C:\Inetpub\wwwroot\cgi\phpBBusers2nukeusers.pl: Perhaps a required
shared library or dll isn't installed where expected


Someone recommended to me to copy mysql.dll and libmysql.dll to the
directories c:\perl\site\lib\DBD\mysql\ and
c:\perl\site\lib\auto\DBD\mysql\ but either that helped at all...

I have read an thread of few days old that was mentioning to a remote
SQL DB and were there a link to a libmysql.dll file that was told if
is downloaded to the c:\perl\site\lib\auto\DBD\mysql\ should make the
job. But failled either. :((((



Any ideas?

Thanks in advance...
NOSPAMeleos@111.hotmail.com


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

Date: Sun, 23 Feb 2003 08:22:51 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Problems comparing strings
Message-Id: <MPG.18c2953a2f70b73898970e@news.mts.net>



In article <b38100$t7m$1@wisteria.csv.warwick.ac.uk>, Mikey 
(PleaseDontThrowSpam@Me.com) says...
> Hi,
> 
> I'm storing names into variables and then trying to compare them. Some
> example names are:
> 
> Mikey Jones
> Jimmy Beef
> Donald H Samuel
> Sarah A Girl
> 
> Unfortunately, the following code does not work:
> 
>     if ($name1 == $name2) {
>         print "Names are the same\n";
>     }
> 
> It gives the error:
> 
> "Argument "Donald H Samuel" isn't numeric in numeric eq (==)"
> 
> For your information: these names are read in from a dat file.
> 
> How can I compare these names?
> 
> Thank-you very much,
> 
> Mikey
> 
> 
> 

Use the "eq" operator to compare strings :     if ( $name1 eq $name2 )
-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Sun, 23 Feb 2003 09:21:41 GMT
From: dSb <afterthefall@entropy.muc.muohio.edu>
Subject: Re: Religious question: commenting
Message-Id: <20030223042214.02ad33e7.afterthefall@entropy.muc.muohio.edu>

> No language is self-documenting. So far no one has been able to come
> up with a language that allows to model an algorithm in a language
> natural to humans. The need for comments will vanish once computers
> are able to understand free text. Well, on the other hand my
> experiences with badly written books tells me that this is not right.
> :-)

What about COBOL?  Depending on how you name your data structures,
the code will tell you exactly what is going on.   But it could just be
a byproduct of the fact that putting asterisks in column seven can be a
serious pain in the ass...

dSb


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

Date: Sun, 23 Feb 2003 09:47:17 +0000
From: Sharon Grant <peakpeek@purethought.com>
Subject: Re: Religious question: commenting
Message-Id: <bk5h5v428qqi97pg4t7opb89q82st65see@4ax.com>

On Sun, 23 Feb 2003 09:21:41 GMT, in comp.lang.perl.misc, dSb <afterthefall@entropy.muc.muohio.edu> wrote:

>> No language is self-documenting. So far no one has been able to come
>> up with a language that allows to model an algorithm in a language
>> natural to humans. The need for comments will vanish once computers
>> are able to understand free text. Well, on the other hand my
>> experiences with badly written books tells me that this is not right.
>> :-)
>
>What about COBOL?  Depending on how you name your data structures,
>the code will tell you exactly what is going on

It is easy to write obfuscated code in Cobol, as in any language. 
That isn't really the issue. The code may be as crystal clear in 
its logical structure, but the purpose could still be obscure, 
especially where the program is implementing some illogical 
requirement from the real world. In those cases, a well-written 
comment will briefly explain the purpose of the code, with a 
precise reference to the relevant text in the specification 
documentation


>But it could just be
>a byproduct of the fact that putting asterisks in column seven can be a
>serious pain

Trivial. Even dinosaur mainframe text editors support some form 
of copy and paste

-- 
Sharon


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

Date: Sun, 23 Feb 2003 08:00:54 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Simple Pattern Problem?
Message-Id: <Xns932B5B96985E8sdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

Jeffrey Lee <jeff@lee-burgin.com> wrote in
news:BA7D8808.C5BE%jeff@lee-burgin.com: 

> in article 3e5841db.17503956@news.erols.com, Jay Tilton at
> tiltonj@erols.com wrote on 2/22/03 7:54 PM:
> 
> 
>> Which is next to useless without some pertinent data.
> 
> Sorry, I'm a bit limited without creating a completely faux data file.
>  I've looked at the chomp issue, and it does fix the immediate bug. 
> Thanks! 
> 
> The pattern which is being matched is misbehaving a bit, but I think I
> can hunt that down!

I suggest you invest a little time in learning the debugger.  It sounds 
like this problem would have been fairly simple to find with a little 
single-stepping.

Or you may want to look into ptkdb, an excellent graphical debugger for 
Perl code.  Do a google search on "ptkdb" and you'll find it.

Good luck :-)

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPljT5mPeouIeTNHoEQIZ4ACglPKdq+z/a5AXy1BO4fsierle2PcAoNhs
zclFcvxuEeckxEq0tI6H+CLd
=Ng53
-----END PGP SIGNATURE-----


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

Date: Sun, 23 Feb 2003 08:26:25 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Simple Pattern Problem?
Message-Id: <MPG.18c2960cbfef3783989710@news.mts.net>



In article <BA7D4E53.C4B8%jeff@lee-burgin.com>, Jeffrey Lee (jeff@lee-
burgin.com) says...
> Ah, it should work, but it doesn't.  I'm a relative Perl newbie, but this
> seems awfully simple:
> 
> I've got the following:
> 
> @samples = grep /$mat_type/, <INPUTFILE>;
> 
> This gives me nothing in @samples.  $mat_type is VAL CLASS 100K
> 
> However, if I change the line to :
> 
> @samples = grep /VAL CLASS 100K/, <INPUTFILE>;
> 
> I get only the lines with the matching text, as I expected.
> 
> Any suggestions? 
> 

@samples = grep /${mat_type}/, <INPUTFILE>;


-- 
---------

Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com


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

Date: Sun, 23 Feb 2003 08:46:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Simple Pattern Problem?
Message-Id: <slrnb5hnlg.bsc.tadmc@magna.augustmail.com>

Barry Kimelman <barryk2@SPAM-KILLER.mts.net> wrote:
> In article <BA7D4E53.C4B8%jeff@lee-burgin.com>, Jeffrey Lee (jeff@lee-
> burgin.com) says...

>> @samples = grep /$mat_type/, <INPUTFILE>;

> @samples = grep /${mat_type}/, <INPUTFILE>;


How would you expect that to change anything?

(it does not change anything)


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


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

Date: 23 Feb 2003 06:54:25 -0800
From: noreply@gunnar.cc (Gunnar Hjalmarsson)
Subject: Re: Switch order of sprintf conversions
Message-Id: <3fcbff18.0302230654.66073274@posting.google.com>

After having considered all the valuable suggestions and comments in
this thread, I added this function to the working copy of my program:

    sub sprintfmt {
      my $string = shift;
      return sprintf $string, @_ if $] >= 5.008;
      my $argref = \@_;
      my (%refidx, @args);
      for (0..$#$argref) { $refidx{$_} = \$argref->[$_] }
      while ($string =~ s/(%)(\d+)\$([\w\.])/$1$3/) {
        push @args, ${delete $refidx{$2-1}} if $refidx{$2-1};
      }
      for (0..$#$argref) { push @args, ${$refidx{$_}} if $refidx{$_} }
      return sprintf $string, @args;
    }
    sprintfmt ('There Is %2$s Than %s Way To Do It', 'One', 'More');

The above returns: "There Is More Than One Way To Do It".

The function aims to simulate the parameter reordering ability that
has been added to the sprintf() function in perl v5.8.0. Your comments
would be appreciated.

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: 23 Feb 2003 03:10:11 -0800
From: dkniveton71@msn.com (casper44)
Subject: Updating a MS Access DB with Perl
Message-Id: <be3be537.0302230310.5edbaea1@posting.google.com>

I have a customer table that I select information from without a
problem.  What I would like to do is add an edit column to the table
(which I guess would be a simple html tag opening a new html document
with all the columns in it) then when I hit submit I would like the
changes I have made to be saved to the database.  Can anyone tell me
how to do that with the below code?

Also at the end I have add data to the database.  Can anyone tell me
how to add data on the fly with perl to an Access DB (I do not want to
define my values in the insert statement but have them pulled from a
table in a new HTML form).  Thanks as always.

#!c:\perl\bin\perl.exe -w 

use strict;
use CGI ':standard';
use Win32::ODBC;  #use ODBC package

my $db;

### Connect to a data source
$db = new Win32::ODBC("DSN=custdb;UID=ncalla;PWD=ncalla")
   or die Win32::ODBC::Error();

### Prepare and Execute a statement
if ($db->Sql("SELECT
cust_id,last_name,first_name,mi,street,city,state,zip_code,date_of_birth
FROM customers")) {
   print "SQL Error: " . $db->Error() . "\n";
   $db->Close();
   exit;
}

### Fetch rows from data source and present in an HTML table 
print "Content-type: text/html\n\n";
print "<center><b><i><h2><font COLOR=red>Customer Data from
Database</font></h2></i></b>";
print "<center>Nicole Calla, CMIS498b Step 9</center> <br>";
print "<table BORDER=1 CELLPADDING=10>";
print    "<tr BGCOLOR=yellow><th>Customer ID</th>";
print                       "<th>Last Name</th>";
print                       "<th>First Name</th>";
print                       "<th>MI</th>";
print                       "<th>Street</th>";
print                       "<th>City</th>";
print                       "<th>State</th>";
print                       "<th>Zip Code</th>";
print                       "<th>Date of Birth</th></tr>";

while ($db->FetchRow) {
   my ($cust_id,$last_name,$first_name,$mi,$street,$city,$state,$zip_code,$date_of_birth)
= $db->Data();  ### Get data values for the row
   print "<tr><td ALIGN=center>" . $cust_id . "</td><td>";
   print                           $last_name . "</td><td>";
   print                           $first_name . "</td><td>";
   print                           $mi . "</td><td>";
   print                           $street . "</td><td>";
   print                           $city . "</td><td>";
   print                           $state . "</td><td>";
   print                           $zip_code . "</td><td>";
   print                           $date_of_birth . "</td></tr>";
}
print "</center></table><p><a href='addcustomer.pl?database=$db'>Add
Entry To Database</a></p>";

### Disconnect
$db->Close();


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

Date: 23 Feb 2003 14:48:48 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Use or not to use modules [was: How do I ...]
Message-Id: <slrnb5hnqg.1au.abigail@alexandra.abigail.nl>

Tad McClellan (tadmc@augustmail.com) wrote on MMMCDLXIII September
MCMXCIII in <URL:news:slrnb5g7hi.32m.tadmc@magna.augustmail.com>:
()  Andrew Lee <spamtrap@nowhere.com> wrote:
()  
() > I would not want to program C without
() > libraries.
()  
()  
()  I don't believe it is possible to write a useful C program
()  without libraries.
()  
()  Can a program that does no I/O be useful?


You can do I/O in C without libraries.

How do *you* think the C libraries do I/O?


Abigail
-- 
 :;$:=~s:
-:;another Perl Hacker
 :;chop
$:;$:=~y:;::d;print+Just.$:


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

Date: 23 Feb 2003 07:30:44 -0800
From: noreply@gunnar.cc (Gunnar Hjalmarsson)
Subject: Re: Use or not to use modules
Message-Id: <3fcbff18.0302230730.16378c16@posting.google.com>

"Jürgen Exner" <jurgenex@hotmail.com> wrote in message news:<liN5a.193$V42.108@nwrddc03.gnilink.net>...
> Gunnar Hjalmarsson wrote:
> > "Steffen Beyer" <Steffen.Beyer@de.bosch.com> wrote in message
> > news:<b34itt$hn8$1@ns2.fe.internet.bosch.com>...
> >> But in general, it is of course a good idea not to re-invent
> >> the wheel and to use modules wherever possible.
> >
> > I don't agree on "wherever possible".
> 
> I think that depends on your personal definition of "possible".
> I prefer "feasible", but I guess that's just playing with definitions.

On the contrary, that's my whole point.

I'm not *against* using modules; that would just be stupid. I use
modules all the time *wherever feasible*. But for tasks, that *I*
consider to be simple enough, I often use my own code, even if it
would have been possible to load a few more modules instead. It
facilitates my own learning, and it makes me feel a little more
comfortable. :)

I don't like dogmatism. That's why I disagree on "wherever possible".

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

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


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