[22401] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4622 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 25 14:05:42 2003

Date: Tue, 25 Feb 2003 11:05:09 -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           Tue, 25 Feb 2003     Volume: 10 Number: 4622

Today's topics:
        Array Access Error - Help! <cbt3a@virginia.edu>
    Re: Array Access Error - Help! (Tad McClellan)
    Re: Checking something to see if it isn't there........ <usenet@tinita.de>
    Re: Checking something to see if it isn't there........ (Anno Siegel)
    Re: compiling perlcc generated c code with gcc <nospam_stigerikson@yahoo.se>
    Re: compiling perlcc generated c code with gcc <nospam_stigerikson@yahoo.se>
    Re: How to temporarily untie and then tie again nobull@mail.com
        Isolate the last 4 characters <zeke03@voila.fr>
    Re: Isolate the last 4 characters <wichmann@uni-wuppertal.de>
    Re: Isolate the last 4 characters <wichmann@uni-wuppertal.de>
    Re: Just wanted to share this technique (and hear some  <mpapec@yahoo.com>
    Re: locate 1, 1 wont work properly, perhaps it's only m <tyrannous@o-space.com>
    Re: Long strings're causing problems <noreply@gunnar.cc>
    Re: Long strings're causing problems <bkennedy@hmsonline.com>
    Re: Perl -- CGI and background process (Randal L. Schwartz)
        setting smalldatetime column to NULL JavaProgrammer@nowhere.com
    Re: Splice problem <usenet@dwall.fastmail.fm>
    Re: Splice problem nobull@mail.com
    Re: Splice problem nobull@mail.com
    Re: Tk::TableMatrix for ActivePerl 8xx Build? (Jim Seymour)
        Tracking web presence with Perl from VB (Fox Cox)
    Re: translate ( tr ) question <mpapec@yahoo.com>
    Re: Using DBI::mysql <jeff@vpservices.com>
    Re: wanted: BZIP2 module for Win32 and Linux <Ed+nospam@ewildgoose.demon.co.uk@>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 25 Feb 2003 11:24:55 -0500
From: "Colin Thomas" <cbt3a@virginia.edu>
Subject: Array Access Error - Help!
Message-Id: <b3g5ks$mju$1@maxwell.acc.Virginia.EDU>

I am getting unexpected out put from this script. The math should be
correct, and should output a zero. However, the call $a[$row] seems to be
accessing the wrong element of the array. Does anyone see why this should
be? (This only happens with certain values of $i (e.g. 29)

Thanks,
Colin

@a = (0,1,0,1,0,1, 0,0,1,0,0,0, 0,0,0,0,0,1, 0,0,0,0,1,1, 0,0,0,0,0,1,
0,0,0,0,0,0);
@b = (0,1,0,1,0,1, 0,0,1,0,0,0, 0,0,0,0,0,1, 0,0,0,0,1,1, 0,0,0,0,0,1,
0,0,0,0,0,0);

$number_to_record = 0;
$num_rows = 6;
$i = 29;

$first = (($i/$num_rows)-(($i % $num_rows)/$num_rows));

$first = $first * $num_rows;
$second = ($i-$first);

#move across row and down column corresponding to place in question
#record indices of items that should be multiplied together

for ($j = 0; $j < $num_rows; $j++){


 $row = $first + $j;
 $column = $second + $num_rows*$j;

 print $row;
 print " ";
 print $a[$row];
 print " ";
 print $column;
 print " ";
 print $b[$column];
 print "\n";

 $new_number = $a[$row]*$b[$column];

 #add the multiplied value to the number to record for place i

 $number_to_record= $number_to_record + $new_number;

}
print $number_to_record;




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

Date: Tue, 25 Feb 2003 12:01:08 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Array Access Error - Help!
Message-Id: <slrnb5nbr3.1q8.tadmc@magna.augustmail.com>

Colin Thomas <cbt3a@virginia.edu> wrote:

> I am getting unexpected out put from this script. 


You have been bitten by this FAQ:

   Why am I getting long decimals (eg, 19.9499999999999) instead 
   of the numbers I should be getting (eg, 19.95)?


> The math should be
> correct, 


But the representation of the numbers is not "correct"...


> and should output a zero. However, the call $a[$row] seems to be
> accessing the wrong element of the array. Does anyone see why this should
> be? (This only happens with certain values of $i (e.g. 29)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

That is a huge clue that you have a number-representaion problem.


>  $row = $first + $j;
>  $column = $second + $num_rows*$j;


Have a look at what indexes you are using, insert after the above 2 lines:

   printf "row: %30.20f (%d)\n", $row, int($row);
   printf "col: %30.20f (%d)\n", $column, int($column);

That should explain why you're accessing the "wrong" array values.


>  print $a[$row];

>  print $b[$column];


Array subscripts are truncated, rather than rounded.

To fix it up, round the values to an int when you calculate them:

    $row = sprintf '%.0f', $first + $j;
    $column = sprintf '%.0f', $second + $num_rows*$j;


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


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

Date: 25 Feb 2003 16:53:58 GMT
From: Tina Mueller <usenet@tinita.de>
Subject: Re: Checking something to see if it isn't there..........
Message-Id: <tinhavjhr$1bo$tina@news01.tinita.de>

Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> Tina Mueller  <usenet@tinita.de> wrote in comp.lang.perl.misc:
>> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
>> > Steven Smolinski  <steven.smolinski@sympatico.ca> wrote in
>> comp.lang.perl.misc:
>> >>     my $operation = shift or die "No operator given";
>> 
>> > Yes, that's a common idiom, and it may be applicable here.  However,
>> > Taking the OP literally, the question was whether the argument was
>> > given at all and scalar @ARGV tests that.  "or" tests if anything
>> > substantial (boolean true) was given, which isn't quite the same thing.
>> > The difference may well not matter here.
>> 
>> defined(my $operation = shift) or die "No operator given";

> That doesn't discern "func()" from "func( undef)".

oh, allright. i just thought we were talking about command line
arguments, so shift() would shift from @ARGV. i don't know
how one could pass an undefined element over the commandline...

regards, tina

-- 
http://www.tinita.de/     \  enter__| |__the___ _ _ ___
http://Movies.tinita.de/   \     / _` / _ \/ _ \ '_(_-< of
http://www.perlquotes.de/   \    \ _,_\ __/\ __/_| /__/ perception
http://www.tinita.de/peace/link.html - Spread Peace


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

Date: 25 Feb 2003 18:20:35 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Checking something to see if it isn't there..........
Message-Id: <b3gc5j$5ds$2@mamenchi.zrz.TU-Berlin.DE>

Tina Mueller  <usenet@tinita.de> wrote in comp.lang.perl.misc:
> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> > Tina Mueller  <usenet@tinita.de> wrote in comp.lang.perl.misc:
> >> Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote:
> >> > Steven Smolinski  <steven.smolinski@sympatico.ca> wrote in
> >> comp.lang.perl.misc:
> >> >>     my $operation = shift or die "No operator given";
> >> 
> >> > Yes, that's a common idiom, and it may be applicable here.  However,
> >> > Taking the OP literally, the question was whether the argument was
> >> > given at all and scalar @ARGV tests that.  "or" tests if anything
> >> > substantial (boolean true) was given, which isn't quite the same thing.
> >> > The difference may well not matter here.
> >> 
> >> defined(my $operation = shift) or die "No operator given";
> 
> > That doesn't discern "func()" from "func( undef)".
> 
> oh, allright. i just thought we were talking about command line
> arguments, so shift() would shift from @ARGV. i don't know
> how one could pass an undefined element over the commandline...

You are right, with @ARGV fresh from the command line, shifting and
testing for definedness is equivalent to testing scalar @ARGV.  I was
speaking in general and forgot we were discussing a special case.

Anno



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

Date: Tue, 25 Feb 2003 18:23:05 +0100
From: stig <nospam_stigerikson@yahoo.se>
Subject: Re: compiling perlcc generated c code with gcc
Message-Id: <b3g8sh$qgn$1@oden.abc.se>

Sisyphus wrote:

> stig <nospam_stigerikson@yahoo.se> wrote in message
> news:<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
> 
> Yesterday, having been unable to post to Usenet for about 3 days (and
> with no end in sight), I sent the OP an email suggesting that it is
> necessary to link to libperl56.a. This file is in the ../lib/CORE
> folder relative to the directory in which perl was built. The include
> files mentioned in the OP's first post are also in the same folder. At
> least that's the way it is for me on Win32 with mingw and gcc.
> 
> To test, I created a little try.pl and ran 'perlcc -c try.pl' which
> produced the file 'try.c'.
> 
> Then I ran:
> gcc try.c -I\downloads\AP633_source\lib\CORE
> -L\downloads\AP633_source\lib\CORE -lperl56
> 
> That built the executable just fine without any warnings or errors.
> Only problem is that when I run the executable, I get a fatal error in
> the form of a popup telling me that 'The instruction at "0x00405067"
> referenced memory at "0x00000000". The memory could not be "read".'
> 
> The include files (perl.h, etc.) also can be found in
> \downloads\AP633_source\, but if I include that directory instead of
> the one I used, then I get errors about other include files (eg
> config.h) not being found.
> 
> That's about as far as I can get with this approach.
> 
> Cheers,
> Rob



hi and thanks for the reply.
just tried it, both with perl 5.6.1 and 5.8.0.
first perlcc -c 
then gcc, both as described and with a Makefile with the switches included.
and also by directly specifying the paths in the c-file on the 
include-lines.

same result though.

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

and many more lines with messages like that.


anyway, dont bother all to much, ill survive somehow.
stig.




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

Date: Tue, 25 Feb 2003 18:25:51 +0100
From: stig <nospam_stigerikson@yahoo.se>
Subject: Re: compiling perlcc generated c code with gcc
Message-Id: <b3g91l$qgn$2@oden.abc.se>

Benjamin Goldberg wrote:

> stig wrote:
>> 
>> 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?
> 
> Is the perl source you got for the same version of perl that you're
> running?
> 
> If you are running perl5.6.1, and the perlcc which comes with it, but
> you've downloaded the sources of a different version, then of course
> you're going to have problems.
> 

same version all the way through.
tried both perl 5.6.1 and 5.8.0, and repeated the procedure all the way from 
the beginning with both versions, did not use the 5.8.0 generated .c-file 
to compile with 5.6.1 headers.




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

Date: 25 Feb 2003 09:32:37 -0800
From: nobull@mail.com
Subject: Re: How to temporarily untie and then tie again
Message-Id: <4dafc536.0302250932.1af54441@posting.google.com>

"John Lin" <johnlin@cht.com.tw> wrote in message news:<b3df2r$2ro@netnews.hinet.net>...
> "Brian McCauley" wrote
> > (John Lin) writes:
> > > I want to temporarily untie [...] and then tie it back again
> > use Tie::Restore;
> > tie *STDOUT, 'Tie::Restore', $tied;    # Yes, it does work.

> Cool!  The source code of this module is only a few lines:

> So, just grabbing what I need, my code becomes:
> 
> tie *STDOUT,'Tie::Restore',$tied;
> sub Tie::Restore::TIEHANDLE { $_[1] }

I would discourge this behaviour.

For one thing if your script ever uses the real Tie::Restore module
indirectly through another module you'll get annoying warnings.

So if you want to roll your own Tie::Restore equivalent then you
should use a different module name.  If you are writing a script this
should be in namespace that's reserved never to appear in a CPAN
module.  If you are writing a module then use part of your own
module's namespace.

Before Tie::Restore existed many people, including myself, would do
exactly this in many of our scripts/modules.

Now Tie::Restore exists it is better to use it.

If the time overhead of loading Tie::Restore is signifcant then you
probably shouldn't be writing in Perl.


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

Date: 25 Feb 2003 16:01:55 GMT
From: zeke03 <zeke03@voila.fr>
Subject: Isolate the last 4 characters
Message-Id: <2003225-17155-434316@foorum.com>


Hello,

 I have to work on files, i would like to isolate the 4 last of the file name 
For exemple :

 exemple.a001                    => return 'a001'
 fic_number1_test.f123           => return 'f123'
 fic_number5                     => return 'ber5'

 

     Anyone has an idea ??

 Thanks
-- 
Ce message a ete poste via la plateforme Web club-Internet.fr
This message has been posted by the Web platform club-Internet.fr

http://forums.club-internet.fr/


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

Date: Tue, 25 Feb 2003 19:16:39 +0100
From: Ingo Wichmann <wichmann@uni-wuppertal.de>
Subject: Re: Isolate the last 4 characters
Message-Id: <b3gc7a$tmq$00$1@news.t-online.com>

zeke03 schrieb:
>  I have to work on files, i would like to isolate the 4 last of the file name 
> For exemple :
> 
>  exemple.a001                    => return 'a001'
>  fic_number1_test.f123           => return 'f123'
>  fic_number5                     => return 'ber5'

perldoc -f substr


Ingo



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

Date: Tue, 25 Feb 2003 19:19:59 +0100
From: Ingo Wichmann <wichmann@uni-wuppertal.de>
Subject: Re: Isolate the last 4 characters
Message-Id: <b3gcdi$tmq$00$2@news.t-online.com>

zeke03 schrieb:
>  I have to work on files, i would like to isolate the 4 last of the file name 
> For exemple :
> 
>  exemple.a001                    => return 'a001'
>  fic_number1_test.f123           => return 'f123'
>  fic_number5                     => return 'ber5'

print substr "exemple.a001", -4;

Ingo



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

Date: Tue, 25 Feb 2003 19:28:50 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: Just wanted to share this technique (and hear some opinions about    it)
Message-Id: <18dn5vskc4obuktil3pjj99eqmcunenopr@4ax.com>

X-Ftn-To: Tassilo v. Parseval 

"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote:
>>>  -e and print, last for map "$_$f", @pre;
>>                ^
>> 
>> Isn't last here a second argument to print? I did perldoc but I'm not sure
>> how to look at this. :)
>
>Nope. If you wanted it to be the second argument to print(), you'd have
>to pass the default of $_ explicitely:
>
>    print $_, last;
>
>Not that "last" has any return value, though. Whenever there is

Would you use print in such way knowing that last will be used as an
argument? From practical standpoint this is absolutely irrelevant but on the
other hand it challenges programing ethic(if such thing exists :)).

>    FUNCTION, SOMETHING;
>
>FUNCTION is assumed to either have no argument or some implicit default
>and SOMETHING is executed afterwards. 

Ok, so perl will not print anything after comma until we explicitly put
first argument; and after first argument all statements separated by , are
considered arguments?


-- 
$_=$2.$1,s sg s sgmx,$/.=$_,while q mnagdaLrrgysiHgsihgca
ek r=m=~m m(. ) (. ) mmxg;print"There is only one God,$/"


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

Date: Tue, 25 Feb 2003 18:37:27 -0000
From: <tyrannous@o-space.com>
Subject: Re: locate 1, 1 wont work properly, perhaps it's only meant for linux
Message-Id: <b3gd56$ik2$1@newsg4.svr.pol.co.uk>

it doesn't locate the cursor to 1, 1 that is what happens.


<tyrannous@o-space.com> wrote in message
news:b3fv1p$m5g$1@news8.svr.pol.co.uk...
> is there any need to be cryptic?
>
> i just want to locate the cursor to 1, 1 or something similar
>
> could you tell me how to do this?
> "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> news:b3fu6h$p84$1@mamenchi.zrz.TU-Berlin.DE...
> > <tyrannous@o-space.com> wrote in comp.lang.perl.misc:
> >
> > Please don't top-post.  I moved your reply to where its context is.
> >
> > > "Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
> > > news:b3fiss$bc6$3@mamenchi.zrz.TU-Berlin.DE...
> > > > <tyrannous@o-space.com> wrote in comp.lang.perl.misc:
> > > > > locate 1, 1 wont work properly, perhaps it's only meant for linux
> > > > >
> > > > >
> > > > > use Term::ASCIIScreen;
> > > >
> > > > What is Term::ASCIIScreen?  It isn't on CPAN.
> > >
> > > i'm sorry, i meant ANSIScreen
> > >
> > > > > system 'cls'; locate 1,1;
> > > > >
> > > > > print chr(65);
> > > > >
> > > > > could someone please tell me how to get this to work on a Windows
ME
> > > system?
> >
> > So what do you expect it to do, and what does it do instead?  All you
> > say is that "it doesn't work right".
> >
> > You need a terminal(-emulation) that understands ANSI controls for the
> > module to work.  I have no idea if you get that under Windows ME by
> > default.
> >
> > Anno
>
>




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

Date: Tue, 25 Feb 2003 17:18:19 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Long strings're causing problems
Message-Id: <b3g613$1m5uui$1@ID-184292.news.dfncis.de>

Tassilo v. Parseval wrote:
> Also sprach Gunnar Hjalmarsson:
>>Do you mean that when using CGI.pm, the POST method is automatically 
>>choosen if no method is stated in the form?
> 
> No, I meant that POST should be specified as post-method in the form.
> Actually I doubt that there is a default for that, so the form wont
> probably do what it is supposed to do when no post-method is given.

Ben Kennedy wrote:
> Tassilo's point is that since CGI.pm encapsulates reading
> parameters from both methods in a single interface, it is trivial to switch
> between GET and POST - it just requires editing your HTML.

Okay, but this sub-thread started with me speculating in the possibility 
that the reason why long (unlike short, obviously) strings cause 
problems may be that the info is passed using GET. Both Helgi and 
Tassilo indicated that, if that's the case, the use of CGI.pm would have 
made a difference. Now I understand that it wouldn't.

I'm a CGI programmer who is rather unfamiliar with CGI.pm. I notice that 
people on this and similar groups push very hard for using that module, 
and some day I may be convinced. However, pushing for CGI.pm at the 
wrong moment won't speed up convincing me.

That's my point. ;-)

/ Gunnar

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



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

Date: Tue, 25 Feb 2003 12:41:11 -0500
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Long strings're causing problems
Message-Id: <QMudnX9I2edKN8ajXTWc2Q@giganews.com>


"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:b3g613$1m5uui$1@ID-184292.news.dfncis.de...

> Okay, but this sub-thread started with me speculating in the possibility
> that the reason why long (unlike short, obviously) strings cause
> problems may be that the info is passed using GET. Both Helgi and
> Tassilo indicated that, if that's the case, the use of CGI.pm would have
> made a difference. Now I understand that it wouldn't.

Keep in mind that the "problem" consists of many pieces - the user's web
browser, the web server, and the script.  If the OP's problem was indeed
created by the GET URL exceeding the web server's limit, and the OP had been
using CGI.pm, his fix would have been to just turn the GET form into a POST
form.  In other words, by using CGI.pm, one can refactor the client/server
protocol to something more extensible in just a few seconds, and be sure
that it's going to work.  If one is parsing parameters by themselves, there
will likely be bugs and time wasted.  Now if the constraints of this problem
dictate that that the type of the form cannot be changed, then we have left
the realm of Perl - there is nothing to do if the data never actually
reaches the script.  All we can do is suggest design alternatives (e.g. use
CGI.pm) to facilitate the fastest and most obvious solution, that is change
the form type.

> However, pushing for CGI.pm at the wrong moment won't speed up convincing
>  me.

A script that needs to transparently start using POST data instead of GET
data is easily one of the best reasons to use CGI.pm!

--Ben Kennedy




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

Date: Tue, 25 Feb 2003 16:49:34 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl -- CGI and background process
Message-Id: <7faa2f6fef391e99f2fcbfb2ace12950@news.teranews.com>

>>>>> "mlm" == mlm  <mlm@nospam.com> writes:

mlm> I would like to have two perl programs, one to manage a connection to a 
mlm> news server, and the other to look after the CGI part.  I want to avoid 
mlm> CGI for the news server part to avoid continually opening and closing the 
mlm> connection to the news server.

mlm> I envisage a program called on first access to the web page which will 
mlm> open a connection to the NNTP server and keep it open waiting for 
mlm> requests to retrieve particular articles.  A CGI program would take HTTP 
mlm> requests and hand them off to the NNTP manager to be serviced and 
mlm> returned to the client browser.  Perhaps after 3-400 seconds of no 
mlm> activity, the NNTP management program would close the NNTP connection and 
mlm> shut itself down.

Been There, Done That.

google site:stonehenge.com cgi nntp fork =>

  http://www.stonehenge.com/merlyn/WebTechniques/col62.html

In fact, thanks to my 160+ magazine column articles online, it's hard
to find a set of interesting keywords that doesn't already have a
solution there.  And if you *do*, please write me, because I'm still
writing 2.5 columns per month, and would give you public credit for a
new idea.

print "Just another Perl hacker,"

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 25 Feb 2003 18:21:13 GMT
From: JavaProgrammer@nowhere.com
Subject: setting smalldatetime column to NULL
Message-Id: <b3gc6p$d0f$1@news.netmar.com>

A co-worker is trying to get her PERL script to UPDATE a record so a (Sybase
System 11) smalldatetime column is set to NULL, but not having any luck.
Apparently a statement like

UPDATE table
SET smalldatetimeColumn = NULL
WHERE ...

doesn't work though it works fine in SQL Advantage. Is there any way to get
the above statement to work in PERL? 


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Tue, 25 Feb 2003 16:08:51 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Splice problem
Message-Id: <Xns932D7165CE904dkwwashere@216.168.3.30>

Tore Aursand <tore@aursand.no> wrote on 25 Feb 2003:

> Hmm.  After some thought I think I might have changed this to code
> to something which I _think_ is more readable...?
> 
>   foreach my $element ( @array ) {
>       next unless ( length($element) >= 5 );
>       push( @new, $element );
>  }
> 
> Oh, well. :)


It can be streamlined a bit:

    foreach my $element (@array) {
        push @new, $element if length $element >= 5;
    }

But as Uri Guttman said, grep() is easier to read, as long as you 
grok grep(). :-)

    @array = grep length >= 5, @array ;

Should be faster, too, although getting it right is more important 
than getting it fast. 

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: 25 Feb 2003 10:10:30 -0800
From: nobull@mail.com
Subject: Re: Splice problem
Message-Id: <4dafc536.0302251010.44ba83d0@posting.google.com>

Jon Rogers <jon@rogers.tv> wrote in message news:<3E5A51E2.1B1608BE@rogers.tv>...

> I can't seem to get splice to work:
> 
> my @array=('aaaaa','bbbbb','ccccc','dd','eeeee','fffff','ggggg');
> 
> my $length = scalar @array -1;
> my $i;
> 
> for ($i=0 ; $i<=$length; $i++) {
> 
>   if (length $array[$i] <5) {
>       @array = splice (@array, $i+1,$i+2); } }
> 
> 
> Having read the docs, I'd say this should take away the element
> containing 'dd' and leave the rest.

When you read the docs, were you sober?

> But this is what i get when i ask it
> to print @array:

for my $i ( reverse 0 .. $#array ) {
   if (length $array[$i] < 5 ) {
      splice (@array, $i, 1); 
   }
}

Note: Unless you have some particular reason for doing this with
splice() I'd say you should use the more natual grep() approach.


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

Date: 25 Feb 2003 10:25:35 -0800
From: nobull@mail.com
Subject: Re: Splice problem
Message-Id: <4dafc536.0302251025.3eb6a83@posting.google.com>

Uri Guttman <uri@stemsystems.com> wrote in message news:<x78yw5mwnw.fsf@mail.sysarch.com>...
> don't use splice. looping in perl for this is slow and clumsy. grep is
> what you want.
> 
> 	@array = grep length < 5, @array ;

That doesn't compile.

After fixing that it is indeed less clumsy and 29% faster than the
splice solution (done correctly) but it is also a bit memory hungry
for huge @array.

#!/usr/bin/perl
use strict;
use warnings;
use Benchmark;

timethese 10000 => {
    grep => sub {
        my @array=('aaaaa','bbbbb','ccccc','dd','eeeee','fffff','ggggg')
x 100;
        @array = grep length() < 5, @array ;
    },
    splice => sub {
        my @array=('aaaaa','bbbbb','ccccc','dd','eeeee','fffff','ggggg')
x 100;
        for ( my $i = $#array; $i >= 0; $i-- ) {
            splice @array, $i, 1 if length $array[$i] < 5;
        }
    },
}
__END__
Benchmark: timing 10000 iterations of grep, splice...
      grep:  9 wallclock secs ( 8.73 usr +  0.00 sys =  8.73 CPU) @
1145.48/s(n=10000)
    splice: 12 wallclock secs (12.31 usr +  0.00 sys = 12.31 CPU) @
812.35/s (n=10000)


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

Date: Tue, 25 Feb 2003 17:50:29 -0000
From: gort@LinxNet.com (Jim Seymour)
Subject: Re: Tk::TableMatrix for ActivePerl 8xx Build?
Message-Id: <v5nb7578gvpp55@corp.supernews.com>

In article <3e5b7ac4.1564075912@news.cis.dfn.de>,
	helgi@decode.is (Helgi Briem) writes:
> On Mon, 24 Feb 2003 23:19:51 -0000, gort@LinxNet.com (Jim
> Seymour) wrote:
> 
>>ActiveState apparently hasn't done the Tk::TableMatrix module for
>>their 8xx build yet.  Anybody know where else I might find it?
> 
> Have you tried CPAN?

For ActivePerl (build 8xx) compatible Win32 binary installs?

Regards,
Jim
-- 
Jim Seymour                    | PGP Public Key available at:
WARNING: The "From:" address   | http://www.uk.pgp.net/pgpnet/pks-commands.html
is a spam trap.  DON'T USE IT! |
Use: jseymour@LinxNet.com      | http://jimsun.LinxNet.com


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

Date: 25 Feb 2003 08:29:42 -0800
From: fabanon1@yahoo.fr (Fox Cox)
Subject: Tracking web presence with Perl from VB
Message-Id: <133056fc.0302250829.12bbef44@posting.google.com>

I am looking for a tool to automatically track the web presence of a
list of contacts in Outlook. Such program (VB) would automatically and
regularly scan the web (by calling a web crawler like Google) to
figure out in which web pages each contact appears. Such thing would
be easy to implement if we can call from VB the webscraping library
that exist in Perl (http://search.cpan.org/author/GLENNWOOD/Scraper-2.26/lib/WWW/Search/Scraper/Google.pm).

I believe such tool would be very interesting to have to figure out
what your friends are up to. Example of usage: in the morning, your
Outlook tells you that "your friend Tom and Bill appears both as the
speaker in conference web page", "John has posted a message in the
HotCar newsgroup", etc.

It seems to me that since it should not be too long to program, it may
already exist in a form or another out there. Does anyone knows about
anything like that ??? If it does not already exist, I am willing to
pay someone to do it.

Thanks for any hint !

Fox 

PS: sorry for hinting at mixing the best and the worst of both world
(I won't say which is which, but we're talking about OpenSource and MS
VB here ! :-)

A bit more details about basic functions
For each contact in the outlook database, the list of presence on the
web (URLs) gathered by scraping Google would be stored inside the
Outlook database (in the journal for instance), with their entering
date, so that ulterior scanning would be able to point at new entries;
by crossing the list of URL by contact, it would also be possible to
know, for each contact, all the pages where other contacts of the
database are mentioned (cross appearance).


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

Date: Tue, 25 Feb 2003 19:36:06 +0100
From: Matija Papec <mpapec@yahoo.com>
Subject: Re: translate ( tr ) question
Message-Id: <ondn5vslt4kmi2vomhld183j1m2og5d5je@4ax.com>

X-Ftn-To: Tad McClellan 

tadmc@augustmail.com (Tad McClellan) wrote:
>> I need to know how to translate letters higher than 
>> J to a number i.e. a=1..z=27
>
>   s/[J-Z]/a=1..z=27/g;
            ^^^^^^^^^

how this interpolates; have a RTFM?



-- 
Matija


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

Date: Tue, 25 Feb 2003 10:20:15 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Using DBI::mysql
Message-Id: <3E5BB3DF.30801@vpservices.com>

Geoff Soper wrote:

> My main
> problem was what to do given that I was expecting a single results to be
> returned as opposed to a group of columns. I perhaps didn't make that clear
> enough in my original posting.


When you only need a single row, you don't need a loop or even a 
statement handle (sth), you can use one of the *database handle* (dbh) 
methods and assign directly to string without any explicit 
prepare/execute/fetch:

   my $fname = $dbh->selectrow_array(
      "SELECT fname FROM x WHERE lname='Smith'"
   );

Or, with bind_params:

   my $fname = $dbh->selectrow_array(
      "SELECT fname FROM x WHERE lname=?",
      {},
      'Smith'
   );

-- 
Jeff



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

Date: Tue, 25 Feb 2003 18:22:29 GMT
From: "Edward Wildgoose" <Ed+nospam@ewildgoose.demon.co.uk@>
Subject: Re: wanted: BZIP2 module for Win32 and Linux
Message-Id: <FvO6a.1619921$TJ.228787@post-02.news.easynews.com>


"Joe Smith" <inwap@inwap.com> wrote in message
news:LaJ6a.4629$io.186344@iad-read.news.verio.net...
> In article <bYJ4a.1260487$TJ.177153@post-02.news.easynews.com>,
> Edward Wildgoose <Ed+nospam@ewildgoose.demon.co.uk@> wrote:
> >Apologies if this is the wrong place.  I have a need for a BZIP2 module
in
> >the style of the current zlib library
> >
> >Anyway, this would be contributed back to CPAN for all to use, but ...
>
> What is wrong with the Bzip2 modules already on CPAN?
>
> http://search.cpan.org/search?query=bzip2&mode=module
>

Hmm, well the Compress::BZip2 module doesn't appear to work (for me at
least).  If someone can supply a working example for either Linux or Win32
then I would be very interested to see it (and the output you get).  For
example does the example from the module synopsis work for you?

> >particularly have a need for the stream compression functions with
"partial
> >flush", etc, ie so I can use it for compressing a real time data stream.
>
> Like IO::Filter::bzip2, perhaps?
> -Joe

Yes, that would be a start.  However, although it says Sep 01 I will swear
that module was not available a few months ago.  In fact the
Meta::Compress::BZip2 snuck on without my knowing it...

I will try these and see which work on win32

Thanks

Ed




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

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


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