RE: Do Else Unless Statements Exist?

2004-01-11 Thread Charles K. Clarkson
Dan Anderson <[EMAIL PROTECTED]> wrote:

: 
: Does Perl have any kind of else / unless statements, sort of
: like elsif?  I tried:
: 
: if ($foo) {
: }
: else unless ($bar) {
: }

What about:

elsif ( ! $bar ) {
}

HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Do Else Unless Statements Exist?

2004-01-11 Thread Dan Anderson
Does Perl have any kind of else / unless statements, sort of like
elsif?  I tried:

if ($foo) {
}
else unless ($bar) {
}

but it just gave me syntax errors.  And I guess I could just do:
if ($foo) {
}
else {
  unless ($bar) {
  }
}

But the place in the code I was trying it was for clarity, and all the
nested unlesses don't seem to add to clarity.

Thanks in advance.

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: script works from shell but not http

2004-01-11 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote:

> #!/usr/bin/perl -w
> use strict;
> BEGIN{open(STDERR, ">./err.txt")}
> print "Content-Type: text/html\n\n";
> foreach my $key (sort keys %ENV) {
>  print "\$ENV{$key} = $ENV{$key}\n";
> }
>
> None of my scripts are functioning on my new server.  The BEGIN statement
> doesn't write err.txt

That is very good.  If your CGI directory were writable, it would be a major
security threat to the system on which it is mounted.  Do your writing to a
sister directory chmod'ed 660.


Joseph


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Perl mapping solution

2004-01-11 Thread R. Joseph Newton
Kyle Sexton wrote:

> I am trying to implement something akin the the perl monger map located
> at http://bath.pm.org/map/.  I have got my map to the point that it
> will pull lat/long information from a web server and generate a map.
> What I am looking to do now is implement zooming in on the map like was
> done on the perl monger map.  If someone could give me some advice on
> what a good solution to read about is it would be greatly appreciated.
> Thanks in advance.
>
> Thanks,
> Kyle Sexton

This can also be done pretty handily in HTML itself, with the usemap
parameter of the image tag:










Of course, you might want to direct the HREFs to a CGI script, perhaps with
some plot label as a query string, rather than calling static pages.

I was thinking that maybe some Javascript could help you get the mouse
coordinates of a click, but it would be indirect, since JS doesn't have
onclick events for images, and the coordinate systems for which  JS does
provide x and y values are not easily resolnable relative to the
cooridnates within an image.

For very precise client-side interactvity, you might consider using a Java
applet to display the map.  That would allow you to have some real
intelligence operating on the client end.

Joseph



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: script works from shell but not http

2004-01-11 Thread Dan Anderson
On Sun, 2004-01-11 at 11:47, zentara wrote:
> On Sun, 11 Jan 2004 06:10:32 EST, [EMAIL PROTECTED] wrote:
> 
> >#!/usr/bin/perl -w
> >use strict;
> >BEGIN{open(STDERR, ">./err.txt")}
> >print "Content-Type: text/html\n\n";
> >foreach my $key (sort keys %ENV) {
> > print "\$ENV{$key} = $ENV{$key}\n";
> >}
> >
> >None of my scripts are functioning on my new server.  The BEGIN statement 
> >doesn't write err.txt
> >But it does function from a shell.  I also changed the code thinking it was a 
> >header problem.  But it does not function either.  
> >#!/usr/bin/perl -w
> >use strict;
> >BEGIN{open(STDERR, ">./err.txt")}
> >use CGI;
> >my$q = CGI::new();
> >print $q->header;
> >foreach my $key (sort keys %ENV) {
> > print "\$ENV{$key} = $ENV{$key}\n";
> >}
> >
> >The permissions are set to 0755.  I thought maybe the .pl extention wasn't 
> >recognized so I changed it to cgi,  No such luck.
> >I'm out of my bag of tricks.  My provider isn't responding to my emails.  I'm 
> >guessing apache isn't configured right.
> 
> Your apache is probably set up to run as nobody::nogroup, or some
> similar lowest permission user::group.
> 
> So your directory has to be "world-writable" for apache to write to it,
> or 777.  It runs from the shell, because you are logged in as a user,
> and 755 will work.

Setting anything world writable is dangerous.  Remember to take proper
precautions, like making the directory inaccessible through apache,
and/or throw it in a database instead.

-Dan 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




netstat in Perl and OT

2004-01-11 Thread mcdavis941
Hi list,

1. Does anyone know of a module in CPAN which lets you implement the netstat function 
within Perl code?  I was expecting to see something like netstat.pm, but a CPAN search 
turned up nothing.
2. If there's no such module, why not?  Any guesses?  It's seems like the kind of 
thing that gets turned into a module, since most IP-related UNIX functions end up in a 
module eventually (e.g. mail, HTTP, FTP, etc., etc.).  

I have a script which uses the output from netstat.  I'm shelling out to run netstat 
to get the results into my script, but it would seem better, for a number of reasons, 
to be able to do it completely within your own code.

And, now, comPLETEly off-topic ... when running netstat, I'm used to seeing numeric IP 
addresses and alphanumeric domain names in the results.  But, every so often, I see 
something that looks like a NETBIOS machine name.  What up with that?  Is this 
expected netstat behavior? Here are some of the values I've seen:

ARBAY112
ATHALON12
BRAD
CHICO
COMPUTER
DGSMS521
DIEGO
E6E8L8
HPPAV
INFO16

OEMCOMPUTER
PC
PKWWW
Q6A1W7
RANDY
SAMTHEGREAT
U8F1M4
V4W3Y9
VALE
VLADO

Does anyone know what condition this represents?  (I realize this last bit is really 
OT; if anyone knows of a more appropriate group I would be grateful for the lead.)

TIA.



__
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Matching invalid characters in a URL

2004-01-11 Thread Dan Anderson
On Fri, 2004-01-09 at 16:54, Wiggins d Anconia wrote:
> > > Any suggestions? Thanks for your help and thoughts.
> > 
> > It is much easier to define the set all chars must be in then not.  Use
> > the =! which is the complement of all charachters matched by =~. 
> > Alternatively, I believe there is a c option you can use.
> > 
> > -Dan
> 
> That (I presume) should be !~ instead of != to complement =~ as opposed
> to ==.  When trying to include a dash in a character class (and not make
> it a range), [], place it as the first character in the class, when
> including a carat ^ do NOT place it as the first character (as that
> negates the class).
Ooops... My apologies.  I was typing too quick and without much
caffeine.  :-(

-Dan


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: script works from shell but not http

2004-01-11 Thread Rob Dixon
[EMAIL PROTECTED] wrote:
>
> #!/usr/bin/perl -w
> use strict;
> BEGIN{open(STDERR, ">./err.txt")}
> print "Content-Type: text/html\n\n";
> foreach my $key (sort keys %ENV) {
>  print "\$ENV{$key} = $ENV{$key}\n";
> }
>
> None of my scripts are functioning on my new server.  The BEGIN
> statement doesn't write err.txt But it does function from a
> shell.  I also changed the code thinking it was a  header
> problem.  But it does not function either.
>
> #!/usr/bin/perl -w
> use strict;
> BEGIN{open(STDERR, ">./err.txt")}
> use CGI;
> my$q = CGI::new();
> print $q->header;
> foreach my $key (sort keys %ENV) {
>  print "\$ENV{$key} = $ENV{$key}\n";
> }
>
> The permissions are set to 0755.  I thought maybe the .pl
> extention wasn't recognized so I changed it to cgi,  No such
> luck. I'm out of my bag of tricks.  My provider isn't
> responding to my emails.  I'm guessing apache isn't configured
> right.

You've committed the cardinal sin of failing to check your 'open'
call. I don't understand why you should want the call in a BEGIN
block anyway, but write this

  open STDERR, '> err.txt' or die $!

and check your Apache log file. It's my guess the cgi-bin directory
is read-only from within your script.

HTH,

Rob



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Regular Exp for Numerics

2004-01-11 Thread Rob Dixon
Mallik wrote:
>
> I have to compare numeric values as below
>
> if (($segsep == 13) || ($segsep == 10) || ($segsep == 0))
>
> Can I use the reg exp as below
>
> if ($segsep =~ /^(13|10|0)$/)
>
> My question is, is it adviceable to use reg exp for numeric values (entire
> value).
> If yes, why?
> If not, why?

No. Because it's slower, and because several different strings can have
the same numeric value.

  for ( qw/ 12 00012 1.2E1 / ) {
print "Numeric match for $_\n" if $_ == 12;
  }

succeeds in all three cases, but clearly

  for ( qw/ 12 00012 1.2E1 / ) {
print "Regexp match for $_\n" if /^12$/;
  }

would match for only the first value.

If you're looking for a more concise way of matching any of a list of numbers
then try

  if ( grep $segsep == $_, 13, 10, 0 )

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




script works from shell but not http

2004-01-11 Thread Motherofperls
#!/usr/bin/perl -w
use strict;
BEGIN{open(STDERR, ">./err.txt")}
print "Content-Type: text/html\n\n";
foreach my $key (sort keys %ENV) {
 print "\$ENV{$key} = $ENV{$key}\n";
}

None of my scripts are functioning on my new server.  The BEGIN statement 
doesn't write err.txt
But it does function from a shell.  I also changed the code thinking it was a 
header problem.  But it does not function either.  
#!/usr/bin/perl -w
use strict;
BEGIN{open(STDERR, ">./err.txt")}
use CGI;
my$q = CGI::new();
print $q->header;
foreach my $key (sort keys %ENV) {
 print "\$ENV{$key} = $ENV{$key}\n";
}

The permissions are set to 0755.  I thought maybe the .pl extention wasn't 
recognized so I changed it to cgi,  No such luck.
I'm out of my bag of tricks.  My provider isn't responding to my emails.  I'm 
guessing apache isn't configured right.


Regular Exp for Numerics

2004-01-11 Thread Mallik
Dear Friends,

I have to compare numeric values as below

if (($segsep == 13) || ($segsep == 10) || ($segsep == 0))

Can I use the reg exp as below

if ($segsep =~ /^(13|10|0)$/)

My question is, is it adviceable to use reg exp for numeric values (entire
value).
If yes, why?
If not, why?

Thank you,
Mallik


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]