[23543] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5751 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 5 00:06:02 2003

Date: Tue, 4 Nov 2003 21: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, 4 Nov 2003     Volume: 10 Number: 5751

Today's topics:
    Re: Big problem with @array and Chomp ... I think :o <tore@aursand.no>
    Re: Big problem with @array and Chomp ... I think :o (Kevin Shay)
        Changing from capital letters to small letters using pe (Venugopal)
    Re: extracting properties of companies with a tag for c <invalid-email@rochester.rr.com>
    Re: Perl can't locate a .pm in @INC <nospam_for_jkeen@concentric.net>
    Re: Perl can't locate a .pm in @INC <noreply@gunnar.cc>
    Re: Perl can't locate a .pm in @INC (Tad McClellan)
    Re: Perl can't locate a .pm in @INC (James Willmore)
    Re: Perl can't locate a .pm in @INC <dmcbride@naboo.to.org.no.spam.for.me>
    Re: Perl can't locate a .pm in @INC <jwillmore@remove.adelphia.net>
    Re: perl regex: stopping short when using .* <REMOVEsdnCAPS@comcast.net>
    Re: perl regex: stopping short when using .* <bitte.keine.werbung@anti-qad.org>
        printing characters <fJogham@yahoo.com>
    Re: printing characters <invalid-email@rochester.rr.com>
    Re: printing characters <nospam_for_jkeen@concentric.net>
    Re: printing characters (Tad McClellan)
    Re: printing characters <abigail@abigail.nl>
    Re: printing characters (James Willmore)
    Re: printing characters <jurgenex@hotmail.com>
    Re: Problem Connecting w Perl/DBD::Oracle as SYSDBA (James Willmore)
    Re: Rounding a float in Perl? ctcgag@hotmail.com
    Re: Rounding a float in Perl? <nospam-abuse@ilyaz.org>
    Re: simplify this if loop <tore@aursand.no>
    Re: simplify this if loop <fJogham@yahoo.com>
    Re: sub confusion <invalid-email@rochester.rr.com>
    Re: testing for 'undefined subroutine' <invalid-email@rochester.rr.com>
        using a hash as condition selector <fJogham@yahoo.com>
    Re: using a hash as condition selector <noreply@gunnar.cc>
    Re: Verbose warnings <wwonko@rdwarf.com>
    Re: Verbose warnings (Tad McClellan)
    Re: Verbose warnings (Randal L. Schwartz)
    Re: Windows binary with debugging support <wwonko@rdwarf.com>
    Re: Windows binary with debugging support <fJogham@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 05 Nov 2003 00:09:03 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Big problem with @array and Chomp ... I think :o
Message-Id: <pan.2003.11.04.22.14.53.359229@aursand.no>

On Tue, 04 Nov 2003 19:22:55 +0000, Robert TV wrote:
> $definedname = CGI::param('name');
> $definedemail = CGI::param('email');
> $newrecipient = "$definedname|$definedemail\n";

Are you using strict and warnings?  And what if there's a '|' in the name
and/or email address?

> print "Content-type: text/html \n\n";
> print <<PRINTHTML;

This can't be repeated too often:  Consider using one of the many template
solutions for separating code and presentation.  HTML::Template looks like
a popular (and good, of course) choice.

> @recipients=<ADDRESSES>;
> foreach $recipient(@recipients) {
> chomp ($recipient);

Actually, you can chomp all the elements in @recipients in one go;

  chomp( @recipients );

> open (FILE,">>$activeuser/csvdump.txt");
> close(FILE);

Huh?

> unlink <$activeuser/csvdump.txt>;

You probably don't want to glob() here.  Try this one instead:

  unlink "$activeuser/csvdump.txt";

> ...onto the CSV parsing code:

 ...which really isn't that good.  There are multiple CSV-related modules
on CPAN which does the job much better.

> After the loop, the printed results are:
> Jane|jane@email.com
> Mike|mike@email.ca
> Kris|kris@yahoo.com
> -- Correct layout, but is still wrong somwhow

It is _somehow_ wrong?  Somehow how? :-)


-- 
Tore Aursand <tore@aursand.no>


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

Date: 4 Nov 2003 19:48:29 -0800
From: kevin_shay@yahoo.com (Kevin Shay)
Subject: Re: Big problem with @array and Chomp ... I think :o
Message-Id: <5550ef1e.0311041948.60c234ab@posting.google.com>

"Robert TV" <ducott_99@yahoo.com> wrote in message
news:<j0Tpb.290847$6C4.168943@pd7tw1no>...
> @recipients = CGI::param('csvdata');
> 
> open (FILE,">>$activeuser/csvdump.txt");
> close(FILE);
> 
> open (ADDRESSES, ">$activeuser/csvdump.txt") or die "Can't open file: $!";
>   print ADDRESSES @recipients;
> close(ADDRESSES);
> 
> open (ADDRESSES, "<$activeuser/csvdump.txt") or die "Can't open file: $!";
>   @recipients = <ADDRESSES>;
> close(ADDRESSES);
> 
> unlink <$activeuser/csvdump.txt>;
> 
> <-- End Code Example -->
> 
> Ok, right about now your wondering why did I take the form contents, write
> it to a temp file, then open and get the data back from the temp file. For
> some reason I cannot get the code to work any other way. 

The problem may lie in the first line of code above:

@recipients = CGI::param('csvdata');

It sounds like you have a single HTML form field called csvdata, into
which the user enters multiple lines of text. If that's the case, the
CGI module will not automatically turn this into a list. It's a single
value. So the entire set of data is being placed into the first
element of @recipients.

When you print that one-element array to a file, it simply prints that
one element; the element happens to have multiple lines, so the
resulting file will have multiple lines. Then, when you re-open the
file and do this:

@recipients = <ADDRESSES>;

Perl reads the lines of the file into the array, one line per element,
which is what you wanted in the first place. So you could probably
just do this to avoid the whole temp file workaround:

@recipients = split(/\n/, CGI::param('csvdata'));

As for the actual chomp problem, it may have something to do with the
way different operating systems encode newlines differently (\n on
Unix, \r\n on DOS/Windows, \r on Mac). Depending on which platform the
user's browser is running on, you may not be getting just \n
characters separating the lines. So you might want to normalize
everything to \n newlines:

my $csvdata = CGI::param('csvdata');
$csvdata =~ s/\r\n?/\n/g;
@recipients = split(/\n/, $csvdata);

Kevin
--
perl -MLWP::UserAgent -e '$u=new LWP::UserAgent;$u->agent("japh");
print join(" ",(split(/\s+/,(split/\n/,$u->request(HTTP::Request->
new(GET=>join("",split(/\n/,"http://groups.google.com/groups?selm=
4365%40omepd.UUCP&output=gplain"))))->content)[60]))[0..3]),",\n"'


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

Date: 4 Nov 2003 20:41:44 -0800
From: balasubv@hotmail.com (Venugopal)
Subject: Changing from capital letters to small letters using perl
Message-Id: <68041301.0311042041.1dc4f858@posting.google.com>

Hi,

Is there an easy way to change all capital letters in a text file 
to small letters using Perl? (Or any other tool!)


Thanking in advance,
Venugopal


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

Date: Wed, 05 Nov 2003 00:53:24 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: extracting properties of companies with a tag for company number
Message-Id: <3FA84786.9080809@rochester.rr.com>

Gunnar Hjalmarsson wrote:

> Vumani Dlamini wrote:
 ...
> Personally I think that the level of detail is fine. Bob gave you some
> good advice, even if I think he missed that the fact that the code
> didn't compile was the reason why you asked for help.
> 

Yeah, any more I go into auto-rant mode when posted code doesn't 
compile, assuming the poster retyped instead of copy/pasted.  I think 
this is the first posting I've seen where the question was actually what 
was causing a compilation error.  My auto-rant could, of course, have 
been avoided if the poster had stated what error it was he was getting.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 05 Nov 2003 00:50:54 GMT
From: "James E Keenan" <nospam_for_jkeen@concentric.net>
Subject: Re: Perl can't locate a .pm in @INC
Message-Id: <bo9hhe$90j@dispatch.concentric.net>


"Gary Hartl" <the-smtpguy@cogeco.ca> wrote in message
news:99e21f6f.0311041333.1b436e32@posting.google.com...
> Hello all again,
>
> I'm not much of a perl programer but I am trying to get this script to
> run and it is giving me a headache :)
>
> I'm getting premature end of script header errors and I'm pretty sure
> why.
>
> Here is everything I think is important for this situation, if i'm
> missing something please let me know and I'll supply anything else.
>
> I have some .pm files ina directory called /home/mach10/dist/lib
>
> the first line of the script calls
> use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
>
The 'use lib' command is expecting a *list* of directories in which to
search for Perl modules.  Items in the list are, in almost all cases,
separated by commas.  You are separating the items in your list by Perl's ||
operator.  This would be correct if this were the body of, say, an 'if'
condition, but it's not a Perl list.  Try:
    use lib ($ENV{'MACH10_LIB'} , '/home/mach10/dist/lib');
and let us know the results.

jimk




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

Date: Wed, 05 Nov 2003 02:13:38 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Perl can't locate a .pm in @INC
Message-Id: <bo9ir8$1bp3om$1@ID-184292.news.uni-berlin.de>

James E Keenan wrote:
> Gary Hartl wrote:
>> I have some .pm files ina directory called /home/mach10/dist/lib
>> 
>> the first line of the script calls
>> use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
> 
> The 'use lib' command is expecting a *list* of directories in which
> to search for Perl modules.  Items in the list are, in almost all
> cases, separated by commas.  You are separating the items in your
> list by Perl's || operator.  This would be correct if this were the
> body of, say, an 'if' condition, but it's not a Perl list.  Try:
>     use lib ($ENV{'MACH10_LIB'} , '/home/mach10/dist/lib');
> and let us know the results.

I don't understand that, Jim. Thought that the expression within
parentheses returned a 'LIST', even if it happens to consist of only
one element: It returns either the value of $ENV{'MACH10_LIB'}, or, if
that value is not true, the string '/home/mach10/dist/lib'.

>> Can't locate Skyweb.pm in @INC (@INC contains: /home/mach10/dist/lib

Doesn't that tell us that OP's "use lib" statement worked?

Nevertheless, I'm not able to suggest a solution.

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



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

Date: Tue, 4 Nov 2003 18:51:07 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Perl can't locate a .pm in @INC
Message-Id: <slrnbqgibr.k9v.tadmc@magna.augustmail.com>

Gary Hartl <the-smtpguy@cogeco.ca> wrote:

> I'm getting premature end of script header errors and I'm pretty sure
                                                            ^^^^^^^^^^^
> why.
  ^^^


But you are not going to tell us?

Is this a test?  :-)


> use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');

> use Skyweb;

> Can't locate Skyweb.pm in @INC (@INC contains: /home/mach10/dist/lib


An essential missing bit of information is where _is_ Skyweb.pm installed?

If it is at

   /home/mach10/dist/lib/Skyweb.pm

then I don't know what the problem might be...


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


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

Date: 4 Nov 2003 18:41:35 -0800
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: Perl can't locate a .pm in @INC
Message-Id: <d61170e5.0311041841.3171c3bf@posting.google.com>

the-smtpguy@cogeco.ca (Gary Hartl) wrote in message news:<99e21f6f.0311041333.1b436e32@posting.google.com>...
> Hello all again,
> 
> I'm not much of a perl programer but I am trying to get this script to
> run and it is giving me a headache :)
> 
> I'm getting premature end of script header errors and I'm pretty sure
> why.
> 
> Here is everything I think is important for this situation, if i'm
> missing something please let me know and I'll supply anything else.
> 
> I have some .pm files ina directory called /home/mach10/dist/lib 
> 
> the first line of the script calls 
> use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
<snip>

You could just set the $ENV{'MACH10_LIB'} variable _first_, then set
the 'lib' path accordingly.

--untested--
$ENV{'MACH10_LIB'} = '/home/mach10/dist/lib' unless defined
$ENV{'MACH10_LIB'};
use lib "$ENV{'MACH10_LIB'}";
--untested--

HTH

Jim
(jwillmore _at_ adelphia _dot_ net)


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

Date: Wed, 05 Nov 2003 02:56:32 GMT
From: Darin McBride <dmcbride@naboo.to.org.no.spam.for.me>
Subject: Re: Perl can't locate a .pm in @INC
Message-Id: <AFZpb.297207$6C4.3143@pd7tw1no>

Gary Hartl wrote:

> Hello all again,
> 
> I'm not much of a perl programer but I am trying to get this script to
> run and it is giving me a headache :)
> 
> I'm getting premature end of script header errors and I'm pretty sure
> why.
> 
> Here is everything I think is important for this situation, if i'm
> missing something please let me know and I'll supply anything else.
> 
> I have some .pm files ina directory called /home/mach10/dist/lib
> 
> the first line of the script calls
> use lib ($ENV{'MACH10_LIB'} || '/home/mach10/dist/lib');
> 
> then it calls the offending module:
> use Skyweb;
> 
> seems like that should work for me ( with my limited knowledge )
> now if i try to run the script from browswer i get the follow error in
> my apache logs:

How about running it manually?  If that doesn't work, then you don't
have Skyweb.pm where you claim to above ;-)

If it does, and under the assumption that you're not lying/deceived
about the above I would have to assume it will work, you've just hit
one of my personal most-frequently-hit problem that bites me nearly
every time I start a new web app.  Permissions.

Generally, the web server runs as "apache" or some other user.  Not as
you.  And that user probably doesn't have read/execute permissions in
one or more of /home, /home/mach10, /home/mach10/dist, or
/home/mach10/dist/lib.  Or it may not have read permissions to the
module in question, but in that case I believe you'd get a different
error message than this, so I would bet on the directories.

> Can't locate Skyweb.pm in @INC (@INC contains: /home/mach10/dist/lib
> /usr/lib/perl5/5.8.0/i386-linux-thread-multi /usr/lib/perl5/5.8.0
> /usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl
> /usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi
> /usr/lib/perl5/vendor_perl/5.8.0 /usr/lib/perl5/vendor_perl .) at
> /usr/local/apache/cgi-bin/sp/mach10.pl line 4.
> BEGIN failed--compilation aborted at
> /usr/local/apache/cgi-bin/sp/mach10.pl line 4.
> [Tue Nov  4 16:23:16 2003] [error] [client 192.168.1.101] Premature
> end of script headers: /usr/local/apache/cgi-bin/sp/mach10.pl
> 
> 
> I'm so novice to perl that i'm completely lost....anyone have any
> ideas.

I do not think this is a perl issue per se, but a unix one.

> Thanks for all the help in advance.
> 
> Gary


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

Date: Wed, 05 Nov 2003 05:03:17 GMT
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Perl can't locate a .pm in @INC
Message-Id: <20031104235823.23f1ccf5.jwillmore@remove.adelphia.net>

On Wed, 05 Nov 2003 02:13:38 +0100
Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> James E Keenan wrote:
> > Gary Hartl wrote:
<snip>
> > if this were the body of, say, an 'if' condition, but it's not a
> > Perl list.  Try:
> >     use lib ($ENV{'MACH10_LIB'} , '/home/mach10/dist/lib');
> > and let us know the results.
<snip>
> >> Can't locate Skyweb.pm in @INC (@INC contains:
> >/home/mach10/dist/lib
> 
> Doesn't that tell us that OP's "use lib" statement worked?

You're right.  I posted something similar as a solution, but you're
right.

> 
> Nevertheless, I'm not able to suggest a solution.

Nor can I :-(

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Pascal Users:  To show respect for the 313th anniversary
<(tomorrow) of the death of Blaise Pascal, your programs will be 
run at half speed. 


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

Date: Tue, 04 Nov 2003 19:26:00 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: perl regex: stopping short when using .*
Message-Id: <Xns9429CFE2B34F2sdn.comcast@216.196.97.136>

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

"john s" <JohnAtYapandaDotCommercial@no.spam> wrote in
news:qETpb.772$156.517437543@newssvr30.news.prodigy.com: 

> I have a string such as:
> blah blah <asl*&23fcLK>  blah blah
> the < and > will always be on the end, IF they are present at all, and
> anything can be in between them.
> How can I capture everything in between without the < and > if they
> even exist?
> 
> I tried variations of:
> [<\s]+(.*(?=>)?)\s+  and also tried using [^>]  in place of (?=>) and
> [<\s]+(.*)[<\s]+
> but everytime i use the .*  it always picks up the > symbol at the
> end, and I can get it to stop there, but i cannot get it to exclude
> the > 
> 
> So, how can I tell it to "get everything, including symbols, and stop
> just before > if it exists, or stop before the space, if > doesnt'
> exist"? 

The best I can come up with always includes the leading < if it's there:

    /(<[^>]*|[^>]*)/

If that's unacceptable, the following, while uglier, may work for you:

    /<([^>]*)|([^>]*)/
    $result = defined $1? $1 : $2;

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

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

iQA/AwUBP6hRpWPeouIeTNHoEQIKaQCfWVGqdirUeqFsfSfTYOY819KX0kwAoM6u
nOyPwVwJ8O+ETZfu0+osZHlW
=0U8N
-----END PGP SIGNATURE-----


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

Date: Wed, 05 Nov 2003 04:08:20 +0100
From: Sven Weise <bitte.keine.werbung@anti-qad.org>
Subject: Re: perl regex: stopping short when using .*
Message-Id: <pan.2003.11.05.03.08.19.979024.6311@futzelnet.de>

On Tue, 04 Nov 2003 21:05:42 +0100, john s wrote:
> How can I capture everything in between without the < and > if they even
> exist?

Maybe:

$string =~ /\<(.*?)\>/;

this will work?


-- 
"Bad admin! No biscuit!"


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

Date: Wed, 05 Nov 2003 10:17:17 +1100
From: Fred <fJogham@yahoo.com>
Subject: printing characters
Message-Id: <3FA8337D.9070303@yahoo.com>

Hello

how can I print Squars and triangles and reversed triangles, sold 
squares, arrows in perl?

thanks



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

Date: Wed, 05 Nov 2003 01:03:53 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: printing characters
Message-Id: <3FA849F9.4040806@rochester.rr.com>

Fred wrote:

 ...
> how can I print Squars and triangles and reversed triangles, sold 
> squares, arrows in perl?
 ...

Hmmmm...not sure exactly what you're asking.  You could

    use GD;

to generate the image you want, and then print that using a browser or 
art package, perhaps automating the print via command-line switches for 
the browser or art package if a browser/package with such functionality 
is chosen.

If you mean "how can I print characters from an oddball font", the 
answer to that will be very platform/OS dependent, and you haven't said 
what your platform/OS is.  It might be printer-dependant too, depending 
on your platform/OS.

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: 05 Nov 2003 01:05:31 GMT
From: "James E Keenan" <nospam_for_jkeen@concentric.net>
Subject: Re: printing characters
Message-Id: <bo9icr$90k@dispatch.concentric.net>


"Fred" <fJogham@yahoo.com> wrote in message
news:3FA8337D.9070303@yahoo.com...
> Hello
>
> how can I print Squars and triangles and reversed triangles, sold
> squares, arrows in perl?
>
You probably should read:
http://www.perldoc.com/perl5.8.0/pod/perluniintro.html to get a grasp on
Perl's Unicode capabilities.




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

Date: Tue, 4 Nov 2003 19:10:46 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: printing characters
Message-Id: <slrnbqgjgm.k9v.tadmc@magna.augustmail.com>

Fred <fJogham@yahoo.com> wrote:

> how can I print Squars and triangles and reversed triangles, sold 
> squares, arrows in perl?


Your question makes no sense, so I think you have some fundamental
misunderstanding that will get in your way.

How a character is rendered depends on many things, but one of
them is _not_ your choice of programming language.



You make output using Perl's print() function.

What output it is that you want to make depends on what you want
to do. In this case, you need the details of whatever display
or character set it is that you are using.

Once you know what character number corresponds to a "triangle",
you can interpolate it as described in the "Quote and Quote-like Operators"
section in perlop.pod.

One of these will likely do it for you:

    \033        octal char      (ESC)
    \x1b        hex char        (ESC)
    \x{263a}    wide hex char   (SMILEY)
    \c[         control char    (ESC)
    \N{name}    named Unicode character


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


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

Date: 05 Nov 2003 01:37:59 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: printing characters
Message-Id: <slrnbqgl3n.mjj.abigail@alexandra.abigail.nl>

Fred (fJogham@yahoo.com) wrote on MMMDCCXVII September MCMXCIII in
<URL:news:3FA8337D.9070303@yahoo.com>:
@@  Hello
@@  
@@  how can I print Squars and triangles and reversed triangles, sold 
@@  squares, arrows in perl?


You can't print squares that have been sold. Once sold, they are
gone. You'll have to buy new squares first.



Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: 4 Nov 2003 18:29:24 -0800
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: printing characters
Message-Id: <d61170e5.0311041829.608b22d6@posting.google.com>

Fred <fJogham@yahoo.com> wrote in message news:<3FA8337D.9070303@yahoo.com>...
> Hello
> 
> how can I print Squars and triangles and reversed triangles, sold 
> squares, arrows in perl?

Depends.

As images?  Then use the GD module.

If you could be more specific, then the answer could be more specific.

HTH

Jim
(jwillmore _at_ adelphia _dot_ net)


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

Date: Wed, 05 Nov 2003 03:23:27 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: printing characters
Message-Id: <P2_pb.9298$n6.267@nwrddc03.gnilink.net>

Fred wrote:
> how can I print

By using the print() function

> Squars and triangles and reversed triangles, sold
> squares, arrows in perl?

By using a character set that contains those symbols.

jue




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

Date: 4 Nov 2003 19:05:32 -0800
From: jwillmore@myrealbox.com (James Willmore)
Subject: Re: Problem Connecting w Perl/DBD::Oracle as SYSDBA
Message-Id: <d61170e5.0311041905.30c7b9e3@posting.google.com>

J R Longwill <longwill@psmfc.org> wrote in message news:<bo9807$97a$1@nntp.psmfc.org>...
<snip>
> The error I get when running this for database BB seems to be occuring 
> in the DBI library, at the exact point of connection to the database. 
> The error is:
> 
>          Uncaught exception from user code:
>          DBI connect('bb','sys',...) failed:  at ./bk3.pl line 80
>          Carp::croak('DBI connect(\'bb\',\'sys\',...) failed: ') called 
>   at /usr/lib/perl5/site_perl/5.6.1/i386-linux/DBI.pm line 579
>          DBI::__ANON__() called at 
> /usr/lib/perl5/site_perl/5.6.1/i386-linux/DBI.pm line 629
>          DBI::connect('DBI', 'dbi:Oracle:bb', 'sys', 'pswd123', 
> 'HASH(0x8335710)') called at ./bk3.pl line 80
> 
> The main error seems to be line 579 of 
> /usr/lib/perl5/site_perl/5.6.1/i386-linux/DBI.pm but I can't be sure.

Have you used the DBI 'trace' method?  This method captures the
"conversation" between the script and the database.  What you have
above is, well, and indication of a problem, but not too much else. 
Plus, the above is really nothing more than a traceback.  It's telling
you the connection failed - which you already knew (nice that the
script let's us know the obvious :-) ).

When ever I've had an issue like this, the 'trace' method _usually_
points out what's going on for me.  OTOH, my experience with Oracle is
_very_ limited.  I installed a "starter" version (from some book I
picked up about 2 years ago) on my Linux box, played around with it a
little, then put it aside :-(  Maybe someone else has other ideas.

HTH

Jim
(jwillmore _at_ adelphia _dot_ net)


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

Date: 04 Nov 2003 23:28:09 GMT
From: ctcgag@hotmail.com
Subject: Re: Rounding a float in Perl?
Message-Id: <20031104182809.119$MY@newsreader.com>

rjohnson@shell.com (Roy Johnson) wrote:
> anno4000@lublin.zrz.tu-berlin.de (Anno Siegel) wrote in message
> news:<bo8rm2$n4$1@mamenchi.zrz.TU-Berlin.DE>...
> > What is the mathematically accurate result of rounding 0.05 to one
> > decimal place?
>
> Convention says it rounds up. Maybe that's not mathematics, per se.
> Maybe it's not even a universal convention, but it's the only one I
> ever heard.

Another popular (and better) convention is to round up if the preceding
digit is odd and down if the preceding digit is even, i.e. 0.05 -> 0.0,
while 0.15 -> 0.2.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Wed, 5 Nov 2003 04:23:42 +0000 (UTC)
From:  Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Rounding a float in Perl?
Message-Id: <bo9u0e$258l$1@agate.berkeley.edu>

[A complimentary Cc of this posting was sent to
Anno Siegel
<anno4000@lublin.zrz.tu-berlin.de>], who wrote in article <bo7nm6$3qn$1@mamenchi.zrz.TU-Berlin.DE>:
> > Hope this slightly compensates my goof with having a constant-folded
> > benchmark ;-),
> 
> Well, it happens.

The real problem is that I know that it happens, so this is the first
thing I check when *somebody else* posts a benchmark.  Sigh....

Ilya


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

Date: Wed, 05 Nov 2003 00:09:04 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: simplify this if loop
Message-Id: <pan.2003.11.04.23.08.22.377198@aursand.no>

On Wed, 05 Nov 2003 06:34:53 +1100, Fred wrote:
> my ( $i ,$m ) = ( 0, 2 );
> my @group;
> foreach my $item ( @data ) {
>      $i++;
>      my ( $tot, $avg );
>      if ( @group == $m ) {
> 	push @group, $item;
> 	shift @group;
>      	foreach my $j ( @group ) { $tot += $j };
> 	$avg = $tot/$m;
> 	print $i, "  ", $item, "  ", $avg, "\n";
>      } else {
> 	push @group, $item;
> 	if ( @group == $m ) {
> 	    foreach my $j ( @group ) { $tot += $j };
> 	    $avg = $tot/$m;
> 	    print $i, "  ", $item, "  ", $avg, "\n";
> 	}
>      }
> }

This method is approximately 34% faster on my computer;

  my ($i, $m) = (0, 2);
  for my $idx ( 0 .. (@data - $m) ) {
      my $avg;
      my $to = ( $idx + $m ) - 1;
      $avg += $_ for ( @data[$idx .. $to] );
      $avg /= $m;
      print $idx + $m . '  ' $data[$idx + 1] . '  ' . $avg . "\n";
  }

Look out for errors in the code above.  For some reason ths copy/paste
functions doesn't work properly on my Linux box anymore.


-- 
Tore Aursand <tore@aursand.no>


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

Date: Wed, 05 Nov 2003 10:22:15 +1100
From: Fred <fJogham@yahoo.com>
Subject: Re: simplify this if loop
Message-Id: <3FA834A7.7050909@yahoo.com>

Fred wrote:
> my ( $i ,$m ) = ( 0, 2 );
> my @group;
> foreach my $item ( @data ) {
>     $i++;
>     my ( $tot, $avg );
>     if ( @group == $m ) {
>     push @group, $item;
>     shift @group;
>         foreach my $j ( @group ) { $tot += $j };
>     $avg = $tot/$m;
>     print $i, "  ", $item, "  ", $avg, "\n";
>     } else {
>     push @group, $item;
>     if ( @group == $m ) {
>         foreach my $j ( @group ) { $tot += $j };
>         $avg = $tot/$m;
>         print $i, "  ", $item, "  ", $avg, "\n";
>     }
>     }
> }
> 
> there is duplicates and I feel there is better way to write a faster 
> more cleaner code.
> 
> thanks for any suggestions
> 


my best, unless some one have a better way,

remove from the code above
foreach my $j ( @group ) { $tot += $j };
       $avg = $tot/$m;

call this function from inside the code instead of the above 2 lines


cal_avg(\@group, $m)

sub cal_avg {
     my $aref = shift;
     my $val = shift;
     my ($tot, $avg);
     for ( @{$aref}[-$val .. -1] ) { $tot += $_ };
     $avg = $tot / $val;
     return $avg;
}



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

Date: Wed, 05 Nov 2003 00:46:03 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: sub confusion
Message-Id: <3FA845CF.20300@rochester.rr.com>

walterg@example.com wrote:

> Eric J. Roode <REMOVEsdnCAPS@comcast.net> wrote:
 ...
> Thanks Eric.  I must be getting overly object-centric to have presumed $_
> would be local and default to the sub's ARGV[0].
> 


What is a "sub's ARGV[0]"???  Perhaps you mean the sub's @_ or perhaps 
$_[0] ?


> Walt

-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Wed, 05 Nov 2003 02:23:03 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: testing for 'undefined subroutine'
Message-Id: <3FA85C78.2010302@rochester.rr.com>

Torsten Mangner wrote:

 ...
> i need a capability (via a skript or something) to test my skripts (at 
> compile time), if all subroutines that are called in the programm are 
> really defined or 'use'd.
 ...

> Torsten
> 

You might try using the B::Xref module, perhaps as in:

    perl -MO=Xref -c programname.pl

The listing from B::Xref should clue you in on the names of any subs 
which aren't defined at compile time.  It should also let you know about 
any which are defined but not used anywhere, again as of compile time.

HTH.
-- 
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl



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

Date: Wed, 05 Nov 2003 10:15:27 +1100
From: Fred <fJogham@yahoo.com>
Subject: using a hash as condition selector
Message-Id: <3FA8330F.5040107@yahoo.com>


Hello
I have
my %hcond =(
	   condition => "1",
	   condition => "2"
	   );

where condition is ($a > $b and $s * $k < $f - 3)
I have many conditions in this hash.

in a code where I need the value out of the hash based on the condition.
the values of all the variables are known at the time the hash value is 
needed but do I have to

 ...code
 ...
$value = $hcond{$long_condition_written_here}
 ...
or there is a better way?

thanks



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

Date: Wed, 05 Nov 2003 00:39:28 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: using a hash as condition selector
Message-Id: <bo9da1$1bf72a$1@ID-184292.news.uni-berlin.de>

Fred wrote:
> I have
> my %hcond =(
>        condition => "1",
>        condition => "2"
>        );
> 
> where condition is ($a > $b and $s * $k < $f - 3)
> I have many conditions in this hash.

What made you think that a hash key can be an expression? To my 
knowledge it can't. Please study

     perldoc perlintro
     perldoc perldata

> $value = $hcond{$long_condition_written_here}
> ...
> or there is a better way?

Probably.

     perldoc perlsyn

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



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

Date: Tue, 4 Nov 2003 23:05:51 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: Verbose warnings
Message-Id: <bo9bcf$fre$1@holly.rdwarf.com>

Richard Voss <erutiurf@web.de> wrote:
: Greg Bacon wrote:
:> In article <3fa6ba78$0$1100$3c090ad1@news.plethora.net>,
:>     Seebs <seebs@plethora.net> wrote:
:> 
:> : Is there any way to find out WHICH variable is uninitialized, short of
:> : breaking a line up into bunches of single lines?
:> : [...]
:> 
:> Here's a start:

: that will only work with package variables, not with lexicals.

: I recommend the debugger.

Couldn't they just put:

no warnings qw(uninitialized);

 ... around the flaky section of code?

They can undo that with:

use warnings qw(uninitialized);

Or am I missing something really simple here?

-- 
Louis Erickson - wwonko@rdwarf.com - http://www.rdwarf.com/~wwonko/

Reality is just a convenient measure of complexity.  -- Alvy Ray Smith


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

Date: Tue, 4 Nov 2003 19:02:19 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Verbose warnings
Message-Id: <slrnbqgj0r.k9v.tadmc@magna.augustmail.com>

Louis Erickson <wwonko@rdwarf.com> wrote:
> Richard Voss <erutiurf@web.de> wrote:
>: Greg Bacon wrote:
>:> In article <3fa6ba78$0$1100$3c090ad1@news.plethora.net>,
>:>     Seebs <seebs@plethora.net> wrote:
>:> 
>:> : Is there any way to find out WHICH variable is uninitialized, 


> Couldn't they just put:
> 
> no warnings qw(uninitialized);

> Or am I missing something really simple here?


I think so.

It does not answer the question that was asked above.  :-)


I think we are working under the assumption that the uninitialized
value is a bug, and we're trying to find it so it can be fixed
(rather than masked).


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


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

Date: Wed, 05 Nov 2003 02:44:00 GMT
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Verbose warnings
Message-Id: <bcfb818ee13b1d859e85841fec86bfcc@news.teranews.com>

>>>>> "Louis" == Louis Erickson <wwonko@rdwarf.com> writes:

Louis> Couldn't they just put:

Louis> no warnings qw(uninitialized);

Louis> ... around the flaky section of code?

Not and be compatible with Perl 5.5, which is still alive and
well in many sites.

-- 
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: Tue, 4 Nov 2003 23:08:08 +0000 (UTC)
From: Louis Erickson <wwonko@rdwarf.com>
Subject: Re: Windows binary with debugging support
Message-Id: <bo9bgo$fvl$1@holly.rdwarf.com>

JW <jweed@justicepoetic.net> wrote:
: Hello,

: Because I have had many problems trying to compile perl on my WinME
: box, I was wondering if anyone knew of a good binary distro for
: windows which was compiled with Debugging support.  5.8.1 preferred.

What do you mean by "with debugging support"?  ActiveState supports
Perl's -d command, and can be used to debug Perl.  It even works with
at least one IDE out there.

Or do you mean with debugging symbols for the system debugger, like
Visual Studio or windbg?  That I'm not aware of, although that doesn't
mean there isn't one.

-- 
Louis Erickson - wwonko@rdwarf.com - http://www.rdwarf.com/~wwonko/

Once, adv.:
	Enough.  -- Ambrose Bierce, "The Devil's Dictionary"


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

Date: Wed, 05 Nov 2003 10:26:24 +1100
From: Fred <fJogham@yahoo.com>
Subject: Re: Windows binary with debugging support
Message-Id: <3FA835A0.8020301@yahoo.com>

JW wrote:
> Hello,
> 
> Because I have had many problems trying to compile perl on my WinME
> box, I was wondering if anyone knew of a good binary distro for
> windows which was compiled with Debugging support.  5.8.1 preferred.
> 
> Thank you for your time,
> 
> JW

free binary Perl distro for windows

http://www.activestate.com/Products/ActivePerl/

enjoy



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

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


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