[19545] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1740 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 13 09:06:51 2001

Date: Thu, 13 Sep 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: <1000386309-v10-i1740@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 13 Sep 2001     Volume: 10 Number: 1740

Today's topics:
    Re: Convert hex dump to binary (Phil Hibbs)
    Re: Efficiency <bart.lateur@skynet.be>
        implicit functions <pilsl_@goldfisch.at>
        io redirection with system command <schrockn@umich.edu>
    Re: io redirection with system command <Thomas@Baetzler.de>
    Re: io redirection with system command <goldbb2@earthlink.net>
        Need Help <kekwee@cwasia.net.sg>
    Re: Need Help (Rafael Garcia-Suarez)
    Re: Need Help <goldbb2@earthlink.net>
    Re: Net::NNTP (Jonadab the Unsightly One)
    Re: Parsing problem (Please HELP ) <goldbb2@earthlink.net>
        Perl and SNMP <sasha_lui@yahoo.com>
    Re: Perl and SNMP (Logan Shaw)
    Re: Printing in Perl <tintin@snowy.calculus>
    Re: Printing in Perl brianr@liffe.com
    Re: Problem after Alarm interrupts system call (Villy Kruse)
        Regular Expression Peculiarity <amarden@altavista.net>
    Re: Regular Expression Peculiarity (Rafael Garcia-Suarez)
    Re: Regular Expression Peculiarity (Randal L. Schwartz)
        scalar global search <pilsl_@goldfisch.at>
    Re: scalar global search (Rafael Garcia-Suarez)
    Re: Search and Replace and Reformat <goldbb2@earthlink.net>
    Re: system() command not wrking in cgi / works fine in  <anpandey@cisco.com>
    Re: system() command not wrking in cgi / works fine in  <Thomas@Baetzler.de>
        Tk::fileevent eating all my CPU cycles (Stan Brown)
    Re: Tk::fileevent eating all my CPU cycles <bkennedy99@Home.com>
        Why the client still waits for input? <yuwen@microtek.com.cn>
    Re: Why the client still waits for input? <simon.oliver@umist.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 13 Sep 2001 02:25:13 -0700
From: phil@snark.freeserve.co.uk (Phil Hibbs)
Subject: Re: Convert hex dump to binary
Message-Id: <979ae699.0109130125.7adb21c9@posting.google.com>

>> I had to move the "my $hex" up to before the while (may
>> be a Perl 5.001 quirk - I know, I should upgrade, don't 
>> bother telling me), 

Martien Verbruggen: 
> Yes it is, and yes, you should upgrade. If you want for my $var LIST
> to work, you should upgrade to at least 5.005. I'd install 5.6.1.

Not an option, sadly.

Phil.


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

Date: Thu, 13 Sep 2001 11:48:17 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Efficiency
Message-Id: <5471qt4prrdf1s2flv7a3kfno61emb63m8@4ax.com>

TM wrote:

>Can Perl instructions either from the core or from specific modules be
>more efficient than system commands such as copy, xcopy, del, move etc
>with their many switches and wildcards. Or maybe that's a nonsense. In
>my case, I'm working on WIn2K with procedures that handle thousands of
>files with such commands that's why I'm looking for improvement in
>execution time of such actions.

In my experience, File::Find is very slow on Win32. So no, if you want
to process whole directory trees, I don't expect it to be blindinly
fast.

Of course, YMMV. It strongly depends on your hardware, and on your OS
too, I presume.

-- 
	Bart.


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

Date: Thu, 13 Sep 2001 14:38:43 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: implicit functions
Message-Id: <3ba0a8d5@e-post.inode.at>


Does perl know such thing like implicit functions or pure functions (like 
known from mathematica or such things)

that means: I need a function only on time and dont want to declare it as a 
sub, but merely 'map' in on the given values.

What do I want ?

I have a sub that returns two values. The first need to be stored and the 
second need to delivered. All has to happen implicit, cause the delivered 
value is used in a s///-operator.

$c='aaaXaaa';$b='x';
$c=~s/X/(@r=fu(), $b.=$r[0], $r[1])/e;
print $c,"-",$b,"\n";
sub fu {return 1,2;} 

The X in $c gets replaced by the second value returned by the function and 
$b gets the first value added.
This works fine, but I really dont like introducing the new variable @r for 
it. Something like
{$b.=$_[0],$_[1]} fu();
would be much cooler ...

is there anything like this ?

peter

-- 
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at



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

Date: Thu, 13 Sep 2001 07:29:10 GMT
From: "Nick Schrock" <schrockn@umich.edu>
Subject: io redirection with system command
Message-Id: <afZn7.46293$ya.494594@typhoon.mw.mediaone.net>

I'm a relative newbie at perl but I'm running into a problem that I couldn't
find an answer to on the spec. Basically I'm just trying to write a testing
script for a simple program that redirects files to stdin and stdout to a
file.

So I write a some code such as:
*****************
@producecommand = ("./a.out","<", $infile, ">" , $producefile)
print Dumper(@producecommand); // Data::Dumper, clearly
system(@producecommand) == 0
        or die "system failed: $? \n";
******************

I know that the command is valid because when I type the same thing in my
shell character for character the command works fine and exits normally.
When I execute this code in perl the new process is waiting for input for
stdio. Can you not redirect a file to stdin using the system command? Or is
there a specific way to do such a thing...


                        Nick Schrock
                        schrockn@umich.edu




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

Date: Thu, 13 Sep 2001 09:45:15 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: io redirection with system command
Message-Id: <cjo0qtsm3gsl3k9cb2nosdqff7haptd4ur@4ax.com>

Hi,

On Thu, 13 Sep 2001, "Nick Schrock" <schrockn@umich.edu> wrote:
[...]
>@producecommand = ("./a.out","<", $infile, ">" , $producefile)
>print Dumper(@producecommand); // Data::Dumper, clearly
>system(@producecommand) == 0
>        or die "system failed: $? \n";
[...]
>When I execute this code in perl the new process is waiting for input for
>stdio.
[...]

"perldoc -f system" is your friend:

: If there is more than one argument in LIST, or if LIST is an array
: with more than one value, starts the program given by the first
: element of the list with arguments given by the rest of the list.
: If there is only one scalar argument, the argument is checked
: for shell metacharacters, and if there are any, the entire argument
: is passed to the system's command shell for parsing (this is
: /bin/sh -c on Unix platforms, but varies on other platforms).

So, what you do is call "a.out '<' 'infilename' '>' 'outfilename'".
Use system with a scalar, i.e.

    system("./a.out <$infile >$outfile");

and you should be fine.

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Thu, 13 Sep 2001 08:46:39 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: io redirection with system command
Message-Id: <3BA0AAAF.29D0158B@earthlink.net>

Nick Schrock wrote:
> 
> I'm a relative newbie at perl but I'm running into a problem that I
> couldn't find an answer to on the spec. Basically I'm just trying to
> write a testing script for a simple program that redirects files to
> stdin and stdout to a file.
> 
> So I write a some code such as:
> *****************
> @producecommand = ("./a.out","<", $infile, ">" , $producefile)
> print Dumper(@producecommand); // Data::Dumper, clearly
> system(@producecommand) == 0
>         or die "system failed: $? \n";
> ******************
> 
> I know that the command is valid because when I type the same thing in
> my shell character for character the command works fine and exits
> normally.

That's because the shell is interpreting > and < and doing the
redirection.

> When I execute this code in perl the new process is waiting for input
> for stdio.

That's because you have passed the >, <, and filenames as arguments to
the command -- normally, the command wouldn't see them, but by passing
them in as a list, it does.

> Can you not redirect a file to stdin using the system command?

Not directly.  But if you pass a single string to the system command,
and if the string contains shell metacharacters, it will in turn pass it
to the shell.

> Or is there a specific way to do such a thing...

There's two solutions: 1, pass a string with shell metacharacters,
rather than pass a list.  2, do the redirection yourself.

Solution 1 would be:
	system("./a.out < $infile > $outfile");
Solution 2 would be something like:
	defined($pid = fork) or die "fork: $!";
	if( not $pid ) {
		open(STDIN, "<", $infile);
		open(STDOUT, "<", $outfile);
		exec "a.out";
		die "Couldn't exec a.out: $!";
	}
	waitpid $pid, 0;
Or:
	open( INF_FOR_A_OUT,  "<", $infile );
	open( OUTF_FOR_A_OUT, ">", $outfile );
	my $pid = open2( ">&OUTF_FOR_A_OUT",  "<&INF_FOR_A_OUT",
		"a.out" );
	waitpid $pid, 0;

In both cases, you have to have call waitpid to be sure that the program
has finished.

There are also other ways to use open2/open3... one one way might to run
your program without using temp files.

Eg:
	my $pid = open2( RDFH, WRFH, "a.out" );
	foreach( @stuff_to_write ) {
		print WRFH $_;
		push @stuff_thatwas_read, scalar <RDFH>;
	}
	waitpid $pid, 0;

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


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

Date: Thu, 13 Sep 2001 15:41:08 +0800
From: "Wee" <kekwee@cwasia.net.sg>
Subject: Need Help
Message-Id: <3ba0634d@news>

This is a multi-part message in MIME format.

------=_NextPart_000_001F_01C13C6A.81DF9CC0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi All,

Can any1 advise me on the follows :

Is there anything wrong on the following statement?

 $a =3D " /usr/local/arts | ls -lrt | awk {'print $5'} | tail -1";

I encounter the following error message while trying to run it "Use of =
uninitialized value in concatenation (.)" =20



I am trying to grep the process number the process number of the logs, =
column 5 <89676060>=20

[root@netflow arts]# ls -lrt
total 87712
drwxr-xr-x    3 root     root         4096 Jun 22 12:26 man
drwxr-xr-x    3 root     root         4096 Jun 22 12:37 include
drwxr-xr-x    3 root     root         4096 Jun 22 12:37 lib
drwxr-xr-x    3 root     root         4096 Jun 22 12:43 data
drwxr-xr-x    3 root     root         4096 Jun 23 00:14 contrib
drwxr-xr-x    2 root     root         4096 Jun 23 01:29 saved
drwxr-xr-x    2 root     root         4096 Jun 28 23:25 bgp
drwxr-xr-x    5 root     root         4096 Jul  5 23:00 graphs
drwxr-xr-x    2 root     root         4096 Aug  2 13:52 bin
drwxr-xr-x    2 root     root         4096 Aug 23 14:44 etc
drwxr-xr-x    2 root     root         4096 Aug 30 18:54 sbin
-rw-r--r--    1 root     root     89676060 Sep 10 10:45 flowscan.log
[root@netflow arts]#=20


Thanks
Wee


------=_NextPart_000_001F_01C13C6A.81DF9CC0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 5.50.4807.2300" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=3DArial size=3D2></FONT><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi All,</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Can any1 advise me on the follows =
:</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Is there anything wrong on the =
following=20
statement?</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>&nbsp;$a =3D " /usr/local/arts | ls =
-lrt | awk=20
{'print $5'} | tail -1";</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I encounter the following error message =
while=20
trying to run it <STRONG>"Use of uninitialized value in concatenation=20
(.)"</STRONG>&nbsp;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am trying to grep the process number =
the process=20
number of the logs, column 5 &lt;89676060&gt;&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>[root@netflow arts]# ls -lrt<BR>total=20
87712<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 22 12:26=20
man<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 22 12:37=20
include<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 22 12:37=20
lib<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 22 12:43=20
data<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 3 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 23 00:14=20
contrib<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 23 01:29=20
saved<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jun 28 23:25=20
bgp<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 5 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Jul&nbsp; 5 =
23:00=20
graphs<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Aug&nbsp; 2 =
13:52=20
bin<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Aug 23 14:44=20
etc<BR>drwxr-xr-x&nbsp;&nbsp;&nbsp; 2 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4096 Aug 30 18:54=20
sbin<BR>-rw-r--r--&nbsp;&nbsp;&nbsp; 1 root&nbsp;&nbsp;&nbsp;&nbsp;=20
root&nbsp;&nbsp;&nbsp;&nbsp; <STRONG>89676060</STRONG> Sep 10 10:45=20
flowscan.log<BR>[root@netflow arts]# <BR></FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>Wee</FONT></DIV>
<DIV><FONT face=3DArial =
size=3D2>&nbsp;</DIV></FONT></FONT></DIV></BODY></HTML>

------=_NextPart_000_001F_01C13C6A.81DF9CC0--



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

Date: 13 Sep 2001 08:44:03 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Need Help
Message-Id: <slrn9q0sf1.g7r.rgarciasuarez@rafael.kazibao.net>

Wee wee'd in comp.lang.perl.misc:
} This is a multi-part message in MIME format.

Please don't.

} Is there anything wrong on the following statement?
} 
}  $a =3D " /usr/local/arts | ls -lrt | awk {'print $5'} | tail -1";

Well, "=3D" is not a valid Perl operator. Oh, unless your software
added it to confuse text-only newsreaders.

} I encounter the following error message while trying to run it "Use of =
} uninitialized value in concatenation (.)" =20

Yes, the $5 variable is not initialized (perl tries to interpolate it in
a double-quoted string). This shows that you use -w : good point for
you.

If you want to get the output of an external command, use the backticks
operator, also known as qx//, and described in perlop.

In fact I suggest to do :

    $x = `ls -lrt /usr/local/arts`;

and implement the awk and tail commands directly within the perl script.
This is shorter, safer, and more efficient.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Could Marconi have invented the radio if he hadn't by pure chance
spent years working at the problem? -- Monty Python, Penguins


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

Date: Thu, 13 Sep 2001 08:52:01 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Need Help
Message-Id: <3BA0ABF1.CA8800F7@earthlink.net>

> Wee wrote:
> 
> Hi All,
> 
> Can any1 advise me on the follows :
> 
> Is there anything wrong on the following statement?
> 
>  $a = " /usr/local/arts | ls -lrt | awk {'print $5'} | tail -1";
> 
> I encounter the following error message while trying to run it "Use of
> uninitialized value in concatenation (.)"

As Rafael said, the problem comes from perl trying to interpolate $5
into the string, and it's uninitialized.

> I am trying to grep the process number the process number of the logs,
> column 5 <89676060>

Unless I'm mistaken, that's the file size, not a process number.
You could simply do:
	my $logsize = -s "/usr/local/arts/flowscan.log";

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


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

Date: Thu, 13 Sep 2001 12:33:11 GMT
From: jonadab@bright.net (Jonadab the Unsightly One)
Subject: Re: Net::NNTP
Message-Id: <3ba0a700.552510@news.bright.net>

W i l l <W_i_l_l@me.com> wrote:

> Does anybody have a sample of a Net::NNTP  script that connects to a
> news server and posts messages with attachments? I looked over the
> Net::NNTP doc and didn't find any real info, maybe I don't know what
> im looking for.... 

Did the Net::NNTP doc have enough info that you can post messages?

Because there's nothing additional you need to know, as far
as Perl goes, to post messages with attachments.  Because the
attachments are just part of the body of the message; that's
how usenet works.  What you probably need is documentation
on MIME, which really has nothing to do with Perl as such,
although there might be a Perl module for it.

- jonadab


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

Date: Thu, 13 Sep 2001 06:37:25 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Parsing problem (Please HELP )
Message-Id: <3BA08C65.F75B838B@earthlink.net>

Laird wrote:
> 
> Benjamin Goldberg wrote:
> > Laird wrote:
> > >
> > > Hi everybody,
> > >
> > > I changed the file in order to be more explicit.
> > > This is what it looks like.
> > >
> > > ---
> > > #       name-1
> > > service         numberone              COMMENTS
> > >
> > > #       name-2
> > > service         numbertwo              COMMENTS
> > >
> > > #       name-3
> > > service         numberthree
> > >
> > > #       name-4  name-5                  COMMENTS
> > > service         numberfour
> > > service         numberfive
> > >
> > > #       name-other                      COMMENTS
> > > service         numberother
> > >
> > > ---
> > >
> > > I'm trying to put numberone after name-1
> > > numbertwo after name-2
> > > numberthree after name-3
> > > numberfour after name-4
> > > numberfive after name-5
> > > numberother after name-other
> >
> > my @names;
> > while( <DATA> ) {
> >       if( /^#/ ) {
> >               @names = /\b(name-\S+)/g;
> >       } else if( my ($service) = /^\S+\s+(\S+)/ ) {
> >               foreach my $name ( @names ) {
> >                       print "name    = $name\n";
> >                       print "service = $service\n";
> >               }
> >       }
> > }
> 
> Hello
> 
> This seems to work half way. The outcome is this:
[snip]

After taking a second look at what you wanted, I think I see my mistake.

my @names;
while( <DATA> ) {
        if( /^#/ ) {
                push @names, /\b(name-\S+)/g;
        } else if( my ($service) = /^\S+\s+(\S+)/ ) {
                print "name    = ", unshift(@names), "\n";
                print "service = $service\n";
        }
}


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


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

Date: Thu, 13 Sep 2001 12:40:58 +0200
From: "Sasha" <sasha_lui@yahoo.com>
Subject: Perl and SNMP
Message-Id: <9nq1bs$4bb$1@newstoo.ericsson.se>

This is a multi-part message in MIME format.

------=_NextPart_000_0048_01C13C51.56992860
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi folks,

I am a new beginer in Perl programming. I was wondering if there is any =
library and exapmle for reading SNMP trap from an agent. I am using SUN =
machine, and i want to receive and print the SNMP trap. If you know good =
websit with some example of perl for using SNMP, i will be very great =
full.

Thanks inadvance    Sasha

------=_NextPart_000_0048_01C13C51.56992860
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>
<DIV><FONT face=3DArial size=3D2>Hi folks,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I am a new beginer in Perl programming. =
I was=20
wondering if there is any library and exapmle for reading SNMP trap from =
an=20
agent. I am using SUN machine, and i want to receive and print&nbsp;the =
SNMP=20
trap. If you know good websit with some example of perl for =
using&nbsp;SNMP, i=20
will be very great full.</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks inadvance&nbsp;&nbsp;&nbsp;=20
Sasha</FONT></DIV></FONT></DIV></BODY></HTML>

------=_NextPart_000_0048_01C13C51.56992860--



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

Date: 13 Sep 2001 06:14:28 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Perl and SNMP
Message-Id: <9nq4ek$o3e$1@charity.cs.utexas.edu>

In article <9nq1bs$4bb$1@newstoo.ericsson.se>,
Sasha <sasha_lui@yahoo.com> wrote:
>I am a new beginer in Perl programming. I was wondering if there is any =
>library and exapmle for reading SNMP trap from an agent. I am using SUN =
>machine, and i want to receive and print the SNMP trap. If you know good =
>websit with some example of perl for using SNMP, i will be very great =
>full.

There are numerous SNMP modules on CPAN.  Try going to
http://search.cpan.org/ and searching for "snmp".  You should get back
a large listing, and the documentation for each one should have some
example code.

  - Logan
-- 
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)


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

Date: Thu, 13 Sep 2001 22:04:24 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Printing in Perl
Message-Id: <bi1o7.12$7L7.544884@news.interact.net.au>


"Graham W. Boyes - TOAO.net" <me@REMOVETHIStoao.net> wrote in message
news:iETn7.5510$jY.86319@news1.rdc1.bc.home.com...
> > Is there some sort of information you want to give us about what
> > operating system you're using and/or how you're trying to send to the
> > printer (over the network, through the OS's queuing system, etc.)?
>
> I'm using a Windows 98 boot disk that networks to a printer on a Windows
> 2000 Professional machine.  I'm using the latest version of the DJGPP
MS-DOS
> port.  The printer is connected via parallel to the Win2K Machine.  I open
> LPT1 like a file and print to it, but the printer won't print the data
until
> I hit the OK button on the printer.
>
> Logan, be more friendly.  Lighten up.  Smile.  Life's too short to yell
and
> scream at people.

How on earth did you manage to interpret Logan's extremely useful questions
as being non friendly and screaming?




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

Date: 13 Sep 2001 13:47:33 +0100
From: brianr@liffe.com
Subject: Re: Printing in Perl
Message-Id: <vt7kv3cl5m.fsf@liffe.com>

logan@cs.utexas.edu (Logan Shaw) writes:
> Actually, if it's DOS, one thing I'd try is the good old naive "send a
> control-Z" and see what happens.  Maybe something like this:
> 
> 	open (PRINTER, ">LPT1:") or die horribly;
> 	print PRINTER @junk;
> 	print PRINTER "\x1A";
> 	close PRINTER;
> 
> That's a total stab in the dark, but remember all I said is that I'd
> try it, not that it'd work.  :-)

I seem to remember (from long ago) that M$ print spoolers used
control-D ("\X04") as a job separator character. I also vaguely
remember that when I directed the printer output from a M$ application
to a file that it had control-D at both the start and end. It may still
be the case. Worth a try.

HTH

-- 
Brian Raven

(Never thought I'd be telling Malcolm and Ilya the same thing... :-)
             -- Larry Wall in <199711071819.KAA29909@wall.org>


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

Date: 13 Sep 2001 07:53:38 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: Problem after Alarm interrupts system call
Message-Id: <slrn9q0pg0.pum.vek@pharmnl.ohout.pharmapartners.nl>

On Wed, 12 Sep 2001 17:40:40 GMT,
    Kirk Bauer <kirk@wuffo.togetherweb.com> wrote:


>The following simple program illustrates a problem I have.
>If SIGALRM interrupts the "system" command, then all
>signals from then on appear to be ignored.
>
>while (1) {
>   eval {
>      # Set a timeout
>      local $SIG{ALRM} = sub { die "alarm\n" }; # NB: \n required
>      alarm 5;
>      # If you use the "sleep" command, everything works fine
>      #sleep 10;
>      # But, if you use the "system" command, all interrupts seem to not work
>      system("sleep 10");
>      # Disable timeout
>      alarm 0;
>   };
>   if ($@) {
>      print "Got here: $@";
>      die unless $@ eq "alarm\n";   # propagate unexpected errors
>      # timed out
>      print "Timed out... now CTRL-C will not kill the program\n";
>   }
>   sleep (1);
>}
>
>Any help you could give me would be greatly appreciated!
>This problem happens on both:
>perl-5.6.0
>perl-5.00503
>




Running strace on the example shows following:  Note that perl sets
SIGINT to ignore and never restores SIGINT.  Can't tell why.

sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}) = 0
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
--- SIGINT (Interrupt) ---
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
--- SIGINT (Interrupt) ---
sigaction(SIGINT, {SIG_IGN}, NULL)      = 0
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
--- SIGINT (Interrupt) ---
sigaction(SIGINT, {SIG_IGN}, NULL)      = 0
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0

Result of running strace:
Version information for perl below.

execve("/usr/bin/perl", ["perl", "/tmp/.x2"], [/* 19 vars */]) = 0
open("/etc/ld.so.preload", O_RDONLY)    = -1 ENOENT
open("/etc/ld.so.cache", O_RDONLY)      = 4
fstat(4, {st_mode=0, st_size=0, ...})   = 0
close(4)                                = 0
open("/lib/libnsl.so.1", O_RDONLY)      = 4
close(4)                                = 0
open("/lib/libdl.so.2", O_RDONLY)       = 4
close(4)                                = 0
open("/lib/libm.so.6", O_RDONLY)        = 4
close(4)                                = 0
open("/lib/libc.so.6", O_RDONLY)        = 4
close(4)                                = 0
open("/lib/libcrypt.so.1", O_RDONLY)    = 4
close(4)                                = 0
personality(PER_LINUX)                  = 0
getpid()                                = 27077
getuid()                                = 227
geteuid()                               = 227
getgid()                                = 227
getegid()                               = 227
time([1000366369])                      = 1000366369
sigprocmask(SIG_BLOCK, NULL, [])        = 0
open("/tmp/.x2", O_RDONLY)              = 4
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
fstat(4, {st_mode=0, st_size=0, ...})   = 0
getpid()                                = 27077
fstat(4, {st_mode=0, st_size=0, ...})   = 0
read(4, "\n\n\nwhile (1) {\n   eval {\n  "..., 4096) = 570
read(4, "", 4096)                       = 0
close(4)                                = 0
sigprocmask(SIG_BLOCK, NULL, [])        = 0
sigaction(SIGALRM, NULL, {SIG_DFL})     = 0
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
sigaction(SIGALRM, {0x8086060, [], 0}, {SIG_DFL}) = 0
alarm(5)                                = 0
fork()                                  = 27078
sigaction(SIGINT, {SIG_IGN}, {SIG_DFL}) = 0
sigaction(SIGQUIT, {SIG_IGN}, {SIG_DFL}) = 0
wait4(27078, 0xbffffb90, 0, NULL) = ? ERESTARTSYS
--- SIGALRM (Alarm clock) ---
sigaction(SIGALRM, {SIG_DFL}, {0x8086060, [], SA_NOCLDSTOP|0x3a}) = 0
sigprocmask(SIG_SETMASK, [], NULL)      = 0
fstat(1, {st_mode=S_ISVTX|0400, st_size=0, ...}) = 0
ioctl(1, TCGETS, {B9600 opost isig icanon echo ...}) = 0
--- SIGCHLD (Child exited) ---
write(1, "Got here: alarm\n", 16)       = 16
write(1, "Timed out... now CTRL-C will not"..., 50) = 50
time([1000366379])                      = 1000366379
nanosleep(0xbffffc8c, 0xbffffc8c, 0x400cae7c, 0x80d7cd8, 0x8056bd0) = 0
time([1000366380])                      = 1000366380
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
sigaction(SIGALRM, {0x8086060, [], 0}, {SIG_DFL}) = 0
alarm(5)                                = 0
fork()                                  = 27081
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
sigaction(SIGQUIT, {SIG_IGN}, {SIG_IGN}) = 0
wait4(27081, [WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 27081
--- SIGALRM (Alarm clock) ---
--- SIGCHLD (Child exited) ---
sigaction(SIGALRM, {SIG_DFL}, {0x8086060, [], SA_NOCLDSTOP|0x3a}) = 0
sigprocmask(SIG_SETMASK, [], NULL)      = 0
write(1, "Got here: alarm\n", 16)       = 16
write(1, "Timed out... now CTRL-C will not"..., 50) = 50
time([1000366390])                      = 1000366390
nanosleep(0xbffffc8c, 0xbffffc8c, 0x400cae7c, 0x80d7cd8, 0x8056bd0) = -1 EINTR
--- SIGINT (Interrupt) ---
time([1000366391])                      = 1000366391
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
sigaction(SIGALRM, {0x8086060, [], 0}, {SIG_DFL}) = 0
alarm(5)                                = 0
fork()                                  = 27084
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
sigaction(SIGQUIT, {SIG_IGN}, {SIG_IGN}) = 0
wait4(27084, 0xbffffb90, 0, NULL) = ? ERESTARTSYS
--- SIGINT (Interrupt) ---
wait4(27084, [WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 27084
--- SIGCHLD (Child exited) ---
sigaction(SIGINT, {SIG_IGN}, NULL)      = 0
sigaction(SIGQUIT, {SIG_IGN}, NULL)     = 0
alarm(0)                                = 4
sigaction(SIGALRM, {SIG_DFL}, {0x8086060, [], 0}) = 0
time([1000366393])                      = 1000366393
nanosleep(0xbffffc8c, 0xbffffc8c, 0x400cae7c, 0x80d7cd8, 0x8056bd0) = 0
time([1000366394])                      = 1000366394
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
sigaction(SIGALRM, {0x8086060, [], 0}, {SIG_DFL}) = 0
alarm(5)                                = 0
fork()                                  = 27085
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
sigaction(SIGQUIT, {SIG_IGN}, {SIG_IGN}) = 0
wait4(27085, 0xbffffb90, 0, NULL) = ? ERESTARTSYS
--- SIGINT (Interrupt) ---
wait4(27085, [WIFEXITED(s) && WEXITSTATUS(s) == 0], 0, NULL) = 27085
--- SIGCHLD (Child exited) ---
sigaction(SIGINT, {SIG_IGN}, NULL)      = 0
sigaction(SIGQUIT, {SIG_IGN}, NULL)     = 0
alarm(0)                                = 4
sigaction(SIGALRM, {SIG_DFL}, {0x8086060, [], SA_RESTART}) = 0
time([1000366395])                      = 1000366395
nanosleep(0xbffffc8c, 0xbffffc8c, 0x400cae7c, 0x80d7cd8, 0x8056bd0) = 0
time([1000366396])                      = 1000366396
sigaction(SIGALRM, {SIG_DFL}, {SIG_DFL}) = 0
sigaction(SIGALRM, {0x8086060, [], 0}, {SIG_DFL}) = 0
alarm(5)                                = 0
fork()                                  = 27086
sigaction(SIGINT, {SIG_IGN}, {SIG_IGN}) = 0
sigaction(SIGQUIT, {SIG_IGN}, {SIG_IGN}) = 0
wait4(27086, 

Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration:
  Platform:
    osname=linux, osvers=2.0.35, archname=i386-linux
    uname='linux 2.0.35 #2 mon dec 7 17:56:48 cet 1998 i686 unknown '
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef useperlio=undef d_sfio=undef
  Compiler:
    cc='cc', optimize='-O2 -m486 -fno-strength-reduce', gccversion=2.7.2.3
    cppflags='-Dbool=char -DHAS_BOOL'
    ccflags ='-Dbool=char -DHAS_BOOL'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lposix -lcrypt
    libc=, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'


Characteristics of this binary (from libperl): 
  Built under linux
  Compiled at Sep  3 2001 15:17:17
  @INC:
    /usr/lib/perl5/5.00503/i386-linux
    /usr/lib/perl5/5.00503
    /usr/lib/perl5/site_perl/5.005/i386-linux
    /usr/lib/perl5/site_perl/5.005
    .




-- 
Villy


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

Date: Thu, 13 Sep 2001 10:12:31 +0100
From: "Andy Marden" <amarden@altavista.net>
Subject: Regular Expression Peculiarity
Message-Id: <9npt9p$d9b$1@neptunium.btinternet.com>

I must be missing something here!

@values = /(%\w+)|##(\w+)/g;

is behaving strangely. I'm expecting a list of values which match either
pattern in my string, in the order they appear in the string. The ordering's
fine, but I get values which are blank between them.

@values = /(%\w+)/g;

gives me 3 values - as expected from my string.

@values = /##(\w+)/g;

gives me 8 values - as expected.

But the combined pattern string gives me 23 values, including blanks.

I'm sure it must be simple, but I can't work it out.

Below is the string that's being matched. Any ideas?

Cheers

Andy

'

%dentist=
   /^\d
    (\d{3})  ##dentist_id
    (.*)     ##dentist_name
   /x if /^1/;

%patient=(
    $dentist{dentist_id}, ##dentist_id
   /^\d
    (\d{4})               ##patient_id
    (.*)                  ##patient_name
   /x) if /^2/;

%treatment=(
    $dentist{dentist_id}, ##dentist_id
    $patient{patient_id}, ##patient_id
   /^\d
    (\d{3})               ##treatment_id
    (.*)                  ##treatment_name
   /x) if /^3/;
'





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

Date: 13 Sep 2001 09:29:05 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Regular Expression Peculiarity
Message-Id: <slrn9q0v3e.gsf.rgarciasuarez@rafael.kazibao.net>

Andy Marden wrote in comp.lang.perl.misc:
} I must be missing something here!
} 
} @values = /(%\w+)|##(\w+)/g;
} 
} is behaving strangely. I'm expecting a list of values which match either
} pattern in my string, in the order they appear in the string. The ordering's
} fine, but I get values which are blank between them.

Let's try to simplify this example.

    perl -le 'print join ",", "ab" =~ /(a)|(b)/g'

prints :

    a,,,b

What's happening here ? Look at perlop again :

	The "/g" modifier specifies global pattern matching--that is,
	matching as many times as possible within the string.  How it
	behaves depends on the context.  In list context, it returns a
	list of the substrings matched by any capturing parentheses in
	the regular expression.  If there are no parentheses, it returns
	a list of all the matched strings, as if there were parentheses
	around the whole pattern.

That is, it returns in our case the list
    ( $1 from 1st match,
      $2 from 1st match,
      $1 from 2nd match,
      $2 from 2nd match, ... )

Hope this helps,

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
use lib sub{$_=$_[1];y;_.mp; ,\n;d;print;
open+0;*0};require Just_another_Perl_hacker;1


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

Date: 13 Sep 2001 02:55:14 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Regular Expression Peculiarity
Message-Id: <m1sndr2z5p.fsf@halfdome.holdit.com>

>>>>> "Rafael" == Rafael Garcia-Suarez <rgarciasuarez@free.fr> writes:

Rafael> Let's try to simplify this example.

Rafael>     perl -le 'print join ",", "ab" =~ /(a)|(b)/g'

Rafael> prints :

Rafael>     a,,,b

Rafael> What's happening here ? Look at perlop again :

Rafael> 	The "/g" modifier specifies global pattern matching--that is,
Rafael> 	matching as many times as possible within the string.  How it
Rafael> 	behaves depends on the context.  In list context, it returns a
Rafael> 	list of the substrings matched by any capturing parentheses in
Rafael> 	the regular expression.  If there are no parentheses, it returns
Rafael> 	a list of all the matched strings, as if there were parentheses
Rafael> 	around the whole pattern.

Rafael> That is, it returns in our case the list
Rafael>     ( $1 from 1st match,
Rafael>       $2 from 1st match,
Rafael>       $1 from 2nd match,
Rafael>       $2 from 2nd match, ... )

It's actually nicer than that:

$ perl -le 'print join ",", map defined $_ ? $_ : "undef", "ab" =~ /(a)|(b)/g'
a,undef,undef,b
$

Note that the branches not taken return undef, not an empty string.
Pretty easy to check to see if that branch participated or not.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Thu, 13 Sep 2001 13:29:25 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: scalar global search
Message-Id: <3ba09896$1@e-post.inode.at>


Can anyone point me in deeper information about the g-option for the m//-op.
I use m//g in scalar context very frequently, but dont know which factors 
influence the internal counter for this 'incremental' search. Is this 
counter bound to the current namespace or maybe to the search variable.
In the latter case I would be able to do m//g parallel on different strings.
like

$t1="a=b;c=d"; $t2="e:f;g:h";
$t1=~/(\w)=(\w)/g;
f($1,$2);
$t2=~/(\w):(\w)/g;
f($1,$2);
$t1=~/(\w)=(\w)/g;
f($1,$2);
$t2=~/(\w):(\w)/g;
f($1,$2);
sub f{print join("\t",@_),"\n";}


While this example works fine here, I'd like to know more and for sure, 
cause I write mod_perl scripts and always have the paranoia that different 
tasks access the same namespace ..

perlop and perlre didnt give me the info what I need, but maybe I'm just 
thinking the wrong way.

thnx,
peter


-- 
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at



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

Date: 13 Sep 2001 11:55:05 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: scalar global search
Message-Id: <slrn9q17l9.hb7.rgarciasuarez@rafael.kazibao.net>

peter pilsl wrote in comp.lang.perl.misc:
> 
> Can anyone point me in deeper information about the g-option for the m//-op.
> I use m//g in scalar context very frequently, but dont know which factors 
> influence the internal counter for this 'incremental' search. Is this 
> counter bound to the current namespace or maybe to the search variable.
> In the latter case I would be able to do m//g parallel on different strings.

The reading of the section of perlfunc that describes the pos() function
may help you.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
Much programming is best done with techniques that do not fall within a
narrow definition of "object-oriented." -- Bjarne Stroustrup


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

Date: Thu, 13 Sep 2001 07:42:32 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Search and Replace and Reformat
Message-Id: <3BA09BA8.BE45C99@earthlink.net>

dh wrote:
> 
> Hi - I have a 6 meg flat file that I'd like to reformat. Here's a
> small example of its current state:
[snip]

#!/usr/local/bin/perl -wln
use strict; BEGIN { $, = "|" }
if( /\AID_Number: (.*)/ ) {
	$::ID_Number = $1;
	<>; # discard one line
} else {
	print $::ID_Number => (split)[0..6];
}
__END__

NB: This code is untested.

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


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

Date: Thu, 13 Sep 2001 16:00:33 +0530
From: "Anupam" <anpandey@cisco.com>
Subject: Re: system() command not wrking in cgi / works fine in .pl
Message-Id: <1000377350.919329@sj-nntpcache-3>

Hi ,

Now i'm using CGI
also absolute path with system. as suggested .

command is :-

sql_user_connection has entry like :-
echo "select * from user_connection where snmp_index=5678" | dbaccess
stratacom

system("/usr/users/svplus/webServer/cgi-bin/sql_user_connection > 123")
if i execute the script contaning this line from command prompt like
perl file_name ;
output file 123 gets created as expected ,

if the same is executed through web browser
output file 123 gets created of zero size

Please advise

~Anupam

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9pvghh.ain.tadmc@tadmc26.august.net...
> Anupam <anpandey@cisco.com> wrote:
>
>
> >system ("./sql_user_connection ");
>           ^^
>           ^^ current directory
>
>
> What is your current directory when run as a CGI?
>
> I'll betcha it isn't the same directory you were in when
> you ran it from the command line.
>
> chdir() to the correct directory, or use absolute pathnames.
>
>
> >perl A.pl --------------> this works fine .
> >
> >If i use the same thing in a cgi script -- i.e
> >i call this page from my web browser :-
> >
> >redirection file i.e result is always blank .
>
>
> And what is in the server log? Error messages are helpful
> for fixing errors.
>
> Or, have the error messages sent to the browser instead:
>
>    perldoc -q CGI
>
>       "How can I get better error messages from a CGI program?"
>
>
> >Please help me ..
>
>
> Below is a whole lot of help that you didn't even know you needed :-)
>
>
> >#!/usr/local/bin/perl -w
>
> use strict;
>
> >require "cgi-bin.pl";
>
> use CGI;  # cgi-bin.pl is really really old
>
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas




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

Date: Thu, 13 Sep 2001 12:56:14 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: system() command not wrking in cgi / works fine in .pl
Message-Id: <1p31qt41ga1qtt017ot309omee0623i022@4ax.com>

On Thu, 13 Sep 2001, "Anupam" <anpandey@cisco.com> wrote:
>system("/usr/users/svplus/webServer/cgi-bin/sql_user_connection > 123")
>if i execute the script contaning this line from command prompt like
>perl file_name ;
>output file 123 gets created as expected ,
>
>if the same is executed through web browser
>output file 123 gets created of zero size
>
>Please advise

If the file is created, then the system() call is working. I don't
have a clue what the program you run is supposed to do, but at this
point it has stopped to be a Perl problem.

Anyways, could it be that your external program depends on environment
settings that are in your account, but not in the environment the web
server is running under? Could it be that it uses the current
username/userid?

HTH,
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: 13 Sep 2001 08:18:28 -0400
From: stanb@panix.com (Stan Brown)
Subject: Tk::fileevent eating all my CPU cycles
Message-Id: <9nq86k$om2$1@panix2.panix.com>

I'm working on a perlTK script which will fetch, and edit datasets from an
Oracle DB.

Some of these datasets are larg (1 million  + rows). In an effort to make
this thing a little easier to use, I have revamped it so that the actul DBI
query is done by a child task that gets forked. The data is returned to the
parent using Storable.

Turns out that does not work for large datasets, so I have broken it up so
that individual rows are returned to the parent. Which brings up the next
problem. 

While this data is being returned (using Tk::fileevent) The updating of teh
wdigets virtualy stops. I figure that mainloop() is so bust servicng the
many, many calbbacks generated by fileevent, that it just takes a while to
do anythign else.

Now since it takes a very long time to get the data back this way, I am
reluctant to just stick a micro sleep in wither the child's loading loop,
or the fileevnt callback.

Any sugestiosn as to how to make the widget updates have a bit higher
priority in this?




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

Date: Thu, 13 Sep 2001 12:35:09 GMT
From: "Ben Kennedy" <bkennedy99@Home.com>
Subject: Re: Tk::fileevent eating all my CPU cycles
Message-Id: <1K1o7.6028$5A3.2025967@news1.rdc2.pa.home.com>


"Stan Brown" <stanb@panix.com> wrote in message
news:9nq86k$om2$1@panix2.panix.com...

> Any sugestiosn as to how to make the widget updates have a bit higher
> priority in this?

You can use the update method on your main window, which will explictly
update everything - good for tight loops with sockets, DBI, etc

--Ben Kennedy




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

Date: Thu, 13 Sep 2001 17:12:01 +0800
From: "Dai Yuwen" <yuwen@microtek.com.cn>
Subject: Why the client still waits for input?
Message-Id: <9npt9a$29bk$1@news.cz.js.cn>

Hi, all

The following code is from the 'perlipc' manpage.  It's a interactive
client.  But when I press '^D' to end the seesion, the client still waits
for input.  Any idea?  Thank in advance.

best regards,
Dai Yuwen

#! /usr/bin/perl -w

# interactive client

use strict;
use IO::Socket;

my ($host, $port, $kidpid, $handle, $line);

unless (@ARGV >= 2) { die "usage: $0 host port\n";}
$host = shift @ARGV;
$port = shift @ARGV;

# create a tcp connection to the specified host and port
$handle = IO::Socket::INET->new (Proto    => "tcp",
PeerAddr => $host,
PeerPort => $port)
    or die "can not connect to port $port on $host: $!";

$handle->autoflush (1);
print STDERR "[Connected to $host:$port]\n";

# split the program into two processes, identical twins
die "cann't fork: $!" unless defined ($kidpid = fork ());

# the if{} block runs only in the parent process
if ($kidpid) {
    # copy the socket to standard output
    while (defined ($line = <$handle>)) {
print STDOUT $line;
    }
    kill ("TERM", $kidpid);
}
# the else{} block runs only in the child process
else {
    # copy standard input to the socket
    while ( ($line = <STDIN>)) {
print $handle $line;
    }

}





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

Date: Thu, 13 Sep 2001 11:44:00 +0100
From: "Simon Oliver" <simon.oliver@umist.ac.uk>
Subject: Re: Why the client still waits for input?
Message-Id: <3ba091ae$1@news.umist.ac.uk>

Many shells require the ^D to be at the start of a new line - and I seem to
remeber that on Win95 you need to use ^Z instead?

--
  Simon Oliver

----- Original Message -----
From: "Dai Yuwen" <yuwen@microtek.com.cn>
Newsgroups: comp.lang.perl.misc
Sent: Thursday, September 13, 2001 10:12 AM
Subject: Why the client still waits for input?


> Hi, all
>
> The following code is from the 'perlipc' manpage.  It's a interactive
> client.  But when I press '^D' to end the seesion, the client still waits
> for input.  Any idea?  Thank in advance.
>
> best regards,
> Dai Yuwen
>
> #! /usr/bin/perl -w
>
> # interactive client
>
> use strict;
> use IO::Socket;
>
> my ($host, $port, $kidpid, $handle, $line);
>
> unless (@ARGV >= 2) { die "usage: $0 host port\n";}
> $host = shift @ARGV;
> $port = shift @ARGV;
>
> # create a tcp connection to the specified host and port
> $handle = IO::Socket::INET->new (Proto    => "tcp",
> PeerAddr => $host,
> PeerPort => $port)
>     or die "can not connect to port $port on $host: $!";
>
> $handle->autoflush (1);
> print STDERR "[Connected to $host:$port]\n";
>
> # split the program into two processes, identical twins
> die "cann't fork: $!" unless defined ($kidpid = fork ());
>
> # the if{} block runs only in the parent process
> if ($kidpid) {
>     # copy the socket to standard output
>     while (defined ($line = <$handle>)) {
> print STDOUT $line;
>     }
>     kill ("TERM", $kidpid);
> }
> # the else{} block runs only in the child process
> else {
>     # copy standard input to the socket
>     while ( ($line = <STDIN>)) {
> print $handle $line;
>     }
>
> }
>
>
>




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

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


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