[15495] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2905 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Apr 29 14:05:18 2000

Date: Sat, 29 Apr 2000 11:05:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957031507-v9-i2905@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sat, 29 Apr 2000     Volume: 9 Number: 2905

Today's topics:
        [Perl] How to find the Perl FAQ <rootbeer&pfaq*finding*@redcat.com>
    Re: clearning contents of a hash <rootbeer@redcat.com>
    Re: Hashes -- case insensitive keys? (Tad McClellan)
    Re: Help - If/Contains/Case/Array Beginners Question <bmb@ginger.libs.uga.edu>
    Re: If slices are so great... <rick.delaney@home.com>
    Re: If slices are so great... (Andrew Johnson)
    Re: overloading & 'constant' subroutines (M.J.T. Guy)
    Re: Perl 5.6.0/Solaris: ok to compile with [but not use (M.J.T. Guy)
    Re: perl in NT .BAT files Question <brents@newsguy.com>
    Re: program that prints itself <jeff@vpservices.com>
    Re: program that prints itself <lr@hpl.hp.com>
    Re: regex <aperrin@davis.DEMOG.Berkeley.EDU>
    Re: Retrieving data from another server <rootbeer@redcat.com>
    Re: Something isn't working, and I can't figure it out <care227@attglobal.net>
    Re: Something isn't working, and I can't figure it out <rootbeer@redcat.com>
    Re: String to scalar <lr@hpl.hp.com>
    Re: Weird Problem With Perl DBI and MySQL (Douglas Wilson)
    Re: Weird Problem With Perl DBI and MySQL otrcomm@wildapache.net
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 29 Apr 2000 16:17:21 GMT
From: Tom Phoenix <rootbeer&pfaq*finding*@redcat.com>
Subject: [Perl] How to find the Perl FAQ
Message-Id: <pfaqmessage957024967.26720@news.teleport.com>

Archive-name: perl-faq/finding-perl-faq
Posting-Frequency: weekly
Last-modified: 29 Apr 2000

[ That "Last-modified:" date above refers to this document, not to the
Perl FAQ itself! The last _major_ update of the Perl FAQ was in Summer
of 1998; of course, ongoing updates are made as needed. ]

For most people, this URL should be all you need in order to find Perl's
Frequently Asked Questions (and answers).

    http://www.cpan.org/doc/FAQs/

Please look over (but never overlook!) the FAQ and related docs before
posting anything to the comp.lang.perl.* family of newsgroups.

For an alternative way to get answers, check out the Perlfaq website.

    http://www.perlfaq.com/

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Beginning with Perl version 5.004, the Perl distribution itself includes
the Perl FAQ. If everything is pro-Perl-y installed on your system, the
FAQ will be stored alongside the rest of Perl's documentation, and one
of these commands (or your local equivalents) should let you read the FAQ.

    perldoc perlfaq
    man perlfaq

If a recent version of Perl is not properly installed on your system,
you should ask your system administrator or local expert to help. If you
find that a recent Perl distribution is lacking the FAQ or other important
documentation, be sure to complain to that distribution's author.

If you have a web connection, the first and foremost source for all things
Perl, including the FAQ, is the Comprehensive Perl Archive Network (CPAN).
CPAN also includes the Perl source code, pre-compiled binaries for many
platforms, and a large collection of freely usable modules, among its
560_986_526 bytes (give or take a little) of super-cool (give or take
a little) Perl resources.

    http://www.cpan.org/
    http://www.perl.com/CPAN/
    http://www.cpan.org/doc/FAQs/FAQ/html/
    http://www.perl.com/CPAN/doc/FAQs/FAQ/html/

You may wish or need to access CPAN via anonymous FTP. (Within CPAN,
you will find the FAQ in the /doc/FAQs/FAQ directory. If none of these
selected FTP sites is especially good for you, a full list of CPAN sites
is in the SITES file within CPAN.)

    California     ftp://ftp.cdrom.com/pub/perl/CPAN/
    Texas          ftp://ftp.metronet.com/pub/perl/
    South Africa   ftp://ftp.is.co.za/programming/perl/CPAN/
    Japan          ftp://ftp.dti.ad.jp/pub/lang/CPAN/
    Australia      ftp://cpan.topend.com.au/pub/CPAN/
    Netherlands    ftp://ftp.cs.ruu.nl/pub/PERL/CPAN/
    Switzerland    ftp://sunsite.cnlab-switch.ch/mirror/CPAN/
    Chile          ftp://ftp.ing.puc.cl/pub/unix/perl/CPAN/

If you have no connection to the Internet at all (so sad!) you may wish
to purchase one of the commercial Perl distributions on CD-Rom or other
media. Your local bookstore should be able to help you to find one.

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 

Comments and suggestions on the contents of this document
are always welcome. Please send them to the author at
<pfaq&finding*comments*@redcat.com>. Of course, comments on
the docs and FAQs mentioned here should go to their respective
maintainers.

Have fun with Perl!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/


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

Date: Sat, 29 Apr 2000 08:17:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: clearning contents of a hash
Message-Id: <Pine.GSO.4.10.10004290809210.21722-100000@user2.teleport.com>

On 29 Apr 2000, M.J.T. Guy wrote:

> % perl
> for (1..10000) {
> my %x;
> @x{1..1000}=();
> push @y, \%x;
> %x = ();         # or  undef %x;
> };

Properly indenting your code would make it easier to read.

> That uses 83 megabytes.    Now change that to undef and it uses 3352K.

perl figures that, since you're keeping the hash around, it's probably
going to get big again. By keeping that memory, adding to the hash again
should be faster. (At least, so I've been told. Perhaps you'll want to
benchmark something.)

But I hope you're not claiming that your example code is much like any
properly-written real-world program!

> To free a hash, always use "undef %hash".

I humbly challenge that 'always'. :-)

In the case of a hash which will be reused, it's probably better to assign
the empty list. If the hash won't be reused, it's probably better for it
to go out of scope. If you're willing to give up some speed to save
memory, perhaps using undef on the hash is a good choice.

Most often, in fact, when the question is "How do I free a hash?" or "How
do I free an array?" the right answer is "Let it go out of scope."

Cheers!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 29 Apr 2000 09:22:51 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Hashes -- case insensitive keys?
Message-Id: <slrn8glohb.4n2.tadmc@magna.metronet.com>

On 29 Apr 2000 05:25:01 GMT, Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Tad McClellan
><tadmc@metronet.com>],
>who wrote in article <slrn8gj6us.2io.tadmc@magna.metronet.com>:
>> But it _does_ return a sorted list.
>
>Nope.
>
>> It is sorted according to the (internal) hash function.
>
>If it were, then the order would not depend on the way keys were
>added/deleted to/from the hash.  


Gak!

So I get what I deserve for thinking of the common 
"hash data structure" instead of thinking of 
_perl's implementation_ of the "hash data structure".

Sorry folks.


>But it does (AFAI can deduce).
                 ^     ^^^^^^

But enquiring minds want to see for themselves...


-----------------------------
#!/usr/bin/perl -w
use strict;

my %h;

%h=();
$h{zero} = 0;
$h{one} = 1;
$h{two} = 2;
foreach ( keys %h ) { print "$_  ==>  $h{$_}\n" } print "------\n";

%h=();
$h{two} = 2;
$h{zero} = 0;
$h{one} = 1;
foreach ( keys %h ) { print "$_  ==>  $h{$_}\n" } print "------\n";
-----------------------------

output:

zero  ==>  0
two  ==>  2
one  ==>  1
------
zero  ==>  0
one  ==>  1
two  ==>  2
------



<sheepish>

 ... OIC  (Oh, I See)

</sheepish>


-- 
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Sat, 29 Apr 2000 12:01:58 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Help - If/Contains/Case/Array Beginners Question
Message-Id: <Pine.A41.4.10.10004291153180.21350-100000@ginger.libs.uga.edu>

On Sat, 29 Apr 2000, Paul wrote:
> Hi,
> 
> Thanks for replying so quickly, I saw this in the faq (How can I tell
> whether an array contains a certain element?) but it was doing exact matches
> I want where any part of an element in an array is anywhere in HTTP_REFERER?
> (I wish case insensitive matches also?)
> 
> e.g. array="org","net"
> if HTTP_REFERER="www.dsjghsdkjg.org it would find a match at element 1
> if HTTP_REFERER="www.network.org it would find a match at element 2 (as net
> is in the string)
> if HTTP_REFERER="www.dsgsg.com would not find any matches as org or net is
> not anywhere in the string
> 
> Any further comments appreciated...
> 
> Cheers
> 
> Paul.

Paul,

It helps to put your comments *after* previous comments.  It's sort of
like a conversation.  As regards your question, just change the exact
matches in the faq example into regular expression matches.  There are
plenty of examples of those around.

--
Brad




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

Date: Sat, 29 Apr 2000 15:45:29 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: If slices are so great...
Message-Id: <390B053C.E144E024@home.com>

Quantum Mechanic wrote:
> 
> I discovered this while trying to find an elegant solution using slices
> equivalent to the following:
> 
>    (undef, undef, @keep) = split( /,/, $string );
> 
> I wanted something like:
> 
>    @keep = split( /,/, $string )[2..-1]
> 
> but this of course doesn't DWYW. Is there another way besides a
> temporary variable?

    (@keep[0,1], @keep) = split /,/, $string;

That's why slices are so great.

-- 
Rick Delaney
rick.delaney@home.com


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

Date: Sat, 29 Apr 2000 16:34:58 GMT
From: andrew-johnson@home.com (Andrew Johnson)
Subject: Re: If slices are so great...
Message-Id: <SaEO4.9384$95.77899@news1.rdc1.mb.home.com>

In article <x7u2glzbqe.fsf@home.sysarch.com>,
 Uri Guttman <uri@sysarch.com> wrote:

[snip]
 
> you are truly warped. must be a requirement to write for manning
> (factoring in the mental state of damian)

That's warped? Then I'm glad I didn't mention carrying it over to
hash slices :-/

> maybe for 5.8? (5.7 will be maintenance release which is needed)

I am under the impression that 5.7 will be the development track,
and the maintenance track will be 5.6.1,  5.6.2 ...

andrew

-- 
Andrew L. Johnson   http://members.home.net/andrew-johnson/epwp.html
      It may be that your sole purpose in life is simply to 
      serve as a warning to others.
      


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

Date: 29 Apr 2000 15:49:37 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: overloading & 'constant' subroutines
Message-Id: <8ef0ah$for$1@pegasus.csx.cam.ac.uk>

In article <8e7c04$dm2$1@charm.magnus.acs.ohio-state.edu>,
Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Tom Phoenix 
><rootbeer@redcat.com>],
>who wrote in article <Pine.GSO.4.10.10004252317510.25963-100000@user2.teleport.com>:
>> Still, I'm not sure why your original code didn't work;
>
>  x * x
>
>is, obviously to any Perler ;-),  x(*x).
>
>How would one fix this?

By prototyping subroutine x to have no arguments.   Which of course
"use constant" does for you automatically.

THough I do question the wisdom of defining a subroutine with the same
name as a Perl operator.


Mike Guy


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

Date: 29 Apr 2000 16:11:10 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Perl 5.6.0/Solaris: ok to compile with [but not use] 5.005 threads?
Message-Id: <8ef1iu$h1v$1@pegasus.csx.cam.ac.uk>

In article <390719FD.4F196AC4@zeegee.com>, Eryq  <eryq@zeegee.com> wrote:
>I'm running Perl 5.6.0 on Solaris, which I've built with 5.005-style
>thread support.  I know that we're not supposed to deploy such a
>Perl in a production environment, but I'd like a little clarification:
>
>Suppose that none of my production scripts *use* threads; I just
>want the Thread support in there for a few non-production scripts.
>Will this setup be okay, or does compiling with 5.005 support 
>somehow comprimise unrelated parts of Perl?

It *should* be all right.   But there are always as-yet-undiscovered
bugs.    And of course, you'll take a speed hit.


Mike Guy


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

Date: Sat, 29 Apr 2000 10:38:45 -0500
From: Brent Stroh <brents@newsguy.com>
Subject: Re: perl in NT .BAT files Question
Message-Id: <6c0mgs86b434fh0so7ckctm0c133fdjtdj@4ax.com>

David Ness <DNess@Home.Com> wrote:

>Thanks for the information. What you say makes perfect sense to me, and 
>although I sure didn't know it was possible, I am happy to try it... 
>My one concern is that this sounds right at the frontier of where 98 may
>differ from NT and from Win2K, but I'll give it a try all three places...

I don't have a '98 or 2000 machine to test on, but I'd imagine that the
PATHEXT trick is only NT.  Without PATHEXT, under 98 or 2000, you'll have
to resort to perl <filename> or a batch file solution, unless you intend to
run them from the GUI.

PATHEXT is more or less equivalent to chmod +x.

>Thanks for taking the trouble to explain.

Good luck!



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

Date: Sat, 29 Apr 2000 08:30:11 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: program that prints itself
Message-Id: <390B0003.100D4767@vpservices.com>

John Lin wrote:
> 
> Dear all,
> 
> There was an old question in the age of APPLE II:
>     Write a BASIC program that prints itself.
> 
> Then, when C got popular, it became:
>     Write a C program that prints itself.
> 
> I wonder what the program would be like in Perl.
> Will you try to solve it?

Been there, done that.  There are dozens of those available in the
archives of this newsgroup.  Abigail won with the shortest file-length
of 0 bytes: an empty file always prints itself :-).  If you want one
that actually prints something, Zenin came up with: @ARGV=$0;print<>;

There is an entire home page devoted to these programs with hundreds
(maybe thousands) of examples in many languages, including Perl:

http://www.nyx.net/~gthompso/quine.htm

P.S., if you asked this because of a homework question, I get the 'A',
not you.  No, wait, Abigail and Zenin get the 'A', not me.

-- 
Jeff


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

Date: Sat, 29 Apr 2000 09:41:47 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: program that prints itself
Message-Id: <MPG.1374b0a1954e9bef98a9b6@nntp.hpl.hp.com>

In article <8ee4nn$hkn@netnews.hinet.net> on Sat, 29 Apr 2000 15:57:46 
+0800, John Lin <johnlin@chttl.com.tw> says...
> There was an old question in the age of APPLE II:
>     Write a BASIC program that prints itself.
> 
> Then, when C got popular, it became:
>     Write a C program that prints itself.
> 
> I wonder what the program would be like in Perl.
> Will you try to solve it?

In a current thread on this subject in the Fun With Perl list, I pointed 
out that a Google search for 'Perl quine' yields 147 references.  No 
need to reinvent that particular wheel here.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 29 Apr 2000 09:27:49 -0700
From: Andrew Perrin - Demography <aperrin@davis.DEMOG.Berkeley.EDU>
Subject: Re: regex
Message-Id: <u5kpur83m9m.fsf@davis.DEMOG.Berkeley.EDU>

jlamport@calarts.edu writes:

> In article <390A88A0.D9D7A0C7@aol.com>,
>   chris <chris@aol.com> wrote:
> > will this work
> > $one =~ s/book/do 'script.pl'/e;
> 
> If $one contains the string 'book', then this will load the script
> 'script.pl', execute it, and replace the first occurance in $one of the
> string 'book' with the last expression to be evaluated in 'script.pl'.
> If this is what you want, then yes, this works.

yup.

> 
> >
> > and will this work
> >
> > $one =~ s/book/script.pl/e;
> 
> If $one contains the string 'book', then this will call the subroutine
> named script, then call the subroutine named pl, and replace the first
> occurance in $one of the string 'book' with the concatenated return
> values of the two subroutines.  If this is what you want, then yes, this
> works.
> 

Nope.  Did you test it?

$one = 'book';
$one =~ s/book/script.pl/e;
print "After second, \$one is $one\n";

aperrin@SLOVO ~/perl % perl s.pl
After second, $one is scriptpl

> (hint:  this version could be more clearly written as:
> 
> $one =~ s/book/ script() . pl() /e;
> 

This one does what you suggested.


-- 
---------------------------------------------------------------------
Andrew J. Perrin - aperrin@demog.berkeley.edu - NT/Unix Admin/Support
Department of Demography    -    University of California at Berkeley
2232 Piedmont Avenue #2120  -    Berkeley, California, 94720-2120 USA
http://demog.berkeley.edu/~aperrin --------------------------SEIU1199


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

Date: Sat, 29 Apr 2000 08:05:52 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Retrieving data from another server
Message-Id: <Pine.GSO.4.10.10004290803591.21722-100000@user2.teleport.com>

On Sat, 29 Apr 2000 crtdude@my-deja.com wrote:

> <SCRIPT LANGUAGE="JavaScript">

Perhaps you meant to post this message to a newsgroup about Javascript.

> I got it to work in Netscape however I am having a problem in IE.

If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 29 Apr 2000 12:44:13 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <390B115D.CDA000F0@attglobal.net>

OK, I've fixed the quotes.  It still doesn't work.  I just bought 
another Perl book (Effective Perl Programming) and while I read 
this one, I thought I'd have one last stab out here.  

Problem summary: The subroutine below, displayed as Item 1, creates
an array containing each value passed to the script.  These values
are the users choices.  I then make sure that the array was actually
created and, if so, pass a reference to the array to the print_forms().

Item 2 is the subroutine called print_forms.  And it does get the 
reference to the array, it reads it and displays the first user
selected page.  It is supposed to then print whats left of that array
out to a file.  This is where it fails, with no error message. 

All subsequent calls to print_forms do not pass the array reference, 
since its only created that one time, hence the relaince on the file
to hold the rest of the array.  print_forms tests (using the unary 
-e) to see if the file exists.  If it doesn't, then it looks for the 
array reference.  If thats not there either, then it exits happily. 

But the file should be there!  Agh!  Not a single error in either
the log or execution via the command line to aid me.  So, not knowing
anyone who even likes Perl IRL, I come here.  Can _anyone_ see 
some fool mistake I may have made?  (be nice)



Item 1:

-------------8<-------------------------------8<---------------------

sub get_form_2 {

my @params = param;
my @pages;
# Here we will gather the params from the subroutine &show_form_2.  We
will test 
# the input to see if the user wanted to use the particular form
function, and if 
# so, we stick it in the array joined with an :.  



		if (param('spec_num') eq 'yes'){
			push @pages, param('spec_num_q') . ':spec_num' ; 
		}

		if (param('spec_proc') eq 'yes'){
			push @pages, param('spec_proc_q') . ':spec_proc' ;
		}

		if (param('price_plan') eq 'yes'){
			push @pages, param('price_plan_q') . ':price_plan' ;

		}

		if (param('css_queue') eq 'yes'){
			push @pages, param('css_queue_q') . ':css_queue' ;
		}


		if (param('dns') eq 'yes'){
			push @pages, param('dns_q') . ':dns' ;
		}

		if (param('promo') eq 'yes'){
			push @pages, param('promo_q') . ':promo' ;
		}

		if (param('links') eq 'yes'){
			push @pages, param('links_q') . ':links' ;
		}

		if (param('warez') eq 'yes'){
			push @pages, param('warez_q') . ':warez' ;
	
		}

		if (param('contacts') eq 'yes'){
			push @pages, param('contacts_q') . ':contacts' ;
		}


	if (@pages){ #making sure that this array is created
		
		&print_forms(\@pages);		
		
	}else{
		
		&done;
	}	

} # end &get_form_2


Item 2:

-------------8<-------------------------------8<---------------------

sub print_forms{   
	
	
my $acct = param('acct_id');

print 	header,

	start_html('Branded Account Page Creator'),
	
	h3({-align=>CENTER}, 'Branded Account Page Creator'),

	p();
	


print 	start_form(-action=>'/cgi-bin/addpage.cgi', -method=>POST),
	hidden(-name=>'acct_id', -value=>$acct),

p();	

my $filename = '/home/httpd/branded_data/' . $acct . '.data';
	
	if (-e $filename){
		
		open (DATA, "< $filename") or 
		die "can't open $filename: $!"; 
		
		@page_array = <DATA>;
		
		close DATA;

		$val_page = pop @page_array;
		chomp $val_page;
		
			if ($page_array[0]){
				open (DATA, "> $filename") or 
				die "can't open $filename: $!"; 
				
					foreach $page_array (@page_array) {
						print DATA $page_array . "\n";
					}

				close DATA;	
					
			}else{
				unlink $filename;
			}	 			

			
			if (defined $val_page){
				
				($value, $display) = split(':', $val_page);
				
			
				if ($display eq "spec_num"){
					
					&print_number($value);
					
				}elsif ($display eq "spec_proc"){
					
					&print_proc($value);
				
				}elsif ($display eq "price_plan"){
			
					&print_price($value);
					
				}elsif ($display eq "css_queue"){
			
					&print_queue($value);
					
				}elsif ($display eq "dns"){
			
					&print_dns($value);
					
				}elsif ($display eq "promo"){
					
					&print_promo($value);
					
				}elsif ($display eq "links"){
					
					&print_links($value);
					
				}elsif ($display eq "warez"){
					
					&print_warez($value);
					
				}elsif ($display eq "contacts"){
					
					&print_contacts($value);
					
				}else { &done; }
			
			}else{ &done; } 
	
	}else{ 	# else here takes over if no $filename was available.
		# Since the file is set by the first page, and not by &get_form_2
		# this is a necessary check.
		
		my $page = shift;
		my $now = pop @$page;

		chomp $now;
		
		my ($value, $firstpage) = split(':', $now);
		
		open (DATA, "> $filename") or die "can't open $filename: $!"; 
		
		print DATA map $_ . "\n" => @$page;
		
		close DATA;
		
		
		if ($firstpage eq "spec_num"){
					
			&print_number($value);
				
		}elsif ($firstpage eq "spec_proc"){
				
			&print_proc($value);
				
		}elsif ($firstpage eq "price_plan"){
			
			&print_price($value);
				
		}elsif ($firstpage eq "css_queue"){
		
			&print_queue($value);
					
		}elsif ($firstpage eq "dns"){
			
			&print_dns($value);
			
		}elsif ($firstpage eq "promo"){
					
			&print_promo($value);
					
		}elsif ($firstpage eq "links"){
					
			&print_links($value);
					
		}elsif ($firstpage eq "warez"){
					
			&print_warez($value);
					
		}elsif ($firstpage eq "contacts"){
					
			&print_contacts($value);
					
		}else { &done; }	
	
	
	
	
	}	



}


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

Date: Sat, 29 Apr 2000 09:53:37 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Something isn't working, and I can't figure it out
Message-Id: <Pine.GSO.4.10.10004290949230.1278-100000@user2.teleport.com>

On Sat, 29 Apr 2000, Drew Simonis wrote:

> Problem summary: The subroutine below, displayed as Item 1, 

Could you cut this down any further? Try to make a small, self-contained
program which shows the one or two lines which aren't doing what you want,
with just enough context so that we can try them ourselves.

> This is where it fails, with no error message. 

Well, perl should never fail to give some dying words when it unexpectedly
has to quit. Probably your other software (a web server, perhaps) is
hiding that message from you. 

There are other ways to do this, but for debugging, I
sometimes put something like this near the top of a script.

    # Remove this block when done debugging!
    BEGIN {
	local($|) = 1;			# Temporarily turn off buffering
	print "Content-type: text/plain\n\n";
	my $date = localtime;
	print "Script $0\nrunning on $date (Perl version $])\n\n";
	unless (open STDERR, ">&STDOUT") {
	    print "Can't redirect STDERR: $!";
	    exit;
	}
	print "\n";
    }

Now you should be able to see any error messages (and everything else)
produced by your script, right on your browser.

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 29 Apr 2000 10:14:36 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: String to scalar
Message-Id: <MPG.1374b84957fe7e0698a9b7@nntp.hpl.hp.com>

In article <390ac1c6.3372230@news.skynet.be> on Sat, 29 Apr 2000 
11:46:41 GMT, Bart Lateur <bart.lateur@skynet.be> says...

 ...

> Perl uses a caching mechanism for scalars, for efficiency. A scalar can
> contain multiple representations of the same value. If a new value
> assigned to a scalar, all other representations are marked "invalid".

WARNING:

A bug introduced into 5.6.0 allows some invalid representations to 
persist.  I reported this last week, and surely it will be corrected 
soon.  Otherwise there is the prospect of insidious wrong answers being 
produced.

I was chided for characterizing the severity of the bug as 'medium'.  
Others may consider it serious enough to put 5.6.0 under suspicion.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Sat, 29 Apr 2000 15:41:15 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: Weird Problem With Perl DBI and MySQL
Message-Id: <390afa3a.529712@news>

On Sat, 29 Apr 2000 08:34:53 GMT, otrcomm@wildapache.net wrote:


>        $SQL = qq{UPDATE transactions
>                SET status="markret"
>                WHERE code = "000129-1"};
>
>DBI->trace(2,"dbi.out");  
>        
>        $sth = $dbh->prepare ($SQL) or die "Cannot SELECT from $table" ;

You could probably stand to use RaiseError or include $dbh->errstr in
your die message here and in the execute (perldoc DBI). Even though your trace
indicates that its not dying. There's also a DESTROY here in your
trace. Was there a previous '$sth' that you're reusing here? If so,
you could stand to use a different variable name here (and use
'my', or at least just use 'my' if this is another enclosed block.
BTW, this (and the following execute) is not a SELECT statement.

>        
>        # excute the query
>        $sth->execute or die "Cannot execute SELECT from $table";      


>        
>        $sth->finish if $sth;
You only need to 'finish' if this is a SELECT statement. You can
'undef $sth' if you're done with it to release resources, though.

The trace looks normal, are you sure you're opening the right database?
are you sure there's a record in that table with that value?
Have you tried the same SQL statement with the mySQL command
line interface and gotten the results you expect, or the same
as the results here?


HTH,
Douglas Wilson


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

Date: Sat, 29 Apr 2000 17:52:29 GMT
From: otrcomm@wildapache.net
Subject: Re: Weird Problem With Perl DBI and MySQL
Message-Id: <390b1dea.741616598@news.wildapache.net>

On Sat, 29 Apr 2000 15:41:15 GMT, dwilson@gtemail.net (Douglas Wilson)
wrote:


>
>You could probably stand to use RaiseError or include $dbh->errstr in
>your die message here and in the execute (perldoc DBI). Even though your trace
>indicates that its not dying. There's also a DESTROY here in your
>trace. Was there a previous '$sth' that you're reusing here? If so,
>you could stand to use a different variable name here (and use
>'my', or at least just use 'my' if this is another enclosed block.
>BTW, this (and the following execute) is not a SELECT statement.

I renamed the variable '$sth1' and included a 'my' statement for $sth1,
$DSN, and $dbh and it worked.

>
>>        
>>        # excute the query
>>        $sth->execute or die "Cannot execute SELECT from $table";      
>
>
>>        
>>        $sth->finish if $sth;
>You only need to 'finish' if this is a SELECT statement. You can
>'undef $sth' if you're done with it to release resources, though.
>

That you for your help here.  I never realized the importance of the 'my'
definition until now.  This will make me go back through all my code and
"localize" the variables.

Thanks again,
Murrah Boswell
otrcomm@wildapache.net

>
>HTH,
>Douglas Wilson



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 2905
**************************************


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