[19472] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1667 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Aug 31 09:05:32 2001

Date: Fri, 31 Aug 2001 06:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <999263108-v10-i1667@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Fri, 31 Aug 2001     Volume: 10 Number: 1667

Today's topics:
    Re: Dangerous Perl Script? (Mark Jason Dominus)
    Re: elegant substitutions <goldbb2@earthlink.net>
        Environment variables and AOL (G.A.D.Miles)
    Re: Environment variables and AOL <bcaligari@fireforged.com>
    Re: help with pipes please (Ilja Tabachniks)
    Re: Help!:compile perl in win98? <no@mail.addr>
    Re: Job Control in Perl <goldbb2@earthlink.net>
        most effective way to search for different words in a t <maspsr@dou.sdu.dk>
    Re: most effective way to search for different words in <liviu75@yahoo.com>
    Re: most effective way to search for different words in <philippe.perrin@sxb.bsf.alcatel.fr>
    Re: Passing arbitray data between ro co-operating per s (Anno Siegel)
    Re: Performance : Shell X Perl <goldbb2@earthlink.net>
    Re: Programming sockets <josef.moellers@fujitsu-siemens.com>
    Re: Programming sockets <krahnj@acm.org>
    Re: Programming sockets (Villy Kruse)
    Re: Sort output and find last. (Anno Siegel)
    Re: Weird -w behaviour (Benoit Gauthier)
    Re: Weird -w behaviour <krahnj@acm.org>
    Re: Weird -w behaviour <djberge@uswest.com>
    Re: Weird -w behaviour (Tad McClellan)
        Which language better <pmishra@mailcity.com>
    Re: Which language better <krahnj@acm.org>
    Re: Which language better (Cameron Laird)
    Re: Which language better <bcaligari@fireforged.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 31 Aug 2001 10:31:34 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: Dangerous Perl Script?
Message-Id: <3b8f6786.2127$18c@news.op.net>

In article <3B8F1319.2DD6C7A@home.com>, What A Man ! <whataman@home.com> wrote:
>I'm told the below script is dangerous. It just looks like a bunch of
>regexs to me. Can someone explain what it does?
>


This part:

>       $out=`$_ 2>&1`; 

The `...` means to run "$_ 2>&1" as a shell command, as if it had been
typed at the terminal, and to collect the output and put it into $out.
The 2>&1 part collects the error messages into $out also.

$_, the command, was supplied by the remote web user:

>       read(STDIN,$_,$ENV{'CONTENT_LENGTH'}); 

This means you are letting the remote web user run a shell command, as
if they had typed it at the terminal.

If you want to let anyone in the entire world run commands on your
computer, then why do you have passwords?  It would be simpler to just
have a public guest account with no password.

Hope this helps.

-- 
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP 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, 31 Aug 2001 07:53:35 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: elegant substitutions
Message-Id: <3B8F7ABF.73F03CF7@earthlink.net>

Just in wrote:
> 
> Hello all,
> 
> I can get the following to work, with some splits and substitutions
> but the code runs into several lines . . . this in itself isn't so bad
> but there's a better way to do it, and while I have been trying
> I'm not getting what I want.
> 
> Here's the low down:-
> 
> A particular variable could have any of the following combinations
> plus others:
> 
> 61[02,02,04] which needs to be interpreted as 6102, 6103, 6104
> 7[20,30]6 which needs to be interpreted as 7206, 7306
> [EA,BA]T which needs to be interpreted as EAT, BAT
> blah blah blah
> 
> How can I get a one line substitution to work?

Well, assuming that you want to convert "[EA,BA]T" into a regular
expression which will match both of "EAT" and "BAT", then the following
should do it:

($re = $orig) =~ tr/[],/()|/;
$something =~ m/$re/;

If you want to convert "[EA,BA]T" into "EAT, BAT", then it's a bit
harder, especially if you want to allow more than one [] grouping.

use Quantum::Superpositions;
my @x = split /\[(.*?)\]/, $str;
my $res = shift @x;
while( my ($group, $literal) = split @x, 0, 2 ) {
	$res .= any(split /,/, $group) . $literal;
}
print join(", ", eigenstates $res), "\n";

print qq["$somestring" matches\n] if $somestring eq $res;

use Quantum::Superpositions UNARY => ["quotemeta"];
my $re = quotemeta $res;
local *Quantum::Superpositions::qstr = sub {
	local $" = "|"; "(?:@{$_[0]})";
};
print qq["$somestring" matches\n] if $somestring =~ /^$re$/;

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Fri, 31 Aug 2001 10:23:19 GMT
From: usad1@gadnet.com (G.A.D.Miles)
Subject: Environment variables and AOL
Message-Id: <3b8f6225.174455117@news.newsguy.com>

I posted a question about this back in January and was so startled by
the tone and content of response from "abigail" that I gave up.

Here, phrased differently, and I hope more to people's liking, is the
question again:

My script needs to know the URL of the web page from which it was
invoked.

Using any of the main browsers it can get this information from:
$ENV{HTTP_REFERER} 

But, in AOL only, if the user invokes the script in a new window (ie
right clicks on the link to the script and selects the new window
option) the above variable is blank. Doing the same thing in IE or
Netscape works fine.

a) where can I get the information from, if not from
$ENV{HTTP_REFERER}

b) Is this a bug in AOL or are they welcome to populate environment
variables with anything they feel like?

And "abigail", if you are reading this and boiling with the same rage
as last time, save yourself some time and don't reply.

Thanks all,

Drummond




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

Date: Fri, 31 Aug 2001 14:34:39 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Environment variables and AOL
Message-Id: <9mo00c0307@enews1.newsguy.com>


"G.A.D.Miles" <usad1@gadnet.com> wrote in message
news:3b8f6225.174455117@news.newsguy.com...
> b) Is this a bug in AOL or are they welcome to populate environment
> variables with anything they feel like?

why not ask aol's support?  They're a big company.  They should have a
support dept.

B.






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

Date: 31 Aug 2001 03:24:28 -0700
From: billy@arnis-bsl.com (Ilja Tabachniks)
Subject: Re: help with pipes please
Message-Id: <5d4a715a.0108310224.57a58ec8@posting.google.com>

"Kevin" <khanrahan@cypresscom.net> wrote in message news:<totv4072nanud2@corp.supernews.com>...
> I am trying to read log data, one line at a time as it comes in, and then
> act upon it. If I use :
> 
>   $alertmsg = <STDIN>;
> ......remainder of script....
> 
> and feed it manually it works great but I want it to be fed automatically so
> instaed of using <STDIN> I tried:
> 
> $alertmsg = open(ALERT, "tail -f /opt/apps/logs/alarm.log|") or die "Can't
> fork";
> 
> while(<ALERT>)
> { 
> .....remainder of script........
> 
> and it dies when it gets new data! ....I am trying to take the result of    tail -f /opt/apps/logs/alarm.log    and use it 
> as input for the script..
> 

You do not need an external program and pipes to get tail(1)
functionality in Perl.

IMHO your question looks like a FAQ:

$ perldoc -q tail
Found in /usr/lib/perl5/pod/perlfaq5.pod
       How do I do a "tail -f" in perl?

 ...

Just read the FAQ...

Good luck,
Ilja.


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

Date: Fri, 31 Aug 2001 18:14:32 +0800
From: MMX166+2.1G HD <no@mail.addr>
Subject: Re: Help!:compile perl in win98?
Message-Id: <ejouotgr319l263rmm5106ed6it474gvbq@4ax.com>

On Thu, 30 Aug 2001 16:09:12 +1000, in comp.lang.perl.misc "Sisyphus"
<kalinabears@hdc.com.au> wrote:
>
>"MMX166+2.1G HD" <no@mail.addr> wrote in message
>news:8qvqot4dlbgocuft96kqctnjh6gvtr24sh@4ax.com...
>> AP629.TAR.GZ, download form
>> http://downloads.activestate.com/ActivePerl/src/5.6/AP629_source.tgz
>>

oh, I have to give up. I just want to use Thread, but it's to complex,
I think I have to use fork instead.


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

Date: Fri, 31 Aug 2001 06:06:49 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Job Control in Perl
Message-Id: <3B8F61B9.3E7415BF@earthlink.net>

Chris Knowlton wrote:
> 
> I have an application where I am spawning children which then spawn
> multiple children in turn.  I am trying to implement the "cancel"
> button for a poller that sits and watches several 'sets' of this type
> of job under Solaris 2.6.
> I have tried using the following kill statement and it only kills off
> the parent and the next process in line is orphaned and continues to
> execute.
> 
>     kill 9, <pid>;
>     waitpid $pid, 0;

Putting in <pid> is not going to work.  It tries to read from the
filehanlde named pid and give the result of the read to kill.

> Then I read a snippet in "Programming Perl" about negating the pid and
> then killing it.  (supposedly this kills the entire job)  This does
> not work but with different behavior...
> 
>     $pid = $pid * -1;
> 
>     kill 9, $pid;
>     waitpid $pid, 0;
> 
> This code does not kill anything and the parent hangs waiting for
> waitpid to unblock.

That's because you are waiting for the negation of the child's process.
Having it negated makes sense to kill, but not waitpid.

Replace those three lines with either:
	$pid = $pid * -1;
	kill 9, $pid;
	$pid = $pid * -1;
	waitpid $pid, 0;

or:
	kill 9, -$pid;
	waitpid $pid, 0;

> Now, I have mis-interpreted stuff in the book before and I am not
> ruling that out, but I suspect that others have done this before and
> may be able to point me to a reference or a code frag that can help me
> out.
> 
> Each job is opened using the following...
> 
> foreach (@command_list) {
>     $pid = (open($handle, "$_ |"));
> }

Since you are assigning to $pid again and again, this results in $pid
containing the the pid of the last item in @commandlist.  Also, since
you end up clobbering each prior handle, perl will wait for earlier
spawned processes from @command_list, when I suspect you want them all
going at the same time.

my (@pid, @fh);
foreach my $command (@commandlist) {
	my $pid = open( my ($handle), "-|", $command );
	push @pid, $pid;
	push @fh, $handle;
}

> Each command immediately spawns several more shells and an xterm.  The
> command and all it's sub-processes need to die for succesful cancel. 
> I have no control over the processes below the XTERM process, they are
> spawned by code I don't own or can't change.

Which implies that the items which spawn the xterms are changable by
you.  Since that is the case, you should not be killing with signal 9,
but rather with something they can catch.  Those children should catch
whatever signal you send them [I suppose with %SIG], and then clean up
after themselves, killing the shells and xterm, and removing any
temporary files.

> 
> The process map looks like
> 
> PERL_SCRIPT -----V                    <---- this is the poller
>     csh -c -----V
>         xterm-----V
>             sh -c-----V
>                 csh-----V
>                 COMPILER

[I reformated this... you indented so much that lines wrapped... I'm
just guessing this is how it's supposed to look]

You've got one perl script, which forks off a bunch of csh scripts.
Each csh script starts an xterm with the -e option.  The xterm uses "sh
-c <whatever>" to figure out what the heck to do with the -e option,
which you have as something like "sh script ; compiler"

Have I got that right?

It sounds to me that you should eliminate all scripts except for your
perl script.

foreach( @compile_command ) {
	my $pid = open($handle, "-|");
	push(@pids, $pid), next if $pid;
	# else, this is the child.
	# do all the stuff csh -c would do.
	# you may want to use Expect.pm to interact with the xterm.
	# It's complicated, get the OReilly book on Expect if you
	# want to chat with the xterm.  However, if you *do*, you
	# don't need any other processes but this, the xterm, and
	# whatever that compiler is.
}

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Fri, 31 Aug 2001 14:25:16 +0200
From: "Peter Sørensen" <maspsr@dou.sdu.dk>
Subject: most effective way to search for different words in a text
Message-Id: <9mnrqn$r9k$1@news.net.uni-c.dk>

Hi,

I would like to ask what the most effective way to do a search in a
text would be. I would like to do a search where I find either following
words: WORD1 WORD2 WORD3 and the word MUST

regards

Peter Sorensen
email: maspsr@dou.sdu.dk




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

Date: Fri, 31 Aug 2001 11:36:02 GMT
From: "Liviu" <liviu75@yahoo.com>
Subject: Re: most effective way to search for different words in a text
Message-Id: <CEKj7.8777$2J2.377221@telenews.teleline.es>

La data de Fri, 31 Aug 2001 07:32:57 -0400, "Liviu" <liviu@mediaimage.ro>
a scris urmatoarea chestie memorabila:

> La data de Fri, 31 Aug 2001 08:25:16 -0400, "Peter Sørensen"
> <maspsr@dou.sdu.dk> a scris urmatoarea chestie memorabila:
> 
>> Hi,
>> 
>> I would like to ask what the most effective way to do a search in a
>> text would be. I would like to do a search where I find either
>> following words: WORD1 WORD2 WORD3 and the word MUST
>> 
>> regards
>> 
>> Peter Sorensen
>> email: maspsr@dou.sdu.dk
>> 
>> 
> $your_text = "this is your text";
> if (($your_text =~ /WORD[123]/) && ($your_text =~ /MUST/)) {
                                               ^^^^^
This is wrong; please excuse me the corect way is 

if (($your_text =~ /WORD[123]/) || ($your_text =~ /MUST/)) {

>   ## do what you want to do
> }
> 
> This is my opinion.
> 
> Liviu

Liviu


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

Date: Fri, 31 Aug 2001 14:23:42 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: most effective way to search for different words in a text
Message-Id: <3B8F81CE.B7A3ED31@sxb.bsf.alcatel.fr>

"Peter Sørensen" wrote:
> I would like to ask what the most effective way to do a search in a
> text would be. I would like to do a search where I find either following
> words: WORD1 WORD2 WORD3 and the word MUST

# $text is the entry
my @words = ("WORD1", "WORD2", "WORD3");
foreach my $word (@words) {
  if($text =~ /\Q$word\E/i &&    # i for non-case-sensitive
     $text =~ /MUST/i) {         # i for non-case-sensitive
      print "I found $word and MUST !\n";
      ...
  }
}

-- 
PhP

($r1,$r2,$r3,$r4)=("19|20","0|1","28|29","5|24");($r5,$r6)=("9|10|15|16|$r1|$r2","9|10|$r3");%h=("1|",$r6,"1=","[1-5]|2[0-4]","1/","0|19","1\\","6|25","2|","0|6|19|25|$r6","2/","1|20","2\\",$r4,"3|","$r2|6|$r1|25|$r6","3/",$r4,"4|","$r2|$r1|$r6","4=","2|3|4|11|12|13|14|21|22|23","4/",$r4,"4\\",15,"5|","$r2|9|15|$r1|20|$r3","5/",10,"6|",$r5,"7|",$r5,"7/",$r3);for($l=1;$l<8;$l++){b:for($i=0;$i<30;$i++){c:foreach(keys
%h){next c if(!(/^$l(.*)$/));$a=$1;if($i=~/^($h{$_})$/){print $a;next
b;}}print " ";}print "\n";}


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

Date: 31 Aug 2001 12:20:42 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Passing arbitray data between ro co-operating per scripts via a pipe
Message-Id: <9mnveq$rmo$1@mamenchi.zrz.TU-Berlin.DE>

According to Stan Brown <stanb@panix.com>:
> I have an application where I need to pass arbitray data (happens to be
> rows retrieved from a db table) between two co-operating perl scripts via a
> pipe. The data will be retrived as collumns and rows using DBI, and I want
> to put it back together as collumn/row data sets on the recieving end. Data
> may be arbitray text strings, mixed with numbers, and dates.
> 
> Is there a standard way of doing this inperl?

Look at Data::Dumper and the other serializing modules.

Anno


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

Date: Fri, 31 Aug 2001 08:20:50 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Performance : Shell X Perl
Message-Id: <3B8F8122.C2F65721@earthlink.net>

Abigail wrote:
> 
> Knob (andrew.savige@ir.com) wrote on MMCMXX September MCMXCIII in
> <URL:news:R%ej7.5$7W4.1083@news0.optus.net.au>:
> }} "Abigail" <abigail@foad.org> wrote in message
> }} news:slrn9oq4j6.t86.abigail@alexandra.xs4all.nl...
> }} >
> }} > Why don't you just say "Prerequisite: perl 5.X.Y". Just as you
> }} > might have a requirement of a minimum amount of diskspace or
> }} > physical memory. You don't ship disks or RAM with your product
> }} > either, do you?
> }} >
> }} > Abigail
> }}
> }} I could try that, but I would certainly be overruled by Product
> }} Management.
> 
> Ah, Product Management. They have their own twisted ideas, and there's
> no reason to come up with technical arguments to justify their
> demands.
> 
> }} Hopefully in a year or two when all our platforms come with Perl 5
> }} pre-installed.
> }} Those that currently dont include AIX prior to AIX433 and HP-UX
> }} (comes with Perl 4 pre-installed!!). If anyone from HP is
> }} listening, please note that upgrading to Perl 5 would be
> }} appreciated by the Perl community.
> }}
> }} There is a strong business case for "out of the box installs".
> }} After all, most customers don't care if the product is written in
> }} Perl or C or whatever; they just want it to work with minimum
> }} effort on their part.  Asking a non-technical person to download
> }} and install Perl does not look good, especially in a pre-sales
> }} situation, where you are trying to emphasize how easy it is to
> }} install and use your product.
> 
> Asking a non-technical person to install *anything*, be it Perl or be
> it your product doesn't not only look "not good", it looks plain
> stupid.
> It's like asking your secretary to do a root canal. Maintainance of a
> machine should be done by qualified people.

Which is why you should have perl bundled with your product -- so the
non-techie who's downloading it just has to click "ok" to get everything
to work.

Ideally, you would your program, whatever it is, as a kind of self
extracting archive -- but one which is smart enough to figure out where
everything goes with minimal user input.  Just one single file which you
just download and run, and everything takes care of itself -- no
thinking about unziping, untaring, etc.

Also, it could check if you have perl on your system already, by looking
in all the standard places.  If it can't find it, or if your perl is
older than what's required, it asks if you want it installed, and if you
click "ok", it does it.  No thought required for those non-techies
users, just click on the button and it gets done.

Actually, if the non-techie is installing from the internet, you can
trim down the installation file by having it connect back to your site
to download whichever extra things are required -- so you don't have to
*include* perl with it, just make the installer download perl as
necessary.  Likewise for any other modules.  On the other hand, if
you're distributing via a CD, then you will almost surely have enough
room to stick whatever is the latest release of perl onto it along with
everything else.

> }} We face a similar dilemma in the Windows market. Do you create a
> }} MSI file and ask the customer to first download Windows Installer
> }} before installing your product, or do you go for "out of the box"
> }} installs via InstallShield?
> 
> Neither. I wouldn't produce for the Windows market to start with. ;-)

Both, and provide both the MSI and an InstallShield version, and tell
your users to pick which is appropriate, and to use the InstallShield
version if they're not sure.

Of course, I don't produce for the Windows market myself, so I don't
know how much work this might be.

-- 
"I think not," said Descartes, and promptly disappeared.


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

Date: Fri, 31 Aug 2001 12:19:18 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Programming sockets
Message-Id: <3B8F64A6.385AA16D@fujitsu-siemens.com>

Crazydj wrote:

> print $socket "HELO mailserver.net";
> print $socket "MAIL FROM: perllover@crazydj.de";
> print $socket "RCPT TO: nice@tester.net";
> print $socket "DATA";
> print $socket "bla test and so on";
> print $socket ".";
> print $socket "QUIT";
> close($socket);
> =

> This program can be run without any problems, but I will never receive
> this email! Is this a fault of my perlscript or maybe a fault of my
> mailserver?

You may need to terminame each line by a \n! If that doesn't work, try
\r\n.

THT,
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Fri, 31 Aug 2001 10:29:28 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Programming sockets
Message-Id: <3B8F677C.159218E7@acm.org>

Crazydj wrote:
> 
> I have got a question on how to program sending sockets.
> To send an email through an SMTP server I would it do this way:
> 
> use IO::Socket;
> $socket = new IO::Socket::INET(PeerAddr => 'test.server.net',
>                                                          PeerPort =>
> '25',
>                                                            Proto =>
> 'tcp') || die "Cannot create socket: $!";
> 
> print $socket "HELO mailserver.net";

print $socket "HELO mailserver.net\015\012";

> print $socket "MAIL FROM: perllover@crazydj.de";

$ perl -le'print "MAIL FROM: perllover@crazydj.de"'
In string, @crazydj now must be written as \@crazydj at -e line 1, near
"MAIL FROM: perllover@crazydj"
Execution of -e aborted due to compilation errors.

print $socket "MAIL FROM: perllover\@crazydj.de\015\012";

> print $socket "RCPT TO: nice@tester.net";

print $socket "RCPT TO: nice\@tester.net\015\012";

> print $socket "DATA";

print $socket "DATA\015\012";

> print $socket "bla test and so on";

print $socket "bla test and so on\015\012";

Did you send all the correct mail headers? Did you send a blank line
after the headers?

> print $socket ".";

print $socket ".\015\012";

> print $socket "QUIT";

print $socket "QUIT\015\012";

> close($socket);
> 
> This program can be run without any problems, but I will never receive
> this email! Is this a fault of my perlscript or maybe a fault of my
> mailserver?
> Where can I get a detailed Tutorial about Socket Programming with Perl?

Is your main objective to learn socket programming or to send an e-mail?

For socket programming read the perlipc man page and chapters 17 and 18
of _Perl Cookbook_. For SMTP read RFC 2821 and RFC 2822.

If you just want to send an e-mail then use Net::SMTP or one of the Mail
or Sendmail modules.



John
-- 
use Perl;
program
fulfillment


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

Date: 31 Aug 2001 12:14:34 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Programming sockets
Message-Id: <slrn9ouvta.4q3.vek@pharmnl.ohout.pharmapartners.nl>

On Fri, 31 Aug 2001 11:41:38 +0200,
    Crazydj <Crazydj@web.de> wrote:


>Hi @ll!!! =)
>I have got a question on how to program sending sockets.
>To send an email through an SMTP server I would it do this way:
>
>use IO::Socket;
>$socket = new IO::Socket::INET(PeerAddr => 'test.server.net',
>                                                         PeerPort =>
>'25',
>                                                           Proto =>
>'tcp') || die "Cannot create socket: $!";
>
>print $socket "HELO mailserver.net";
>print $socket "MAIL FROM: perllover@crazydj.de";
>print $socket "RCPT TO: nice@tester.net";
>print $socket "DATA";
>print $socket "bla test and so on";
>print $socket ".";
>print $socket "QUIT";
>close($socket);
>
>This program can be run without any problems, but I will never receive
>this email! Is this a fault of my perlscript or maybe a fault of my
>mailserver?
>Where can I get a detailed Tutorial about Socket Programming with Perl?
>Thanx and best greets
>



You realy need to make your program listen to what the smtp
server has to say.  Then you might find out what is wrong.



Villy


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

Date: 31 Aug 2001 10:54:43 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Sort output and find last.
Message-Id: <9mnqdj$o3h$1@mamenchi.zrz.TU-Berlin.DE>

According to peter pilsl  <pilsl_@goldfisch.at>:
> Joe Meyer wrote:
> 
> > I am a beginner in Perl programming.  I am looking for a way to sort a
> > dataset on a Perl variable, so multiple responses to an internet survey
> > are
> > grouped together.  Then, I want to pick up the last non-missing response
> > to
> > each question for each respondent.  I think I know how to sort the data,
> > but I am not sure how to pick up the last non-missing value of each
> > variable after the sort is done.
> > 
> 
> Chris is right : I really dont understand what you want to do ...

Ah, but that's easy if your crystal ball is in working order.

The OP has a list of hashes, where each hash represents a response
of a participant to a questionnaire.  Participants may have replied
multiple times, and in a reply they may have answered only part of
the questions.  The keys in each hash are "participant", "date",
and a subset of @questions.

He wants a hash of hashes, where each key is a participant and the
corresponding hashref contains, for this participant, the latest
valid answer to each question.  The date gets lost in the process.

Do do this, it is enough to sort the list of hashes according to
ascending date; it is not necessary to bring participants together.

The hash %res of "consolidated" replies can now be built like this
(untested):

    for my $r ( @responses_sorted_by_date ) {
        for my $q ( @questions ) {
            $res{ $r->{ participant}}->{ $q} = $r->{ q} if defined $r->{ $q};
        }
    }

Anno


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

Date: Fri, 31 Aug 2001 10:41:07 GMT
From: gauthier@circum.com (Benoit Gauthier)
Subject: Re: Weird -w behaviour
Message-Id: <3b8f6922.4093852@news.videotron.ca>

On Thu, 30 Aug 2001 23:01:56 -0400, Samneric
<samneric@tigerriverOMIT-THIS.com> wrote:
>> [Thu Aug 30 21:13:26 2001] [error] (2)No such file or directory: exec
>> of /.../test.cgi failed
>
>"/usr/bin/perl^M" isn't on your server. No such file.
>"/usr/bin/perl -w^M" is.
>
>Your script contains carriage returns.

(2001.08.31, 06:39)

Thanks for your feedback.

1) How do you figure out there were carriage returns?

2) I edited the program again in vi (linux), with the same result.

3) I do normally edit my scripts in Windows and then FTP them to the
server. I do that with all my scripts. Why would this one bug?


Benoît Gauthier, mailto:gauthier@circum.com
Réseau Circum inc. / Circum Network Inc.

Enregistrez votre adresse élec. pour être informé(e)
des nouvelles de Circum à l'URL http://circum.com

Register your e-mail to be informed of Circum news at
http://circum.com

74, rue du Val-Perché, Hull, Québec (Canada) J8Z 2A6
+1 819.770.2423  télec. fax: +1 819.770.5196

==============================================

* * * Essayez des options : courriel avec The Bat!, Web avec Opera
* * * Try alternatives : e-mail with The Bat!, Web with Opera
http://www.ritlabs.com/the_bat/
http://www.opera.com/


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

Date: Fri, 31 Aug 2001 12:13:33 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Weird -w behaviour
Message-Id: <3B8F7FE1.6B39E251@acm.org>

Benoit Gauthier wrote:
> 
> On Thu, 30 Aug 2001 23:01:56 -0400, Samneric
> <samneric@tigerriverOMIT-THIS.com> wrote:
> >> [Thu Aug 30 21:13:26 2001] [error] (2)No such file or directory: exec
> >> of /.../test.cgi failed
> >
> >"/usr/bin/perl^M" isn't on your server. No such file.
> >"/usr/bin/perl -w^M" is.
> >
> >Your script contains carriage returns.
> 
> (2001.08.31, 06:39)
> 
> Thanks for your feedback.
> 
> 1) How do you figure out there were carriage returns?

Do you think you are the first person with this problem?  :-)

> 2) I edited the program again in vi (linux), with the same result.

If all lines end with CR and LF then vi will edit the file in "DOS"
mode.

> 3) I do normally edit my scripts in Windows and then FTP them to the
> server. I do that with all my scripts. Why would this one bug?

Some FTP clients default to binary, some default to text. Use an editor
like UltraEdit that can save files in unix format and save (and open)
via FTP. Unix text files will work just fine on Windows with Perl.



John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 31 Aug 2001 07:58:08 -0500
From: Mr Sunblade <djberge@uswest.com>
Subject: Re: Weird -w behaviour
Message-Id: <3B8F89E0.87D7D19A@uswest.com>

Benoit Gauthier wrote:

<snip>

> Thanks for your feedback.
>
> 1) How do you figure out there were carriage returns?
>
> 2) I edited the program again in vi (linux), with the same result.
>
> 3) I do normally edit my scripts in Windows and then FTP them to the
> server. I do that with all my scripts. Why would this one bug?

<snip>

I've seen similar behavior with text that I've scp'd from Windows to Unix.
No apparent ^M characters anywhere, yet they're clearly still there.  I've
even run text through dos2unix and *still* had bizarre behavior (i.e. there
were still ^M chars somewhere).  An 'od' should show you for sure.

There have been times where I literally had to copy and paste from one gvim
to another gvim in order to "fix" the text.

That was pretty rare, and I couldn't tell you what caused it - normally
text copies over just fine.  Only thing I can think of is your ftp 'mode' -
leave it ASCII if it's just text (i.e. don't turn on bin mode).

Regards,

Mr. Sunblade

--
"Evil will always triumph because Good is *dumb*."
-- Dark Helmet, 'Spaceballs: The Movie'





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

Date: Fri, 31 Aug 2001 07:55:34 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Weird -w behaviour
Message-Id: <slrn9ouupm.3h5.tadmc@tadmc26.august.net>

Benoit Gauthier <gauthier@circum.com> wrote:
>On Thu, 30 Aug 2001 23:01:56 -0400, Samneric
><samneric@tigerriverOMIT-THIS.com> wrote:
>>> [Thu Aug 30 21:13:26 2001] [error] (2)No such file or directory: exec
>>> of /.../test.cgi failed
>>
>>"/usr/bin/perl^M" isn't on your server. No such file.
>>"/usr/bin/perl -w^M" is.
>>
>>Your script contains carriage returns.


>1) How do you figure out there were carriage returns?


An educated guess, as someone is here about once a week with
the same problem.

You can easily strip the CRs:

   perl -p -i.dos -e 'tr/\r//d' filenames...

If foo.cgi.dos is larger that foo.cgi, then it found some
CRs to remove.


>2) I edited the program again in vi (linux), with the same result.


Yes, but did you remove the carriage returns in the editor?

It doesn't remove them automatically.


>3) I do normally edit my scripts in Windows and then FTP them to the
>server. I do that with all my scripts. Why would this one bug?


Maybe because you didn't transfer this one correctly.

Use "ASCII" or "text" mode FTP transfers, not "binary" mode.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Fri, 31 Aug 2001 17:30:02 +0530
From: Prakash Mishra <pmishra@mailcity.com>
Subject: Which language better
Message-Id: <3B8F7C42.EE19CA77@mailcity.com>

which language is better to use for developing testing tools....Perl or Tcl


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

Date: Fri, 31 Aug 2001 12:32:32 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Which language better
Message-Id: <3B8F8454.97F1FDC@acm.org>

Prakash Mishra wrote:
> 
> which language is better to use for developing testing tools....Perl or Tcl

The best language to use for developing testing tools is Algol. and
Basic.

The two best languages to use for developing testing tools are Algol and
Basic. and Forth.

The three best languages to use for developing testing tools are Algol,
Basic and Forth. and Lisp.

The four best languages to use for developing testing tools are Algol,
Basic, Forth and Lisp. and Befunge.

The five best languages to use for developing testing tools are Algol,
Basic, Forth, Lisp and Befunge. and Rebol.

The six best languages ...


(no one expects the language inquisition)



John
-- 
use Perl;
program
fulfillment


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

Date: 31 Aug 2001 08:01:06 -0500
From: claird@starbase.neosoft.com (Cameron Laird)
Subject: Re: Which language better
Message-Id: <D8C19A73AF7DB978.33B6E8B5FE49B74E.86225D965C0D1648@lp.airnews.net>

In article <3B8F7BA0.6BEAF6B4@mailcity.com>,
Prakash Mishra  <pmishra@mailcity.com> wrote:
>For developing a testing tool, which language is better to use...Perl or Tcl ?

The one that better fulfills all your other
requirements--the ones you haven't yet told
us.

People successfully use both Perl and Tcl in
this role.  In fact, *I* use both, for test-
ing (among other purposes).  I prefer Tcl,
for reasons whose pertinence to your situation
is impossible to know in the absence of more
information.
-- 

Cameron Laird <claird@NeoSoft.com>
Business:  http://www.Phaseit.net
Personal:  http://starbase.neosoft.com/~claird/home.html


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

Date: Fri, 31 Aug 2001 14:33:43 +0200
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: Which language better
Message-Id: <9mnvuk02tv@enews1.newsguy.com>


"Prakash Mishra" <pmishra@mailcity.com> wrote in message
news:3B8F7C42.EE19CA77@mailcity.com...
> which language is better to use for developing testing tools....Perl or
Tcl

The one you know best

Both are very good languages.  Perl has modules for just about everything,
and all available from one central site (http://www.cpan.org).  Tcl
extensions are evolving rapidly but Ihave a feeling they isn't yet such a
comprehensive tried and tested library.

Tcl is also very closely tied to c, in that it is exceptionally easy to
embed or extend.  Tcl interpreters can be found embedded in many devices,
such as cisco routers.

Over the past year I've been playing a little bit with Perl (in between one
thing and another) and I quite like it.  Every day you spend with Perl you
find yourself doing things you wouldn't even have dreamt of doing just hours
before.  Tcl I had a bit of a look at and I hope to one day have the time to
do a bit more.


B





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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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


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