[18203] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 371 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 27 21:05:31 2001

Date: Tue, 27 Feb 2001 18:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <983325910-v10-i371@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Feb 2001     Volume: 10 Number: 371

Today's topics:
    Re: "Offset outside string" errors in syswrite - <K.H.Pennemann@Informatik.Uni-Oldenburg.DE>
        Absent Config.pm <youngb@uclink.berkeley.edu>
        Aliasing refs while using strict <micah@cowanbox.com>
    Re: Aliasing refs while using strict <bart.lateur@skynet.be>
        CGI not working with Personal Web Server <mark_shutt@hotmail.com>
    Re: dereferencing an array of references using join <joeykid6@yahoo.com>
    Re: Easy REGEX question <katz@underlevel.net>
    Re: Easy REGEX question <ren@tivoli.com>
        RE: Easy REGEX question newsone@cdns.caNOSPAM
    Re: Easy REGEX question <krahnj@acm.org>
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari <iltzu@sci.invalid>
    Re: How are SOL_SOCKET and SO_REUSEADDR defined in vari (Kenny McCormack)
    Re: How the CLPM turns <peter.sundstrom-eds@eds.com>
    Re: How the CLPM turns <bart.lateur@skynet.be>
    Re: Learning Perl <tlav1@mediaone.net>
    Re: Learning Perl <parrot0123@yahoo.ca>
        Perl CGI.pm RESET problem <whataman@home.com>
    Re: Perl program review request (Bill Feidt)
    Re: Perl program review request <uri@sysarch.com>
    Re: Perl/DBD Question - Suppressing error messages for  <bill_border@agilent.com>
        Redirect Problem <rthomasboyd@hotmail.com>
    Re: Registry Entries - Help <nouser@emailunwelcome.com>
    Re: Registry Entries - Help <mark_shutt@hotmail.com>
    Re: sending to sockets <um@no.com>
    Re: sending to sockets <um@no.com>
    Re: Sorting by date <sorryno@email.at.all>
    Re: Sorting by date <godzilla@stomp.stomp.tokyo>
    Re: statement for(list); <iltzu@sci.invalid>
    Re: Subject=Re: Creating string of values ignoring empt <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 28 Feb 2001 02:07:01 +0100
From: "Karl-Heinz Pennemann" <K.H.Pennemann@Informatik.Uni-Oldenburg.DE>
Subject: Re: "Offset outside string" errors in syswrite -
Message-Id: <97hj0s$9k9@news.Informatik.Uni-Oldenburg.DE>


Ren Maddox wrote:
> > Look at the little program, which follows. My question is: Why does
> > the error occur in line 10? Yes I know, the offset is outside the
> > buffer, but why doesn't the error occur in line 7? Because the
> > amount of data to copy (called LENGTH in the docs, but not to
> > confuse with length($buffer)) is zero?? It's zero in line 10, too!?
> 
> Implementation aside, this is straight out of the docs for syswrite:
> [...] In the case the SCALAR is empty you can use OFFSET but only
> zero offset.

Thanks Ren, I must admit that this perfectly describes the behaviour of syswrite. It is clear to me that
length(buffer)=0, amount=0, offset=0 is a special case which shouldn't be lead to an error. Aside from that, I still think the case length(buffer)=n, amount=0, offset=n (with n>0) should also provoke no errors.

Take a look at the following problem, where two sockets share on buffer:
sub problem {
  my ($buffer, $socketA, $socketB, $offsetA, $offsetB) = @_;
  while(1) {
    # sysread(...,$buffer,...,...);
    my $a = syswrite($socketA, $buffer, $offsetB-length($buffer), $offsetA);
    my $b = syswrite($socketB, $buffer, $offsetB-length($buffer), $offsetB);
    $offsetA += $a;
    $offsetB += $b;
    my $val = smallest($offsetA, $offsetB);
    substr($buffer,0,$val,"");
    $offsetA -= $svalue;
    $offsetB -= $svalue;
  }
}
This program should run smooth until one of the sockets falls behind the other. Then, one socket will have an offset of 0 and the other will (if the connection is fast enough) have an offset of length($buffer) if he has written/transfered all available data in one loop. Whoops!. I don't think that should lead to an error.

But I do think, that length(buffer)=0, amount=n, offset=0 (line #8) should lead to one! If a specified amount is greater than the buffer-length, then the program contains definitively an error!

--
Karl-Heinz Pennemann


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

Date: Tue, 27 Feb 2001 17:08:43 -0800
From: "Brett Young" <youngb@uclink.berkeley.edu>
Subject: Absent Config.pm
Message-Id: <97hj2u$fdp$1@agate.berkeley.edu>

Hi All:

I was trying to install a Perl module on a Unix machine and the script told
me that it could not find the Config module used in the @INC statement.  I
went looking for Config.pm with all of the other modules (or a Config
directory) and it wasn't there.

Since Config.pm seems to be a core module, how can I explain the fact that
it is absent?  Can the Config.pm module even be excluded during normal
installation?

Brett.






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

Date: 27 Feb 2001 16:22:51 -0800
From: Micah Cowan <micah@cowanbox.com>
Subject: Aliasing refs while using strict
Message-Id: <yu8ofvnejvo.fsf@mcowan-linux.transmeta.com>


I love to use this sort of construct:

sub bar (\@);

my @foo = ( "Hello", "cheez", 10 );
&bar (@foo);

sub bar (\@) {
  local *foo = shift;
  print @foo;  # or whatever...
}

To alias a reference to a variable.

The problem is, I also love to use strict.  I can't use the above
construct unless I disable strict vars /AND/ refs, because we're
screwing with the namespace (which is only globals and local()ized
globals).

Now, of course, I could do:

sub bar (\@) {
  my @foo = @{$_[0]};
  ...
}

But if the argument is a /huge/ array, I don't /want/ to copy it into
another array.

Is there a better way of performing aliases such as this?

Thanks for the help,
Micah


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

Date: Wed, 28 Feb 2001 00:28:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Aliasing refs while using strict
Message-Id: <ieho9tgvqgfo96j20p17ffiqrt436gopoi@4ax.com>

Micah Cowan wrote:

>sub bar (\@);
>
>my @foo = ( "Hello", "cheez", 10 );
>&bar (@foo);
>
>sub bar (\@) {
>  local *foo = shift;
>  print @foo;  # or whatever...
>}
>
>To alias a reference to a variable.
>
>The problem is, I also love to use strict.

>Is there a better way of performing aliases such as this?

No. There even isn't a possibility for lexical aliases (except for
scalars, using "for"). But you can do:

	use vars '*foo';

That's the @foo inside the sub, not the one you make the call with, with
also happens to be named "foo".

-- 
	Bart.


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

Date: Wed, 28 Feb 2001 00:30:08 -0000
From: Mark <mark_shutt@hotmail.com>
Subject: CGI not working with Personal Web Server
Message-Id: <t9ohkg99qaljd5@corp.supernews.com>

Hi,

I'm using Perl and MS PWS. When I submit a form to display a simple 
message, the Perl script executes by quickly pulling up a DOS prompt and 
the page just sits there. I have the registry correct with the ScriptMap I 
think. I've seen numerous examples that all say the same thing. Does 
anyone know why my perl scripts would execte as if I ran them from the DOS 
prompt or as if I double clicked the script from windows explorer? I have 
also since removed the "Open" action of Windows explorer because I thought 
that may have been affecting it, but that doesn't seem to be the case.

Thanks,
Mark

--
Posted via CNET Help.com
http://www.help.com/


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

Date: Tue, 27 Feb 2001 18:33:17 -0500
From: "Joe Williams" <joeykid6@yahoo.com>
Subject: Re: dereferencing an array of references using join
Message-Id: <97hdjt$rea$1@slb4.atl.mindspring.net>

Thanks, Ren.  For some reason, I thought I tested without the quotes and got
an error.  You win for the most concise code and the least impatient
response.  Although a guy named Greg was nice as well.  I am teaching myself
from books as a hobby, and so make some goofy mistakes.
Joe

Ren Maddox <ren@tivoli.com> wrote in message
news:m3ofvnkhsu.fsf@dhcp9-175.support.tivoli.com...
> On Tue, 27 Feb 2001, joeykid6@yahoo.com wrote:
>
> >     if ($all_file_data["$rm_row"]["$name_loc"] eq "") {
> >      $all_file_data["$rm_row"]["$name_loc"] = $t_name;
> >      $all_file_data["$rm_row"]["$email_loc"] = $t_email;
>
> Don't use quotes like that -- it works, but only in spite of, not
> because of the quotes.  First of all, putting a single scalar in
> quotes servers very little purpose; and second, arrays are indexed by
> numbers, so why would you use strings?
>
> >  for (@all_file_data) {
> >      $i = 0;
>
> This resets $i each time through the loop....
>
> >      $row_str = join("\t",@{$all_file_data["$i"]});
> >      print WEEKW "$row_str\n";
> >      $i++;
> >  }
> >  close (WEEKW);
>
> Try this:
>
>     foreach my $row (@all_file_data) {
>         print WEEKW join "\t", @$row;
>     }
>
>
>
> --
> Ren Maddox
> ren@tivoli.com




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

Date: 27 Feb 2001 19:25:01 -0500
From: Jordan Katz <katz@underlevel.net>
Subject: Re: Easy REGEX question
Message-Id: <m31ysjr6w2.fsf@underlevel.underlevel.net>

Todd Bair <todd@ti.com> writes:

> I just can't seem to get this to work.  How do a split a line
> based on two or more spaces, but leave single spaces alone.
> 
> ie...
> 
> $line = 'column one     column two   column three';
> @row = split/  /,$line;
> 
> so that
> 
> $row[0] eq 'column one';
> $row[1] eq 'column two';

Hey, try:

my $line = 'column one     column two   column three';
my @row = split /\s{2,}/, $line;
print $row[0] . "\n";
print $row[1] . "\n";
-- 
Jordan Katz <katz@underlevel.net>  |  Mind the gap


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

Date: 27 Feb 2001 17:34:09 -0600
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Easy REGEX question
Message-Id: <m3g0gzk8em.fsf@dhcp9-175.support.tivoli.com>

On 27 Feb 2001, katz@underlevel.net wrote:

> Todd Bair <todd@ti.com> writes:
> 
>> $line = 'column one     column two   column three';
>> @row = split/  /,$line;
> 
> Hey, try:
> 
> my $line = 'column one     column two   column three';
> my @row = split /\s{2,}/, $line;
> print $row[0] . "\n";
> print $row[1] . "\n";

Yeah, you'd think so wouldn't you?  Except that every time I tried
that using the OP's data, it didn't work.  Of course, it isn't
completely obvious that it didn't work, since the problem is extra
trailing spaces, which aren't going to be very visible when printing
as you did.  Instead, I used:

  print ":$_:\n" for @row;

Not only did the spaces *not* go away, but even worse, the split
stopped working as soon as I edited it.  It was very puzzling.  I
finally realized that the reason it didn't work was that those extra
characters in there are *not* spaces.  They are extended ASCII
characters (decimal 160), which I assume is a hard space or something
similar.

Unfortunately, this character is not included in the class represented
by "\s", so using that in the regex didn't help.  Now, I don't know if
the OP's *original* data has this problem, or if it was just in the
posting.  I'm hoping the later, in which case Todd's solution is right
on (though I actually prefer "\s\s+" to "\s{2,}").  But if it is the
former, then something like:

  @row = split /[\240 ]{2,}/, $line; # or [\240\s] if more appropriate

is needed instead (240 being the octal version of decimal 160).

-- 
Ren Maddox
ren@tivoli.com


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

Date: 28 Feb 2001 01:06:15 GMT
From: newsone@cdns.caNOSPAM
Subject: RE: Easy REGEX question
Message-Id: <97hiu7$fr8$1@news.netmar.com>


I just can't seem to get this to work.  How do a split a line
 based on two or more spaces, but leave single spaces alone.
 
 ie...
 
 $line = 'column one     column two   column three';
 @row = split /  /,$line;
 
 so that
 
 $row[0] eq 'column one';
 $row[1] eq 'column two';
 
 Thanks,
 
 Todd
 ==============

Todd:

##############
# Clumsy but hey, what the "h"

&reg_ex_problem;
&reg_ex_problem2;

sub reg_ex_problem {

 $line = "column one     column two   column three";

# assuming a limit on the number of spaces between your names, like not
infinite or 
# ridiculously large. I used a beginning value of 5 spaces and in second
example, 10

$line =~ s/     /:/g;
$line =~ s/    /:/g;
$line =~ s/   /:/g;
$line =~ s/  /:/g;

# should produce $line = 'column one:column two:column three'

 @row = split (/:/,$line);
 
print "Column 1 name is: $row[0]\n";
print "Column 2 name is: $row[1]\n";
print "Column 3 name is: $row[2]\n";

print "This works\n\n\n\n";

}

sub reg_ex_problem2 {

 $line = "column one     column two   column three       column four";

# assuming a limit on number of possible spaces, I used a beginning value of
10 spaces

#Initialize array starting with 10 spaces, 9 spaces, 8 spaces, etc.

@ary = ('          ','         ','        ','       ','      ','     ','   
','   ','  '); #an array with space count starting at 10

for ($i = 0; $i < 9; $i++) {
   $splitchar = $ary[$i];
   $line =~ s/$splitchar/:/g;
}


 @row = split (/:/,$line);
 
   $number_of_columns = 3;

   for ($i = 0; $i < $number_of_columns; $i++) {      
      print "Column ", $i + 1, " name is: $row[$i]\n";
   }

   print "This works too\n";

}


Eric  Remove NOSPAM to email.


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Wed, 28 Feb 2001 01:34:59 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Easy REGEX question
Message-Id: <3A9C570E.46A841E0@acm.org>

Todd Bair wrote:
> 
> I just can't seem to get this to work.  How do a split a line
> based on two or more spaces, but leave single spaces alone.
> 
> ie...
> 
> $line = 'column one     column two   column three';
> @row = split/  /,$line;

@row = split/  +/,$line;


John


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

Date: 28 Feb 2001 00:51:13 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <983320648.10316@itz.pp.sci.fi>

In article <97h45p$8pa$1@yin.interaccess.com>, Kenny McCormack wrote:
>
>(*) It is also possible that there is some magic bullet in Perl that could
>do this.  Clearly, Perl (something with which I am only moderately
>familiar-with/skilled-in) "knows" the values of these constants (gathered
>while it was being compiled) and it is not inconceivable that it could be
>possible for a running Perl program to determine these constants at runtime
>thereby.

Oh yes it does.  When you build perl, it extracts the information from
the C header files, stores it, and makes it available through..

Yep, you guessed it.  Socket.pm.

Now, if this part of perl has since been amputated, then you're in the
position of someone asking how to run with their legs cut off.  If the
systems you're working with have a working C compiler, you _could_ try
building and installing (to a private directory if necessary) your own
copy of Socket, since an old version (1.50) seems to be available as a
separate package on CPAN.  But if your perl is missing bits, you might
not be able to count on the C header files being intact either.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"There seems to be a very, very fine line between cutting-edge physicists
 and utter nutballs."               -- Steve VanDevender in the monastery

Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: 27 Feb 2001 19:39:37 -0600
From: gazelle@yin.interaccess.com (Kenny McCormack)
Subject: Re: How are SOL_SOCKET and SO_REUSEADDR defined in various flavors of Unix?
Message-Id: <97hksp$cbe$1@yin.interaccess.com>

In article <97h57q$2926$1@xlerb.dynas.se>,
Mikko Tyolajarvi <mikko@dynas.se> wrote:
 ...
>>Now, where this is all coming from is that in the past, I've found that
>>Solaris seems to do things differently than most other Unixes.  So, I've
>
>s/Solaris/Linux/
>
>>done this:
>
>>    $SOCK_STREAM = $ENV{'OSTYPE'} =~ /solaris/ ? 2 : 1;
>
>Apart from this being a bad idea from a mainatanence perspective,
>Solaris, AIX, HP-SUX, FreeBSD and even M$ winsock use the same
>definitions - most likely inheritance from the BSD TCP/IP stack.

This is, in fact, not true.  I just installed ActiveState Perl on my Win9X
machine, and took a server program from Solaris (that set SOCK_STREAM to 2)
and tried to run it on the Win9X machine.

You guessed it.  Had to change SOCK_STEAM to 1 - after which it worked fine.

So, I think the score so far is:

		    Solaris	Linux, HP/UX, Win9X (probably others)
		    =======	=====================================
SOCK_STREAM value:	2		1



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

Date: Wed, 28 Feb 2001 11:38:39 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: How the CLPM turns
Message-Id: <97ha9l$qjn$1@hermes.nz.eds.com>


"Bernard El-Hagin" <bernard.el-hagin@lido-tech.net> wrote in message
news:slrn99mn0h.n9t.bernard.el-hagin@gdndev32.lido-tech...
>
> After frequenting this newsgroup for over 2 years I've come to know
> some of the regular posters here and decided that, as a service to
> newbies, I'd write up some typical regular poster replies to typical
> newbie questions. That way someone new to the group can pick the style
> of answer he/she prefers and look for that person in the future.
>
> DISCLAIMER!
> My goal in doing this is not to offend anyone. Quite the contrary,
> actually.

It gave me the biggest laugh I've had in ages.  You should publish it on a
website.

>
> __________
> Typical newbie question:
>
> Subject: NEWBIE DEMANDS HELP NOW!!!!!!
>
> I'm new to PERL. I want to sort an array, but don't know how. I've spent
> hours searching the Web, the docs, the FAQs, the books, and under my
> bed, but couldn't find the answer. You must help me NOW or I'll get
> fired.

I would have thought a more typical newbie question would be:

I'm too lazy to search Usenet archives, use a search engine, read a book or
even search the Perl documentation on my hard disk, so I'm demanding that
someone give me an instant answer even though I'm aware that Usenet articles
can take a while to propagate.
And for good measure, I'll individually post this message in alt.perl and
comp.lang.perl with different subject lines.






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

Date: Wed, 28 Feb 2001 00:24:19 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: How the CLPM turns
Message-Id: <29ho9toj6e0qo57b7jmkvubc1dhvnls0aj@4ax.com>

Peter Sundstrom wrote:

>I would have thought a more typical newbie question would be:
>
>I'm too lazy to search Usenet archives, use a search engine, read a book or
>even search the Perl documentation on my hard disk, so I'm demanding that
>someone give me an instant answer even though I'm aware that Usenet articles
>can take a while to propagate.
>And for good measure, I'll individually post this message in alt.perl and
>comp.lang.perl with different subject lines.

Please only mail me the answer, because I don't read this newsgroup. Oh
yeah, my e-mail address is invalid, but you'll figure it out.

-- 
	Bart.


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

Date: Tue, 27 Feb 2001 23:41:32 GMT
From: ted <tlav1@mediaone.net>
Subject: Re: Learning Perl
Message-Id: <3A9C65F2.6014DC72@mediaone.net>

The O'Reilly book _Learning Perl_ is also very good.  Also try the
Visual QuickStart Guide book if you prefer a more "visual" way of
learning, but VQSG is a little skimpy.  It's more of a "here, this is
what works" rather than an explaination of perl and its subtleties.

Good luck!

ted




Robert Clark wrote:

> How can i go about learning perl??
>
> --
> Steve Wright
>
> schumie@totalise.co.uk



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

Date: Wed, 28 Feb 2001 00:43:58 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: Learning Perl
Message-Id: <iRXm6.251269$Pm2.3983686@news20.bellglobal.com>

There are some nice tutorials on www.webmonkey.com

You could also do a search for Perl Tutorials on your favourite search
engine and I'm sure you'll come up with a ton of stuff.  If you already know
how to program you might want to try finding some free code to download and
fiddle around with to see what makes it tick.  www.freecode.com has some
good stuff.

Robert Clark <Trebor_Clark@btinternet.com> wrote in message
news:97h3r4$fk0$1@plutonium.btinternet.com...
> How can i go about learning perl??
>
> --
> Steve Wright
>
> schumie@totalise.co.uk
>
>




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

Date: Wed, 28 Feb 2001 01:08:17 GMT
From: "What A Man !" <whataman@home.com>
Subject: Perl CGI.pm RESET problem
Message-Id: <3A9C4FF5.55DEE58A@home.com>

How do I get my RESET button in the script below to clear
the HTTP REFERRER out of the input field when someone hits
RESET? I don't want to use Javascript or have to create
another file to do this. I've been studying CGI.pm all day
and can't figure it out. Is there a way to do this with
raw Perl if CGI.pm won't do it?

#!/usr/local/bin/perl -wd
use CGI qw(fatalsToBrowser);
use CGI qw(:standard);

print "Content-type: text/html\n\n";

print "<HTML><BODY bgcolor=99CCFF topmargin=0>
<CENTER><!--#echo banner=''-->";

$query = new CGI;

print $query->start_form(-method=>$method,
                         -action=>$action,
                         -enctype=>$encoding);

print $query->textfield(-name=>'url',
                        -default=>"$ENV{HTTP_REFERER}",
                        -size=>60,
                        -maxlength=>300);
print "<BR>";

print $query->reset(-name=>'RESET',
                    -value=>'param()');
print "&nbsp;&nbsp;&nbsp;&nbsp;";
print $query->submit(-name=>'submit',
                     -value=>'SUBMIT');
print "</CENTER></BODY></HTML>";
print $query->endform;


Thanks,
Dennis


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

Date: 27 Feb 2001 18:50:13 -0500
From: wfeidt@his.com (Bill Feidt)
Subject: Re: Perl program review request
Message-Id: <9055B81CBwfeidthiscom@216.200.68.12>

uri@sysarch.com (Uri Guttman) wrote in <x7r90jg4pa.fsf@home.sysarch.com>:

>>>>>> "BF" == Bill Feidt <wfeidt@his.com> writes:

>  BF>         }
>  BF>         elsif ( $percent_digits > 84 )  {
>  BF>             $percent = "<strong>$1</strong>%";
>
>why use $1 here when you assigned it to $percent_digits?

Thought I got them all, but obviously missed that one. It
has been changed now.

>and what if $percent_digits <= 84? you don't set $percent in that case.

I only highlight the number if it exceeds those thresholds.  
Otherwise it remains as set by the split:

   my ($date2, $volume, $percent) = split (/\|/, $line);

earlier.

I've updated the Web page that contains the code again.  So
if anyone wants to see the whole megillah in its current
iteration, you can visit:

  http://www.cpcug.org/dialup/shdisk.txt

Bill
Bill@ng3k.com




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

Date: Tue, 27 Feb 2001 23:55:15 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl program review request
Message-Id: <x7itlvfzq4.fsf@home.sysarch.com>

>>>>> "BF" == Bill Feidt <wfeidt@his.com> writes:

  BF> uri@sysarch.com (Uri Guttman) wrote in <x7r90jg4pa.fsf@home.sysarch.com>:

  >> and what if $percent_digits <= 84? you don't set $percent in that case.

  BF> I only highlight the number if it exceeds those thresholds.  
  BF> Otherwise it remains as set by the split:

  BF>    my ($date2, $volume, $percent) = split (/\|/, $line);

  BF> earlier.

that again is not clear coding. like your deprecated reuse of $line, you
should not reuse $percent for input and output. learn that rule now
before it bites you in the future.

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: Tue, 27 Feb 2001 16:17:05 -0700
From: "Bill Border" <bill_border@agilent.com>
Subject: Re: Perl/DBD Question - Suppressing error messages for "normal" errors
Message-Id: <983315847.141082@goodnews.cos.agilent.com>

I found it. thanks anyway. Reply if you want to
know how to do this.

Bill


"Bill Border" <bill_border@agilent.com> wrote in message
news:983309396.777333@goodnews.cos.agilent.com...
> Hi All,
>
>   I am working on a DBD program where I insert a row into an Oracle table
> with a unique index. It is normal for this call to get a SQL error when
> there
> is a duplicate row. I do handle the error after the call with $dbh->err;
> Here
> is my question: how do I prevent this error:
>
> DBD::Oracle::db do failed: ORA-00001: unique constraint
(DBAMON.HISTORY_X1)
> violated (DBD ERROR: OCIStmtExecute) at /opt/dbamon/lib/histCreate.pl line
> 28.
>
> from displaying on STDOUT???
>
> TIA,
> Bill
>
>
>
>




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

Date: Tue, 27 Feb 2001 19:02:55 -0800
From: "rthomasboyd" <rthomasboyd@hotmail.com>
Subject: Redirect Problem
Message-Id: <V_Xm6.1667$m7.254358@e3500-chi1.usenetserver.com>

I have a script that redirects a link and writes the URL to a file . My
problem is that when it logs a large PDF file it keeps recording over and
over again. Attached is the script. I am not sure if there is something I
did wrong or if maybe files time out then log back in to finish downloading.
Any help would be great.

Thanks Dan

#!C:/Perl/bin/perl.exe -w

$url = $ENV{'QUERY_STRING'};
chomp($url);
if ($url eq 'stats'){
&stats;
}
if ($url eq 'total'){
&total;
}

print "Location: http://cgi-bin/redirect2.pl?$url\n\n";

################## PRINT TO A FILE ALL ENTERYS open (SAFE, '>>hits.txt') ||
die ("no file");
@all = <SAFE>;
print SAFE "$url\n";
close(SAFE);

############## START CHECK TO SEE IF NEW
open (OUTFILE, 'counts.txt') || die ("no file");
@all = <OUTFILE>;
close(OUTFILE);

foreach $line(@all){
chomp($line);
($curl, $n) = split(/,/, $line);
if ($curl eq $url){
&MATCH ($curl, $n, @all);
}
}

open (NEW, '>>counts.txt') || die ("no file");
@in = <NEW>;
print NEW "$url,1\n";
close(NEW);
exit;


############# SUBS HERE

########## Stats Page ################
sub stats {
print "Content-type: text/html\n\n";

open (PAGE, 'page1.htm') || die ("no file");
@out = <PAGE>;
close(NEW);
print "@out";
print "<h3>This is a list of redirected links<br>and the number of times
they have been visited</h3>";
open (NEW, 'counts.txt') || die ("no file");
@in = <NEW>;
close(NEW);
foreach $f(@in){
print "$f<br>";
}
print "</td></tr></body></html>";
exit;
}

sub total {
print "Content-type: text/html\n\n";


open (PAGE, 'page1.htm') || die ("no file");
@out = <PAGE>;
close(NEW);
print "@out";
print "<h3>This is a list of all redirected links</h3>";
open (NEW, 'hits.txt') || die ("no file");
@in = <NEW>;
close(NEW);
foreach $f(@in){
print "$f<br>";
}
print "</td></tr></body></html>";
exit;
}

##### If A MATCH IS FOUND ######
sub MATCH {
print "Found a match<br>";

open (FILE, '>counts.txt') || die ("no file");
@out = <FILE>;

foreach $U(@all){
chomp $U;
if ($U ne "$url,$n"){
print FILE "$U\n";
}
}
$n++;
print FILE "$url,$n\n";
close(FILE);

exit;
}





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

Date: Tue, 27 Feb 2001 18:43:41 -0500
From: Jay Tilton <nouser@emailunwelcome.com>
Subject: Re: Registry Entries - Help
Message-Id: <skeo9t0i5tj8dh2akq5c39jjgrap2avcpa@4ax.com>

"KevinP" <kev@kdpsoftware1.nospmrs.demon.co.uk> wrote:

>What do I put in the registry to map scripts to the "appropriate
>interpreter.
>
>I am using W98 and PWS to work with.

See http://perl.xotechnologies.net/tutorials/PWS/PWS.htm


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

Date: Wed, 28 Feb 2001 00:30:06 -0000
From: Mark <mark_shutt@hotmail.com>
Subject: Re: Registry Entries - Help
Message-Id: <t9ohkevacircf@corp.supernews.com>

Kevin, I found this website to tell you where to put the entries. However, 
I still can't get my perl cgi working (I'm also using PWS and Win98). I 
have a simple test script to write "Hi" to the screen. Instead it pulls 
up  a DOS box and executes it and I have to go into the Task Manager to 
delete the process. I installed PWS before ActivePerl. I hope this URL 
works for you, and if you know my problem I'd appreciate a response.

Thanks.

Mark

http://perl.xotechnologies.net/tutorials/PWS/PWS.htm

KevinP wrote:
> 
> 
> What do I put in the registry to map scripts to the "appropriate
> interpreter.
> 
> I am using W98 and PWS to work with.
> 
> TIA
> 
> Kev
> 
> 


--
Posted via CNET Help.com
http://www.help.com/


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

Date: Tue, 27 Feb 2001 19:49:59 -0800
From: "Ben L." <um@no.com>
Subject: Re: sending to sockets
Message-Id: <3a9c4d7f$1_2@news2.one.net>

The problem here is you are trying to send and receive data on one socket in
the same process ... in the words of the Perl gods only try that if you are
a wizzard or really into pain!  If you want *bidirectional* communication
like what you're doing in your script, the easiest way is to do a fork and
listen in the parent process and write in the child process (or vice versa)
 ... it's way easier to do one thing in two processes than to do two things
in one process.  Go find the interprocess communication tutorial; there is
an excellent example under "interactive tcp client with IO::socket".

Ben

Ted Fiedler <tfiedler@zen.moldsandwich.com> wrote in message
news:Pine.LNX.4.21.0102270650150.18443-100000@zen.moldsandwich.com...
> Ive been working on this for several hours and CANNOT seem to figure out
> what im doing wrong - all I want to do is get the output from the socket
> and write it to a file. any help is appreciated.
>
> use strict;
> use IO::Socket;
>
> ######################################################
> #            Configs go here                         #
> ######################################################
> #
> #
> my ($remote_host);
> my ($remote_port);
> my ($protocol);
> #
> # $protocol="udp";
> $protocol="tcp";
> $remote_port="23"; # or whatever
> $remote_host="rainmaker.wunderground.com"; # this should usually be the
> same???
> ######################################################
> #           End user configs                         #
> ######################################################
>
>
>
> ######################################################
> #              constants                             #
> ######################################################
> #
> my ($socket);
> my ($awnser);
> #
> ######################################################
> #                   End of Constants                 #
> ######################################################
>
> open(WEATHERFILE, ">weather.dat") || die "couldnt open weather.dat";
>
> $socket = IO::Socket::INET->new(PeerAddr => $remote_host,
>                                 PeerPort => $remote_port,
>                                 Proto    => $protocol,
>                                 Type     => SOCK_STREAM);
> sleep 5;
> print $socket "\r";
> sleep 10;
> $awnser=<$socket>;
> print WEATHERFILE "$awnser";
> print $socket "bgm\r";
> $awnser=<$socket>;
> print WEATHERFILE "$awnser";
> sleep 3;
> print $socket "x";
> sleep 2;
> print $socket "\r";
> close ($socket);
> close WEATHERFILE;
>
> ******FYI -- This is the out put that I get in weather.dat ******
> --------------------------------------------------------------------------
----
> ^M*               Welcome to THE WEATHER UNDERGROUND telnet
> service!           *
>
>
> Thanks in advance
>
> Ted
>




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

Date: Tue, 27 Feb 2001 19:52:09 -0800
From: "Ben L." <um@no.com>
Subject: Re: sending to sockets
Message-Id: <3a9c4e01$1_2@news2.one.net>

and here is the link to that tutorial:

http://www.perl.com/pub/doc/manual/html/pod/perlipc.html





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

Date: Tue, 27 Feb 2001 23:33:58 -0000
From: "Brian J" <sorryno@email.at.all>
Subject: Re: Sorting by date
Message-Id: <3a9c3974_2@news2.uncensored-news.com>


"Godzilla!" <godzilla@stomp.stomp.tokyo> wrote in message
news:3A9C0ACA.3ADC67F9@stomp.stomp.tokyo...
> Brian J wrote:
<snipped some very useful info>


I couldn't get


$modified = (stat ($filename)) [9];


to return any value whatsoever, perhaps it doesn't work on NT?  I have
found another way around it now and by adapting the code you posted I
have sorted it according to the time value stored within each .txt file.



opendir (TOPICS, "$topic_directory")
or die "Can't open topic directory";
$file_ext= ".txt";
while (defined ($filename = readdir (TOPICS)))
 {
  if ($filename =~ /[\w+]$file_ext$/)
   {
    &set_modified;
    $filename = "$modified:$filename";
    push (@Array, $filename);
   }
 }
@topics = reverse sort (@Array);

sub set_modified {
$topic = $filename;
$topic =~ s/(.+)\.txt/$1/;
&open_topic;
$topic_text = join '', @topic_text;
# Extract the date when the file was last modified
if ($topic_text =~ /<last_modified>(.*)<\/last_modified>/s) {
$modified = $1;
}
else {
$err = "lastmod";
return undef;
}
}

sub open_topic {
$topic_file = "$topic_directory/" . $topic . ".txt";
eval {
open (TOPIC, "< $topic_file")
or die "Can't open topic file";
@topic_text = <TOPIC>;
};
if ($@) {
$error = $@;
return undef;
}
else {
return 1;
}
}


--

Brian



______________________________________________________________________
Posted Via Uncensored-News.Com - Still Only $9.95 - http://www.uncensored-news.com
 With Servers In California, Texas And Virginia - The Worlds Uncensored News Source
  


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

Date: Tue, 27 Feb 2001 15:52:01 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Sorting by date
Message-Id: <3A9C3DA1.7CD0588D@stomp.stomp.tokyo>

Brian J wrote:
 
> Godzilla! wrote:
> > Brian J wrote:

> I couldn't get
 
> $modified = (stat ($filename)) [9];
 
> to return any value whatsoever, perhaps it doesn't work on NT?

(snipped)

I do not know if stat () is supported under Windows NT.
Perhaps another will read this and suggest some coding
which will perform a similar function for Windows NT. 

For comparison, I am running Perl 5.6 via Apache 1.3.14
both under Windows 98se, if this helps.

Godzilla!


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

Date: 28 Feb 2001 01:12:44 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: statement for(list);
Message-Id: <983322199.13531@itz.pp.sci.fi>

In article <t9o4nuirb3js79@corp.supernews.com>, Greg Bacon wrote:
>
>In Perl, for and foreach are synonyms.  I'm not sure when for became a
>legal modifier, but I think it was somewhere in 5.004.

Nope, it's new in 5.005.  From perldelta.pod, 5.005_03:

: NAME
:        perldelta - what's new for perl5.005
:
: DESCRIPTION
:        This document describes differences between the 5.004
:        release and this one.
:
 [long snip]
:
:        EXPR foreach EXPR is supported
:
:        See the perlsyn manpage.

-- 
Ilmari Karonen - http://www.sci.fi/~iltzu/
"The next phase, of course, is to make 'ultramini low-heat tubes' that
 throw away the cosmetic glass tube portion and just have the tube socket
 base with the chip buried in it.  Of course, you could sell these for
 even more than your 'real' tubes, with an even higher profit margin."
                                    -- Steve VanDevender in the monastery

Please ignore Godzilla / Kira -- do not feed the troll.


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

Date: Wed, 28 Feb 2001 00:05:01 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Subject=Re: Creating string of values ignoring empty
Message-Id: <05go9to7csl6c5ti5qoaang7gs5a9b8hlt@4ax.com>

Thomas Wolfmaier wrote:

>map { $record->{$_} ? ACCESS_PERMISSION->{$_}->{$lang} : () }

This is a map and a grep rolled into one. Something like this:

	@filtered = map { ACCESS_PERMISSION->{$_}->{$lang} } 
	  grep { $record->{$_} } @access;

-- 
	Bart.


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

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 V10 Issue 371
**************************************


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