[16589] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4001 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 13 11:05:48 2000

Date: Sun, 13 Aug 2000 08:05:11 -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: <966179110-v9-i4001@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 13 Aug 2000     Volume: 9 Number: 4001

Today's topics:
    Re: Access using basic authorization and Sockets (Martien Verbruggen)
    Re: calculating with getting a formula out of a $string nobull@mail.com
    Re: chmod question (Colin Keith)
    Re: duplicating STDIN (Colin Keith)
    Re: duplicating STDIN <abe@ztreet.demon.nl>
    Re: duplicating STDIN <emiller@charterpa.net>
    Re: Hash Reference Won't Print (Colin Keith)
        how can I optimize a tied hash for speed <webqueen@my-deja.com>
        In search of file searching script,output,every line oc <chris9_No@Spam_micron.net>
    Re: In search of file searching script,output,every lin (Marcel Grunauer)
    Re: In search of file searching script,output,every lin (Martien Verbruggen)
    Re: Javascript to Perl (Colin Keith)
    Re: London £30-35K Perl Programmers Required (Maggert)
    Re: London £30-35K Perl Programmers Required nobull@mail.com
    Re: map | grep (Colin Keith)
    Re: Need some debuging help nobull@mail.com
    Re: Need some debuging help (Colin Keith)
    Re: Need some debuging help (Martien Verbruggen)
    Re: Negativity in Newsgroup (Colin Keith)
    Re: Negativity in Newsgroup <godzilla@stomp.stomp.tokyo>
        Online Script...?. (T. & D. Gregor, Sr.)
        Size of a directory jimmy_mcnamara@my-deja.com
    Re: URGENT ---> How do keep a socket open while .....   (David Efflandt)
    Re: utime Function Not Working centelec@my-deja.com
    Re: utime Function Not Working (Keith Calvert Ivey)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 13 Aug 2000 10:49:05 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: Access using basic authorization and Sockets
Message-Id: <slrn8pcv5l.uu1.mgjv@martien.heliotrope.home>

On Sun, 13 Aug 2000 09:24:23 GMT,
	ak_perl@my-deja.com <ak_perl@my-deja.com> wrote:

> Hi,

Ho,

> I have a script accessible from a browser via port 648, the directory
> uses basic authorization. For direct access from the browser the URL
> would be
> "username:password@domainname.com:648/directory/scriptname.cgi".
> 
> I want to be able to pass info, and read the resulting output, to this
> script from another perl script running on a different machine. I have
> the following code for the second script:

[snip of handrolled partially correct socket stuff]

> Can someone help me how I can pass the username and password to the remote
> server? I can't find any info on this anywhere....

Don't try to do all this yourself. You're going to make the same
mistakes that everyone else has made. Use the fact that someone has
already made all these mistakes, and has written decent, robust code for
you: 

use the LWP modules.

# man lwpcook
[snip]
ACCESS TO PROTECTED DOCUMENTS
       Documents protected by basic authorization can easily be
       accessed like this:

         use LWP::UserAgent;
         $ua = LWP::UserAgent->new;
         $req = HTTP::Request->new(GET => 'http://www.linpro.no/secret/');
         $req->authorization_basic('aas', 'mypassword');
         print $ua->request($req)->as_string;

       The other alternative is to provide a subclass of
       LWP::UserAgent that overrides the get_basic_credentials()
       method. Study the lwp-request program for an example of
       this.
[snip]

I'm pretty sure that 

use LWP::Simple;
$doc = get 
  'http://username:password@domainname.com:648/directory/scriptname.cgi';

will also work.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | In the fight between you and the
Commercial Dynamics Pty. Ltd.   | world, back the world - Franz Kafka
NSW, Australia                  | 


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

Date: 13 Aug 2000 14:24:35 +0100
From: nobull@mail.com
Subject: Re: calculating with getting a formula out of a $string
Message-Id: <u9wvhlcmzw.fsf@wcl-l.bham.ac.uk>

mgjv@martien.heliotrope.home (Martien Verbruggen) writes:

> On 11 Aug 2000 17:13:55 +0100,
> 	nobull@mail.com <nobull@mail.com> wrote:
> > mgjv@martien.heliotrope.home (Martien Verbruggen) writes:
> > 
> > So that would be an argument for writing it as:
> > 
> > $formula = sub { my ($thing) = @_; $thing * 1.16 };
> 
> No. That's taking it too far. In real code, with large subs, I would
> probably do that, but my main objection was the use of $_ in a place
> where one normally would see $_[0]. Fine for anyone who knows how to use
> it, but didactically a dangerous thing to do. As I said before, Perl's
> variable and array syntax, combined with the names of builtins can be
> very confusing for the unsuspecting passer-by who happens to read that,
> read it not deeply enough, and think, "Hey, I didn't know you could just
> use $_ for that as well!". It can be useful, and it can be very fast,
> but if you're writing example code that is going to be read by hyndreds
> of inexperienced perl programmers, I'd say you need to take extra care
> in explaining what's going on.

OK I'll admit that perhaps I didn't sufficiently explain the use of
the global $_ to carry an argument to a trivial subroutine.  I _thought_
that by showing both the formal argument list approach and the
informal shared global variable approach and by using an explicit
local() (rather than for) I _was_ making things clear.  But then the
author is never the best person to judge the clarity of his own work.

I see now that we re clearly bascially in total agreement.

> [explaining what's going on] was what I was trying to do mainly :)

OK, if that was the case I'm sorry.  It came over more that you were
suggesting that the technique was something we shouldn't do in front
of the children^H^H^H^H^H^H^H^Hnewbies.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Sun, 13 Aug 2000 11:52:12 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: chmod question
Message-Id: <MZvl5.107$DT4.3489352@nnrp2.clara.net>

In article <39959107.7890480@news.freeserve.net>, u2o@u2orange.co.uk (u2orange) wrote:

>system ("chmod 0777 $orderfile");

Eww, icky. It even uses an incomplete file name :)
Besides which, if that works then the Perl chmod() function will work since 
they both use chmod(2) (afaik). 

Could the OP say what file permissions they get set when using this? Does 
the chmod fail? (it returns the number of files successfully changed, so in 
your case, it should return 1).

Dumb question, but just to check, you are using what you posted, 
  chmod(0777, $filename);

and the 0777 bit isn't quoted in anyway?
  chmod('0777', $filename);
and
  $mode = '0777';
  chmod($mode, $filename);

will not set the permissions that you want.

Finally, you do have the value you expect in $filename, don't you? If its 
still not working, get verbose with something like this in your code:

my($file) = '/etc/master.passwd';
open(LOGFILE, ">>log") || die "barf ($!)";
print LOGFILE  "chmod of $file : "
               chmod(0777, $file) ? "Successful\n" : "Failed ($!)\n";

maia% cat log
chmod of /etc/master.passwd : Failed (Operation not permitted)


Hmmm, that suggests two new error handling subs,
hiccup()
barf()

Warning: Small hiccup at ./runme line 26. Retrying.
Fatal:   Something barfed at ./runme line 30.

:)

Hmmm. crash() and burn() maybe? :)
Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 12:54:28 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: duplicating STDIN
Message-Id: <8Uwl5.108$DT4.3496069@nnrp2.clara.net>

In article <8n5h45$l9f$1@nnrp1.deja.com>, LimboStar <dontspamme@awdang.com> wrote:
>I'm almost positive this is impossible, but I'm asking anway.

Very little is impossible, most of it is just so mind-bogglingly improbable 
that it can only be described by bistromathics :)

>Now I've learned some, and I've become Impatient and Lazy.  I'm adding
Ooh, something to look forward too :)

>  1) rewrite my entire suite of scripts to use CGI.pm, which would take
>approximately forever;

Is this a rough or calculated approximation? :) This would be your best 
option. If you continue to use broken code it will come back to haunt you 
no matter how many hacks you put in. ... Now if only our development team 
could understand this .. :)

>  2) somehow read in the data, parse it, and then put it back so it's
>there for NeoMail (not bloody likely)

Ooooh, actually this is easy. Well, its not as difficult as you might think. 
The subject of your post gave me a suggestion as to what you could do here, 
and I played and tested and it worked. Incidently I have no idea what 
NeoMail is, but not understanding should never get in the way of a stunning 
answer ... :))

'nyway hows about using open's 'dup' facility? It is in the man pages, but 
to demo it I appended this to the top of the demo CGI script I posted 
yesterday:

  #!/usr/bin/perl -w
  use strict;
  use CGI qw/:standard/;

  # We want to er .. yeah, record this to a log file
  open(MY_STDIN, "<&STDIN") || die "Can't dup STDIN ($!)";
  open(LOGFILE, ">>/tmp/log") || die "Can't append to /tmp/log ($!)";
  print LOGFILE scalar(localtime(time())), ": $0 :\n";
  while(defined( ($_ = <MY_STDIN>)) ){
    print LOGFILE $_;
  }
  print LOGFILE "\n---\n";

I couldn't think of what to do, so I figured a logfile would do. Now, since 
your module doesn't mangle $ENV{'QUERY_STRING'}, that should be fine. Your 
module can process it and it will still be fresh and untouched for CGI.pm to 
use. If you dup STDIN and tell your module to work on the duplicate file 
handle instead of STDIN, then ... bob is your closely related family member.

Of course, your module probably plays with STDIN on its own elsewhere, so 
you'll need to hack it a bit so it uses 'a filehandle' rather than STDIN, 
and if you give it a filehandle then it uses that. Something like:

  my($mycgimod) = MyCGI->new(\*MY_STDIN);

or if its not OO:

  set_fh(\*MYSTDIN);
  my($name) = get_param('name');


>  3) overhaul my library to use CGI.pm and have it tell me what's
>passed on what form.

It really depends on what your module does that is over-and-above the CGI 
module. If you have a function print_corporate_header() say, which tootles 
out your company logo, that's fine, just plonk in a module. If you're 
overriding things like die() so it always prints a nicely formatted page 
complete with footer, header, and other goofy bits, you could can just 
subclass CGI. Calls to subs go to your module first and it can pass them on, 
or if it doesn't define them perl will search on through the packages to 
find that sub.

And now I've completely lost what I was saying having been dragged off to 
fix a solaris install so I hope this helps, sorry if its vague at the end, 
my thoughts only exist for short periods of time :) Come back if you need 
more help :)

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 15:43:26 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: duplicating STDIN
Message-Id: <i08dps8nber4s5brkihspasngrabu02ciu@4ax.com>

On Sun, 13 Aug 2000 07:01:25 GMT, LimboStar <dontspamme@awdang.com>
wrote:

> I'm almost positive this is impossible, but I'm asking anway.
> 
> I'm working a very large CGI script that I began development on a long
> time ago, before I knew about CGI.pm.  I quickly developed my own
> personal version, extremely dumbed down, which parses the input data
> into things passed by GET and things passed by POST.
> 
> Now I've learned some, and I've become Impatient and Lazy.  I'm adding
> web-based email into what has become a suite of scripts based on my
> very naive CGI handler.  And that's the problem - the webmail script
> I'm using (NeoMail) wisely was Lazy and Impatient and uses CGI.pm.

I don't know NeoMail. The answer to your question depends on _how_ it
uses CGI.pm and the way your program uses NeoMail.

> 
> But because my scripts read the POST data into a hash, it isn't there
> when NeoMail goes looking for it.  I got away with this for a while by
> saying:
> 
>   foreach(keys %POSTFORM){param($_,$POSTFORM{$_});}
> 
Why do you _insist_ your routine does better than CGI.pm?

Please (re)read the documentation for CGI.pm

	perldoc CGI

Look for 'PROGRAMMING STYLE' and 'request_method()'.
Populate the appropriate hash with the values from CGI.pm

-- 
Good luck,
Abe


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

Date: Sun, 13 Aug 2000 10:36:39 -0400
From: Ernie Miller <emiller@charterpa.net>
Subject: Re: duplicating STDIN
Message-Id: <B5BC2AB6.236%emiller@charterpa.net>

Hi Stephen,

    Without knowing precisely how you plan on integrating NeoMail with your
current setup, it's difficult to make a judgement call, but is there any
reason you can't simply continue letting NeoMail use CGI.pm while the rest
of your scripts use your custom module?  If your site is frame-based you
could load the NeoMail pages in their own frame and they'd likely behave
just fine, depending on what you're doing.

-Ernie 'Neo' Miller

in article 8n5h45$l9f$1@nnrp1.deja.com, LimboStar at dontspamme@awdang.com
wrote on 8/13/00 3:01 AM:

> The third is probably the best choice, and the only thing that's
> stopping me from doing it right now is that my suite of scripts
> differentiates between GET and POST, storing them in seperate hashes.
> If CGI.pm can seperate them, that's great - I'll just have it do that
> and be on my merry way.
> 
> So, how do I do that?  Can I do that?
> 
> Or, I can rip out the parts I need just to get NeoMail running and
> integrated, but that wouldn't be very pretty, and I'm looking for the
> quick fix.
> 
> Thanks in advance.
> 
> --
> Stephen.



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

Date: Sun, 13 Aug 2000 13:35:59 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Hash Reference Won't Print
Message-Id: <3vxl5.109$DT4.3500162@nnrp2.clara.net>

In article <spc1b63on4t62@corp.supernews.com>, "Gabe" <grichards@flashcom.net> wrote:
>Code follows:
>
>  my $getmsgs = $dbh->prepare(qq{SELECT mid, pid, subject, name FROM
>messages});
>  $getmsgs->execute;

You should check that this was successful. $DBI::errstr will contain any 
error messages. 

>  foreach (@{$children{0}}) {
>      Thread($_, 0);
>  }

I'm confused by this. Why are you using a hardcoded 0 when you use $pid 
putting them into the hash? Do they all have a pid of 0 ?And why does 
Thread() have two parameters? I can't see the second one used anywhere in 
Thread(). Is this just a cut down version?

>  sub Thread {
>      my $id    = shift;
>
>     $content{'main'} .= qq{<li><a
>href="http://www.myurl.com/cgi-bin/user.cgi?go=MyBoard&type=Get&mid=$id">$ms
>gs{$id}{subject}</a> -- Posted By: $msgs{$id}{name}};
>
># Right there. $id prints as expected, but $msgs{$id}{subject} and
>$msgs{$id}{name} do not.
># But @row above contains the values I expect!

Okay, but here you're just doing it for $msgs{0}, if you print out the 
key/value pairs of msgs you do see what you expect still?

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 14:40:38 GMT
From: webqueen, queen of the web <webqueen@my-deja.com>
Subject: how can I optimize a tied hash for speed
Message-Id: <8n6c15$61k$1@nnrp1.deja.com>

I just benchmarked my ap thru CGI- 10,000 element hash going through it
one item at a time, 4 minutes on a P450! Something like:

tie %h ...

foreach (keys %h) {do some simple sorting and printing}

untie %h;



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


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

Date: Fri, 11 Aug 2000 20:03:09 -0700
From: Chris <chris9_No@Spam_micron.net>
Subject: In search of file searching script,output,every line occurance occurs
Message-Id: <3994BE6D.77BAA16E@Spam_micron.net>

Hi,
 First off, I apologize if this is rude and off topic, I'm desperate.

 I'm in search a perl script that will search for a word[s] in one file
and output every line that word occurs in.

 So say I have a field where I enter "string" and every line in the file
searched, say "search.txt" file, is outputted.

search.txt=
"blah blah blah
blah string blah
blah
string blah"

output=
"blah string blah
string blah"

  Thanks, and I'm not in search of hiring someone.


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

Date: Sun, 13 Aug 2000 11:32:00 GMT
From: marcel@codewerk.com (Marcel Grunauer)
Subject: Re: In search of file searching script,output,every line occurance occurs
Message-Id: <slrn8pd1no.6al.marcel@gandalf.local>

On Fri, 11 Aug 2000 20:03:09 -0700, Chris <chris9_No@Spam_micron.net> wrote:

> I'm in search a perl script that will search for a word[s] in one file
>and output every line that word occurs in.

grep(1)

>  Thanks, and I'm not in search of hiring someone.

Welcome, and I take my coffee without sugar.

-- 
Marcel
sub AUTOLOAD{($_=$AUTOLOAD)=~s;^.*::;;;y;_; ;;print} Just_Another_Perl_Hacker();


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

Date: 13 Aug 2000 11:44:26 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: In search of file searching script,output,every line occurance occurs
Message-Id: <slrn8pd2in.uu1.mgjv@martien.heliotrope.home>

On Fri, 11 Aug 2000 20:03:09 -0700,
	Chris <chris9_No@Spam_micron.net> wrote:
> Hi,
>  First off, I apologize if this is rude and off topic, I'm desperate.

That's not really an excuse. If I was really in need of some money,
would you think it was ok if I asked you for it?

>  I'm in search a perl script that will search for a word[s] in one file
> and output every line that word occurs in.

I am really, really surprised that you were unable to find an answer to
this. Did you try to ise a web search engine? www.deja.com? Did you read
this group for the last week (and yes, it did come up)?

That program you are looking for is called 'grep' on unix machines, and
is available for many other platforms as well. There is a one available
as paert of the perl power tools (http://languange.perl.com/ppt).

A very simplistic version:

# perl -ne 'print if /strict/' files/* gruff/* foo.*.txt

>  So say I have a field where I enter "string" and every line in the file
> searched, say "search.txt" file, is outputted.

Perl has no fields... Are you talking about some HTML input form, and
some perl backend script that uses CGI or so?

To do CGI processing:
	use CGI;
To open a file:
	open(FOO, $filename) or die "Couldn't open $filename: $!";
To get matching lines:
	my @lines = grep /pattern/, <FOO>

All of this has been discussed in the last week on this very group. I've
been more than helpful enough. It's now up to you to search
www.deja.com, and to read some documentation:

# perldoc CGI
# perldoc -f open
# perldoc -f grep
# perldoc perlsyn
# perldoc -f close

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | +++ Out of Cheese Error +++ Reinstall
Commercial Dynamics Pty. Ltd.   | Universe and Reboot +++
NSW, Australia                  | 


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

Date: Sun, 13 Aug 2000 13:53:50 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Javascript to Perl
Message-Id: <OLxl5.110$DT4.3501225@nnrp2.clara.net>

In article <39963D9F.DF58BBD9@hotmail.com>, Andy <andychu@hotmail.com> wrote:
>Does anyone know how to pass the value from Javascript to Perl?

Er, that depends on the context. If you mean your have a web page with 
javasacript and want to pass the variable to a CGI script ... then via CGI. 
If you're doing it in another fashion .. sorry. Dunno. If its the former, 
then its a javascript question, nothing to do with Perl and is best asked in 
a javascript authoring group.

But briefly, you need to create a new form element to stash your value in. 
If you add:
  <INPUT TYPE="HIDDEN" NAME="myvalue" VALUE=0>
to your HTML, then you can just use for code to update it

><script language="Javascript">
>function add(value){
>   var myvalue = Math.abs(value) + 100;
    document.forms[myform].element[myvalue] = myvalue;
>}
></script>


>code segment in the perl:
><a href="anyscript.cgi?thevalue=myvalue" onclick="add(10)">test</a>

This is not perl, this is HTML. You should ask questions about this in the
comp.infosystems.www.* or comp.lang.javascript groups. There you will find 
people who can give you the do's/don't's on this stuff, the same way as 
people here can give you 'the best way' to do something in Perl.

Col.

follow ups' set to comp.lang.javascript


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 13:56:50 GMT
From: mag@ionet.net (Maggert)
Subject: Re: London £30-35K Perl Programmers Required
Message-Id: <3996a59c.217367908@news.ionet.net>

On Thu, 10 Aug 2000 19:40:39 -0700, checker
<c_barnes_ukNOc_SPAM@hotmail.com.invalid> wrote:


>If you think I'm dreaming about salaries then go on, wake me
>up !!
>

	Hey at least you answer up to your post. Most don't ever look
back.

	You'll never get the quality Perl Programmers for less than
55K. British Pounds. You might be able to snag some up and comers for
between  40 - 50 though. 
	Take into account that I just got offered a job for $65K US a
year and I am not nearly as good as what you described in your post.
$65K US converts to 43K British Pounds. I also didn't take it.<G>
	In the mean time you can post your offer to
http://jobs.perl.org .


MP


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

Date: 13 Aug 2000 15:12:52 +0100
From: nobull@mail.com
Subject: Re: London £30-35K Perl Programmers Required
Message-Id: <u9r97tckrf.fsf@wcl-l.bham.ac.uk>

mag@ionet.net (Maggert) writes:

> 	In the mean time you can post your offer to
> http://jobs.perl.org .

Really?  As far as I can see that's a very US-centric site.


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

Date: Sun, 13 Aug 2000 14:08:29 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: map | grep
Message-Id: <xZxl5.111$DT4.3502514@nnrp2.clara.net>

In article <8n54gp$dc1$1@nnrp1.deja.com>, johnvert@my-deja.com wrote:
> I'm wondering what is the difference between:

maia% diff y x
1c1
<  2. my @list=qw(1 2 3 4);
---
>  1. my @list=qw(1 2 3 4);

Are you sure this is what you meant to post? 
They're identical apart from the example number.

> also, I heard map / grep should not be used instead of a plain loop,
>so  what are very simple examples where they might be used?

As with everything, that depends on what you're doing.

Hmm, well I thougth they performed about the same, bu using the example for 
map() from perlfunc:

maia% perl -w -Mstrict -MBenchmark
my($i);
sub getkey { return $i++; };
timethese( 10000, {
  'map' => sub { my(%hash) = map { getkey($_) => $_ } (0..100); },
  'foreach' => sub { my(%hash) = (); 
                     foreach $_ (0..100){ $hash{getkey($_)} = $_; } }
});

Benchmark: timing 10000 iterations of foreach, map...
   foreach: 47 wallclock secs (36.67 usr +  0.02 sys = 36.70 CPU)
       map: 26 wallclock secs (24.26 usr +  0.02 sys = 24.27 CPU)

So I guess that's a reasonable answer.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: 13 Aug 2000 14:01:11 +0100
From: nobull@mail.com
Subject: Re: Need some debuging help
Message-Id: <u9ya21co2w.fsf@wcl-l.bham.ac.uk>

Todd Eddy <vrillusions@mail.com> writes:

> I am working on making a script that will show the people that signed up
> for a LAN party.  I am trying to figure out why I can't get it display
> the contents.

I do not believe you.  If you were _trying_ then one of the first
things you'd have done is checked that the open() succeded and if it
not logged why it failed.  There's no evidence that you've done this.

> open (DATA, "$datalocation");

open (DATA, "$datalocation") or die "Failed to open $datalocation: $!";

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Sun, 13 Aug 2000 14:14:26 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Need some debuging help
Message-Id: <63yl5.112$DT4.3503707@nnrp2.clara.net>

In article <39962D68.D29F04F1@mail.com>, vrillusions@mail.com wrote:

>open (DATA, "$datalocation");
  \ /
   X
  / \
>foreach (@lines) {

I put a nice big X where I think the problem is ... :)
I assume that the data you're wanting to print is in this file. But you 
don't actually do anything with this file handle except close it again. 
Perhaps:

  @lines = <DATA>;

Is missing ?
Or better still, rather than slurping it all into memory:

  while(defined($_ = <DATA>)){

in place of the foreach() line and do this with 1 line of text in memory at 
once.

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: 13 Aug 2000 14:33:47 GMT
From: mgjv@martien.heliotrope.home (Martien Verbruggen)
Subject: Re: Need some debuging help
Message-Id: <slrn8pdccu.vgf.mgjv@martien.heliotrope.home>

On Sun, 13 Aug 2000 05:08:44 GMT,
	Todd Eddy <vrillusions@mail.com> wrote:

> open (DATA, "$datalocation");

open(DATA, $datalocation) or die "Cannot open $datalocation: $!";

> foreach (@lines) {

What's @lines? Where did that come from? Are you for some reason
expecting @lines to contain the lines from $datalocation? Maybe you
meant

while (<DATA>)
{

instead

>  # Now split up the info:
> showname|name|showemail|email|callsign|location
>  ($df_showname, $df_name, $df_showemail, $df_email, $df_callsign,
> $df_location) = split(/\|/, $_);
> 
>  chomp $df_location;

You could have done that chomp before the split. Would have made
slightly more sense.

You should probably check that that split read everything you need, with
something like:

die "Invalid line: $." unless $df_location;

>  if ($df_showname == 0) { $df_name = " "; }

$df_name = '' unless $df_showname;

>   if ($df_showemail == 1) { $df_name = "<A
> HREF=\"mailto:".$df_email."\">".$df_name."<\/A>"; }

$df_name = qq(<A HREF="mailto:$df_email">$df_name</a>);

>   print "<TR>\n";
>  print " <TD VALIGN=\"middle\">$df_name</td>\n";
>  print " <TD VALIGN=\"middle\">$df_callsign</td>\n";
>  print " <TD VALIGN=\"middle\">$df_location</td>\n";
>  print "</TR>\n";

You should learn to use here-docs. 

# perldoc perldata

or you should use qq or double quotes, and not worry about the line
ends.

> }
> close DATA;
>
> 
> print qq~

So... You do know about qq and stuff like that? Why didn't you use it
above? Worse than bad style is inconsistent style.

> I checked it through perl and I had no errors, I checked all the
> variables and they are what they're supposed to be.

Which variables did you check? In the code that was posted, none of the
variables, except for the file ame, ever would have been filled, unless
you did that somewhere else. None of the lines in that file would have
been read, unless you did that somewhere else.

And you probably should start using -w and strict as well, unless you
already are.

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | I took an IQ test and the results
Commercial Dynamics Pty. Ltd.   | were negative.
NSW, Australia                  | 


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

Date: Sun, 13 Aug 2000 14:22:27 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Negativity in Newsgroup
Message-Id: <Dayl5.113$DT4.3504663@nnrp2.clara.net>

In article <lYil5.909$2q.170355@paloalto-snr1.gtei.net>, "Joe C. Hecht" <joehecht@code4sale.com> wrote:
>spelling, I find it difficult to speak properly at all
>though a keyboard.

*picks up the mouse*
"Halloo computerr" :)

>Is that Miss. Godzilla!, Mrs. Godzilla!, Ms. Godzilla!,
>or is there another, more approprate title I should use?

"Ma'am, Yes Ma'am!"  ? :)

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Sun, 13 Aug 2000 07:39:21 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Negativity in Newsgroup
Message-Id: <3996B319.E8A2FB26@stomp.stomp.tokyo>

"Joe C. Hecht" wrote:

 
> [Godzilla! tempts me out of lurk mode]

I am less tempting when nude, which is almost
always, least at home. However I have no tanlines
which seems attractive to some.


> I am unsure. Having miserbly failed english and
> spelling, I find it difficult to speak properly at all
> though a keyboard.

Develop an exceptionally talented tongue. You
will experience better luck with this method
and, perhaps better luck as a lover.

 
> I see no reason to be offended, although, I
> must admit, I am swooned by your use of
> the English language.

I know nothing about use of English. I am quite
talented at copy and paste from books of cute
quips and quotes.

 
> Is that Miss. Godzilla!, Mrs. Godzilla!, Ms. Godzilla!,
> or is there another, more approprate title I should use?

You may refer to me as God for short.


> I must admit, you are far too kind...

I am capable of being less kind, if this
would please you.


Godzilla!

-- 
Join comp.lang.perl.misc campaign of hatred!
Learn to send secretive very hateful email!
Learn vulgarity, bigotry, hatred and crime!
Enjoy your USENET experience with vile hatred!
For further information, contact Perl Mongers!


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

Date: Sun, 13 Aug 2000 13:51:30 GMT
From: tdg@erols.com (T. & D. Gregor, Sr.)
Subject: Online Script...?.
Message-Id: <3996a7d5.803915@news.erols.com>

Good evening group:

Not so quick question...

What I’m searching for is the equivalent of the "Online.cgi" script
(hack) for the Ultimate Bulletin Board or UBB. This hack through
cookie manipulation via PERL... shows who’s online at any given point
in time, by popping-up a window showing USER NAME - DATE/TIME -
WHERE... I’ve looked at the hack... and well... it appears to the
uninitiated (read me) to be solely dependent on the larger UBB
(program - script) to function at all... in short this hack ain’t no
stand alone script.

So the question begs... is there something “out there” that would
function in a similar manner...?.

Any and all feedback is most welcome...

Thanks

Tom Gregor, Sr.
-------------------------------------

Name: T. & D. Gregor, Sr.
E-Mail: tdg@erols.com
Web site: http://www.erols.com/tdg/
"The Scenery Hall of Fame"
Subscribe to our Newsletter:
Scenery-subscribe@listbot.com

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


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

Date: Sun, 13 Aug 2000 13:39:50 GMT
From: jimmy_mcnamara@my-deja.com
Subject: Size of a directory
Message-Id: <8n68f6$3ml$1@nnrp1.deja.com>

Hi Folks,

Just wondering is there a function in Perl that will tell me the
size of a directory(i.e. the total size of all the files in it) rather
than using the unix shell commands to access this info.


Regards

Jimmy


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


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

Date: Sun, 13 Aug 2000 12:43:40 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: URGENT ---> How do keep a socket open while .....  ( Please read  !!!)
Message-Id: <slrn8pd5vg.fik.efflandt@efflandt.xnet.com>

On Sat, 12 Aug 2000, Savant_cubed <superegoNOsuSPAM@execs.com.invalid> wrote:
>If I wanted to keep a Socket open, send something to a webpage,
>then after the user does something again get more information
>from the socket and send more info to a webpage, How would I do
>it ?
>   I think after I first send info from the socket to the
>webpage the program will close the socket and end the program.
>Is there any way to freeze the program until more input is
>added, so that I may continually send and read to socket
>depending on what happens from a webpage ? I know there has to
>be a way to do this (or am I just a newbie ?)

No, HTTP is stateless, one request and one response.  Although, Netscape
can handle server push, which returns multiple content types (pages,
images, etc) in that one response.  But there is no interactivity.

Depending upon what you are trying to do, you would either have to write
your own server and client for it or use some existing protocol, like
telnet.

-- 
David Efflandt  efflandt@xnet.com  http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://hammer.prohosting.com/~cgi-wiz/  http://cgi-help.virtualave.net/



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

Date: Sun, 13 Aug 2000 13:37:49 GMT
From: centelec@my-deja.com
Subject: Re: utime Function Not Working
Message-Id: <8n68bd$3m6$1@nnrp1.deja.com>

In article <EVpl5.18977$f_5.85652@news1.rdc1.ct.home.com>,
  decklin+usenet@red-bean.com (Decklin Foster) wrote:
> centelec@my-deja.com <centelec@my-deja.com> writes:
>
> > On a Windows NT server, I uploaded a file and tried to timestamp it.
> > After the script, I checked the modified date of the file with -M
and
> > its zero's. The code follows:
>
> Two questions...
>
> 1. How are you using -M? are you also checking with something besides
>    Perl?
Using -M as follows:

opendir (DIR,"$basedir") || die "Can't open photo directory!\n";
  @parentfiles = readdir(DIR);
closedir (DIR);
print "Content-type: text/html\n\n";
foreach $file (@parentfiles) {
printf "$file %f \n", -M $file;
}

> 2. Why are you updating the modification time on a file you just
>    modified?

I am findind 0.00000 for the mod days whether I force something or not.
I want the script to delete the file if it is
over 30 days old but need to see something in the mod days first.

>
> >   while (read($file, my $buffer, 1024)) {
> >      binmode($buffer);
>
> Don't do that. Read the documentation for binmode and turn on -w.

Windows NT requires the binmode. Without it, I get garbage in the file.

>
> --
> There is no TRUTH. There is no REALITY. There is no CONSISTENCY. There
> are no ABSOLUTE STATEMENTS. I'm very probably wrong. -- BSD fortune(6)
>


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


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

Date: Sun, 13 Aug 2000 14:19:23 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: utime Function Not Working
Message-Id: <3998ad14.90279237@news.newsguy.com>

centelec@my-deja.com wrote:

>Using -M as follows:
>
>opendir (DIR,"$basedir") || die "Can't open photo directory!\n";
>  @parentfiles = readdir(DIR);
>closedir (DIR);
>print "Content-type: text/html\n\n";
>foreach $file (@parentfiles) {
>printf "$file %f \n", -M $file;
>}

That's what I suspected.  You're getting a list of files from
the directory $basedir and then looking for them in the current
directory (which is probably not $basedir).  Think about it: how
is -M supposed to know where $file is if you don't tell it?

Either change the current directory using chdir() or use 
-M "$basedir$file".

[snip]
>> >   while (read($file, my $buffer, 1024)) {
>> >      binmode($buffer);
>>
>> Don't do that. Read the documentation for binmode and turn on -w.
>
>Windows NT requires the binmode. Without it, I get garbage in the file.

Yes, it requires binmode(), but read the documentation for
binmode().  It takes a filehandle argument.  And it needs to be
used *before* you read from the file.  Normally you'd put it
right after the open.  You wouldn't want it in a loop unless you
were opening the file in a loop.

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


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

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


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