[8022] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1647 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 15 13:17:41 1998

Date: Thu, 15 Jan 98 10:00:19 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 15 Jan 1998     Volume: 8 Number: 1647

Today's topics:
     Re: Comparing strings <ldanna@hotmail.com>
     Re: Displaying GIFs - oops <*@qz.to>
     does anyone know . . . <maxwll@erols.com>
     Re: Example of handling 2 STDIN 's? <tchrist@mox.perl.com>
     Getting Perl Programs to print out bit by bit <bholness@nortel.ca>
     Re: How can I set enviroment variables on Win32? (Jamie O'Shaughnessy)
     Re: How can I set enviroment variables on Win32? <ldanna@hotmail.com>
     Re: How come this works <joseph@5sigma.com>
     Newbie: perl scripts search floppy drive bspiker@wiesbaden.netsurf.de
     NNTP package - uploading stuff to an INN NNTP server -  <pxharding@csi.com>
     Re: perl -- a language for LEARNING programming? <joseph@5sigma.com>
     Re: Perl appears VERY slow <dboorstein@ixl.com>
     Printing quote punctuation in strings to e-mail (Dave Barak)
     Re: Read STDERR from child? <tchrist@mox.perl.com>
     Re: Recursive mkdir() <barnett@houston.Geco-Prakla.slb.com>
     Re: Recursive mkdir() <quentin@remington.amd.com>
     Re: sending emails with perl ? <eryq@zeegee.com>
     timeout for external call? <kargatis@jackaldog.gsfc.nasa.gov>
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Jan 1998 12:04:38 -0500
From: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: Comparing strings
Message-Id: <34BE41A6.7AFBC20@hotmail.com>

John Porter wrote:

> Sure it's legal, but it's still wrong.  To compare strings, you should
> use cmp, not ==, like so:
> 
>     if ( $s1  cmp  $s2 ) { ...
>

it should be eq, not cmp.  cmp
is the string equivalent of <=>

 
---------------------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
|               -Winston Churchill
---------------------------------------------------
Larry D'Anna                   "eschew obfuscation"


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

Date: 15 Jan 1998 17:37:18 GMT
From: Eli the Bearded <*@qz.to>
Subject: Re: Displaying GIFs - oops
Message-Id: <qz$9801151223@qz.little-neck.ny.us>
Keywords: from just another new york perl hacker

brian d foy <comdog@computerdog.com> wrote:
> Tom Phoenix <rootbeer@teleport.com> posted:
> >On Wed, 14 Jan 1998, John Porter wrote:
> >> Don't forget, you can't send html content and image content
> >> in the same response! 
> >I can. But (of course) I don't have to use any particular protocol if I
> >don't wish to. :-)
> since Elijah uses Lynx, i include uuencoded image data in the 
> comments of some of my web things.  not many people seem to 
> notice why a short paragraph needs to transfer 50k ;)

I noticed that. Lynx has some bugs that that exposes, in particular it
loses trailing whitespace. So I needed to massage the uuencoded text to
make a decoder happy with it. (I seem to recall that the gif was only
about 8k or have you hidden other ones?) UUencoding also has a defiency
for that sort of thing in that "-" and ">" are valid characters in the
output mapping, the base64 encoding used by mime uses a character set
without " ", "-", or ">" avoiding these problems.

Elijah
------
people probably just think you used a wordprocessor to make your HTML


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

Date: Thu, 15 Jan 1998 12:31:02 -0500
From: Maxwell Watman <maxwll@erols.com>
Subject: does anyone know . . .
Message-Id: <34BE47D5.568D69DF@erols.com>

Does anybody know a perl search engine akin to swish (with wwwwais) or
glimpse that would grab the  paragraph in which the string was found,
and report it with the file info/link?
If no one knows one, does anyone want to write one?
please write to:
m watman
tech@newcriterion.com



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

Date: 15 Jan 1998 17:20:16 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Example of handling 2 STDIN 's?
Message-Id: <69lggg$84t$2@csnews.cs.colorado.edu>

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

In comp.lang.perl.misc, paul@f1world.com writes:
:Can someone post an example of how I can listen for STDIN from a
:socket connection and STDIN from the keyboard at the same time using
:select?

It's hard.  You have to put the tty in cbreak mode, then not
use stdio.  Then use select.  Here's ancient perl4 code
that did that.  It's not expected to work today, but you might
learn from it.

Scary how I wrote things eight years ago.

--tom

#!/usr/bin/perl
#
# statmon - check for hosts going up and down, or with bad clocks
# tom christiansen <tchrist@convex.com> on 3/8/90
#

RESTART:  			# shouldn't really need this...

($program = $0) =~ s%.*/%%;
$version = 0.3;

$| = 1;

&bad_usage unless $#ARGV >= 0;

printf "%s v%3.1g; ", $program, $version;

if ($compiled) {
    print "quick start.... ";
} else {
    print "initializing... ";
    
    # some useful constants
    $sockaddr_t	= 'S n a4 x8';
    $inetaddr_t = 'C4';
    $sgttyb_t   = 'C4 S';            

    $SINCE_1970 = 2208988800;

    $def_timeout  = 5;      # how long we give a host to answer us
    $def_timewarp = 10;     # how far time may vary until we complain
    $def_retries  = 5;	    # he gets this many tries to answer us
    $def_sleep    = 5;      # between send loops

    $retries      = $def_retries;
    $timeout      = $def_timeout;
    $timewarp     = $def_timewarp;
    $sleep        = $def_sleep;

    $OOPS = ", can't continue";

    $dashes = ('-' x 75) . "\n";

    %cmds = (
	'q',	'quit',
	'x',	'quit',
	'h',	'help',
	'?',	'help',
	't',	'timers',
	'd',	'downers',
	'u',	'uppers' ,
	'm',	'missing',
	'U',	'usage' 
    );

    &source('sys/errno.h');
    &source('sys/socket.h');
    &source('sizeof.h');
    &source('sys/ioctl.h');
    &source('ctime.pl');
    &source('getopts.pl');
} 


&Getopts('udmt:r:c:s:') || &bad_usage;

$debug = $opt_d;


$retries  = $opt_r if defined $opt_r;
$timeout  = $opt_t if defined $opt_t;
$timewarp = $opt_c if defined $opt_c;
$sleep    = $opt_s if defined $opt_s;

DUMP: {
    if ($opt_u) {  # dump this puppy
	if ($compiled++) {
	    warn "already dumped, ignoring -u\n";
	    last DUMP;
	} 
	print "dumping\n";
	reset 'o';		# so the opt_* vars (especially $opt_u!) go away
	dump RESTART;
	# not reached
    } 
}

$SIG{'INT'}  = $SIG{'HUP'} = $SIG{'TERM'} = $SIG{'QUIT'} = 'quit';
$SIG{'CONT'} = 'continue';

# if they say -m, then they want to take stuff from /usr/adm/MACHINES
#
# which is of the general form:
#
#	NAME	features
#
#	spool   vax bsd
#	coyote	sunos4 diskserver
#	pokey	sunos4 diskless slow
#	gort 	convex bsd 
#
if ($opt_m) {
    # try very hard to find a machines file
    $MACHINES = $ENV{'GHOSTS'};
    $MACHINES = $ENV{'MACHINES'} 	    unless $MACHINES;		
    $MACHINES = $ENV{'HOME'} . '/.ghosts'   unless $MACHINES;
    $MACHINES = $ENV{'HOME'} . '/.machines' unless -f $MACHINES;
    $MACHINES = '/usr/adm/MACHINES'         unless -f $MACHINES;

    die "Can't find any MACHINES file"      unless -f $MACHINES;

    open MACHINES ||                        die "can't open $MACHINES: $!";

    print "opened $MACHINES\n"		    if $debug;
    @hosts = <MACHINES>;
    close MACHINES;

    @hosts = grep(/^\w+\s/, @hosts);

    while ($criterion = shift) {
	@hosts = grep(/\b$criterion\b/, @hosts);
    } 

    for (@hosts) {
	chop;
	s/^(\w+).*/$1/;
    } 
} else {
    @hosts = @ARGV;
} 

if ($#hosts < 0) {
    print "No hosts\n";
    &bad_usage;
} 

print "hosts are @hosts\n" if $debug;

#
# ok, now create our socket we want everyone to talk to us at
#

chop ($localhost = `hostname`);

(($name, $aliases, $type, $len, $thisaddr) = gethostbyname($localhost))
    || die "no localhost \"$localhost\"$OOPS";

(($name, $aliases, $port, $proto) = getservbyname('time', 'udp'))
    || die "no udp service for \"time\"$OOPS";

print "service is $name, port is $port\n" 
    if $debug;


(($name, $aliases, $proto) = getprotobyname('udp'))
    || die "can't get udp proto$OOPS" ;


socket(SOCKET, &AF_INET, &SOCK_DGRAM, $proto) 
    || die "can't get socket$OOPS";

$this = &sockaddr(&AF_INET, 0, $thisaddr);

bind(SOCKET, $this) 
    || die "can't bind socket: $!$OOPS";

#
# now go find all of our hosts' addresses, storing
# these in %hosts keyed on $name
#


print "fetching addrs... ";

for $host (@hosts) {
    (($name, $aliases, $type, $len, @addrs) = gethostbyname($host))
	|| die "no remote \"$host\"\n";

    $name =~ s/\.convex\.com$//;

    $hosts{$name} = $addrs[0];
}

print "done.\nType 'h' for help.\n";

$rin = $win = $ein = '';
vec($rin,fileno(SOCKET),1) = 1;
vec($ttyin,fileno(STDIN),1) = 1;
$rin |= $ttyin;



# now keep interrogating forever
for (;;) {
    %sent = ();  # haven't sent anybody anything yet
    $sent = 0;

    &cbreak;

    print $dashes, "entering send loop\n" if $debug;

    while (($name, $addr) = each %hosts) {
	$that = &sockaddr(&AF_INET, $port, $addr);

	if (!send(SOCKET,0,0,$that)) {
	    printf STDERR "couldn't send to %-12s %-16s\n", $name, &fmtaddr($addr);
	    next;
	}

	$sent{$name}++;
	$sent++;

	#printf "sent to %-12s %s\n", $name, &fmtaddr($addr) if $debug;
    }

    print $dashes, "entering recv loop\n" if $debug;

    $ntimeout = $timeout;

    while ($sent > 0) {
	    $then = time;
	    last unless $nfound = select($rout=$rin, $wout=$win, $eout=$ein, $ntimeout);
	    if ($nfound < 0) {
		warn "select failed: $!\n" unless $! == &EINTR;
		redo;
	    } 
	    $took = (time - $then);
	    $ntimeout -= $took; 

	    &readsock if vec($rout,fileno(SOCKET),1); 
	    &readtty if vec($rout,fileno(STDIN),1); 
    }

    for $name (sort keys %sent) {
	$missed{$name}++;
	printf "%-12s missed %d times\n", $name, $missed{$name} if $debug;
	if (! $down{$name}) {
	    next unless $missed{$name} > $retries;
	    next if $down{$name};
	    $down{$name} = time;
	    printf "%-12s %-16s down at %s", 
		$name, &fmtaddr($hosts{$name}), &ctime($down{$name});
	}
    } 

    print "sleeping $sleep -- hit any key to interrupt\n" if $debug;
    select($ttyout = $ttyin, $wout=$win, $eout = $ein, $sleep);
    &readtty if vec($ttyout,fileno(STDIN),1); 
}

sub sockaddr {
    if (wantarray) {
	    unpack($sockaddr_t, $_[0]);
    } else {
	    pack($sockaddr_t, $_[0], $_[1], $_[2]);
    } 
} 

sub inetaddr {
    if (wantarray) {
	    unpack($inetaddr_t, $_[0]);
    } else {
	    pack($inetaddr_t, $_[0], $_[1], $_[2]);
    }
} 

sub source {
    local($file) = @_;
    local($return) = 0;

    $return = do $file;
    die "couldn't do \"$file\": $!" unless defined $return;
    die "couldn't parse \"$file\": $@" if $@;
    die "couldn't run \"$file\"" unless $return;
}

sub usage {
    print STDERR <<EOM;
usage: $program [switches] host ...
   or: $program [switches] -m [criterion ...]

switches are:
    -m  look in MACHINES file for hosts matching criteria

    -t	timeout for responses (default $def_timeout)
    -r	retries until timed-out host considered down (default $def_retries)
    -c  clock drift tolerance (default $def_timewarp)
    -s  sleep interval between send loops (default $def_sleep)

    -d  print out debugging information
    -u  dump state to disk for faster init
EOM
} 

sub bad_usage {
    &usage;
    exit(1);
} 

sub fmtaddr {
    sprintf("[%d.%d.%d.%d]", &inetaddr(@_[0]));
} 


sub readsock {
    ($hisaddr = recv(SOCKET,$histime='',4,0))
	|| (warn "couldn't recv: $!$OOPS", return);

    $sent--;

    ($addrtype, $port, $iaddr) = &sockaddr($hisaddr);

    $histime = unpack('L',$histime);
    $histime -= $SINCE_1970;

    unless (($name,$aliases,$addrtype,$length,@addrs) =
		gethostbyaddr($iaddr,$addrtype)) 
    {
	printf STDERR "received reply from unknown address %sn",
				&fmtaddr($iaddr);
	next;
    } 
    $name =~ s/\.convex\.com$//;

    printf "%-12s %-16s thinks it's %s", 
		$name, &fmtaddr($iaddr), &ctime($histime) if $debug;

    $delta = ($histime - time);
    $delta = -$delta if $delta < 0;
    $delta{$name} = $delta;

    delete $missed{$name};

    if ($down{$name}) {
	printf "%-12s %-16s back at %s",
		$name, &fmtaddr($iaddr), &ctime(time);
	delete $down{$name};
    } 

    printf "funny, i didn't send $name anything\n" unless $hosts{$name};
    delete $sent{$name};
}

sub readtty {
    local($cmd) = getc;
    local($routine) = '';

    $cmd = sprintf ("%c", ord($cmd) & 0x7f);

    if (defined $cmds{$cmd}) {
	$routine = $cmds{$cmd};
	print "\n",$dashes unless $routine eq 'quit';
	&$routine;
	print $dashes;
    } else {
	printf " -- unknown command: `%s' (0x%02x)\n", $cmd, ord($cmd);
    } 
} 

sub quit {
    $SIG{'TTOU'} = "IGNORE";
    &cooked;
    exit 0;
} 

sub help {
    local($cmd);
    print "Key\tCommand\n";
    for $cmd (sort keys %cmds) {
	printf "%s\t%s\n", $cmd, $cmds{$cmd};
    } 
} 

sub timers {
    local($name);
    print "Bad Clocks exceeding $timewarp seconds\n";
    for $name (sort keys %delta) {
	next unless $delta{$name} > $timewarp;
	printf "%-12s %-16s has a clock that's %4d seconds off\n", 
	    $name, &fmtaddr($hosts{$name}), $delta{$name};
    }
}


sub missing {
    local($name);
    print "Missing Hosts\n";
    for $name (sort keys %missed) {
	printf "%-12s %-16s has missed %d timeout%s of %d seconds\n",
	    $name, &fmtaddr($hosts{$name}), $missed{$name},
	    ($missed{$name} == 1) ? " " : "s", $timeout;
    }
} 

sub downers {
    local($name);
    print "Down Hosts\n";
    for $name (sort keys %down) {
	printf "%-12s %-16s down since %s", 
	    $name, &fmtaddr($hosts{$name}), &ctime($down{$name});
    } 
} 

sub uppers {
    local ($name);

    print "Up Hosts\n";

    for $name (sort keys %hosts) {
	next if $down{$name};
	printf "%-12s up\n", $name;
    } 
} 

sub continue { 
    print "continuing...\n";
    &cbreak; 
}

sub cbreak {
    &set_cbreak(1);
} 

sub cooked {
    &set_cbreak(0);
} 

sub set_cbreak {
    local($on) = @_;

    ioctl(STDIN,&TIOCGETP,$sgttyb) 
	|| die "Can't ioctl TIOCGETP: $!";

    @ary = unpack($sgttyb_t,$sgttyb);
    if ($on) {
	$ary[4] |= &CBREAK;
	$ary[4] &= ~&ECHO;
    } else {
	$ary[4] &= ~&CBREAK;
	$ary[4] |= &ECHO;
    }
    $sgttyb = pack($sgttyb_t,@ary);
    ioctl(STDIN,&TIOCSETP,$sgttyb)
	    || die "Can't ioctl TIOCSETP: $!";

}
-- 
	Tom Christiansen	tchrist@jhereg.perl.com


I use `batshit' in an idiosyncratic fashion. --Andrew Hume


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

Date: Thu, 15 Jan 1998 17:16:09 +0000
From: Ben Holness <bholness@nortel.ca>
Subject: Getting Perl Programs to print out bit by bit
Message-Id: <34BE4459.8E2@nortel.ca>

HI all,

I would like to know if it is possible for a perl program to print out
bit-by-bit.

Here is an example of what I mean:

Perl Program (Running from a browser):

[Normal HTML processing - eg print context/type: html, body etc.]
print "Processing 1st set<br>";

[Do Some Processing]

print "Processing 2nd set<br>";

[Do Some Processing]

print "Processing 3rd set<br>";

[Do Some Processing]

print "Finished";
print "</body></html>";
etc.

And when loaded from the web, it prints each message bit-by-bit, rather
than all at once, when the program has finished, so the user would see:

Processing 1st set
[Couple of seconds pass]
Processing 2nd set
[Couple of seconds pass]
Processing 3rd set
[Couple of seconds pass]
Finished

If anyone knows, please let me know! 

Cheers

Ben
-- 
  _____________________________________
 /                                     \
|        *-=Ben Holness=-*              |
|                                       |
|    Dept. 7e24 % bholness@nortel.ca    |
|-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-|
| ESN: 590-4957 % PSTN: (01628) 434957	|
|=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=|


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

Date: Thu, 15 Jan 1998 16:53:42 GMT
From: joshaugh@uk.oracle.com (Jamie O'Shaughnessy)
Subject: Re: How can I set enviroment variables on Win32?
Message-Id: <34be3b68.2583337432@newshost.us.oracle.com>

On 14 Jan 1998 09:19:46 GMT, "Xaver Weibel" <nweibx@abs.ascom.ch> wrote:

>How can I set enviroment variables on Win32?
>nweibx@abs.ascom.ch

That depends on what you mean by set :)

If you want to set the env var within your script and for any programs you call
from within your script (e.g. by doing a system()) - just add/set the env var
in %ENV, e.g.
$ENV{new_var} = "value";

If you want to set the env var in *future* command prompts then you can set the
env var in the registry (using Win32::Registry). The env vars are stored in:
\\HKEY_CURRENT_USER\\Environment

Some example code to set an env var in the registry is:

use Win32::Registry;
my $regkey;
$HKEY_CURRENT_USER->Open('Environment', $regkey) || die;
$regkey->SetValueEx("env_var_name", &NULL, &REG_SZ, "value");
$regkey->Close();

You get my drift. This only works on NT as 95 doesn't store env vars in the
registry. For 95 you have to alter autoexec.bat. 

If you want to alter the env vars within the shell/program that called your
perl script, this is a different matter. The only way I've found to do this is
to write out a temporary file from within your perl script, and then execute
this as a batch file, e.g.

@rem = 'Perl Script Wrapper';
@rem = '
set CMD=%0
set ARGS=
:loop
if .%1==. goto endloop
set ARGS=%ARGS% %1
shift
goto loop
:endloop
perl.exe -S %CMD% %ARGS%
if exist %temp%\shellenvs.bat call %temp%\shellenvs.bat
if exist %temp%\shellenvs.bat del %temp%\shellenvs.bat
goto endofperl
@rem ';

# this is where the perl starts!!!
my $tempfile = $ENV{TEMP} . "\\shellenvs.bat";
open(BATFILE, "> $tempfile") || die;
print BATFILE "set THISVAR=VALUE\n";
close(BATFILE);

__END__
:endofperl

Save all of the above in a .bat file and it should work. Note the couple of
lines at the top of the .bat bit that calls the shellenvs.bat - this is the
script your perl script will generate and it's in here that you issue the shell
"set" commands to set the env vars.

All of the above methods work and I use them in a number of scripts we use
daily.

Hope that helps,
Jamie

___________________________________________________________________________ 
Jamie O'Shaughnessy                        Work: joshaugh @ uk.oracle.com 
Oracle C++ Object Layer Generator Team
______________________________________________________  __  __ _  __ .   __ 
Opinions expressed here are my own and not those of... (__)|-</-\(__ |__ -_ 


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

Date: Thu, 15 Jan 1998 12:27:41 -0500
From: Larry D'Anna <ldanna@hotmail.com>
Subject: Re: How can I set enviroment variables on Win32?
Message-Id: <34BE470D.FECF0688@hotmail.com>

Xaver Weibel wrote:
> 
> How can I set enviroment variables on Win32?
> 
> nweibx@abs.ascom.ch

%ENV works just fine in Win32.

---------------------------------------------------
|Democracy is the worst system of government. --
|Except for all the others
|               -Winston Churchill
---------------------------------------------------
Larry D'Anna                   "eschew obfuscation"


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

Date: Thu, 15 Jan 1998 10:32:13 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: How come this works
Message-Id: <34BE47E9.B18641F@5sigma.com>

Beats me, since they both work fine on my machine.

	-joseph
	 http://www.effectiveperl.com

Builders Connection wrote:
> 
> If someone could please tell me how this piece of code works take out
> all commas and new lines but the second dos'nt work
> 
> $test="\nJim,\n and, Patty,\n";
> $test=~ s/\n|,//g; # this takes out all , and new lines
> print "$test";
> --
> $test="\nJim,\n and, Patty,\n";
> $test=~ s/,|\n//g; # this takes out all , and new lines
> print "$test";


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

Date: Thu, 15 Jan 1998 17:39:30 GMT
From: bspiker@wiesbaden.netsurf.de
Subject: Newbie: perl scripts search floppy drive
Message-Id: <34be48ef.5065479@news.wiesbaden.netsurf.de>


I recently installed Perl w95 v5.03, and I'm being bothered that
everytime I run a perl script, there is a search on my system
including a floppy drive serach, and I haven't a clue why.

This occurs even with the "hello world" script. I have verified that
the A:\ isn't in my %PATH and I've tried to list items in the perl
eenvironment trying to findout what it might be.

I've heard that there is a "@INC" that is te path for searching for
libraries, but I haven't found any references to it yet.

Any clues?

Thanks!


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

Date: Thu, 15 Jan 1998 16:39:01 +0000
From: Piers <pxharding@csi.com>
Subject: NNTP package - uploading stuff to an INN NNTP server - msg: 480 Transfer Permission denied
Message-Id: <34BE3BA3.755B4A86@csi.com>

Hi,

I have written a small script to take nntp articles from one server to
another:

#!/perl/bin/perl
use Net::NNTP;
use Net::Cmd;
@ISA = qw(Net::Cmd);
$source = 'pharding';
$other = '159.167.35.92';

$nntp = Net::NNTP->new($source) || die "could not log onto server $! ";
$othernntp = Net::NNTP->new($other) || die "could not log on to
remoteserver $! ";

@list = qw( blah.lang.perl.misc );

foreach $group ( @list ) {

  $nntp->group($group) || die " no change to $group allowed $! ";
  $othernntp->group($group) || die "no change to other $group allowed $!
";
    $res = $othernntp->code();
    print " other change code - $res \n";
    $res = $othernntp->message();
    print " ihave message - $res \n";

  print "\n Group: $group \n";
  $newn = $nntp->newnews($group) || die "did not like get - $!";
  @newn = @{$newn};
  chomp(@newn);

#print map @{$nntp->article($_)}, @n; #ooh!

  foreach $art (@newn) {
    print "  Article: $art \n";
    $article = $nntp->article($art);
    @iart = @{$article};
    $res = $othernntp->ihave($art); # returns 480 - transfer pem denied
    $res = $othernntp->code();
    print " ihave code - $res \n";
    $res = $othernntp->message();
    print " ihave message - $res \n";
    $othernntp->datasend(@iart);
    $othernntp->dataend();
    print @iart;
    $res = $othernntp->code();
    print "     Article sent - $res  \n";
  };
};

$nntp->quit;
$othernntp->quit;

: the problem is that the INN server returns a 480 message code -
transfer permission denied ( on the ihave ), even though if I telnet
directly onto the port 119 and do an IHAVE  that works fine - ie.
returns a code 335 ( successful ).

Any suggestions welcome.

Cheers.



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

Date: Thu, 15 Jan 1998 10:26:13 -0700
From: "Joseph N. Hall" <joseph@5sigma.com>
Subject: Re: perl -- a language for LEARNING programming?
Message-Id: <34BE4680.C4A8C36B@5sigma.com>

If you're planning on taking university classes or something
similar, you'll probably have to learn C (or perhaps Pascal or
even LISP).  What will that do for you?  I don't know.  Most
or perhaps all of the good or better programmers I know learned
on their own.  But classes are a good way of picking up the
more theoretical material.  Too bad there aren't many taught
in Perl!  (Yet.)

Some classes are useful but don't involve any programming.
Discrete math, for example.

	-joseph

notsew@wwa.com wrote:
> 
> what i'm wondering, i guess, is whether my knowledge of perl (and
> other languages, many of whose basic constructs derive from c/c++)
> would be enough to get me through some of the "theory" i'm interested
> in learning.  should i pick up a book in data structures, for example,
> where examples are given entirely in c, would i be lost, or would
> things in essence look pretty familiar?  i mean, a for loop is a for
> loop.  similarly, would i be able to convince a professor (whose
> consent i'd need to take his class without the requisite c/c++
> knowledge) of as much?


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

Date: Thu, 15 Jan 1998 11:55:47 -0500
From: Dan Boorstein <dboorstein@ixl.com>
To: Clive McAdam <cmcadam@icl.co.za>
Subject: Re: Perl appears VERY slow
Message-Id: <34BE3F93.E62D54FB@ixl.com>

i believe this is not perl related. it is more likely your
web server or browser. watch the process tables of your
server machine to see if perl fires up as soon as you
submit the form. i doubt you will see it until the connection
is finished. if you do see it, then post your code. perhaps
you have done something to cause a hang-up.

good luck,

dan

Clive McAdam wrote:
> 
> Perl v5.0.0.3
> Solaris 2.5.1
> Netscape Enterprise Server 3.0
> 
> My perl program reads input from a form, opens a file on disk, writes to
> that file, closes the file, opens another file, writes some data to that
> file and then closes that file, that's all.
> 
> Sometimes the procedure is blazing fast and other times my browser just
> sits on "Connect: Host www.xyz.com contacted. Waiting for reply..." with
> no joy. Only if I stop and reload a couple of times will it *maybe* come
> right.
> 
> Does anybody know what could be causing this non-performance?
> 
> Regards
> Clive McAdam
> 
> PS. I checked the server errors and there are none.


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

Date: 15 Jan 1998 17:41:10 GMT
From: Zwebmaster@formz.com (Dave Barak)
Subject: Printing quote punctuation in strings to e-mail
Message-Id: <Zwebmaster-1501981242510001@205.133.76.196>

Hello,

I've got a (hopefully) simple question (I'm new to Perl, and my books are
at home). I need to have a form mailer script print the quote sign ( " )
to my e-mail. Do I need some sort of special code for that? The string I'm
printing is, of course, enclosed in quotes, but I need to include quotes
as part of the string.

Dave


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

Date: 15 Jan 1998 17:14:51 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Read STDERR from child?
Message-Id: <69lg6b$84t$1@csnews.cs.colorado.edu>

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

Have you read this yet?

=head2 How do I capture a command's stdout?

    $output = `cmd`;
or
    $pid = open(PH, "cmd |");
    while (<PH>) { }

=head2 How do I capture a command's stderr and stdout together?

    $output = `cmd 2>&1`;
or
    $pid = open(PH, "cmd 2>&1 |");
    while (<PH>) { }

=head2 How do I capture a command's stdout and discard stderr?

    $output = `cmd 2>/dev/null`;
or
    $pid = open(PH, "cmd 2>/dev/null |");
    while (<PH>) { }


=head2 How do I capture a command's stderr and discard stdout?

    $output = `cmd 2>&1 1>/dev/null`;
or
    $pid = open(PH, "cmd 2>&1 1>/dev/null|");
    while (<PH>) { }

=head2 How do I capture a command's stderr and stdout separately?

    $CMD = 'grep . /tmp/foo /etc/motd /tmp/bar';

    # METHOD 1:
    @all = `($CMD | sed 's/^/stdout: /' ) 2>&1`;
    for (@all) { push @{ s/stdout: // ? \@outlines : \@errlines }, $_ }
    print "STDOUT:\n", @outlines, "\n";
    print "STDERR:\n", @errlines, "\n";

    # METHOD 2:
    $pid = open(PH, "($CMD | sed 's/^/stdout: /' ) 2>&1 |");
    @outlines = @errlines = ();
    while (<PH>) {
	if (s/stdout: //) {
	    push @outlines, $_;
	} else {
	    push @errlines, $_;
	}
    }
    print "STDOUT:\n", @outlines, "\n";
    print "STDERR:\n", @errlines, "\n";

    # METHOD 3:
    use IPC::Open3;
    $pid = open3(\*HIS_IN, \*HIS_OUT, \*HIS_ERR, $CMD);
    close(HIS_IN);  # give end of file to kid, or feed him
    @outlines = <HIS_OUT>;
    @errlines = <HIS_ERR>;
    print "STDOUT:\n", @outlines, "\n";
    print "STDERR:\n", @errlines, "\n";

    # METHOD 4:
    use IPC::Open3;
    use IO::Handle;
    $his_input  = IO::Handle->new();
    $his_output = IO::Handle->new();
    $his_errors = IO::Handle->new();
    $pid = open3($his_input, $his_output, $his_errors, $CMD);
    close($his_input);  # give end of file to kid, or feed him
    @outlines = <$his_output>;
    @errlines = <$his_errors>;
    print "STDOUT:\n", @outlines, "\n";
    print "STDERR:\n", @errlines, "\n";

    # NON METHOD:

You can't open to do blocking simulataneous blocking reads
on his output and error.  You could use select, but then you wouldn't
be allowed to use <FH> because you can't mix select and stdio.

(i have ideas about this, but it's not pretty)
-- 
	Tom Christiansen	tchrist@jhereg.perl.com

    "Since when did you hear people talk about writing LISP or BASIC *scripts*?
     JCL and shell make command *scripts*; perl and LISP make *programs*."  --me


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

Date: Thu, 15 Jan 1998 10:50:03 -0600
From: Dave Barnett <barnett@houston.Geco-Prakla.slb.com>
Subject: Re: Recursive mkdir()
Message-Id: <34BE3E3B.56E9358C@houston.Geco-Prakla.slb.com>

Ed Avis wrote:
> 
> Many versions of mkdir(1) have a -p flag to create all directories in
> a specified path.  For example
> 
> mkdir -p foo/bar/baz
> 
> works, creating directories foo and bar if they do not already exist.
> 
> Is there a feature like this in Perl?
> 
Yes.

See the File::Path module (part of std dist, I think).  The
documentation inside of File::Path is pretty detailed.  Looking up
mkpath should tell you what you need to know.

> TIA,
>
Sure. 
> --
> Ed Avis

Dave

-- 
"Security through obscurity is no security at all."
		-comp.lang.perl.misc newsgroup posting

------------------------------------------------------------------------
* Dave Barnett               U.S.: barnett@houston.Geco-Prakla.slb.com *
* DAPD Software Support Eng  U.K.: barnett@gatwick.Geco-Prakla.slb.com *
------------------------------------------------------------------------


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

Date: 15 Jan 1998 11:03:45 -0600
From: Quentin  Fennessy <quentin@remington.amd.com>
Subject: Re: Recursive mkdir()
Message-Id: <xim7m81fz4e.fsf@remington.amd.com>


epa@datcon.co.uk (Ed Avis) writes:
>
> Many versions of mkdir(1) have a -p flag to create all directories in
> a specified path.  For example
>   mkdir -p foo/bar/baz
> works, creating directories foo and bar if they do not already exist.
> Is there a feature like this in Perl?

Ed-
	Check out File::Path.  mkpath() does what you want.

>From perldoc File::Path:

 ...
     The mkpath function provides a convenient way to create
     directories, even if your mkdir kernel call won't create
     more than one level of directory at a time.  mkpath takes
     three arguments:
 
     o    the name of the path to create, or a reference to a
         list of paths to create,
 
     o    a boolean value, which if TRUE will cause mkpath to
         print the name of each directory as it is created
         (defaults to FALSE), and
 
     o    the numeric mode to use when creating the directories
         (defaults to 0777)

-- 
Quentin Fennessy			AMD, Austin Texas


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

Date: Thu, 15 Jan 1998 11:58:45 -0500
From: Eryq <eryq@zeegee.com>
To: perry@iway.fr
Subject: Re: sending emails with perl ?
Message-Id: <34BE4045.2BFA@zeegee.com>

Pascal PERRY wrote:
> 
> memeier@bene.baynet.de wrote:
> >
> > Hi !
> > Can anybody tell me how send emails with perl-scripts ?
> >
> > Mike
> 
>  1) Create a socket localy with socket()
>  2) Connect to a remote SMTP server with connect()
>     (for instance, STMP mail server of your ISP)
>  3) Send through this socket your SMTP-formated message

Or use Mail::Internet and Net::SMTP, which take care of all
this stuff for you.  See http://www.perl.com/CPAN .

-- 
   ___  _ _ _   _  ___ _  Eryq (eryq@zeegee.com)
  / _ \| '_| | | |/ _ ' / President, Zero G Inc: http://www.zeegee.com
 |  __/| | | |_| | |_| |      "Talk is cheap. Let's build." - Red Green.
  \___||_|  \__, |\__, |___/\ Visit STREETWISE, Chicago's newspaper by/
            |___/    |______/ of the homeless: http://www.streetwise.org


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

Date: Thu, 15 Jan 1998 11:46:26 -0500
From: Vincent Kargatis <kargatis@jackaldog.gsfc.nasa.gov>
Subject: timeout for external call?
Message-Id: <34BE3D62.41C6@jackaldog.gsfc.nasa.gov>

Can one call an external program in perl and wait only a certain time
before deciding to move on?  That is, can I execute some kind of child
process where I want to get the output of that process if it comes
back soon enough, but if not, give an error message?  I must admit to
failing to understand the nitty gritty of forking and such - reading
the little bit in the Wall and Schwartz books didn't fully hack away
my ignorance.

Can this be done more easily putting the external script as a
subroutine in the main program?

In general, what's the best way to call an external perl script - can
you get both the output of that script and an exit status?  Do you
need to put that external script in a package or module?

If any of these questions deserve RTFM, please specify which one.

thanks, vince
-- 
Vincent Kargatis                Address:  Code 631
Archive Scientist, Raytheon STX           Goddard Space Flight Center
PH   301-286-6128                         Greenbelt MD 20771
FAX  301-286-1771               e-mail:   kargatis@xfiles.gsfc.nasa.gov


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.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 1647
**************************************

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