[18234] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 402 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 2 21:05:52 2001

Date: Fri, 2 Mar 2001 18:05:14 -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: <983585113-v10-i402@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 2 Mar 2001     Volume: 10 Number: 402

Today's topics:
    Re: Convert macintosh file to unix <bart.lateur@skynet.be>
        deep recursion error <dsmith@fitnessontherun.com>
    Re: flock and close   with  empty read strangeness <bart.lateur@skynet.be>
    Re: flock and close   with  empty read strangeness (Gwyn Judd)
    Re: Global problem with array <mjcarman@home.com>
    Re: Global problem with array <krahnj@acm.org>
    Re: Help Matt with small programs <ren@tivoli.com>
    Re: Help with sockets <mischief@velma.motion.net>
    Re: Help with sockets <mischief@velma.motion.net>
    Re: HelpOnHashes?!?! (Chris Fedde)
    Re: HelpOnHashes?!?! <Jonathan.L.Ericson@jpl.nasa.gov>
        LOCALE Problem. Please HELP me. <niski@niski.com>
        Mail::Mailer & Mail::Send .. difficulties <maheshasolkar@yahoo.com>
    Re: mod_perl and conventional perl scripts simultanious <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Perl, Cookies, and Apache. <parrot0123@yahoo.ca>
    Re: Perl, Cookies, and Apache. <parrot0123@yahoo.ca>
    Re: Perl, Cookies, and Apache. <parrot0123@yahoo.ca>
    Re: Problem with #! line using RedHat 7 <krahnj@acm.org>
    Re: Proper way to include perl output in IIS <Jonathan.L.Ericson@jpl.nasa.gov>
    Re: Question! <godzilla@stomp.stomp.tokyo>
    Re: Secret planned perl feature revealed <rick.delaney@home.com>
    Re: use strict; <micah@cowanbox.com>
    Re: Verifying pgp signed message? (Tony L. Svanstrom)
    Re: What is \cM ? <elijah@workspot.net>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sat, 03 Mar 2001 00:51:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Convert macintosh file to unix
Message-Id: <eud0at8aob84natlafrq7o5rukohd7s6hl@4ax.com>

TcN wrote:

>I'll try to convert a macintosh text file in Unix Format.
>My problem is with the accent (I'm french..sorry ;-)
>Do you a script to do that ??

I assume you want to convert texts using the Western Mac character set
(AKA Mac-Roman) into ISO-Latin-1?

Well, here's how you can create a script that will generate a converter.
First get the text file from
<ftp://ftp.unicode.org/Public/MAPPINGS/VENDORS/APPLE/ROMAN.TXT>, save it
as native text. When I downloaded it on PC, I got Mac line endings. That
won't work.

I assume you save it using the name ROMAN.TXT, and place it in the same
directory as this script:

    @ARGV = 'ROMAN.TXT';
    while(<>) {
        /^\s*(0x\w+)\s+(0x\w+)/i or next;
        $unicode[hex $1] = hex $2;
    }
    my $rhs = '';
    for(128..255) {
        $rhs .= sprintf '\\%03o',
          ($unicode[$_] && $unicode[$_] <= 255)? $unicode[$_] : 127;
    }

    print "tr/\\015\\200-\\377/\\012$rhs/;\n";

There you have it: a 535 characters long tr statement.

A few remarks:

 * The idea is based on the fact that the lower 256 character codes for
Unicode (the second column in the data file) are equivalent to the
ISO-Latin-1 character codes. So this table is also a Mac->ISO-Latin-1
conversion table.

 * Character 32 through 126 are the same for Mac and for ISO-Latin-1
(ASCII). So the tr statement doesn't include those.

 * But I do need conversion from CR, chr(13), "\015", into LF, chr(10),
"\012".

 * For whatever Mac character there is no ISO-Latin-1 equivalent, I used
chr(127) instead. That one isn't used for anything else, it is the
character code of the DELETE key, and shouldn't appear in text files;
therefore it should be easily recognizable. It's just a choice.

-- 
	Bart.


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

Date: Fri, 2 Mar 2001 19:41:19 -0600
From: "David Smith" <dsmith@fitnessontherun.com>
Subject: deep recursion error
Message-Id: <6F21B98C1F9B63D7.332C70AE96B4D49C.EEB469BECA057530@lp.airnews.net>

I'm trying to call a redirect from the end of a script that creates a
cookie. Maybe this is wrong (since I'm new to all of this). I've got some
base code here (not pretty) that shows what I'm doing. Perhaps someone here
can tell me what I'm doing wrong.  Thanks.

use CGI;

$query = new CGI;
$cookie = $query->cookie(-name=>'ID',
                        -value=>'This thing should work!',
                        -expires=>'+1y',
                        -path=>'/',
                        -domain=>'192.168.1.2',
                        -secure=>0);

print $query->header(-cookie=>$cookie);

&redirect();

sub redirect {

use CGI qw(:standard);
print redirect('http://192.168.1.2/cgi-bin/test.cgi');

}

Fitness on the Run, by Travel Fitness LLC




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

Date: Sat, 03 Mar 2001 00:54:32 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <s7g0atsm81m4rq6gcgkgs5eael9krhoklg@4ax.com>

Gwyn Judd wrote:

>>it turns out the the open for write truncates/empties the file.
>
>So open for update instead. That's mode '+<' for the hard of RTFM'ing.

Note that "+<" mode fails if the file doesn't exist. Duh!

-- 
	Bart.


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

Date: Sat, 03 Mar 2001 01:14:23 GMT
From: tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
Subject: Re: flock and close   with  empty read strangeness
Message-Id: <slrn9a0hbd.96i.tjla@thislove.dyndns.org>

I was shocked! How could Bart Lateur <bart.lateur@skynet.be>
say such a terrible thing:
>Gwyn Judd wrote:
>
>>>it turns out the the open for write truncates/empties the file.
>>
>>So open for update instead. That's mode '+<' for the hard of RTFM'ing.
>
>Note that "+<" mode fails if the file doesn't exist. Duh!

Interesting. Where in the documentation is that mentioned? This doesn't
prevent you from checking for the existance of said file and creating it
if necessary beforehand if necessary.

-- 
Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
Once I finally figured out all of life's answers, they changed the questions.


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

Date: Fri, 02 Mar 2001 16:56:22 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: Global problem with array
Message-Id: <3AA02516.A6C245AA@home.com>

Shazad Iqbal wrote:
> 
> I have just started using perl on a piece of work. What I want to do is
> read the file and assign what I find to variables which are declared
> global.

Semantic point: You don't have any global variables in your script. my()
variables are lexical -- scoped to the enclosing block (or file, in this
case).

> But when I use a variable outside the for loop, it doesnt recognise it.

Can you tell us which variable or do we have to dig it out ourselves?

> The code is below could anyone see what I am doin wrong.
 
> #!/opt/perl/bin/perl -w
> use strict;

So far, so good!
 
> my $line;
> my $Semester;
> my $Day;
> my $StartTime;
> my $Type;
> my $Week;
> my $Course;
> my $Group;
> my $Room;
> my @Semester;
> my @Day;
> my @StartTime;
> my @Type;
> my @Week;
> my @Course;
> my @Group;
> my @Room;
> my $index;

You can define more than one variable in a my():

my (@Semester, @Day, @StartTime, ...);

And don't declare things you never use. ($Semester, $Day, etc.)

Stylistic point: Most programmers disdain the use of 'StudlyCaps' and
use all lowercase for most variables, ALL_CAPS for globals, and
Title_Case for (most) subroutines.

> open USER, "table_pr"or die "Could not open file: $:";
                                                    ^^
Good to see that you're checking the return of open(), but you want $!
here, not $:

>   # e.g. line
>   # 1    MONDAY 11.00 L  Wa ab103_X   Wind  - AJWest PCCapon JSANDHAM
>   # Sem    Day  Time Typ Wk  Crs Grp   Rm   - Rest
> 
>   foreach $line (<USER>)
>   {
>     chomp $line;
>     if ( $line =~ m{^([12])     # sem
>                    \s
>                    (\S+)        # day
>                    \s+
>                    ([0-9]+\.[0-9]+) # Time
>                    \s
>                    (\S)         # type
>                    \s+
>                    (\S+)        # week
>                    \s
>                    ([^_ ]+)(|_\S*) # course and group
>                    \s+
>                    (\S+)        # room
>                    \s+
>                    (-.*)}x      # ignore
>        )

That's a lot of work to split on whitespace. Why not use split()
instead?

my @fields = split(/\s+/, $line);

>      {
>       @Semester=$1;
>       @Day=$2;
>       @StartTime=$3;
>       @Type=$4;
>       @Week=$5;
>       @Course=$6;
>       @Group=$7;
>       @Room=$8;
>      }

Ack! Don't assign a scalar to an array! Either 1) use a scalar variable
if that's what you want or 2) use push() to add an element to an array.

>    print "Courses @Course\t and it days @Day\t at the time @StartTime in
> room @Room\n";
>   }

Again, don't use an array where you want a scalar.
 
>    print "what module do u want information of?\n\n";
>    my $module_choice = <STDIN>;
>    chomp $module_choice;
>    print "The module you choice $module_choice\n";
> 
>    for ($index=0; $index <= $#Course; $index++)
>    {
>     if ( $Course[$index] =~ /$module_choice/)

The Perlish way of doing this would be:

foreach my $course (@Course) {
    if ($course eq $module_choice) {
        #...

But since you clobbered @Course every pass through the loop, you only
have one element in the array and (therefore) nothing to loop through. I
guess that means you wanted approach 2) above. Actually, I think what
you really want is a hash. Here's how my first crack at it would look:

#!/usr/local/bin/perl5 -w
use strict;

my %course_info;

while (<DATA>) {
    chomp;
    my ($sem, $day, $time, $type, $week, $course, $room, undef) = split;

    $course_info{$course} = {
        semester => $sem,
        day      => $day,
        'time'   => $time,
        type     => $type,
        week     => $week,
        room     => $room,
    };

   print "Course $course is on $day at $time in room $room\n";
}

print "What module do you want information on?\n";
chomp(my $choice = <STDIN>);
print "You chose is module $choice\n";

if ($course_info{$choice}) {
    printf("The module happens on %s, at %s.\n", 
        $course_info{$choice}{day},
        $course_info{$choice}{'time'});
    printf("The module is %s in room %s\n\n",
        $course_info{$choice}{type},
        $course_info{$choice}{room});
}
else {
    print "You have not selected in a valid module.\n";
}

__DATA__
1    MONDAY   11.00 L  Wa ab101_X   Wind  - AJWest PCCapon JSANDHAM
2    TUESDAY  11.00 L  Wa ab102_X   Wind  - AJWest PCCapon JSANDHAM
1    THURSDAY 11.00 L  Wa ab103_X   Wind  - AJWest PCCapon JSANDHAM
2    FRIDAY   11.00 L  Wa ab104_X   Wind  - AJWest PCCapon JSANDHAM

-mjc


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

Date: Fri, 02 Mar 2001 23:21:36 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Global problem with array
Message-Id: <3AA02C4E.EEE9F80F@acm.org>

Shazad Iqbal wrote:
> 
> Hi
> I have just started using perl on a piece of work. What I want to do is
> read the file and assign what I find to variables which are declared
> global.
> But when I use a variable outside the for loop, it doesnt recognise it.
> The code is below could anyone see what I am doin wrong.
> 
> #!/opt/perl/bin/perl -w
> use strict;
> 
> my $line;
> my $Semester;
> my $Day;
> my $StartTime;
> my $Type;
> my $Week;
> my $Course;
> my $Group;
> my $Room;
> my @Semester;
> my @Day;
> my @StartTime;
> my @Type;
> my @Week;
> my @Course;
> my @Group;
> my @Room;
> my $index;
> open USER, "table_pr"or die "Could not open file: $:";
>   # e.g. line
>   # 1    MONDAY 11.00 L  Wa ab103_X   Wind  - AJWest PCCapon JSANDHAM
>   # Sem    Day  Time Typ Wk  Crs Grp   Rm   - Rest
> 
>   foreach $line (<USER>)

  while ( $line = <USER> )

>   {
>     chomp $line;
>     if ( $line =~ m{^([12])     # sem
>                    \s

                   \s+

>                    (\S+)        # day
>                    \s+
>                    ([0-9]+\.[0-9]+) # Time
>                    \s
>                    (\S)         # type
>                    \s+
>                    (\S+)        # week
>                    \s
>                    ([^_ ]+)(|_\S*) # course and group
>                    \s+
>                    (\S+)        # room
>                    \s+
>                    (-.*)}x      # ignore
>        )
>      {
>       @Semester=$1;
>       @Day=$2;
>       @StartTime=$3;
>       @Type=$4;
>       @Week=$5;
>       @Course=$6;
>       @Group=$7;
>       @Room=$8;

perldoc -f push
perldoc -f unshift

Each time through the loop you are assigning a value to the array and
overwriting the previous value.

      push @Semester, $1;



John


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

Date: 02 Mar 2001 16:47:48 -0600
From: Ren Maddox <ren@tivoli.com>
Subject: Re: Help Matt with small programs
Message-Id: <m3itlreqjv.fsf@dhcp9-175.support.tivoli.com>

On 02 Mar 2001, ren@tivoli.com wrote:

> Or, for in a more Perl-ish way:
> 
> int($_/5) == $_/5 and print "$_ " for 0..99; # requires 5.6

I left off the obvious enhancement of:

$_ % 5 or print "$_ " for 0..99;

-- 
Ren Maddox
ren@tivoli.com


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

Date: Fri, 02 Mar 2001 23:30:23 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Help with sockets
Message-Id: <ta0b8fca284m89@corp.supernews.com>

Ben L. <um@no.com> wrote:
> The problem is you are trying to send and receive through the same socket in
> the same process.  In the words of the Perl gods you should only attempt
> that if you are a real wizard, or if you are really into pain.  What you

This is not necessarily true. If you're interested in simple data exchange,
such as full lines of ASCII text, then it's easy to do. Perl doesn't even
make you use read and write or sysread and syswrite. You can do it all with
print and the diamond operator. Fixed-length records are, of course, a bit
different.

> need to do is modify your scirpt to fork an identical copy of itself ...
> with the parent reading the socket and the child writing to it (or
> vice-versa) ... that is the only way to accomplish the bi-directional
> communication you desire while remaining sane.  There is some excellent
> sample code for this in the IPC (inter-process communication) tutorial:

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

You can do this without forking, too.

The OP is interested in a client, not a multi-connection server. If the
client needs are simple enough, then it's a breeze. I just sent myself
a dozen emails by running this a dozen times:

###----- _begin_ code -----
#!/usr/bin/perl -w
use strict;
use Socket;

socket( SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp') );
my $server_addr =  inet_aton("127.0.0.1");
my $connect_addr = pack_sockaddr_in(25, $server_addr);
connect( SOCKET, $connect_addr) || die "Can't connect to server!\015\012";

print "Opened socket.\n";

select SOCKET;
$| = 1;

my $server_said = <SOCKET>;
print SOCKET "HELO localhost.localdomain\015\012";
$server_said = <SOCKET>;
if( $server_said !~ /2\d{2}/ ) {
    die "The server doesn't like us!\n";
}

select STDOUT;
print "Said hello!\n";

print SOCKET "MAIL FROM: mischief\@localhost\015\012";
$server_said = <SOCKET>;
if( $server_said !~ /2\d{2}/ ) {
    die "The server dislikes the sender!\n";
}

print "Good sender.\n";

print SOCKET "RCPT TO: mischief\@localhost\015\012";
$server_said = <SOCKET>;
if( $server_said !~ /2\d{2}/ ) {
    die "The dislikes the recipient!\n";
}

print "Good recipient.\n";

print SOCKET "DATA\015\012";
$server_said = <SOCKET>;
if( $server_said !~ /3\d{2}/ ) {
    die "The server is just plain broken!\n";
}

print "Good DATA line.\n";

print SOCKET "Subject: testing a simple email sender\015\012\015\012test\015\012.\015\012";
$server_said = <SOCKET>;
if( $server_said !~ /2\d{2}/ ) {
    die "The server is just plain broken!\n";
}

print "Message should have been sent!\n";

shutdown(SOCKET, 2);
###----- _end_ code -----

If I'm developing a new protocol, I base it on how SMTP, POP3, and a few
other basic protocols act. It sends a nice simple text string in each
direction. If I need to send binary data, I usually encode it as text
and unencode on the other end.

If I'm dealing with an existing protocol that requires me to handle binary
data, then I use read and write when I can get by with it. The network order
functions and vec() come in handy then.

The problem of using sysread and syswrite is that all reads and writes
must be done using them - you don't want to mix buffered and unbuffered
IO when you can help it.

Chris

-- 
Christopher E. Stith
Even in the worst of times, there is always someone who's
never had it better. Even in the best of times, there is
always someone who's never had it worse.



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

Date: Fri, 02 Mar 2001 23:47:46 -0000
From: Chris Stith <mischief@velma.motion.net>
Subject: Re: Help with sockets
Message-Id: <ta0c9243oj2008@corp.supernews.com>

Chris Stith <mischief@velma.motion.net> wrote:
> Ben L. <um@no.com> wrote:
>> The problem is you are trying to send and receive through the same socket in
>> the same process.  In the words of the Perl gods you should only attempt
>> that if you are a real wizard, or if you are really into pain.  What you

> This is not necessarily true. If you're interested in simple data exchange,
> such as full lines of ASCII text, then it's easy to do. Perl doesn't even
> make you use read and write or sysread and syswrite. You can do it all with
> print and the diamond operator. Fixed-length records are, of course, a bit
> different.

Forgot to put in a few lines that could prevent a useless process just
hanging around.

Between each print to the socket and read from it, it would help to have
the line:

    alarm 5;

If you wanted to print a message on timeout, then towards the top of the
program you'd include:

    $SIG{ALRM} = sub { die "\cG\cGTimed out on operation!\n"; };

 ...or something to that effect. Otherwise, it'd just hang around until
it got a line from the server. More sophisticated error handling can be
accomplished without too much more hassle.

Chris

-- 
Christopher E. Stith
Even in the worst of times, there is always someone who's
never had it better. Even in the best of times, there is
always someone who's never had it worse.



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

Date: Sat, 03 Mar 2001 01:18:21 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: HelpOnHashes?!?!
Message-Id: <xDXn6.276$T3.170579456@news.frii.net>

In article <3A9F689D.58F797C4@email.sps.mot.com>,
Robert Joost  <r51446@email.sps.mot.com> wrote:
>-=-=-=-=-=-
>
># cat 2001-02-22-22:19:32.outage
>userid=rxxxxx
>date=22%20Feb%202001%201550
>duration=3%20min
>remedy=
>server=prodserver
>app=Static_Site
>description=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
>savefile=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
>action=SAVE
>=
>
>I want to split each line off into key/value pairs, but what I am
>scouring the net/faqs/books/mags for is how to
>make the hash write out  to Report like this --  ( without action=SAVE
>and = )
>rxxxxx    22 Feb 2001  1550     20min     prodserver
>Static_Site     adsfadfadsfasdfasdfadfadfad adsfadfadsfasdfasdfadfadfa
>

A good first step might be something like this.

#!/usr/bin/perl

use strict;
use warnings;

undef $/;

my @wanted_keys = qw( userid date duration server app description savefile
);

my %hash = split(/[=\n]/gsm, <DATA>);

print join("\t", map { s/%(\w\w)/chr(hex($1))/eg; $_ }
@hash{@wanted_keys}), "\n
";

__END__
userid=rxxxxx
date=22%20Feb%202001%201550
duration=3%20min
remedy=
server=prodserver
app=Static_Site
description=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
savefile=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
action=SAVE
=


-- 
    This space intentionally left blank


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

Date: 03 Mar 2001 01:06:08 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: HelpOnHashes?!?!
Message-Id: <86wva7zmnz.fsf@jon_ericson.jpl.nasa.gov>

Robert Joost <r51446@email.sps.mot.com> writes:

[I had a hard time understanding what you were talking about, so I
snipped everything but the data and code.  The rest was mostly
gibberish to me.  The code is also very poorly wrapped, so I
rearranged it a bit.]

> # cat 2001-02-22-22:19:32.outage
> userid=rxxxxx
> date=22%20Feb%202001%201550
> duration=3%20min
> remedy=
> server=prodserver
> app=Static_Site
> description=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
> savefile=adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
> action=SAVE
> =

You want to divide this file into key/value pairs, right?

> sub report_parameters {
> #use diagnostics;
> #open the directory with the files
> opendir(TICKETS, "/usr/local/apache/htdocs/outages/tickets");

You need to check the return status of this command.  Something like:

  opendir(TICKETS, "/usr/local/apache/htdocs/outages/tickets") 
    || die("can't opendir /usr/local/apache/htdocs/outages/tickets: $!");

>   my @outages = readdir(TICKETS);   # set up the array of files
> closedir(TICKETS);

I hardly ever use (open|read|close)dir.  I use glob or qx{ls}, which
are easier and less error-prone in my opinion.  
   
> # open the Report for append
> open(REPORT, ">>/usr/local/apache/htdocs/outages/Report");

Once again - please check your return code.

> foreach $outage (@outages) {   #for each file
>   # open the file
>   open(TICKET, "/usr/local/apache/htdocs/outages/tickets/$outage"); 

Are you sure this worked?  How do you know unless you check?

>   #iterate over the line in each file (each file has only one line)
                                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^    
I don't know what this part of the comment means.

>   while ($line = <TICKET>) {
>        chomp $line;
>        # split the line by "=" for key/value pairs
>        ($key, $val) = split /=/, $line;
>        $config{$key} = $val;  # get the value

You do know that $line, $key, $val and %config are not local to this
function, right?  They are likely to be *global* variables.  (While
I'm at it, are you using strict?  Do you have warnings turned on?)

>    }
>   print "\n";

What's the point of this print?  Where do you think the newline goes?

>   # print to Report the value in tab-delimited format
>   print REPORT "$config{$val}";

1) The comment doesn't match the code at all.

2) You probably wanted to leave this command inside the above while
loop.

3) You seem to be confused about how hashes work or you made a typo
that warnings would have told you about if you had turned them on.

>   close(REPORT);
>   close(TICKET);
> }
> }

Is this what you were expecting as output:

  userid  rxxxxx
  date    22%20Feb%202001%201550
  duration        3%20min
  remedy
  server  prodserver
  app     Static_Site
  description     adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
  savefile        adsfadfadsfasdfasdfadfadfa%0D%0A%0D%0Ad
  action  SAVE


Here's a one-liner that I used:

  $ perl -e 'while (<>){print join "\t", split/=/;}' data

Jon


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

Date: Fri, 02 Mar 2001 21:00:51 +0000
From: niski <niski@niski.com>
Subject: LOCALE Problem. Please HELP me.
Message-Id: <3AA00A03.82A8D4F9@niski.com>

Hello. Whenever I try to run any perl script (at my shell) I got this

$ perl -v
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
        LANGUAGE = "en_US:en",
        LC_ALL = "en_US",
        LC_CTYPE = "ISO-8859-1",
        LANG = "en_US"
    are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
 
This is perl, v5.6.0 built for i386-linux

<SNIP>

Well, I try to follow the instructions in 
http://www.perl.com/pub/doc/manual/html/pod/perllocale.html#LOCALE_PROBLEMS

But it did not helped so much.

Well, my /etc/sysconfig/i18n is =
LANGUAGE=en_US:en
LANG=en
LC_CTYPE=ISO-8859-1
LC_ALL=en_US
SYSFONT=lat1u-16
SYSTERM=linux 

and running locale -a drops
C
POSIX
bokmal
bokmål
catalan
croatian
czech
danish
dansk
de
de@euro
de_AT
de_AT.iso885915
de_AT@euro
de_BE
de_BE.iso885915
de_BE@euro
de_CH
de_CH.iso885915
de_CH@euro
de_DE
de_DE.iso885915
de_DE@euro
de_LU
de_LU.iso885915
de_LU@euro
deutsch
dutch
eesti
en
en@euro
en_AU
en_BW
en_CA
en_DK
en_GB
en_GB.iso885915
en_GB@euro
en_IE
en_IE.iso885915
en_IE@euro
en_NZ
en_US
en_ZA
en_ZWfrench
galego
galician
german
greek
hebrew
hrvatski
hungarian
icelandic
iso8859
iso88591
italian
ja
ja_JP
ja_JP.ujis
japanese
japanese.euc
japanese.sjis
ko_KR
korean
korean.euc
lithuanian
nb_NO
norwegian
nynorsk
polish
portuguese
pt
pt@euro
pt_BR
pt_PT
pt_PT.iso885915
pt_PT@euro
romanian
russian
slovak
slovene
slovenian
spanish
swedish
thai
turkish 


Well, please someone tell me what to do (step by step) pelase.

I using LinuxMandrake 7.2

Thanks
estonian
finnish
français                    




-- 
Niski:
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah lreP gnuoy rehtona tsuJ
";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/
^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep
rand(2)if/\S/;print


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

Date: Fri, 2 Mar 2001 15:28:03 -0800
From: "Mahesh A" <maheshasolkar@yahoo.com>
Subject: Mail::Mailer & Mail::Send .. difficulties
Message-Id: <ta0b44j1ppabca@corp.supernews.com>

Hi,

I am trying to automate my mailing services with Perl. To start with, I want
to write a small script that sends one mail. I am using Mail::Mailer and
Mail::Send modules for the purpose.

Following are snippets of code I found in the docs. I am, however, not sure
how to corelate them.

There is a 2 line comment that says...
# Launch mailer and set headers. The filehandle returned
# by open() is an instance of the Mail::Mailer class.
 ... in the Mail::Send doc. Can someone here help me with this?

Documentation of both modules points to each other.

I am doing all this with perl, v5.6.0 built for MSWin32-x86. And I ant to
use SMTP.

Any pointers appriciated,

TIA,
M.

------------------------------------------------------
use Mail::Mailer;

$msg = new Mail::Send;
my %headers = {"From" => 'Perl Mailer <me@myhome.com>',
               "To" => 'me@myoffice.com',
               "Cc" => 'me@club.com',
               "Bcc" => 'me@shhh.com'
               };
$mailer = new Mail::Mailer 'smtp', Server => 'mail.myhost.com';
$mailer->open(\%headers);

my $body = qq{Hi There,
Hope you ge this message.
me\@myhome.com};

print $mailer $body;
$mailer->close;
-------------------------------------------
require Mail::Send;
$msg = new Mail::Send;

# Launch mailer and set headers. The filehandle returned
# by open() is an instance of the Mail::Mailer class.

$fh = $msg->open;

print $fh $body;

$fh->close;           # complete the message and send it

# $fh->cancel;        # not yet implemented





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

Date: 03 Mar 2001 01:19:40 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: mod_perl and conventional perl scripts simultaniously ?
Message-Id: <86r90fzm1f.fsf@jon_ericson.jpl.nasa.gov>

mfischer-news@josefine.ben.tuwien.ac.at (Fischer Markus) writes:

> 	I hope this question is appropriate to this newsgroup and
> apologize if not.

Take a look at http://perl.apache.org/.  If you can't find an answer
there, the mod_perl mailing list is the place to ask.

> Neverthless to say, those scripts were never written in mind to work
> unter mod_perl ( mostly no variable initialisation, no -w or use
> strict) and what I've read from the mod_perl documentation and which
> seems reasonable for me such things are necessary and highly
> recommended.

It's a good idea to have both strict and warnings turned on anyway.

Jon


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

Date: Sat, 03 Mar 2001 01:38:37 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: Perl, Cookies, and Apache.
Message-Id: <xWXn6.300481$Pm2.4343786@news20.bellglobal.com>


jb <jb@yperite.demon.co.uk> wrote in message
news:3AA0189B.22B59C01@yperite.demon.co.uk...
> > <nobull@mail.com> wrote in message
news:u9n1b5o034.fsf@wcl-l.bham.ac.uk...
>
> Amongst other things, it covers why you shouldn't "top post" and also
> why you shouldn't post in HTML. Although its title refers to uk.*, it is
> equally applicable to all newsgroups.
>
> "top posting" sucks!

I've done some research which suggests that there are users out there who
are equally disturbed at 'bottom posting' techniques.  I guess it depends on
your preferences.  I think that top posting is superior in certain
situations - but I'm not going to get into a big fight about it.  It's
certainly not worth getting into a flame war over.  It seems like bottom
posting is the norm around here, so I'll adjust.




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

Date: Sat, 03 Mar 2001 01:40:30 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: Perl, Cookies, and Apache.
Message-Id: <iYXn6.300487$Pm2.4344004@news20.bellglobal.com>

jb <jb@yperite.demon.co.uk> wrote in message
news:3AA018F8.C3711904@yperite.demon.co.uk...
>
> No matter. You'll just be killfiled.

Did you read what I wrote?  I said I'd start bottom posting - why will I be
killfiled?




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

Date: Sat, 03 Mar 2001 01:51:55 GMT
From: "Parrot" <parrot0123@yahoo.ca>
Subject: Re: Perl, Cookies, and Apache.
Message-Id: <%6Yn6.300536$Pm2.4345333@news20.bellglobal.com>


jb <jb@yperite.demon.co.uk> wrote in message
news:3AA018F8.C3711904@yperite.demon.co.uk...
>
> It's not absurd. If you've read usenet for any time at all you'll learn
> why.
>

I'm sorry, but yes it is absurd, and frankly more than a little pathetic, to
get that upset over the way somebody quotes.  Like I said, I can understand
if people are used to reading messages a certain way and don't want to
bother reading ones that don't fit that criteria.

So I can see that it would be best to bottom post, you understand.  What I
can't justify is somebody, having seen an example of 'top-posting',
imediately getting pissed at the infidel dog who'se dared to do such a
thing - 'The Traitor Must Be Flamed!!!'

Anybody who gets that deeply offended by the placement of a quote needs to
re-examine their life.




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

Date: Fri, 02 Mar 2001 23:08:25 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Problem with #! line using RedHat 7
Message-Id: <3AA02934.3236A0E5@acm.org>

mwhyte@pmds.com wrote:
> 
> I was hoping someone might help me.  I've got a very simple Hello World script
> written (the script follows):
> 
> #!/usr/bin/perl -w
> 
> use strict;
> use diagnostics;
> 
> print "Hello World\n";
> 
> When I run "perl hello.pl", everything works fine.  I've changed the
                   ^^^^^^^^
> permissions of the file hello.pl to be 777, but I am unable to run the
                          ^^^^^^^^
> program by simply typing "hello".  When I do, I get this message:
                            ^^^^^
> bash: hello: command not found
        ^^^^^
> 
> Is there a step I'm missing?  I'm reading a freebie online course and it says
> all I need to make the script itself executable is to change the permissions,
> and to have the #! as the first line.  I'd appreciate any help anyone can
> provide.

The problem is that in DOS/Windows the program "HELLO.BAT" or
"HELLO.COM" or "HELLO.EXE" can be executed by simply typing "HELLO" and
the operating system determines the correct extention to use. In Unix
"hello" and "hello.pl" are two different programs. Unix doesn't know
about or care about the ".pl" at the end of the file name it is only a
file extention if a user program treats it as a file extention otherwise
it is just part of the file name.


John


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

Date: 03 Mar 2001 00:08:57 +0000
From: Jon Ericson <Jonathan.L.Ericson@jpl.nasa.gov>
Subject: Re: Proper way to include perl output in IIS
Message-Id: <861ysf1zom.fsf@jon_ericson.jpl.nasa.gov>

"Matthew Azzaro" <azzaro@oswego.edu> writes:

> I would like to be able to include output from a Perl cgi app in my web
> page, using MS IIS 5. From searching the docs, the only way i can tell to do
> this is using the <!--#exec...--> directive. I heard this is a security risk
> and not the proper way to handle this situation. What is the correct way??

Even though the string "Perl" appears in this question, it is
off-topic for this newsgroup.  I mentally performed a s/perl//gi; on
this message.  The only thing that stopped making sense was the name
of the newsgroup.

Perhaps someone on comp.infosystems.www.servers.ms-windows could
help you.

Jon


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

Date: Fri, 02 Mar 2001 17:29:49 -0800
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Question!
Message-Id: <3AA0490D.9944492@stomp.stomp.tokyo>

Simon wrote:
 
> Is it possible to add the .html extension to the script 
> mapping options in Perl/Apache so it is processed in the
> same manner as Perl scripts.

(snipped)

Yes. Find your ISEXT section of your httpd.conf file,
or your section pertaining to AddHandler. Add this line:

AddHandler cgi-script .html

Restart Apache if needed to read your new httpd.conf file.

You may run cgi scripts with .htm or .html extensions
or any other extension you like. This does cost you a
bit of efficiency but this is relatively insignificant
for personal usage or light web usage.


Godzilla!
-- 
@©=(a .. z);@®=qw(7 15 4 26 9 12 12 1 18 15 3 11 19);
$Ñ="\n";srand(time()^($$+($$<<15)));for($§=$®[$®[0]];
$§<$®[2];$§++){sub G{rand($®[8])<$®[4]?"\u$1":"\l$1";}
foreach$¿(@®){$¢=$©[$¿-1];$¢=~s¡([a-z])¡G($1)¡gie;
$Ø="$Ø$¢";}$Ø="$Ø! ";$ø=substr($Ø,$®[12]-$®[11],0," ");
$Ø=~s¯(a)(r)¯$1 $2¯i;push (@Ø,$Ø);}print"$Ñ$ÑC:\\>",
"$©[22]$©[$®[0]]$©[14] $©[$®[8]-$®[7]]o$©[$®[2]/2]ks",
" $©[24]o?$©[$®[8]]";undef$z;$Ø="\b";select$z,$z,$z,.5;
print$Ø;select$z,$z,$z,.5;print$Ø;select$z,$z,$z,.75;
print"$©[$®[12]+$®[7]]";select$z,$z,$z,.75;print"?";
select$z,$z,$z,1;print"$Ñ$Ñ";$Ø=.05;foreach$¡(@Ø)
{@©=split(//,$¡);foreach$§(@©){print$§;select$z,$z,$z,
$Ø;}print$Ñ;}@¶=reverse(@Ø);foreach$¶(@¶){@®=split(//,$¶);
foreach$¢(@®){print$¢;select$z,$z,$z,$Ø;}print $Ñ;}exit;


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

Date: Sat, 03 Mar 2001 02:01:30 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Secret planned perl feature revealed
Message-Id: <3AA053BD.BB127075@home.com>

Chris Stith wrote:
> 
> I bet, with my idea I think suported by the 'Null filename' errors below,
> that in 5.6.0 attempting to call a subroutine with 'do' actually _sometimes_
> invokes one of do()'s other semantics - that of compiling a Perl source
> file and returning the last value evaluated in that file.

There is no need to bet here.  All of these cases of dereferencing and
calling a coderef fall under do EXPR (aka do 'file').

> Perhaps what needs to be done is a doc update more than a bugfix for the code.
> It would seem that calling a subroutine with 'do' is not only deprecated, but
> is also of undefined behavior. If this isn't the intent, then there does need
> to be a change to the code - unless it's easier to just enforce the deprecation
> by not changing the code. It has been deprecated for some time now.

This is certainly a bug.  If you look at line 2912 in pp_ctl.c in the
v5.6.0 source you will see this:

   2912     if (SvNIOKp(sv)) {
   2913         UV rev, ver, sver;
   2914         if (SvPOKp(sv)) {               /* require v5.6.1
*/       

In a v5.7 version (not bleadperl) you can see this:

   2955     if (SvNIOKp(sv))
{                                                      2956         if
(SvPOK(sv) && SvNOK(sv)) {           /* require v5.6.1 */

which doesn't look much better.  Either way, depending on how you put
together your scalar, perl can get confused and think you mean require
VERSION instead of require EXPR.

$ perl -e 'do "10"+1.1;'
Perl v11.100.0 required--this is only v5.6.0, stopped (did you mean
v11.1.0?) at -e line 1.


-- 
Rick Delaney
rick.delaney@home.com


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

Date: 02 Mar 2001 15:48:36 -0800
From: Micah Cowan <micah@cowanbox.com>
Subject: Re: use strict;
Message-Id: <yu83dcv3f6z.fsf@mcowan-linux.transmeta.com>

Todd Anderson <todd@mrnoitall.com> writes:

> I am trying to implement "use strict;
> My script is crippled when this is inserted asis. I was told that "use
> strict;" can't be used when requiring other scripts.
> Is it possible to 'use srict;' after you have required the other
> scripts?
> Thanks for your remarks...

This is certainly /not/ true.

Although, as to requiring scripts, I'd prefer to use require on
modules, instead...

Micah


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

Date: Sat, 03 Mar 2001 00:01:36 GMT
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Verifying pgp signed message?
Message-Id: <1epo5fy.z14sus16xshd8N%tony@svanstrom.com>

Ted Wart <t_wart@hotmail.com> wrote:

>  I'm looking for code to verify a pgp signed string. I'm writing cgi
>  software and have a pgp signed string with the key from someone. How can
>  I simply verify the string is signed. Any modules to do this? TIA, tw

Install PGP (or GPG) and then get piping, and/or search for a module at
<URL:http://search.cpan.org/> Where you, of course, checked before
asking your question.


        /Tony


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

Date: 2 Mar 2001 23:14:05 GMT
From: Eli the Bearded <elijah@workspot.net>
Subject: Re: What is \cM ?
Message-Id: <eli$0103021806@qz.little-neck.ny.us>

In comp.lang.perl.misc, Philip Newton  <nospam.newton@gmx.li> wrote:
> Eli the Bearded <elijah@workspot.net> wrote:
> > \c{FOO} is control character {FOO}. So \c[ is <ESC> and
> > \cM is <CR>. In general, {FOO} is the ascii char of the
> > control char plus 64. \c? is one exception, it is minus
> > 64. Lower case letters are treated as uppercase ones by
> > perl for this.
> In other words, in general, {FOO} is chr(ord(control char) ^ 64),
> right? (This would account for the "discrepancy" between
> "add/subtract".)

Essentially. From handy.h in perl-5.6.0 (in the non-ebcdic section):

#  define toCTRL(c)    (toUPPER(c) ^ 64)

> It also seems to work for other things, for example "\c=" is "}", and
> "\c}" is "=".

Didn't you see my JAPH on that?

print"\c*\c5\c3\c4\c`\c!\c.\c/\c4\c(\c%\c2\c`\c0\c%\c2\c,\c`\c(\c!\c#\c+\c%\c2"

Elijah
------
doesn't really know the perl source well, but can grep it fast


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

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


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