[16181] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3593 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 10 18:43:51 2000

Date: Mon, 10 Jul 2000 15:43:40 -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: <963269020-v9-i3593@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 10 Jul 2000     Volume: 9 Number: 3593

Today's topics:
        Problems running the perl debugger (Joe Brenner)
    Re: Problems running the perl debugger <jason.holland@dial.pipex.com>
    Re: Problems running the perl debugger (Joe Brenner)
    Re: Problems running the perl debugger (Joe Brenner)
    Re: Problems running the perl debugger <jason.holland@dial.pipex.com>
    Re: Problems running the perl debugger (Joe Brenner)
        Problems with a string ufssin@my-deja.com
    Re: Problems with a string <pap@sotonians.org.uk>
    Re: Problems with a string ufssin@my-deja.com
    Re: Problems with a string ufssin@my-deja.com
    Re: Problems with a string (Tad McClellan)
        Problems with accessing dbm file <dvo@novosoft.nsc.ru>
    Re: Problems with accessing dbm file (jason)
        Problems with querystring ufssin@my-deja.com
    Re: Problems with querystring ufssin@my-deja.com
        Problems with || and "that IF this" <skylemon@ne.mediaone.net>
    Re: Problems with || and "that IF this" <uri@sysarch.com>
        Pull 2nd argument out of Hash Array (BUCK NAKED1)
    Re: Pull 2nd argument out of Hash Array (BUCK NAKED1)
    Re: Pull 2nd argument out of Hash Array (Keith Calvert Ivey)
    Re: Pull 2nd argument out of Hash Array (Reini Urban)
    Re: Pull 2nd argument out of Hash Array (BUCK NAKED1)
    Re: Pull 2nd element out of Hash Array (BUCK NAKED1)
    Re: push question eedlin@my-deja.com
        Q: Looking for a spider that just lists changed urls ? <iain@bricbrac.de>
        Question: Basic SMTP Problem <senatorpalpatineNOseSPAM@dereth.net.invalid>
    Re: Question: Basic SMTP Problem <qvaff@hotmail.com>
    Re: Question: Basic SMTP Problem <senatorpalpatineNOseSPAM@dereth.net.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 6 Jul 2000 07:19:00 GMT
From: doom@kzsu.stanford.edu (Joe Brenner)
Subject: Problems running the perl debugger
Message-Id: <8k1bt4$3o1$1@nntp.Stanford.EDU>

I've decided it's about time I dropped the somewhat cheesy
technique of scattering statements like this around 

  ($DEBUG) && print STDERR "The number of large fasteners is: $scrwups\n";

and see if I can finally overcome my mental block on using
a debugger.  

But I haven't even been able to get the perl debugger to run
without changing the first line of my scripts to: 

   #!/usr/bin/perl -d

Typically, they're something like this: 

   #!/usr/bin/perl -wT

I can obviously toggle the first lines back and forth during
the debugging proces, but that strikes me as error prone.  
I feel like I've got to be missing some simple trick about 
how to run under the debugger... But I don't see anything
like this in any FAQs out there that I can find.

If I don't remove the -T flag, I get errors like this:

   Too late for "-T" option at color.pl line 1.

   Cannot print stack trace, load with -MCarp option to see
   stack at /usr/lib/perl5/5.00503/perl5db.pl line 1952.
   Debugged program terminated.  Use q to quit or R to restart,

And if I don't remove the -w flag, I can run the debugger 
from the command line (with a "perl -d") but it fails if 
I try and do this from inside of emacs (with an 
"M-x perldb"). 

Anyone have any suggestions?



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

Date: Thu, 06 Jul 2000 21:33:22 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Re: Problems running the perl debugger
Message-Id: <3964FB22.FE795176@dial.pipex.com>

Joe,

I sometimes use:

	perl -S -d script.pl

where the -S switch makes perl look for the script in your $PATH.

I usually put a link to the scripts I'm developing into my ~/bin
directory for easy access. This will probably work on Win32 as well.

Jason

-- 
"Throw me a bone people!"

                 Dr Evil


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

Date: 7 Jul 2000 02:16:14 GMT
From: doom@kzsu.stanford.edu (Joe Brenner)
Subject: Re: Problems running the perl debugger
Message-Id: <8k3ehe$qbn$1@nntp.Stanford.EDU>

Jason Holland <jason.holland@dial.pipex.com> writes:

>I sometimes use:

>	perl -S -d script.pl

>where the -S switch makes perl look for the script in your $PATH.

>I usually put a link to the scripts I'm developing into my ~/bin
>directory for easy access. This will probably work on Win32 as well.

Thanks, though maybe I didn't make it clear that I can run
run the script under the debugger with a 

   perl -d script.pl

without any trouble, the (main) problem is that the debugger won't 
run at all if the first line of the script tries to turn on
taint mode (with the -T flag).  I was also having some odd
problems running the debugger from under emacs, but that
seems to come and go. 

These are cgi scripts I'm working on at the moment, so I'm
reluctant to turn off taint mode during debugging (I might
forget to turn it back on).  And in general I like to run 
with -w (even if that is of limited utility for a cgi
script). 

It seems like this should be a really common problem, I'd be
surprised if there isn't a solution I'm missing.  Like say, 
a way of running a script that overrides the #! line.   

Come to think of it, this seems to work: 

   tail +2 script.pl | perl -d

I can't quite see how to get this to work from inside of
emacs, though.

And I see there's a "--" flag that terminates switch
processing, so it'd be nice if this worked (but it doesn't
seem to):

   perl -d -- script.pl

Or maybe there's a way of making things like taint mode
conditional on how the script was run?  Can you turn taint
mode on and off in a script? 

Just thinking out loud at this point.  
Feel free to jump in if anyone has any better ideas. 



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

Date: 7 Jul 2000 02:48:55 GMT
From: doom@kzsu.stanford.edu (Joe Brenner)
Subject: Re: Problems running the perl debugger
Message-Id: <8k3gen$qoq$1@nntp.Stanford.EDU>

Ah, more fun and excitement.  Doing a web search for the
error: 

  Too late for "-T" option

Turns up some information that makes me realize that the
trouble is that the script is getting run like 

   perl -d script.pl

But the poundbang line at the top also then invokes the -T
flag.  But perl needs that -T to be in the first group of 
flags, or else it gives up and says "you should've thought
of that sooner".  

So, all I need to do is run it more like: 

   perl -dT script.pl

and then the _T in the poundbang will just be redundant. 


   
  Too late for "-T" option

Turns up some information that makes me realize that the
trouble is that the script is getting run like 

   perl -d script.pl

But the poundbang line at the top also then invokes the -T
flag.  But perl needs that -T to be in the first group of 
flags, or else it gives up and says "you should've thought
of that sooner".  

So, all I need to do is run it more like: 

   perl -dT script.pl

and then the _T in the poundbang will just be redundant. 

That works in a terminal shell, but it doesn't work in
emacs.  If I do an M-x perldb, it then asks 

   Run perldb (like this):

And if I answer 

    perl -Td script.pl

It just seems to die without seeing "script.pl"... 


And if I answer 

     perl -dT script.pl 

Then the debugger tries to run perl5db.pl in taint mode, 
and it dies because with taint warnings on the debugger
itself:  

     DB<1> Insecure dependency in eval while running with -T
     switch at /usr/lib/perl5/5.00503/perl5db.pl line 1239, <IN>
     chunk 3.

I guess they never planned on running perl5db.pl as a CGI
script.  Go figure. 

Anyway, in case it isn't obvious I'm running 
perl5db.pl version 1.0402 under perl version 5.00503, 
on a linux box (RedHat 6.1). 

And any hints about this one would certainly be
appreciated.  Nothing urgent, but it would help my peace of
mind tremendously. 



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

Date: Fri, 07 Jul 2000 19:57:54 +0000
From: Jason Holland <jason.holland@dial.pipex.com>
Subject: Re: Problems running the perl debugger
Message-Id: <39663642.5DAD7E1@dial.pipex.com>

Hello Joe,

Hm, looking in "perlrun" and "perlsec", apparently taint checking needs
the -T switch to turn it on explicitly. Taint checking is also made
active if the script is run setuid. Personally though I've not used
taint checking much in my own programs.

I was wondering if there was a special variable in Perl that would
toggle taint checking, but when you think about this probably wouldn't
make much sense ;-)

If it's a CGI script, I sometimes write a wrapper module that simulates
the CGI environment that the script will run in; sometimes it's more
convenient that way.

Good luck!

Jason

-- 
"Drink Cisk and prosper."

                Mr Spock


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

Date: 7 Jul 2000 23:45:48 GMT
From: doom@kzsu.stanford.edu (Joe Brenner)
Subject: Re: Problems running the perl debugger
Message-Id: <8k5q3c$jah$1@nntp.Stanford.EDU>

Jason Holland <jason.holland@dial.pipex.com> writes:

>Hm, looking in "perlrun" and "perlsec", apparently taint checking needs
>the -T switch to turn it on explicitly. Taint checking is also made
>active if the script is run setuid. Personally though I've not used
>taint checking much in my own programs.

>I was wondering if there was a special variable in Perl that would
>toggle taint checking, but when you think about this probably wouldn't
>make much sense ;-)

Yes, I can't find anything like that, myself, but I can
easily imagine that there might be uses for it.  

Just as you might want to toggle -w mode, if you knew some
of your code was going to continually generate spurious
warnings, for example something like: 

  ($1st, $3rd, $4th, $5th, $others_if_any) = split /\s+/, $stuff;

Is pretty guaranteed to give you lots of "variable not
initialized" warnings.  

I bet there are equivalent cases with "taint" mode (how
about this one: taint complains about using DBI to put
tainted data in an external database... but is this *really*
a dangerous operation?  It's not like it's going to go
through the shell).

>If it's a CGI script, I sometimes write a wrapper module that simulates
>the CGI environment that the script will run in; sometimes it's more
>convenient that way.

Yes, something like that may be the solution.  The wrapper
module calls the script itself, but strips off the first
line?  

Or I guess it'd be simpler to have a wrapper script that
contains just the first line, and a call to the main
program.  You run the program directly for debugging
purposes, when you don't want the pound-bang... 

My main goal is to run it inside of emacs, so I just may
just write some emacs code that toggles between two
pound-bang lines before running M-x perldb.

Seems like a really silly business to me, but as far as I
can tell, the gods of perl regard this as "operating as
designed".  



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

Date: Mon, 10 Jul 2000 10:18:47 GMT
From: ufssin@my-deja.com
Subject: Problems with a string
Message-Id: <8kc7u8$o8f$1@nnrp2.deja.com>

I open a aspl-skript with the following URL
script.aspl?text=hello
now the script.aspl should read it it and put in
in the var $text, I tried all but I can't do
this, can you help me? thx


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


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

Date: Mon, 10 Jul 2000 12:05:44 +0000
From: "Paul Taylor" <pap@sotonians.org.uk>
Subject: Re: Problems with a string
Message-Id: <09ia5.1855$6W.299311@nnrp4.clara.net>

In article <8kc7u8$o8f$1@nnrp2.deja.com>, ufssin@my-deja.com wrote:
> I open a aspl-skript with the following URL script.aspl?text=hello now
> the script.aspl should read it it and put in in the var $text, I tried
> all but I can't do this, can you help me? thx

What's aspl?  Is it Perl running through ASP or something?

If you're having a Perl issue, please post your script and tell us what
you're trying to do.

Pap.


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

Date: Mon, 10 Jul 2000 11:43:19 GMT
From: ufssin@my-deja.com
Subject: Re: Problems with a string
Message-Id: <8kccsl$f8h$1@nnrp1.deja.com>

aspl is PerlScrip is like php, you can put in HTML and PerlScript-Code
the PerlScript is in <%  %>.
I want to read a url-string from a form or so, how do I do this? (sorry
about my English, It isn't my mother-language)I hope someone can help
me I need it.


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


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

Date: Mon, 10 Jul 2000 12:48:43 GMT
From: ufssin@my-deja.com
Subject: Re: Problems with a string
Message-Id: <8kcgn6$hpn$1@nnrp1.deja.com>

I tried this 3 commands, but the don't work:

$value7 = TRIM( Request( "t" ) );
$value7= param("t");
$value7=$Request->QueryString("t");



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


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

Date: Mon, 10 Jul 2000 08:17:43 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Problems with a string
Message-Id: <slrn8mjfn7.tf8.tadmc@magna.metronet.com>

On Mon, 10 Jul 2000 11:43:19 GMT, ufssin@my-deja.com <ufssin@my-deja.com> wrote:

>I want to read a url-string from a form or so, how do I do this?


   perldoc CGI


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


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

Date: Wed, 5 Jul 2000 18:08:17 +0700
From: "Dmitry Otchenash" <dvo@novosoft.nsc.ru>
Subject: Problems with accessing dbm file
Message-Id: <8jv4pn$aet$1@nl.novosoft.ru>

Hi all,

I experience the following problem with database stored in DBM format. If I
use the following code

foreach $key (keys %DATABASE) { # step through all values
    print "$key $DATABASE{$key}\n";
}

all pairs key, value are printed. But if I change this to following


while (($key, $value) = each(%DATABASE)) {
    print "$key $value\n";
}

some of the pairs are not printed. Does anybody have any clue why this
happens?

Thanks,

Dmitry.


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

Date: Thu, 06 Jul 2000 14:43:34 GMT
From: elephant@squirrelgroup.com (jason)
Subject: Re: Problems with accessing dbm file
Message-Id: <MPG.13cf385a6a00125798976f@news>

  [ removed alt.perl and comp.lang.perl.moderated ]

Dmitry Otchenash writes ..
>I experience the following problem with database stored in DBM format. If I
>use the following code
>
>foreach $key (keys %DATABASE) { # step through all values
>    print "$key $DATABASE{$key}\n";
>}
>
>all pairs key, value are printed. But if I change this to following
>
>
>while (($key, $value) = each(%DATABASE)) {
>    print "$key $value\n";
>}
>
>some of the pairs are not printed. Does anybody have any clue why this
>happens?

well .. this comes from the documentation for each

"
If you add or delete elements of a hash while you're iterating over it, 
you may get entries skipped or duplicated, so don't.
"

if it's a tied hash then the adding and deleting might be happening

-- 
 jason - elephant@squirrelgroup.com -


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

Date: Mon, 10 Jul 2000 10:21:01 GMT
From: ufssin@my-deja.com
Subject: Problems with querystring
Message-Id: <8kc824$c1a$1@nnrp1.deja.com>

I open my script script.aspl with
script.aspl?text=hello
the script should put the value from text in a var, but how can I do
this? thx for solutions
sorry about my English I'm Swiss


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


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

Date: Mon, 10 Jul 2000 10:27:07 GMT
From: ufssin@my-deja.com
Subject: Re: Problems with querystring
Message-Id: <8kc8dh$cb2$1@nnrp1.deja.com>

ups I forgott It's PerlScript :_)


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


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

Date: Mon, 03 Jul 2000 19:49:51 GMT
From: Sky Lemon <skylemon@ne.mediaone.net>
Subject: Problems with || and "that IF this"
Message-Id: <3960EDFB.44133476@ne.mediaone.net>

Perlish people,

    I'm a newbie to perl using the book "Learning Perl" by Schwartz pub.
O'Reilly. I'm attempting exercise 3 from chapter 10 in that book, but
that isn't as relevent. I'm wondering why I'm getting this error:

syntax error at .//filespecs.perl line 12, near ""is readable, " if"
Scalar found where operator expected at .//filespecs.perl line 13, at
end of line
        (Missing operator before ?)
syntax error at .//filespecs.perl line 16, near "}"
Execution of .//filespecs.perl aborted due to compilation errors.

When I try to execute this code:

#!/usr/bin/perl -w
#
# Takes input filenames and tells you wether or they are readable,
writable, executable, or exist.

do {
   print "Enter a filename to give specs about: "; chomp($filename =
<STDIN>);
   $list[$index++] = $filename;
} while $filename;

foreach $filename (@list) {
   $message  = "does exist, " if (-e $filename) || (print "$filename
does not exist.\n" && next);
   $message .= "is readable, " if (-r $filename) || $message .= "is not
readable, ";
   $message .= "is writeable, " if (-w $filename) || $message .= "is not
writeable, ";
   $message .= "and is executable." if (-x $filename) || $message .=
"and is not executable.";
   print "$filename $message\n";
}

    I've tried a few things, like grouping everything in parenthesis,
but nothing seems to work. It seems that it's not liking my .='s. Does
anyone have any tips? Thanks.

-Sky Lemon



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

Date: Mon, 03 Jul 2000 21:42:00 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Problems with || and "that IF this"
Message-Id: <x73dlqsxg8.fsf@home.sysarch.com>

>>>>> "SL" == Sky Lemon <skylemon@ne.mediaone.net> writes:

  SL> foreach $filename (@list) {
  SL>    $message  = "does exist, " if (-e $filename) || (print "$filename
  SL> does not exist.\n" && next);

that line of code is very goofy. even though using || for side effect
code is a common idiom, i have rarely seen it used like that and with a
print command.

do you realize that print returns a true value if it prints something?
yes it does. so the || will always be true even if the file doesn't
exist and you will assign that string. better make that a regular if
statement.

	if ( -e $filename ) {
		$message = 'does exist' ;
	}
	else {
		print "$filename doesn't exist\n" ;
		next ;
	}

  SL>    $message .= "is readable, " if (-r $filename) || $message .= "is not
  SL> readable, ";

yucky!!

	$message .= ( -r $filename ) ? 'is readable' : 'is not readable' ;


  SL>    $message .= "is writeable, " if (-w $filename) || $message .= "is not
  SL> writeable, ";

|| binds tighter than .= so that code is way off base. why are you
trying such hard ways to do such simple stuff? just use ?: or simple if
statements.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Sat, 8 Jul 2000 01:23:58 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Pull 2nd argument out of Hash Array
Message-Id: <5628-3966C8FE-98@storefull-244.iap.bryant.webtv.net>

Can someone please tell me how to pull the 2nd argument out of this Hash
Array?
$title = int($rand[+1]);   <<<That's the line I'm having trouble with.
Thanks, and I'd really appreciate it if you could email me at
dennis100@webtv.net

#!/usr/local/bin/perl 
print "Content-type:text/html\n\n"; 
%songs = ("mid/g-l/gloria.mid", "Gloria", 
"mid/a-f/aintnomountain.mid", "Ain/'t No 
Mountain High Enough", 
"mid/m-r/new_york_city_boy.mid", "New 
York City Boy");   
$rand = int(rand(%songs)); 
$play = $songs[$rand]; 
$title = int($rand[+1]);
print("<body bgcolor='black'><EMBED 
SRC='$play' hidden='true' 
autostart='true'>"); 
print("</EMBED><center><font size='1' 
color='white'></EMBED>");
print("Now Playing... ");
print("</font>");
print("<font size='2' color='#66CCFF'>");
print($title);
print("</font></center></body>") 



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

Date: Sat, 8 Jul 2000 09:07:46 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Pull 2nd argument out of Hash Array
Message-Id: <2583-396735B2-3@storefull-246.iap.bryant.webtv.net>

Can someone PLEASE HELP?!?!?!!!!!!!!!  FWIW, I'm not just a webtv'er...
lol. Further, I've done the script above with elsif conditions and also
with arrays, and it worked fine. I'm just trying to make it better and
less prone to errors. I think the script would be less prone to errors,
if the song titles could be listed in an array right after the URL,
instead of in a separate array. I just don't know how to extract the
random title from a hash array. Of course, the random title has to match
the random URL that is selected.

Thanks again,
Dennis
 



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

Date: Sat, 08 Jul 2000 14:25:59 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: Pull 2nd argument out of Hash Array
Message-Id: <39673591.3962553@nntp.idsonline.com>

dennis100@webtv.net (BUCK NAKED1) wrote:

>Can someone please tell me how to pull the 2nd argument out of this Hash
>Array?

You need to learn the differences between scalars, arrays, and
hashes.  There's no relation between the variables $foo, @foo,
and %foo.

>$title = int($rand[+1]);   <<<That's the line I'm having trouble with.
>Thanks, and I'd really appreciate it if you could email me at
>dennis100@webtv.net
>
>#!/usr/local/bin/perl 

Adding "-w" after "perl" here would turn on warnings, which
would help you find problems with your program.  Adding the line
"use strict;" next would provide additional help.

>print "Content-type:text/html\n\n"; 
>%songs = ("mid/g-l/gloria.mid", "Gloria", 
>"mid/a-f/aintnomountain.mid", "Ain/'t No 

Why is there a slash before the apostrophe?

>Mountain High Enough", 
>"mid/m-r/new_york_city_boy.mid", "New 
>York City Boy");   
>$rand = int(rand(%songs)); 

rand(%songs) gives you a random number greater than or equal to
0 and less than the number of filled buckets in the hash %songs.
I don't think that's what you want.

>$play = $songs[$rand]; 

Now you're using $rand as an index to the array @songs, which
you haven't defined.

>$title = int($rand[+1]);

Now you're using the second element (+1 is the same as 1) of the
array @rand, which you also haven't defined.

>print("<body bgcolor='black'><EMBED 
>SRC='$play' hidden='true' 
>autostart='true'>"); 
>print("</EMBED><center><font size='1' 
>color='white'></EMBED>");
>print("Now Playing... ");
>print("</font>");
>print("<font size='2' color='#66CCFF'>");
>print($title);
>print("</font></center></body>") 
>

This would be more readable as a here-doc:

print <<EOT;
<body bgcolor="black">
<embed src="$play" hidden="true" autostart="true"></embed>
<center>
<font size="1" color="white">Now Playing...</font>
<font size="2" color="#66ccff">$title</font>
</center>
</body>
EOT

Of course, having automatic background sounds on your pages is a
good way to get people to hit the back button and leave
immediately.  I hate it when I'm sitting in trying to find
something on the Web and suddenly some noise starts coming out
of the speakers.  So do my coworkers.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Sat, 08 Jul 2000 14:56:01 GMT
From: rurban@sbox.tu-graz.ac.at (Reini Urban)
Subject: Re: Pull 2nd argument out of Hash Array
Message-Id: <39673fa8.11172825@news>

BUCK NAKED1 wrote:
>Can someone please tell me how to pull the 2nd argument out of this Hash
>Array?

hashes are not ordered, there's no such thing as the "2nd argument on an
hash array". there exist "arrays" which have a "2nd element" and there
are "functions" which accept "2nd arguments".
so maybe you need the 2nd element of an array. 
this would be $arr[1] for @arr, assuming @arr is zero based. perl is not
VB nor autolisp so it is zero-based. fine.

so please try to fix the crap below.

some hints: 
[+1] is the same as [1]
$rand is no array, 
$rand[1] extracts the 2nd element from @rand.

>$title = int($rand[+1]);   <<<That's the line I'm having trouble with.
>Thanks, and I'd really appreciate it if you could email me at
>dennis100@webtv.net
>
>#!/usr/local/bin/perl 
>print "Content-type:text/html\n\n"; 
>%songs = ("mid/g-l/gloria.mid", "Gloria", 
>"mid/a-f/aintnomountain.mid", "Ain/'t No 
>Mountain High Enough", 
>"mid/m-r/new_york_city_boy.mid", "New 
>York City Boy");   
>$rand = int(rand(%songs)); 
>$play = $songs[$rand]; 
>$title = int($rand[+1]);
>print("<body bgcolor='black'><EMBED 
>SRC='$play' hidden='true' 
>autostart='true'>"); 
>print("</EMBED><center><font size='1' 
>color='white'></EMBED>");
>print("Now Playing... ");
>print("</font>");
>print("<font size='2' color='#66CCFF'>");
>print($title);
>print("</font></center></body>") 
>

--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


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

Date: Sat, 8 Jul 2000 17:14:08 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Pull 2nd argument out of Hash Array
Message-Id: <2582-3967A7B0-87@storefull-246.iap.bryant.webtv.net>

Thanks Reini for the helpful info and tips. I really do appreciate your
help. 

Kind Regards,
Dennis 



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

Date: Sat, 8 Jul 2000 17:08:15 -0500 (CDT)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Pull 2nd element out of Hash Array
Message-Id: <2584-3967A64F-13@storefull-246.iap.bryant.webtv.net>

kcivey@cpcug.org (Keith=A0Calvert=A0Ivey) wrote:
>You need to learn the differences
>between scalars, arrays, and hashes.
>There's no relation between the
>variables $foo, @foo, and %foo. 

Thanks, perhaps it's a matter of terminology, or even getting my
terminology confused between JS and perl. I believe I know the
difference though, between the three.

$bean =3D ("penny") ...that is a SCALAR; 
@bean =3D ("penny", "dime", "quarte") is an ARRAY; and % =3D  ("penny", "1=
",
"dime", "10", "quarter", "25") is a HASH or associative array, no?

>Adding "-w" after "perl" here
>would turn on warnings, which
>would help you find problems with
>your program. Adding the line "use >strict;" next would provide
additional >help. 

Thanks. That's really helpful. I've tried -w before but couldn't get it
to work. I'll give it another try.

>print "Content-type:text/html\n\n"; 
>%songs =3D ("mid/g-l/gloria.mid", 
>"Gloria", "mid/a-f/aintnomountain.mid", >"Ain/'t No 
>>Why is there a slash before the >>apostrophe?
 
Oops! I had that in a print statement and miscopied it.

>rand(%songs) gives you a random >number greater than or equal to 0
>and less than the number of filled >buckets in the hash %songs.

Again, thanks. Good info. Now, I know why I've been coming up with "Now
Playing...0"   LOL

>Now you're using $rand as an
>index to the array @songs, which
>you haven't defined. 

Thanks.

>Now you're using the second
>element (+1 is the same as 1) of
>the array @rand, which you also
>haven't defined. 

More great help... thanks. 

print <<EOT;
<body bgcolor=3D"black"> 
<embed src=3D"$play" hidden=3D"true" autostart=3D"true"></embed>
<center> 
<font size=3D"1" color=3D"white">Now Playing...</font> <font size=3D"2"
color=3D"#66ccff">$title</font> </center> 
</body>
EOT 

Yep, I was afraid I'd get chastised for those excessive print
statements. I do know how to use EOF, EOM, or EOT, etc. Sometimes,
however, I purposely use alot of prints to make the code easier to read,
and I thought I read somewhere that a print statement can be too long? 

>Of course, having automatic
>background sounds on your pages
>is a good way to get people to hit
>the back button and leave immediately.

I'm aware of this and agree. However, my website is a music site, so it
is expected. I also want to use the code in e-mail for the few friends I
have that enjoy music in their e-mail. Most people don't. I realize
that.

Thanks again for your time,
Dennis 
 



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

Date: Wed, 05 Jul 2000 20:30:42 GMT
From: eedlin@my-deja.com
Subject: Re: push question
Message-Id: <8k05ti$oua$1@nnrp1.deja.com>

In article <8i8pfu$ekp$1@nnrp1.deja.com>,
  law_40@hotmail.com wrote:
> I have an array $array="1 2 3 4 5 6";

no... you have a scalar not an array.

>
> if i want to append an element to the array by way of the push
command,
> so that $array ="1 2 3 4 5 6";
>
> how can I do that?  I tried
>
> push @array, "6";
>
> with this command, $array="1 2 3 4 5" and @array="6";
>
you've got scalars and arrays backwards.

> when I try
>
> push $array, "6";
>
> errors occur...
because the first arg of push must be an array.

Try something like this:

#!/usr/local/bin/perl -w

use strict;
my @array = qw(one two three);
my $slice = 'four';

print "\@array is ....... @array.\n";

push @array, $slice;

print "\@array is now ... @array.\n";

<END>
--------------------------------------------

When run it returns the following:

cds11011:eedlin {60} push.pl
@array is ....... one two three.
@array is now ... one two three four.


>
> any suggestions?
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


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


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

Date: Sun, 09 Jul 2000 15:05:09 GMT
From: Iain Lea <iain@bricbrac.de>
Subject: Q: Looking for a spider that just lists changed urls ?
Message-Id: <Fw0a5.1$Ak.133@news.ecrc.de>

Before going and writing another little script to goto a website
download a list of all the urls and there mtime's and then running
the said script daily to find just the changed urls could anyone
point me to a script that does just that ?

Thanx in advance

-- 
Iain Lea    +49-9131-990622    +49-170-4464355    http://www.bricbrac.de/


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

Date: Fri, 07 Jul 2000 08:35:01 -0700
From: Synpax <senatorpalpatineNOseSPAM@dereth.net.invalid>
Subject: Question: Basic SMTP Problem
Message-Id: <14b63e14.1077d05c@usw-ex0103-019.remarq.com>

I'd appreciate any help I can get. So let me thank you upfront.

Trying to get a webpage to print out the domain name of the SMTP
server known as mailhost. Installed the net::smtp module,
already. Not sure of what I should do.

However, what I get in the browser is "testTEST ->domain". Take
a look and tell me what you think.

-----Code Starts--------


#!/usr/local/bin/perl -w

use Net::SMTP;
$smtp = Net::SMTP->new('s10599');




print <<ENDOFTEXT;
HTTP/1.0 200 OK
Content-Type: text/html

<HTML>
<HEAD><TITLE>My test for mail</TITLE></HEAD>
<BODY>
testTEST
ENDOFTEXT

print "$smtp->domain";

$smtp->quit;

print <<ZZZ;

</BODY>
</HTML>
ZZZ

exit(0);

-----END of Coe------

What could be causing the problem?




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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

Date: 07 Jul 2000 18:22:40 -0400
From: qvaff <qvaff@hotmail.com>
Subject: Re: Question: Basic SMTP Problem
Message-Id: <kusog49bmxb.fsf@buphy.bu.edu>

Synpax <senatorpalpatineNOseSPAM@dereth.net.invalid> writes:
> $smtp = Net::SMTP->new('s10599');

Check if $smtp was defined. Ack!

> print "$smtp->domain";

print $smtp->domain, "\n";   #read the docs, dude :)


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

Date: Fri, 07 Jul 2000 22:41:25 -0700
From: Synpax <senatorpalpatineNOseSPAM@dereth.net.invalid>
Subject: Re: Question: Basic SMTP Problem
Message-Id: <137498ec.c684572c@usw-ex0108-063.remarq.com>

thanks a lot. Problem is solved.


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

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com



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

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


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