[11375] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4975 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 26 11:37:29 1999

Date: Fri, 26 Feb 99 08:29:34 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 26 Feb 1999     Volume: 8 Number: 4975

Today's topics:
        Help a newbie please! <mreglein@ix.netcom.com>
    Re: Help a newbie please! <kenhirsch@myself.com>
    Re: Help a newbie please! <kprice@cardinal.co.nz>
    Re: Help a newbie please! <Allan@Due.net>
    Re: Help a newbie please! <kprice@cardinal.co.nz>
        Help Assigning Split Results lmak@verio.net
    Re: Help Assigning Split Results (Greg Bacon)
    Re: Help Assigning Split Results <jglascoe@giss.nasa.gov>
    Re: Help Assigning Split Results (Randal L. Schwartz)
    Re: Help Assigning Split Results (Greg Bacon)
    Re: Help Assigning Split Results (Greg Bacon)
    Re: Help Assigning Split Results <aqumsieh@matrox.com>
    Re: Help Assigning Split Results <ebohlman@netcom.com>
    Re: Help needed urgently! (Ronald J Kimball)
    Re: Help needed urgently! droby@copyright.com
    Re: Help needed urgently! <wmtoh@singnet.com.sg>
        Help on CGI!! <yfang@gte.com>
    Re: Help on CGI!! <jglascoe@giss.nasa.gov>
    Re: Help on CGI!! scraig@my-dejanews.com
    Re: Help on CGI!! <news@duh.crash.nu>
    Re: Help Please: CGI-String terminator problem (Martin Vorlaender)
    Re: Help Please: CGI-String terminator problem <hwb@heise.de>
    Re: Help Please: CGI-String terminator problem <marnic@ludomedia.ch>
    Re: Help Please: CGI-String terminator problem <liuruogo@pilot.msu.edu>
        Help Translating IPs to Domain Name <Steve@ramjam.net>
    Re: Help Translating IPs to Domain Name (Abigail)
    Re: Help Translating IPs to Domain Name (Larry Rosler)
    Re: Help Translating IPs to Domain Name <Tony.Curtis+usenet@vcpc.univie.ac.at>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Mon, 22 Feb 1999 19:22:31 -0500
From: "Michael Reglein" <mreglein@ix.netcom.com>
Subject: Help a newbie please!
Message-Id: <7ass9l$iu5@sjx-ixn10.ix.netcom.com>

I'm taking a Perl programming class  and am having some trouble using $ARGV
and @ARGV.

How do you do an evaluation of what file Perl is looking at?

This is what I've tried:
$>  test.pl group.dat temp.dat

if ($ARGV =~ 'group.dat') {
    do stuff;
}
elsif ($ARGV =~ 'temp.dat') {
    do other stuff;
}


Please let me know what I'm doing wrong...

Thanks

Mike Reglein





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

Date: Tue, 23 Feb 1999 11:17:49 -0500
From: "Ken Hirsch" <kenhirsch@myself.com>
Subject: Re: Help a newbie please!
Message-Id: <7auka0$39n$1@fir.prod.itd.earthlink.net>


Michael Reglein wrote in message <7ass9l$iu5@sjx-ixn10.ix.netcom.com>...
>I'm taking a Perl programming class  and am having some trouble using $ARGV
>and @ARGV.
>
>How do you do an evaluation of what file Perl is looking at?
>
>This is what I've tried:
>$>  test.pl group.dat temp.dat
>
>if ($ARGV =~ 'group.dat') {
>    do stuff;
>}
>elsif ($ARGV =~ 'temp.dat') {
>    do other stuff;
>}


As another reply stated, if you know that the filename will be exactly
"group.dat" without any prefix, you should use "eq" instead of "=~"
         if ($ARGV eq  'group.dat')

If you need to use a regular expression, you need to use slashes // or the
m// operator:
I would write it as:
         if ($ARGV =~  /group\.dat$/)

Ken Hirsch
Carrboro, NC







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

Date: Tue, 23 Feb 1999 14:30:00 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: Help a newbie please!
Message-Id: <36D20498.D7126A89@cardinal.co.nz>

Michael Reglein wrote:
> 
> I'm taking a Perl programming class  and am having some trouble using $ARGV
> and @ARGV.
> 
> How do you do an evaluation of what file Perl is looking at?
> 
> This is what I've tried:
> $>  test.pl group.dat temp.dat
> 
> if ($ARGV =~ 'group.dat') {
>     do stuff;
> }
> elsif ($ARGV =~ 'temp.dat') {
>     do other stuff;
> }
> 
> Please let me know what I'm doing wrong...
> 
> Thanks
> 
> Mike Reglein

@ARGV is the list of arguments supplied to the script.  $ARGV is
nothing, but $ARGV[0] is the first argument, $ARGV[1] is the second and
so on.  Read more about perl data structures.  In your example you will
find that $ARGV[0] eq 'group.dat' and $ARGV[1] eq 'temp.dat' and @ARGV =
( group.dat, temp.dat ).

HTH

Kelvin


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

Date: Mon, 22 Feb 1999 20:50:26 -0500
From: "Allan M. Due" <Allan@Due.net>
Subject: Re: Help a newbie please!
Message-Id: <ZPnA2.490$986.10300@nntp1.nac.net>

Kelvin Price wrote in message <36D20498.D7126A89@cardinal.co.nz>...
:Michael Reglein wrote:
:> I'm taking a Perl programming class  and am having some trouble using $ARGV
:> and @ARGV.
:> How do you do an evaluation of what file Perl is looking at?
:> This is what I've tried:
:> $>  test.pl group.dat temp.dat
:> if ($ARGV =~ 'group.dat') {
:>     do stuff;
:> }
:> elsif ($ARGV =~ 'temp.dat') {
:>     do other stuff;
:> }
:> Please let me know what I'm doing wrong...
:> Thanks
:> Mike Reglein
:@ARGV is the list of arguments supplied to the script.  $ARGV is
:nothing,
[snip]

Interesting, in my version of Perl $ARGV contains the name of the current file
when reading from <ARGV>.  I would hardly call that nothing! <g>

AmD








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

Date: Tue, 23 Feb 1999 16:37:38 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: Help a newbie please!
Message-Id: <36D22282.1C6C2CE7@cardinal.co.nz>

"Allan M. Due" wrote:
> 
> Kelvin Price wrote in message <36D20498.D7126A89@cardinal.co.nz>...
> :Michael Reglein wrote:
{{SNIP}}
> :@ARGV is the list of arguments supplied to the script.  $ARGV is
> :nothing,
> [snip]
> 
> Interesting, in my version of Perl $ARGV contains the name of the current file
> when reading from <ARGV>.  I would hardly call that nothing! <g>
> 
> AmD

Doh! That's what happens when you have a 2 week holiday and dive right
back into things.  The original question didn't involve reading from
<ARGV> though, so I'm going to let myself off with a warning.  I still
think the original poster should use eq instead of =~ for comparing
against filenames.


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

Date: Wed, 24 Feb 1999 19:42:22 GMT
From: lmak@verio.net
Subject: Help Assigning Split Results
Message-Id: <7b1kms$5jm$1@nnrp1.dejanews.com>

I'd appreciate any help with this.  I am trying to assign the results of a
split to certain variables and i can't seem to get it quite right.

I need to extract the date and state from the key to this hash so that I can
sort it properly.  It must be first sorted by state and then by year.  So it
seems the only way to do this is to map it?

Examples)
19990115CAABN00078
19990115CAABN00088
19990118
19990118AZHBN02167
19990118AZHBN02231

Ideally Arizona (contains AZ) lines should come first and then I need to have
it sorted by date also.  So the above should read...

19990118AZHBN02167
19990118AZHBN02231
19990118
19990115CAABN00078
19990115CAABN00088

my current idea runs:

to map it somehow...
foreach $v (sort keys %preindex)
        { ($test_date =$1, $test_state=$2 ) = split(/(\d+)(\w\w)/$v/; }

to sort it somehow...
@sort = sort { lc($b) cmp lc($a)  or  $b <=> $a } keys(%preindex);


thanks,
lisa

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 24 Feb 1999 20:48:43 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Help Assigning Split Results
Message-Id: <7b1ojb$e50$1@info.uah.edu>

[long lines wrapped]

In article <7b1kms$5jm$1@nnrp1.dejanews.com>,
	lmak@verio.net writes:
: I need to extract the date and state from the key to this hash so that
: I can sort it properly.  It must be first sorted by state and then by
: year.  So it seems the only way to do this is to map it?

This is Perl; of course it's not the only way! :-)  However, as Tom
explains in <URL:http://www.perl.com/CPAN-local/doc/FMTEYEWTK/sort.html>,
it's better to do O(n) matches than it is to do O(n log n) matches.
There won't be much of a difference in small examples like yours, but
you'll notice it when n is very large.

Use the Schwartzian Transform:

    my @data = qw(
        19990115CAABN00078
        19990115CAABN00088
        19990118
        19990118AZHBN02167
        19990118AZHBN02231
    );

    my @sorted = map  { $_->[0] }
                 sort {
                     $b->[1] cmp $a->[1] 
                             ||
                     $b->[2] cmp $a->[2]
                 }   
                 map  { /^(\d{8})([A-Z][A-Z])?/; [ $_, $1, ($2 || '') ] }
                 @data;

Hope this helps,
Greg
-- 
There is always death and taxes. However death doesn't get worse every year.


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

Date: Wed, 24 Feb 1999 16:03:58 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: lmak@verio.net
Subject: Re: Help Assigning Split Results
Message-Id: <36D4693E.774CE337@giss.nasa.gov>

[courtesy copy of post sent to Lisa]

lmak@verio.net wrote:
> 
> I'd appreciate any help with this.  I am trying to assign the results of a
> split to certain variables and i can't seem to get it quite right.
> 
> I need to extract the date and state from the key to this hash so that I can
> sort it properly.  It must be first sorted by state and then by year.  So it
> seems the only way to do this is to map it?
> 
> Examples)
> 19990115CAABN00078
> 19990115CAABN00088
> 19990118
> 19990118AZHBN02167
> 19990118AZHBN02231
> 
> Ideally Arizona (contains AZ) lines should come first and then I need to have
> it sorted by date also.  So the above should read...
> 
> 19990118AZHBN02167
> 19990118AZHBN02231
> 19990118
> 19990115CAABN00078
> 19990115CAABN00088
> 

one problem: what to do with the line "19990118"?
It has no state.  Why put it between Arizona and California?

my @lines = <IN_FILE>;
my @sorted = sort compare @lines;
print OUT_FILE @sorted;

sub compare
{
	my ($a_state, $a_date) = compare_helper($a);
	my ($b_state, $b_date) = compare_helper($b);
	return ($a_state cmp $b_state) or ($a_date cmp $b_date);
}

sub compare_helper
{
	my ($year, $day, $month, $state) = unpack "a4a2a2a2", shift;
	return ($state, "$year$month$day");
}

	Jay Glascoe
--   
	The software required "Windows 95 or better",
	so I installed Linux.


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

Date: 24 Feb 1999 14:08:00 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Help Assigning Split Results
Message-Id: <m14sob4fr3.fsf@halfdome.holdit.com>

>>>>> "Greg" == Greg Bacon <gbacon@itsc.uah.edu> writes:

Greg>                  map  { /^(\d{8})([A-Z][A-Z])?/; [ $_, $1, ($2 || '') ] }

Danger Will Robinson.  Never use $1 (et.seq.) without testing the
success of the regex that you *think* might be setting it.  Remember,
a failed regex match does not set those.

bad code.  Bad Code. :)

print "Just another Perl hacker," =~ /(.*)/osmosis;

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: 24 Feb 1999 22:37:29 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Help Assigning Split Results
Message-Id: <7b1uv9$hcq$1@info.uah.edu>

In article <36D4693E.774CE337@giss.nasa.gov>,
	Jay Glascoe <jglascoe@giss.nasa.gov> writes:
: one problem: what to do with the line "19990118"?
: It has no state.  Why put it between Arizona and California?

Its date is later than the California dates.

Greg
-- 
Only great masters of style can succeed in being obtuse.
    -- Oscar Wilde
Most UNIX programmers are great masters of style.
    -- The Unnamed Usenetter


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

Date: 24 Feb 1999 22:43:53 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: Help Assigning Split Results
Message-Id: <7b1vb9$hcq$2@info.uah.edu>

In article <m14sob4fr3.fsf@halfdome.holdit.com>,
	merlyn@stonehenge.com (Randal L. Schwartz) writes:
: >>>>> "Greg" == Greg Bacon <gbacon@itsc.uah.edu> writes:
: Greg> map  { /^(\d{8})([A-Z][A-Z])?/; [ $_, $1, ($2 || '') ] }
: 
: Danger Will Robinson.  Never use $1 (et.seq.) without testing the
: success of the regex that you *think* might be setting it.  Remember,
: a failed regex match does not set those.

Lisa didn't mention that the input data might not be trustworthy.
For example, she may be pulling those values out of a database,
and the database might be checking that the data are well-formed
before inserting.

I do agree with your advice, but checking for well-formed data is
a seperate problem.  I assumed that if the data might be suspect,
she would have mentioned it in her post.

Too much faith in people?  Me? :-)

Greg
-- 
Let me guess: you're a Windows ``programmer'', aren't you?  Do you
know why Unix programmers make more money than Windows ``programmers''?
Because we Unix people know how to read the manual -- and you don't.
    -- Tom Christiansen


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

Date: Wed, 24 Feb 1999 17:43:02 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Help Assigning Split Results
Message-Id: <x3yww17ctjd.fsf@tigre.matrox.com>


lmak@verio.net writes:

> I'd appreciate any help with this.  I am trying to assign the results of a
> split to certain variables and i can't seem to get it quite right.

did you read some documentation on split?

perldoc -f split

> I need to extract the date and state from the key to this hash so that I can
> sort it properly.  It must be first sorted by state and then by year.  So it
> seems the only way to do this is to map it?
> 
> Examples)
> 19990115CAABN00078
> 19990115CAABN00088
> 19990118
> 19990118AZHBN02167
> 19990118AZHBN02231
> 
> Ideally Arizona (contains AZ) lines should come first and then I need to have
> it sorted by date also.  So the above should read...
> 
> 19990118AZHBN02167
> 19990118AZHBN02231
> 19990118
> 19990115CAABN00078
> 19990115CAABN00088
> 
> my current idea runs:
> 
> to map it somehow...
> foreach $v (sort keys %preindex)

what is in the hash %preindex ? I assume the keys are the lines above.

>         { ($test_date =$1, $test_state=$2 ) = split(/(\d+)(\w\w)/$v/; }

The above line contains a few errors. Moreover, split() is not the
proper way to go here. I would use a regexp:

for my $v (keys %preindex) {
	($date, $state) = $v =~ /^(\d+)(\w{2})/;
	$preindex{$v}{date} = $date;
	$preindex{$v}{state} = defined $state ? $state : "";
}

@sort = sort { $preindex{$a}{date} <=> $preindex{$b}{date}
				   ||
	       $preindex{$a}{state} cmp $preindex{$b}{state}
	} keys %preindex;


HTH,
Ala



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

Date: Thu, 25 Feb 1999 03:09:44 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Help Assigning Split Results
Message-Id: <ebohlmanF7ows9.9I7@netcom.com>

Greg Bacon <gbacon@itsc.uah.edu> wrote:
: Use the Schwartzian Transform:

:     my @data = qw(
:         19990115CAABN00078
:         19990115CAABN00088
:         19990118
:         19990118AZHBN02167
:         19990118AZHBN02231
:     );

:     my @sorted = map  { $_->[0] }
:                  sort {
:                      $b->[1] cmp $a->[1] 
:                              ||
:                      $b->[2] cmp $a->[2]
:                  }   
:                  map  { /^(\d{8})([A-Z][A-Z])?/; [ $_, $1, ($2 || '') ] }
:                  @data;

Because the two sort keys are fixed-length, it's possible to preprocess 
the keys so we can use sort()'s internal comparison routine rather 
than passing a block; this usually speeds things up quite a bit:

my @sorted = map  { substr($_, 10) }
               sort
                 map  { /^(\d{8})([A-Z][A-Z])?/; ($2 || '  ') . $1 . $_ } 
                   @data;

This also sorts in the order the original poster requested (state first, 
then date; as you wrote it, it's just a slower version of 'sort @data'.



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

Date: Sun, 21 Feb 1999 16:42:14 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Help needed urgently!
Message-Id: <1dnl3z6.1ah4bn81ahdgrwN@bay3-468.quincy.ziplink.net>

Luke <wmtoh@singnet.com.sg> wrote:

> How do I randomly select X number of items from Y with no repeat where X is
> less than Y.

I would do this by choosing one element from Y at a time, and then
removing it from Y so it won't be selected again.


@Y = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z);

$X = 13;

while (@X < $X) {
  push (@X, splice(@Y, rand(@Y), 1));
}

print "@X\n";


If you want to preserve @Y, just copy it to a temporary array first.


-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


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

Date: Mon, 22 Feb 1999 15:05:34 GMT
From: droby@copyright.com
Subject: Re: Help needed urgently!
Message-Id: <7arrno$44b$1@nnrp1.dejanews.com>

In article <slinberg-2002991801030001@cc11620-a.lwmrn1.pa.home.com>,
  slinberg@crocker.com (Steve Linberg) wrote:
> In article <7anc0i$h2i$1@mawar.singnet.com.sg>, "Luke"
> <wmtoh@singnet.com.sg> wrote:
>
> > How do I randomly select X number of items from Y with no repeat where X is
> > less than Y.
>
> Populate an array of Y entries with the information you want.  Randomize
> it by iterating through it randomly swapping positions.  Pop X entries off
> of the array.  Nothing to it.
>

If you want to fully shuffle before the deal, see perlfaq4 - "How do I shuffle
an array randomly".  This gives a more efficient shuffle  (Fisher-Yates) than
the one you describe.

But if X is 5 and Y is 1,000,000,000, this may still not be great.  ;-)

If Y is much greater than X, you'll save a bit of your machine's time and
energy by modifying the Fisher-Yates algorithm so that it only selects X
elements (with an obvious mod to the foreach).

--
Don Roby

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 23 Feb 1999 11:24:39 +0800
From: "Luke" <wmtoh@singnet.com.sg>
Subject: Re: Help needed urgently!
Message-Id: <7aqjkm$rve$1@mawar.singnet.com.sg>

Hi people!!

     Thanks to Steve, I solved the problem.  I used his advice, did a random
shuffle of an array I populated and popped out an element.  Loop this X
number of times and I have my non-repeated list!!

     I used the algo from the Perl FAQ on randomizing an array.

     I didn't use the technique given by the rest of you cos my array was
populated by reading data from several files.  Thanks for all your help!!
Those other tips aren't wasted cos I just learnt new ways of doing things
from you guys!!



Luke


Luke wrote in message <7anc0i$h2i$1@mawar.singnet.com.sg>...
>Please email me with the answer if you know it.
>
>How do I randomly select X number of items from Y with no repeat where X is
>less than Y.
>
>eg randomly choosing 5 out of 20 unique numbers and none of the 5 numbers
>chosen are repeated numbers.
>
>I really would like to know how because the code I wrote using hashes
>doesn't work.  Here's what I did.  The program will pick a random number
and
>then delete that entry from the hash.  Then it will repeat with another
>pick.  However, sometimes it randomly picks a key that was already picked
>before (but it was deleted).  I don't know why it can still pick an already
>deleted key.  Anyway, I need to squeeze the hash down before randomly
>picking again.....anyone know how??
>
>Luke
>
>
>




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

Date: Tue, 23 Feb 1999 17:37:34 -0500
From: Yu Fang <yfang@gte.com>
Subject: Help on CGI!!
Message-Id: <36D32DAE.E8ABEC16@gte.com>

My dear friends:

This question may not be related to this site. I don't know what place
to turn to. Sorry to bother.

I have a CGI script (in perl) which writes back the page piece by piece
every couple of seconds. I want the browser shows the page piece by
piece too - not waiting until the whole page is finished.

The following script works on http://www.telcoip.com/cgi-bin/temp2.cgi 
but not on my Sun Web Server (sorry the server is behind a firewall). Do
I need to do something special to configure my web server?

Thanks.
--
#!/bbn/bin/perl

# test script

$|=1;

print STDOUT "Content-type:text/html\n\n";
$now = localtime time;
print STDOUT "$now : First Try. Will try again in 5 seconds. Please
wait. <p>\n";

$allsec = time;
$allsecb = ($allsec + 5);

while ($allsecb > $allsec) {
$allsec = time;
}

$now = localtime time;

print STDOUT "Total seconds since 1970: $allsec <p>\n";
print STDOUT "$now : Still Trying. Will try again in 5 seconds. Please
wait. <p>\n";

$allsec = time;
$allsecb = ($allsec + 5);

while ($allsecb > $allsec) {
$allsec = time;
}

$now = localtime time;

print STDOUT "Total seconds since 1970: $allsec <p>\n";
print STDOUT "$now : Still Trying. Will try again in 5 seconds. Please
wait. <p>\n";

exit;



-- 
Frank Yu Fang 

GTE Internetworking
40 Sylvan Road
Waltham, MA 02451-1128


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

Date: Tue, 23 Feb 1999 20:17:03 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Yu Fang <yfang@gte.com>
Subject: Re: Help on CGI!!
Message-Id: <36D3530F.B471B70A@giss.nasa.gov>

[courtesy copy sent to Yu]

hi Yu,

Yu Fang wrote:
> 
> My dear friends:
> 
> This question may not be related to this site. I don't know what place
> to turn to. Sorry to bother.
> 
> I have a CGI script (in perl) which writes back the page piece by piece
> every couple of seconds. I want the browser shows the page piece by
> piece too - not waiting until the whole page is finished.

You may need to use a client-side script, like JavaScript, 
to achieve the effect you're after.  I don't know.

> $allsec = time;
> $allsecb = ($allsec + 5);
> 
> while ($allsecb > $allsec) {
> $allsec = time;
> }

woh.  That is seriously wasteful.  Your system
is working its butt off to update "allsec" every
nanosecond or so.  :-()

try "sleep 5;" but also check the docs:

perldoc -f sleep

	Jay Glascoe
--  
ping.


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

Date: Wed, 24 Feb 1999 01:29:15 GMT
From: scraig@my-dejanews.com
Subject: Re: Help on CGI!!
Message-Id: <7avkl2$ff9$1@nnrp1.dejanews.com>

In article <36D32DAE.E8ABEC16@gte.com>,
  Yu Fang <yfang@gte.com> wrote:

> I have a CGI script (in perl) which writes back the page piece by piece
> every couple of seconds. I want the browser shows the page piece by
> piece too - not waiting until the whole page is finished.

  The browser won't be forced to show the page unless it receives an </HTML>
tag, in which case it won't show anything after that.  This is because they
work on a client/server relationship.  The server sends what the browser asks
for in one package -- the server doesn't control the browser.

    Maybe, you could use multipart documents.  This is not a Perl topic. Also,
there isn't an accepted standard among the different browsers as to how these
work, and they are not efficient with resources.

    Depending on what the page does, you may want to use an applet instead.

HTH


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Thu, 25 Feb 1999 01:28:23 +0100
From: "news.casema.net" <news@duh.crash.nu>
Subject: Re: Help on CGI!!
Message-Id: <7b25a7$mcr$1@news.casema.net>

Hi,

I must say I find this an interesting topic since I have been thinking about
this
'problem' as well. If people are interested I have an example where it is
done
the way I want to be able doing it :)
The site is a realtime HTML chat, consisting of 2 frames. The top frame is
used for entering text to send into the chat etc, and the bottom frame shows
the text sent by chatter. This bottom page is viewable, but never done
loading.
It doesn't reload every x seconds as in most HTML based chats, but the page
just stays 'open'. How is it done?
The adress of the chat is : http://www.hotelchat.com/
I use perl CGI's on a Linux based system.

Jeroen

scraig@my-dejanews.com heeft geschreven in bericht
<7avkl2$ff9$1@nnrp1.dejanews.com>...
>In article <36D32DAE.E8ABEC16@gte.com>,
>  Yu Fang <yfang@gte.com> wrote:
>
>> I have a CGI script (in perl) which writes back the page piece by piece
>> every couple of seconds. I want the browser shows the page piece by
>> piece too - not waiting until the whole page is finished.
>
>  The browser won't be forced to show the page unless it receives an
</HTML>
>tag, in which case it won't show anything after that.  This is because they
>work on a client/server relationship.  The server sends what the browser
asks
>for in one package -- the server doesn't control the browser.
>
>    Maybe, you could use multipart documents.  This is not a Perl topic.
Also,
>there isn't an accepted standard among the different browsers as to how
these
>work, and they are not efficient with resources.
>
>    Depending on what the page does, you may want to use an applet instead.
>
>HTH
>
>
>-----------== Posted via Deja News, The Discussion Network ==----------
>http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own




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

Date: Sun, 21 Feb 1999 18:47:47 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Help Please: CGI-String terminator problem
Message-Id: <36d046c3.524144494f47414741@radiogaga.harz.de>

[Removed comp.lang.perl, as it doesn't exist any more. As this has nothing
 to do with modules, removed comp.lang.perl.modules from the F'up]

Yan Ge (yage@waksman.rutgers.edu) wrote:
: I am new to perl and having trouble to run the simplest
: CGI-perl program on my machine.  I copied the howdy CGI program from the
: Learning Perl book got this message when I tried to run on my machine :
: "Can't find string terminator "end_of" anywhere befor EOF at xxfile.."

This normally means that the "end_of" isn't alone on its line (trailing
blanks!), or isn't followed by a \n. The exact string the compiler is
looking for is "\nend_of\n".

: The Learning Perl book used the above way to do it
: while a tutorial on the web use 
:
: print "Content-type: text/html\n\n";
:
: instead.  I wonder whether they all work.

They probably will.

cu,
  Martin
--
                        | Martin Vorlaender | VMS & WNT programmer
 VMS is today what      | work: mv@pdv-systeme.de
 Microsoft wants        |       http://www.pdv-systeme.de/users/martinv/
 Windows NT 8.0 to be!  | home: martin@radiogaga.harz.de


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

Date: Sun, 21 Feb 1999 21:28:12 +0100
From: Harald Boegeholz <hwb@heise.de>
Subject: Re: Help Please: CGI-String terminator problem
Message-Id: <36D06C5C.BB866BE8@heise.de>

Yan Ge wrote:
> 
> Hi! Everyone!  I am new to perl and having trouble to run the simplest
> CGI-perl program on my machine.  I copied the howdy CGI program from the
> Learning Perl book got this message when I tried to run on my machine :
> "Can't find string terminator "end_of" anywhere befor EOF at xxfile.."
> I don't quite get it since the terminator is in the program as the
> follow:
> 
> #!/usr/local/bin/perl -w
> # howdy
> print <<end_of;

try it without the ; on the above line...

> Content-type: text/html
> 
> <html>
>     <head>
>     <title> Hello World </title>
>      </head>
>      <body>
>      <h1> Greetings </h1>
>      </body>
> </html>
> 
> end_of

 ... and with another line containing a ; after this.

-- 
Harald Boegeholz   <hwb@heise.de> (PGP encrypted mail preferred)
Redaktion c't      Tel.: +49 511 5352-300  Fax: +49 511 5352-417
                   http://www.heise.de/ct/Redaktion/bo/

                   int f[9814],b,c=9814,g,i;long a=1e4,d,e,h;
                   main(){for(;b=c,c-=14;i=printf("%04d",e+d/a),e=d%a)
                   while(g=--b*2)d=h*b+a*(i?f[b]:a/5),h=d/--g,f[b]=d%g;}
                                                          (Arndt/Haenel)

                   Oft ist das Denken schwer, indes
                   Das Schreiben geht auch ohne es.
                                      Wilhelm Busch


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

Date: Tue, 23 Feb 1999 12:54:48 +0100
From: Marc Nicole <marnic@ludomedia.ch>
To: Yan Ge <yage@waksman.rutgers.edu>
Subject: Re: Help Please: CGI-String terminator problem
Message-Id: <36D29708.AF4EED59@ludomedia.ch>

I got a similar problem when executing perl on my web server.
It was because I uploaded the file in binary mode instead of
ascii mode, maybe it's a EOL problem $10 $13 ...
have a look in a hex editor.

hope it helps,

regards

Marc

Yan Ge wrote:
> 
> Hi! Everyone!  I am new to perl and having trouble to run the simplest
> CGI-perl program on my machine.  I copied the howdy CGI program from the
> Learning Perl book got this message when I tried to run on my machine :
> "Can't find string terminator "end_of" anywhere befor EOF at xxfile.."
> I don't quite get it since the terminator is in the program as the
> follow:
> 
> #!/usr/local/bin/perl -w
> # howdy
> print <<end_of;
> Content-type: text/html
> 
> <html>
>     <head>
>     <title> Hello World </title>
>      </head>
>      <body>
>      <h1> Greetings </h1>
>      </body>
> </html>
> 
> end_of
> 
> I installed the ActivePerl on my NT4.0 system and it worked  when I
> tested out the example.pl.   Another question I have is the declaration
> of the MIME type.  The Learning Perl book used the above way to do it
> while a tutorial on the web use
> 
> print "Content-type: text/html\n\n";
> 
> instead.  I wonder whether they all work.
> 
> Thanks a lot in advance for your reply.
> 
> Yan.

-- 
_____________________________________________________________________

  L  U  D  O  M  E  D  I  A                   http://www.ludomedia.ch
  -------------------------                 Phone: ++ 41 21 311.60.93
  G A M E   -   D E S I G N                mailto:marnic@ludomedia.ch
_____________________________________________________________________


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

Date: Tue, 23 Feb 1999 23:23:08 -0500
From: Ruogong Liu <liuruogo@pilot.msu.edu>
To: Yan Ge <yage@waksman.rutgers.edu>
Subject: Re: Help Please: CGI-String terminator problem
Message-Id: <36D37EAC.33C06329@pilot.msu.edu>

> "Can't find string terminator "end_of" anywhere befor EOF at xxfile.."

Carefully check the white space after and before your "end_of".

Roger



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

Date: Fri, 26 Feb 1999 07:07:19 +0000
From: Steve Tobin <Steve@ramjam.net>
Subject: Help Translating IPs to Domain Name
Message-Id: <6Zvm2DAngk12EwPH@rmmgroup.demon.co.uk>

I am writing a perl script to analyse my server logs.

The logs contain only the IP addresses of visitors and I would like to
convert these to domain names.

I have tried using nslookup and parsing the output but this is very
slow...

Does anyone know a quicker way to translate IP addresses ?

TIA

Steve Tobin
mailto:Steve@rmmgroup.demon.co.uk


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

Date: 26 Feb 1999 07:51:50 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Help Translating IPs to Domain Name
Message-Id: <7b5jqm$88c$1@client2.news.psi.net>

Steve Tobin (Steve@ramjam.net) wrote on MMV September MCMXCIII in
<URL:news:6Zvm2DAngk12EwPH@rmmgroup.demon.co.uk>:
$$ I am writing a perl script to analyse my server logs.
$$ 
$$ The logs contain only the IP addresses of visitors and I would like to
$$ convert these to domain names.


gethostbyaddr



Abigail
-- 
perl -wlne '}{print$.' file  # Count the number of lines.


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

Date: Thu, 25 Feb 1999 23:55:54 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Help Translating IPs to Domain Name
Message-Id: <MPG.113ff3632d79ebe989690@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <6Zvm2DAngk12EwPH@rmmgroup.demon.co.uk>, on Fri, 26 Feb 1999 
07:07:19 +0000 Steve@ramjam.net says...
 ...
> Does anyone know a quicker way to translate IP addresses ?

perldoc -f gethostbyaddr

-- 
Larry Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 26 Feb 1999 11:46:51 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: Help Translating IPs to Domain Name
Message-Id: <83zp61o31g.fsf@vcpc.univie.ac.at>

Re: Help Translating IPs to Domain Name, Steve
<Steve@ramjam.net> said:

Steve> I am writing a perl script to analyse my
Steve> server logs.  The logs contain only the IP

What kind of server?

Steve> Does anyone know a quicker way to translate
Steve> IP addresses ?

perldoc -f gethostbyname

and an internal lookup hash.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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

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

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4975
**************************************

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