[9657] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3251 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 25 00:07:32 1998

Date: Fri, 24 Jul 98 21:00:21 -0700
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, 24 Jul 1998     Volume: 8 Number: 3251

Today's topics:
    Re: ? about binmode() behavior <rootbeer@teleport.com>
        Baffled!! system() mashton@my-dejanews.com
    Re: chomp or other command to eliminate LF and or CR fr (Abigail)
    Re: Detecting Countries (Abigail)
    Re: Detecting Countries <nexes@epix.net>
    Re: eval and CGI::Carp qw(fatalsToBrowser) (brian d foy)
    Re: Expanding $1 in a variable substitution (Kevin Reid)
    Re: fork strangeness <goodaci@mbs.gov.on.ca>
    Re: forking processes in proxy script <merlyn@stonehenge.com>
    Re: has anyone attempted a script that can replicate it (Kevin Reid)
    Re: more perl uploading problems <rootbeer@teleport.com>
    Re: Nice Numbers (Larry Rosler)
    Re: parsing question (Tad McClellan)
        passing arguments to external prgm failing on NTServer mashton@my-dejanews.com
        Perl 5.005 - IRIX 5.3: groups.t test failure <dwatts.nospam@dimentech.com>
        Perl 5.005: perldoc problems (j)
    Re: Perl array name (Kevin Reid)
    Re: Perl with SSI (brian d foy)
        Perl(sendmail) and Psiweb problem (Terry1519)
    Re: Perl(sendmail) and Psiweb problem (Abigail)
    Re: Personality testing <rootbeer@teleport.com>
    Re: question about the @_ variable (Kevin Reid)
    Re: References as strings (Kevin Reid)
    Re: two "should-be" FAQ's re:arrays (Abigail)
    Re: Wrong Line # <rootbeer@teleport.com>
    Re: Y2K problem in PERL with localtime() (Tad McClellan)
    Re: Y2K problem in PERL with localtime() (Abigail)
    Re: Y2K problem in PERL with localtime() (Abigail)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Sat, 25 Jul 1998 03:50:52 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: ? about binmode() behavior
Message-Id: <Pine.GSO.4.02.9807242044230.25503-100000@user2.teleport.com>

On Tue, 21 Jul 1998, Brent Verner wrote:

> does binmode() only work when using
> 
>     while(<STDIN>)
>     {
>         print <SOMEFILE> "$_";
>     }

That's not what you want. But really, binmode is for binary files, and the
line input operator is for text files. Never the twain shall meet.

> or 'should' it also work using
> 
>     read STDIN,$buffer,$length,$offset;
>     print <SOMEFILE> "$buffer";

If you check the return value from read, and if your variables are
properly set, and if you fix the print statement to not use the line
operator, binmode should work there. (And you could make me even happier
by removing the superfluous quote marks from $buffer. :-)

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Sat, 25 Jul 1998 01:11:55 GMT
From: mashton@my-dejanews.com
Subject: Baffled!! system()
Message-Id: <6pbbcr$9g9$1@nnrp1.dejanews.com>

I'm baffled!!!

Does anyone have any idea why?

On my winNT Wrkstn it works but it doesn't on my NTServer.

Okay here is the sample code.


$cmd = "mycprog1 -para1 $x1 | mycprog2 -para2 $x2 -para3 $tmpfile";

system($cmd);
open( FROM, "< $tmpfile" );
binmode FROM;
binmode STDOUT;

# Print out the contents of the temporary file.
print <FROM>;
close FROM;

For some reason on NT Server I can't it to pass the command line parameters
correctly to my C progs. But if I take the $cmd and put it in a bat and
execute it from the command line it works.

Any ideas???

Thanks

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 25 Jul 1998 02:48:20 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: chomp or other command to eliminate LF and or CR from lines
Message-Id: <6pbh1k$r8g$7@client3.news.psi.net>

Mark Thompson (mark-lists@webstylists.com) wrote on MDCCLXXXVIII
September MCMXCIII in <URL: news:35b91eba.4916101@news.supernews.com>:
++ 
++ I know chomp will only get rid of the EOL character that's in $/ which varies
++ from time to time.  Is there an easy way to get rid of all LF and CR (and
++ regular spaces for that matter)?  It can't get rid of tabs though (the last
++ field might be blank but I need to differentiate that condition from the
++ condition of not having the right number of fields.)

    s/[\r\n ]+//;


Abigail
-- 
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$r=-2449231+gm_julian_day+time);do{until($r<$#r){$_.=$r[$#r];$r-=$#r}for(;
!$r[--$#r];){}}while$r;$,="\x20";print+$_=>September=>MCMXCIII=>()'


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

Date: 25 Jul 1998 02:53:05 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Detecting Countries
Message-Id: <6pbhah$r8g$8@client3.news.psi.net>

Chris (nexes@epix.net) wrote on MDCCLXXXVIII September MCMXCIII in
<URL: news:6pb16o$5ps$1@news1.epix.net>:
++ Hello,
++ 
++ I have an encryption program that may not be exported except to Canada. It
++ may only be sold in the US and Canada.
++ 
++ I want the perl script to check if the user is the US or Canada, and if they
++ are not - tell them that they must be from the US or Canada.
++ 
++ So far I have written a perl script that checks by using
++ $ENV{'HTTP_ACCEPT_LANGUAGE'}. I looks for a the match "en-us". Is this the
++ best way to do this? Can someone point me to a list of
++ 'HTTP_ACCEPT_LANGUAGE' so I can find all the ones for US and Canada?


*Pffff* Of course not. Anyone can send anything as language. Netscape
probably ships using "en-us" by default. To mention the fact Canada is
a multi-languagal country. Or the large amount of people in the US not
using English as their native tongue.

And I bet a few American and Canadian people have sneaked out of the
country.


If you are concerned about those encryption laws - don't sell over the
web. Have them come and pick up the program personally - at make sure
you keep their passports, otherwise they might hop on a plane and fly
away!



Abigail
-- 
perl -wle 'print "Prime" if (1 x shift) !~ /^1?$|^(11+?)\1+$/'


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

Date: Fri, 24 Jul 1998 23:24:31 -0400
From: "Chris" <nexes@epix.net>
Subject: Re: Detecting Countries
Message-Id: <6pbj6n$has$1@news1.epix.net>

I realize that there are different languages within the US and Canada.
However you seem to be correct in that it isn't the best way, or completely
accurate way to do this.

I have seen a CGI script that has done this before however. It was done on
Bruce Schneier's website for twofish. Perhaps IP addresses were used. Are IP
addresses assigned acording to location? Perhaps I could get a hold of a
list of US and Canadian IPs - prefix directory of sorts. Any other ideas?

Not sell over the web? *Pffff* That would hurt my back pocket too much. =)

I appreciate your suggestions
- Chris




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

Date: Fri, 24 Jul 1998 21:11:27 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: eval and CGI::Carp qw(fatalsToBrowser)
Message-Id: <comdog-2407982111270001@news.panix.com>
Keywords: just another new york perl hacker

In article <35B78CCE.D4B5A2DF@etsetb.upc.es>, Francesc Guasch <frankie@etsetb.upc.es> posted:

> I got a cgi perl script ( the question is more perl than cgi, for sure)
> I do:
> 
> use CGI::Carp qw(fatalsToBrowser);
> 
> so when the cgi dies I see the message in the browser.
> I wanted to use eval, but the die message for eval
> is showed in the browser ( and passed to $@ )

i'm not sure what you mean here.  if i have a bit of code like

   #!/usr/bin/perl

   use CGI::Carp qw(fatalsToBrowser);

   eval { die "this is from eval" };

   print "after eval: [$@]\n";
   __END__

the die does whatever $SIG{__DIE__} tells it to do, but the eval
doesn't let it end the program.  $@ is set and the final print
statement is executed.  the format of what is in $@ is affected
by the black magic that CGI::Carp performs.

if you want die to act differently inside the eval block, you can
make a local version of $SIG{__DIE__}:

   #!/usr/bin/perl

   use CGI::Carp qw(fatalsToBrowser);

   eval {
        local $SIG{__DIE__} = sub { print "my die: $_[0]\n"};
        die "this is from eval"
      };

   print "after eval: [$@]\n";

   die "this should be from CGI::Carp";
   __END__

once you leave the eval block, the previous value of $SIG{__DIE__} -
the one from the CGI::Carp.

is that close to answering your problem?

> I really searched the docs for a way to get rid from
> the use CGI::Carp in the eval block but I just can
> find it.

i've found that if CGI::Carp doesn't do exactly what you want it
to do, you might as well roll your own. :)

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: Fri, 24 Jul 1998 21:54:12 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Expanding $1 in a variable substitution
Message-Id: <1dcmcn1.1thgdxw1qsotstN@slip166-72-108-202.ny.us.ibm.net>

Robert Seals <rseals@fore.com> wrote:

> I really have looked for the answer all over the place!
> 
> #!/usr/local/bin/perl -w
> $m = "abc(.*)m";
> $r = '$1$1$1';
> $pat = "abcdefghijklmnop";
> 
> $pat =~ s/$m/$r/;
> print "$pat\n";
> 
> In other words, I want to refer to the matched
> text in the replacement string. I've tried all manner
> of escaping and /e, and so far no go.

#!/usr/local/bin/perl -w
$m = "abc(.*)m";
$r = '"$1$1$1"';
$pat = "abcdefghijklmnop";

$pat =~ s/$m/$r/ee;
print "$pat\n";

__END__

Useeful tidbit: s///ee doees thee eequivaleent of an eeval.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Fri, 24 Jul 1998 20:37:48 -0400
From: Ian Goodacre <goodaci@mbs.gov.on.ca>
Subject: Re: fork strangeness
Message-Id: <35B928DC.A951B5@mbs.gov.on.ca>

I have been experimenting some more, and discovered that if I end the child
with exec('/bin/true') instead of with exit, then it does what I expect.

My modified program is:

#!/usr/local/bin/perl5.00404 -w
#
$| = 1;
print "start $$\n";
unless(open(SRC,"<./input")) {
    die "./input: $!";
}

$SIG{CHLD} = sub {
    wait;
};

while(defined($record = <SRC>)) {
    print "$$: $record";
    unless(defined($pid = fork)) { die "fork: $!"; }
    if($pid) {  # parent
        print "$$ spawned $pid\n";
    } else {    # child
        print "child $$\n";
        exec('/bin/true');
    }
}
print "$$ done\n";

And this works just fine (i.e., it reads every line in the input file once,
then terminates), except that I don't like the overhead of the exec call to
terminate the child. So am I doing something wrong to use exit instead of
exec('/bin/true')? How should I terminate the child process?

> Any help would be much appreciated.
> Thanks,
> Ian Goodacre
> Ian.Goodacre@mbs.gov.on.ca





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

Date: Sat, 25 Jul 1998 02:38:09 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: forking processes in proxy script
Message-Id: <8c90limz92.fsf@gadget.cscaper.com>

>>>>> "schnibitz" == schnibitz  <schnibitz@my-dejanews.com> writes:

schnibitz> First I have to appologize if this is a copy of a previous
schnibitz> message.  Dejanews is wierd.

In many ways.  One is that you aren't using it effectively. :)

schnibitz> below is a link to a page where I have a proxy perl script.
schnibitz> You are all welcome to use it if you want.

Why are you reinventing everything from the ground up?  Check out my
WebTechniques column, where I give away a free script that does what
yours does and a lot more (handling ftp and gopher proxies as well).

Oh, yes, it's at http://www.stonehenge.com/merlyn/WebTechniques/,
and look for column # 11.  Yes, that's from Feb 97... a while ago.

print "Just another Perl hacker,"

-- 
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: Fri, 24 Jul 1998 21:54:21 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: has anyone attempted a script that can replicate itself and then run the copy?
Message-Id: <1dcmuan.1yddma5116okkyN@slip166-72-108-202.ny.us.ibm.net>

<jhestyr@my-dejanews.com> wrote:

> has anyone attempted a script that can replicate itself and then run the
> copy?

Save this as "Dup.0":

#!perl -w

use File::Copy;

$new_name ||= "0";
$old_name = $new_name;
$new_name++;

print "old: $old_name new: $new_name\n";

copy("Dup.$old_name", "Dup.$new_name");
do "Dup.$new_name";

__END__

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Sat, 25 Jul 1998 03:58:22 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: more perl uploading problems
Message-Id: <Pine.GSO.4.02.9807242057360.25503-100000@user2.teleport.com>

On Tue, 21 Jul 1998, Indra Rosadi wrote:

> However, when I tried it with Netscape Navigator 4.05.. everything is
> cool 

Then it's not a perl problem, is it? :-)

If you're following the proper protocol but some browser or server doesn't
cooperate, then it's the other program's fault. If you're not following
the protocol, then it's your fault. If you aren't sure about the protocol,
you should read the protocol specification. If you've read it and you're
still not sure, you should ask in a newsgroup about the protocol.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 24 Jul 1998 18:15:39 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Nice Numbers
Message-Id: <MPG.1022d19aecf5f24989787@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <35B92026.D5A0F141@telapex.com> on Fri, 24 Jul 1998 19:00:38 -
0500, Kenneth A. Holm III <rets01@telapex.com> says...
> Just a thought.  Most comments appreciated:
> 
> #################
> sub nice_number {
>     my $number = shift; # number to be nice-ified
>     my $places = shift; # places to round to
>     Error ("nice_number",
>            "No value passed [NUMBER]",
>     1) unless $number;
>     $places = $places || 2; # defaults to 2 places (US currency)
>     my $remain = 1 / ( 10 ** int( $places + 1 ) );
>     $remain *= 5;
>     $number += $remain;
>     $number = int ($number * (10 ** int( $places ) ) );
>     $number = $number / (10 ** int( $places ) );
>     ($integer, $decimal) = split(/\./, $number);
>     $decimal .= "0" x $places;
>     $decimal = substr($decimal, 0, $places);
>     $number = join ".", $integer, $decimal;
>     return $number;
> }
> 
> This has a call to my own error function.  It automatically rounds up to
> the $places decimal places.

I think you have just won the Wheel-Reinvention of the Year award.

sub nice_number {
    my $number = shift; # number to be nice-ified
    my $places = shift; # places to round to

#    Error ("nice_number",
#           "No value passed [NUMBER]",
#    1) unless $number;
#  Is there something offensive about a value of 0???
#  Maybe you mean 'defined $number'?

#  $places = $places || 2; # defaults to 2 places (US currency)
#  Is there something offensive about a value of 0???
#  Of course, there *is* something offensive about a negative value,
#  but you don't deal with it.
   $places = defined $places && $places >= 0 ? $places : 2;

   sprintf "%.${places}f", $number;
}

Of course, this rounds negative numbers *down* (i.e., -4.6 becomes -5.0), 
but I don't think you worried much about them either.

You can read all about it in perlfaq4: "Does perl have a round function? 
What about ceil() and floor()?" and `perldoc -f sprintf`.

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


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

Date: Fri, 24 Jul 1998 20:44:35 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: parsing question
Message-Id: <3adbp6.ssp.ln@localhost>

Martin (minich@globalnet.co.uk) wrote:
: >   Both are reported as equal.
: >
: >   Executes fine with or without the double quotes.


: What about:

: $num = 123/3;         # number
: $nummy = "123/3";     # string

: print "ha\n" if $num eq $nummy;
: print "ho\n" if $num == $nummy;

: Exit(0);

: $num equates to 41 but $nummy remains as 123/3
: so the "s are crucial.
     ^^^^^  ^^^^^^^^^^^


   Yes, but you quoted me (sans attribution) out of context.

   Here's the context:

   : but if the data were all numerals then
   : if ($data eq $para) would turn out false
   : wouldn't it


   Your example is not all numerals...


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


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

Date: Sat, 25 Jul 1998 01:21:40 GMT
From: mashton@my-dejanews.com
Subject: passing arguments to external prgm failing on NTServer
Message-Id: <6pbbv4$a4u$1@nnrp1.dejanews.com>

I'm stumped!

My code works on my winNT Wrkstn but not on My NTServer.
For some reason NTServer is not allowing the parameters to be passed,
and all my other standard scripts work.

SAMPLE CODE
===========
$prgm1 = "mycprg1.exe";
$prgm2 = "mycprg2.exe";
$tmpfile = "xx.$$.jpg";
$cmd = "$prgm1 -param1 $param1 | $prgm2 -param2 $param2 -outfile $tmpfile";

system($cmd);
open( FROM, "< $tmpfile" );
binmode FROM;
binmode STDOUT;
print <FROM>;
close FROM;

Now if I save $cmd as a bat file and execute it onthe command line it works
on the NTServer.

Any suggestions would be greatly appreciated.

Thx, Mike

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Fri, 24 Jul 1998 21:58:35 -0400
From: Dan Watts <dwatts.nospam@dimentech.com>
Subject: Perl 5.005 - IRIX 5.3: groups.t test failure
Message-Id: <35B93BCB.4B6BB55E@dimentech.com>

I've just downloaded and built Perl 5.005 on my SGI IRIX 5.3 system.
When I ran
the tests I got one error.  Executing the failing test shows:


     % ../perl groups.t
     1..2
     ok 1
     not ok 2 (groupstype should be type short, not long)
     %

Has anyone else seen this on IRIX 5.3?  I used the defaults during the
configuration.
I'm not planning on allowing setuid scripts. Will the above error be a
problem? I
suspect the problem might be caused by the fact that IRIX 5.3 has two
versions
of getgroups. One is BSD flavor, the other is POSIX flavor:

        POSIX:
          ngrps = getgroups(int setlen, gid_t *gidset);

        BSD:
          ngrps = getgroups(int setlen, int *gidset);

Any help/recommendations appreciated.

Dan




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

Date: Sat, 25 Jul 1998 01:00:01 GMT
From: jjones@nospam.elementdesign.com (j)
Subject: Perl 5.005: perldoc problems
Message-Id: <35b92d3d.327149@nntp.best.com>

	
I just did a clean install of Perl 5.005, I removed all my previous
perl installations, including modules, and reinstalled.

Everything seems to be working, except for one essential thing:
perldoc.

I installed the libnet modules, tested perldoc out on them, and it
doesn't quite work correctly.

If I type 'perldoc Net::FTP' it comes up with the appropriate man
page, but if i simply type 'perldoc Net' it tells me no entry was
found.

perldoc on my previous installation simply spit out something like
this:

you may want to look at:
Net::FTP
Net::SNMP
Net::NNTP
etc...

when I typed 'perldoc Net'

I installed perl 5.005 to all of the default directories, which i also
did on my previous installation.

any help appreciated... thanks!




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

Date: Fri, 24 Jul 1998 21:54:24 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Perl array name
Message-Id: <1dcmui5.xu16nx1njrby8N@slip166-72-108-202.ny.us.ibm.net>

Tom Christiansen <tchrist@mox.perl.com> wrote:

>  [courtesy cc of this posting sent to cited author via email]

Your newsreader should look at my "Mail-Copies-To:" header and know not
send me a copy.

> In comp.lang.perl.misc, kpreid@ibm.net (Kevin Reid) writes:
> :For opening files, I prefer:
> :
> :$FILE = '/etc/motd';
> :open FILE or die "open of $FILE failed: $!";
> :while (<FILE>) {
> 
> 1) I am afraid of an || sneaking in there.'

Do you mean 'I am afraid someone might use || instead of or.'?

> 2) That doesn't help your warn and die messages.

I don't understand what you mean.

> 3) That only works on globals.

I know.

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Fri, 24 Jul 1998 21:14:22 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: Perl with SSI
Message-Id: <comdog-2407982114220001@news.panix.com>
Keywords: just another new york perl hacker

In article <6p847f$c8h$1@netnews.upenn.edu>, rjking@blue.seas.upenn.edu (Rachel J King) posted:

> This question was asked just a few weeks ago, if I remember correctly.  
> In most cases, it is impossible to get the resulting web page to process 
> the SSI.

it's the server that parses the output, not the "web page".  some
servers will parse data generated by external programs, some won't.
check your server documentation for details.

good luck :)

-- 
brian d foy                                 <http://computerdog.com>
Comprehensive Perl Archive Network (CPAN) <URL:http://www.perl.com>
Perl Mongers <URL:http://www.pm.org>


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

Date: 25 Jul 1998 02:32:03 GMT
From: terry1519@aol.com (Terry1519)
Subject: Perl(sendmail) and Psiweb problem
Message-Id: <1998072502320300.WAA12078@ladder01.news.aol.com>

Hello,

Whats wrong with my script? The script itself which is a lot bigger works
but, the sendmail does not function. The funny thing is that it appears to
send the mail but, the mail is never received. This script works fine on
other servers but, not on PSIWEB. I have contacted PSIWEB and they are
clueless as to what CGI and PERL are. I have tried other locations for the
sendmail program such as /usr/slib/sendmail, /usr/lib/sendmail, /usr/bin/mail
and many more. Does any know what is wrong with the following script or
the problem with Psiweb? Oh, also I know the server is using Unix. 
Please help.  Terry


THE SENDMAIL FUNCTION OF THIS SCRIPT(Other functions are working fine, not
listed).


#!/usr/local/bin/perl
# mail
 
$mailprog = "/usr/lib/sendmail";
$recipient = "terry1519\@aol.com";
$uri = $ENV{'DOCUMENT_URI'};



read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
$postinput = $buffer;
$postinput =~ s/&/\n/g;
$postinput =~ s/\+/ /g;
$postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig;
  


open(MAIL,"|$mailprog -t");
print MAIL "To: $recipient\n";
print MAIL "From: Web site\n";
print MAIL "Subject: Upgrade request\n";
print MAIL "\n";
print MAIL $postinput;
print MAIL "\n\n";
print MAIL $counts{$file};
close(MAIL);
print "Content-type:text/html\n\n";
print "ok";
 
exit true;  <<<<< SCRIPT NEEDS TO EXIT TRUE


One note. Not even other formmail programs work either including formmail.pl
from matts scripts and Alienmail.pl.



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

Date: 25 Jul 1998 03:54:51 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Perl(sendmail) and Psiweb problem
Message-Id: <6pbkub$sau$1@client3.news.psi.net>

Terry1519 (terry1519@aol.com) wrote on MDCCLXXXIX September MCMXCIII in
<URL: news:1998072502320300.WAA12078@ladder01.news.aol.com>:
++ Hello,
++ 
++ Whats wrong with my script?

It would be easier to ask, "what is right with my script".

++ 
++ #!/usr/local/bin/perl

Big error 1: There is no -w
Big error 2: There is no -T
Big error 3: There is no use strict;
Big error 4: There is no use CGI;
Big error 5: You aren't use a module to send mail.

(You'd be fired three times by now if I were your boss)

++ # mail
++  
++ $mailprog = "/usr/lib/sendmail";
++ $recipient = "terry1519\@aol.com";
++ $uri = $ENV{'DOCUMENT_URI'};
++ 
++ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

And, how many bytes were actually read?

++ $postinput = $buffer;
++ $postinput =~ s/&/\n/g;
++ $postinput =~ s/\+/ /g;
++ $postinput =~ s/%([\da-f]{1,2})/pack(C,hex($1))/eig;

Why use a module if you can reinvent the wheel?

++ open(MAIL,"|$mailprog -t");

What's the return value of open?

++ print MAIL "To: $recipient\n";
++ print MAIL "From: Web site\n";
++ print MAIL "Subject: Upgrade request\n";
++ print MAIL "\n";
++ print MAIL $postinput;
++ print MAIL "\n\n";
++ print MAIL $counts{$file};

Yeah, let's make a new print statement for every line. Never mind
here documents.

++ close(MAIL);

What's the return value of close?



Where are the error message from the error_log? What happens from the
command line? 


I hope you aren't charging anyone for such junk.



Abigail
-- 
perl -MNet::Dict -we '(Net::Dict -> new (server => "dict.org")\n-> define ("foldoc", "perl")) [0] -> print'


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

Date: Sat, 25 Jul 1998 03:39:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Personality testing
Message-Id: <Pine.GSO.4.02.9807242037160.25503-100000@user2.teleport.com>

On Tue, 21 Jul 1998, Clinton Gormley wrote:

> Do you know of a personality test written in perl that i could
> incorporate into a web site?

If you're wishing merely to _find_ (as opposed to write) programs,
this newsgroup may not be the best resource for you. There are many
freeware and shareware archives which you can find by searching Yahoo
or a similar service. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 24 Jul 1998 21:54:19 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: question about the @_ variable
Message-Id: <1dcmhzl.2v2al5kd2534N@slip166-72-108-202.ny.us.ibm.net>

Larry <larryq@nospam.tuttle.com> wrote:

> Hi all,
> 
> 
>     I've got a little subroutine that does something like the following:
> 
> sub MySub
> 
> {
> 
>     $tempvar=@_;
> 
>     print length($tempvar);
> 
> }
> 
> 
> the subroutine gets called like so:
> 
> $hello="hello world";
> 
> &MySub($hello);
> 
> 
> What's strange is that the print $length($tempvar) statement above always
> prints out a "1".  So my question is how can I get the actual length of my
> string out of that length() function?  Just a basic question, but I've left
> my Perl book at home!

@_ (or any array) in scalar context returns the length of the array.

Also, you should be using 'my' to localize the variable.

my ($tempvar) = @_;

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: Fri, 24 Jul 1998 21:54:14 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: References as strings
Message-Id: <1dcmczw.zj8v801pmcdfiN@slip166-72-108-202.ny.us.ibm.net>

Hakan Jonsson <hakjo733@student.liu.se> wrote:

> I am trying to store references as strings, and then later dereference
> them. THis far, I have not succeded. Perhaps someone could give me an
> advice.
> 
> For example, if I do like this:
> 
> $a = "string";
> $ref_to_a = \$a;
> $string_ref_to_a = "$ref_to_a";
> 
> $string_ref_to_a upon being printed looks something like
> SCALAR(0x9f29c), but
> it can not be dereferenced. Is there a way to convert the "stringed"
> reference back into a hard reference, or some other way to get to the
> data in that location without using the real reference variable?

You can't do that, because it would mess up Perl's reference counts.

Try this:

$a = 'string';
$string_ref_to_a = 'a';
print $$string_ref_to_a, "\n";

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 25 Jul 1998 02:43:16 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: two "should-be" FAQ's re:arrays
Message-Id: <6pbgo4$r8g$6@client3.news.psi.net>

Tom Christiansen (tchrist@mox.perl.com) wrote on MDCCLXXXVIII September
MCMXCIII in <URL: news:6paq5f$33q$1@csnews.cs.colorado.edu>:
++ 
++ 
++ :2. Is there a $ variable for the "current key" in a for loop through an
++ :array? i.e.
++ 
++ Nope, use a real C-style for loop.


map {++ $i;  # Do what you want } @array;


But I wouldn't do that.


Abigail
-- 
perl -e '$a = q 94a75737420616e6f74686572205065726c204861636b65720a9 and
         ${qq$\x5F$} = q 97265646f9 and s g..g;
         qq e\x63\x68\x72\x20\x30\x78$&eggee;
         {eval if $a =~ s e..eqq qprint chr 0x$& and \x71\x20\x71\x71qeexcess}'


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

Date: Sat, 25 Jul 1998 03:20:20 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Wrong Line #
Message-Id: <Pine.GSO.4.02.9807242019050.25503-100000@user2.teleport.com>

On 20 Jul 1998, Eric Sheng wrote:

> 	I am having a problem with the PERL compiler/interpreter.  I
> have noticed that the warning/error messages during run time is
> inaccurate.  For example, "use of uninitialized value @ line ##" does
> not refer to the correct line that generated the warning.  In my PERL
> script, I have some pretty long lines for printing.  I was wondering
> if these long lines are the cause of the wrong line # on perl warning
> messages.

There was a bug in some early releases of 5.004 which could cause this. If
you're pretty sure that you've found something that's not fixed in the
current release, file a bug report. Thanks!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Fri, 24 Jul 1998 21:21:26 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6ffbp6.b1q.ln@localhost>

Erdem Ozsaruhan (EOZSARUH@nsf.gov) wrote:

: When I run the following perl program:

: #! /usr/local/bin/perl


   Except in real life you use the -w switch to enable warnings, right?


:  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
:  chop($date = sprintf ("%02d-%02d-%02d\n",$mon+1,$mday,$year));
   ^^^^                                 ^^
   ^^^^                                 ^^

   Put a newline in. 

      Take a newline out.

   You do the hokey pokey

      and you turn yourself about.



   Got cycles that need spending or something?



:  print "Date: $date\n";
:  exit;

: I get:

: Date: 02-29-100  


  Wadya know.  Just like the docs for localtime() say.

  Darn docs. All the time being right and what not...


: When I run a date command from the command line on each platform I ran
: the script, I get:

: # date +"%m-%d-%y"
: 02-29-00


  Looks like you have a year 2000 problem _there_ though.

  Is that 1800?  1900?  2000?  2100? ...


-------------
DATE(1L)                                                 DATE(1L)

NAME
       date - print or set the system date and time

 ...

       %y     last two digits of year (00..99)
-------------

  Hmmm. That "last two digits" part sounds just like the classic
  year 2000 problem.


  Good thing there are no problems like that with the way perl
  handles years, huh?



: The date on all my machines is "Tue Feb 29 18:14:28 EST 2000".

: I tried the program on the following platforms and PERL versions:

: SOL 2.6		5.002
: SUNOS 4.1.4	5.004_01
: DOS		5.003_07
: AIX 4.2.1	5.004_01

: Any ideas?


   Looks like you have a bunch of perls that are working just fine.

   Congratulations!  ;-)




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


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

Date: 25 Jul 1998 03:01:42 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pbhqm$r8g$9@client3.news.psi.net>

Erdem Ozsaruhan (EOZSARUH@nsf.gov) wrote on MDCCLXXXVIII September
MCMXCIII in <URL: news:EOZSARUH.128.19D3E9AE@nsf.gov>:
++ 
++ When I run the following perl program:
++ 
++ #! /usr/local/bin/perl
++ 
++  ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
++  chop($date = sprintf ("%02d-%02d-%02d\n",$mon+1,$mday,$year));
++ 
++  print "Date: $date\n";
++  exit;
++ 
++ I get:
++ 
++ Date: 02-29-100  
++ 
++ When I run a date command from the command line on each platform I ran
++ the script, I get:
++ 
++ # date +"%m-%d-%y"
++ 02-29-00
++ 
++ The date on all my machines is "Tue Feb 29 18:14:28 EST 2000".
++ 
++ Any ideas?


Looks like all perls and all dates behave as documented. What is the problem?



Abigail
-- 
perl -weprint\<\<EOT\; -eJust -eanother -ePerl -eHacker -eEOT


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

Date: 25 Jul 1998 03:03:27 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Y2K problem in PERL with localtime()
Message-Id: <6pbhtv$r8g$10@client3.news.psi.net>

Ronald J Kimball (rjk@coos.dartmouth.edu) wrote on MDCCLXXXIX September
MCMXCIII in <URL: news:1dcotlk.or14k61rsd44bN@bay2-88.quincy.ziplink.net>:
++ 
++ > # date +"%m-%d-%y"
++ > 02-29-00
++ 
++ Hmm...  And perl is the one with the Y2K problem???  (Is that 2000 or
++ 1900?)

Are you suggesting date has a Y2K problem? Or, are for some reason
unknown to me, the last 2 digits of '2000' not '00'?


     %y   last two digits of year (00..99)


Abigail
-- 
perl -wle '$, = " "; print grep {(1 x $_) !~ /^(11+)\1+$/} 2 .. shift'


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

Date: 12 Jul 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 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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