[25224] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 7469 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 1 09:05:48 2004

Date: Wed, 1 Dec 2004 06:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 1 Dec 2004     Volume: 10 Number: 7469

Today's topics:
        [Proposal] Q: RE lexical scopes and sub declarations <bik.mido@tiscalinet.it>
        A problem with fork() and managing processes <bik.mido@tiscalinet.it>
    Re: Buy Programming Books (krakle)
        FAQ 3.26: Why don't Perl one-liners work on my DOS/Mac/ <comdog@panix.com>
        GD Graph Pie Formatting (Pascal)
    Re: GD Graph Pie Formatting <spamtrap@dot-app.org>
        How to combine XPathScript with YAML? <franz@127.0.0.1>
    Re: how to manage phpBB, windows 2003 server and FreeBS (jiing)
    Re: how to manage phpBB, windows 2003 server and FreeBS (Jeremiah Foster)
    Re: how to manage phpBB, windows 2003 server and FreeBS <bik.mido@tiscalinet.it>
        Is this possible in perl? madhav_a_kelkar@hotmail.com
    Re: Is this possible in perl? <spamtrap@dot-app.org>
    Re: Is this possible in perl? <jurgenex@hotmail.com>
        Monitor a Serial Port (Win2k) (Kean)
    Re: PAR problems Win32 (Can't Spawn, line 372) (solved) burlo.stumproot@gmail.com
    Re: parse tr socket $buf <tassilo.von.parseval@rwth-aachen.de>
    Re: parse tr socket $buf dogdog@noemail.com
    Re: parse tr socket $buf <bart.lateur@pandora.be>
        Perl Timer (Mitchell Hulscher)
    Re: Perl Timer <jurgenex@hotmail.com>
    Re: Perl Timer <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Perl Timer (Mitchell Hulscher)
    Re: Perl Timer <tadmc@augustmail.com>
    Re: Redirecting STDOUT to Scalar behaves not as expecte <bik.mido@tiscalinet.it>
    Re: Redirecting STDOUT to Scalar behaves not as expecte <bik.mido@tiscalinet.it>
    Re: Regarding Usage on Perl <tintin@invalid.invalid>
        SMPT Connection Errors <simon.andrews@bbsrc.ac.uk>
    Re: split function syntax <bik.mido@tiscalinet.it>
    Re: SQLite - problem connecting to database (or doing a <bart.lateur@pandora.be>
        suid-perl deprecated... why? chris-usenet@roaima.co.uk
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 01 Dec 2004 12:49:04 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: [Proposal] Q: RE lexical scopes and sub declarations
Message-Id: <6p9rq0t22e83goc9bi2h0f76h15m8vp77d@4ax.com>

This is Yet Another Humble Proposal... I am aware of the risks of
exposing possibly naive ideas like this, but I'm asking anyway.

I wonder wether forward declaring a sub in a lexical scope could be
made to let the actual sub access variables lexically scoped to it. In
other words if

  {
      my $u;
      sub u;
  }
  
  # ...
  
  sub u { 
      $u;
  }

could be made to be implicitly equivalent to

  {
      my $u;
      sub u { 
  	$u;
      }
  }

Of course this a priori depends on p5p and on technical details, but
what I'd like to know is wether you would judge such a semantic
disruptive of anything or potentially useful from the UI point of
view. I've been working on a program recently in which I would have
liked to put all the subs at the end, but with forward declarations at
the top, one of which like above. IMHO it would have marked clearly
the structure of the program.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 01 Dec 2004 12:49:04 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: A problem with fork() and managing processes
Message-Id: <qnbrq09gleb8o99m9i9mok3brugg48pabo@4ax.com>

I hope that the subject is not too imprecise and that this is not too
OT (I am aware that part of the issue is OS-specific rather than
Perlish)...

I was experimenting with fork(), signals, and other process management
functions in perl. I am reproducing a minimal example here:


  #!/usr/bin/perl -l
  
  use strict;
  use warnings;
  
  sub busy ();
  sub rest();
  
  sleep 5;
  busy;
  
  sub busy () {  # Let the fun begin!! ;-)
      my $forked=0;
      my @family;
      for (1..7) {
  	defined (my $pid=fork) or
  	  warn "Couldn't fork: $!\n";
  	$forked *= 2;
  	if ($pid) {
  	    push @family, $pid;
  	} else { 
              @family=();
              $forked++;
  	}
      }
      
      local $SIG{TERM} = sub { 
  	kill 15, @family;
          waitpid $_, 0 for @family;
  	die "[$forked:$$] Stopping now: ",
            "signaled (@family)\n";
      };
      
      while (1) {
  	next if $forked;
  	kill 15, @family;
          goto &rest;
      }
  }
  
  sub rest () {
     sleep 10 while 1;
  }
  
  __END__


It should (i) fork() up to 127 copies of itself, (ii) kill them and
then go to rest.

Now, *generally* it works, *but* (i) it still leaves around exactly
seven <defunct> childs; (ii) what's worst, *in some cases*
(appearently at random), it leaves a small but variable number of
active childs too.


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 30 Nov 2004 21:18:00 -0800
From: krakle@visto.com (krakle)
Subject: Re: Buy Programming Books
Message-Id: <237aaff8.0411302118.8a8dd8c@posting.google.com>

Rich <webmaster@qubitcode.com> wrote in message news:<Xns95B0B175AEB6webmasterqubitcodeco@63.223.5.241>...
> QubitCode.com
  ^^^

Spam.

> 
> Offering programming books related to:

And not relating to this newsgroup:

> 
>     	C++

Offtopic.

>     	C#

Offtopic.

>     	Java

Offtopic.

>     	Javascript

Offtopic.

>     	HTML

Offtopic.

>     	Perl

:)


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

Date: Wed, 1 Dec 2004 11:03:01 +0000 (UTC)
From: PerlFAQ Server <comdog@panix.com>
Subject: FAQ 3.26: Why don't Perl one-liners work on my DOS/Mac/VMS system?
Message-Id: <cok8d5$d2k$1@reader1.panix.com>

This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with Perl.

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

3.26: Why don't Perl one-liners work on my DOS/Mac/VMS system?

    The problem is usually that the command interpreters on those systems
    have rather different ideas about quoting than the Unix shells under
    which the one-liners were created. On some systems, you may have to
    change single-quotes to double ones, which you must *NOT* do on Unix or
    Plan9 systems. You might also have to change a single % to a %%.

    For example:

        # Unix
        perl -e 'print "Hello world\n"'

        # DOS, etc.
        perl -e "print \"Hello world\n\""

        # Mac
        print "Hello world\n"
         (then Run "Myscript" or Shift-Command-R)

        # MPW
        perl -e 'print "Hello world\n"'

        # VMS
        perl -e "print ""Hello world\n"""

    The problem is that none of these examples are reliable: they depend on
    the command interpreter. Under Unix, the first two often work. Under
    DOS, it's entirely possible that neither works. If 4DOS was the command
    shell, you'd probably have better luck like this:

      perl -e "print <Ctrl-x>"Hello world\n<Ctrl-x>""

    Under the Mac, it depends which environment you are using. The MacPerl
    shell, or MPW, is much like Unix shells in its support for several
    quoting variants, except that it makes free use of the Mac's non-ASCII
    characters as control characters.

    Using qq(), q(), and qx(), instead of "double quotes", 'single quotes',
    and `backticks`, may make one-liners easier to write.

    There is no general solution to all of this. It is a mess.

    [Some of this answer was contributed by Kenneth Albanowski.]



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

Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short.  They represent an important
part of the Usenet tradition.  They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.

If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile.  If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.

Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release.  It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.

The perlfaq manual page contains the following copyright notice.

  AUTHOR AND COPYRIGHT

    Copyright (c) 1997-2002 Tom Christiansen and Nathan
    Torkington, and other contributors as noted. All rights 
    reserved.

This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.


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

Date: 30 Nov 2004 22:56:32 -0800
From: pascal@straec.com (Pascal)
Subject: GD Graph Pie Formatting
Message-Id: <3c155555.0411302256.5a3cbb6@posting.google.com>

I am trying to create dynamic bar charts using data from a database
and am having issues formatting it. The labels can be long so i use
vertical labels but the font is small and hard to read. I try setting
font but it doesn't make a difference. Am i doing something wrong?  I
am using the following code:

use strict;
use CGI::Carp qw(fatalsToBrowser);

use GD::Graph::Data;
use GD::Graph::bars;
use GD;

my $dataset = GD::Graph::Data->new() || die 'cant create dataset';

foreach (@Data)
{
 my ($label,$value) = split(/,/, $_);			
 $dataset->add_point($label, $value) || die 'cant add data point';
 }

my $my_graph = new GD::Graph::bars(600,600) || die 'cant define';
$my_graph->set_x_label_font=>(gdLargeFont);
$my_graph->set_y_label_font=>(gdLargeFont);

$my_graph->set( 
y_label           => 'Number of Incidents',
title             => 'GRAPH TITLE',
cycle_clrs=>1,
bar_spacing=>2,
x_labels_vertical=>1,
show_values=>1			
) or die $my_graph->error;


my $gd = $my_graph->plot($dataset) || die $my_graph->error;

print "Content-type: image/jpeg\n\n";

print $gd->jpeg;


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

Date: Wed, 01 Dec 2004 02:08:43 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: GD Graph Pie Formatting
Message-Id: <Q-Kdnf9ijqtg8DDcRVn-gw@adelphia.com>

Pascal wrote:

> print $gd->jpeg;

Not really on-topic for a Perl group, but you might want to try an image 
type that's better suited for this type of imagery, like GIF or PNG. 
JPEG is optimized for photographic content, and it isn't very well 
suited to blocks of solid colors with sharp boundaries.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 01 Dec 2004 13:33:01 +0100
From: franz <franz@127.0.0.1>
Subject: How to combine XPathScript with YAML?
Message-Id: <pan.2004.12.01.13.33.01.96471.536@127.0.0.1>

I like XPathScript (AxKit) for transforming XML,
but I would like to use YAML for defining the template-hash.

I put a "PerlModule YAML" in apache httpd.conf and put
%$t= %{YAML::Load(<<'...')};
in my XPathScript template.

That works fine, but I also want to put 'testcode' subkeys into the YAML
part. These contain perl subroutnines and I don't know how to load code.
I have seen an option LoadCode in YAML's manpage but I can't figure out
how to use it.

greetz,
franz


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

Date: 30 Nov 2004 23:08:08 -0800
From: jiing.deng@gmail.com (jiing)
Subject: Re: how to manage phpBB, windows 2003 server and FreeBSD user accounts simultaneously.
Message-Id: <b7b95676.0411302308.2920895@posting.google.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<lshpq059l777fi7fmsaptenemdsdj9vjhl@4ax.com>...
> On 29 Nov 2004 20:18:01 -0800, jiing.deng@gmail.com (jiing) wrote:
> 
> >I want to write a program which can manage phpBB, windows 2003 server
>                                             ^^^^^
>                                             ^^^^^
> >and FreeBSD user accounts simultaneously.
> >  Where can I find related information? Could you show me the
> >direction?
> >  any related CPAN modules
> 
> I may be wrong, but are you sure phpBB has anything to do with CPAN,
> let alone Perl?!?
>
> Michele

Thanks Michele, it's good to get your response. 
Let me restate my question again.
I want to manage the accounts of phpBB (someone said it just need to
modify the database of phpBB, I am not quite sure), accounts of
Windows 2003 server, and accounts of FreeBSD.
I have tried to find out some CPAN modules that may be useful:
                Win32:Admin        author:Dava Roth
                Win32::AdminMisc                
                Win32::NetAdmin
                Win32::Lanman      author:Jens Helberg
                HTTPD::UserAdmin
                Net::LDAP
But I am just a newbie of Perl, and not very sure what I should do,
what information I should find.
in fact, I do not know the account management at all, either in
FreeBSD or in Windows 2003 server.

Can anyone give me some suggestion?
thanks a lot.


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

Date: 1 Dec 2004 02:35:06 -0800
From: jeremiah.foster@gmail.com (Jeremiah Foster)
Subject: Re: how to manage phpBB, windows 2003 server and FreeBSD user accounts simultaneously.
Message-Id: <5bb6e425.0412010235.62c245e8@posting.google.com>

> in fact, I do not know the account management at all, either in
> FreeBSD or in Windows 2003 server.
> 
> Can anyone give me some suggestion?
> thanks a lot.

I recommend looking at LDAP (lightweight directory access protocol)


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

Date: Wed, 01 Dec 2004 12:49:02 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how to manage phpBB, windows 2003 server and FreeBSD user accounts simultaneously.
Message-Id: <k3brq099fflq3m985po09voq7tdi4qu51u@4ax.com>

On 30 Nov 2004 23:08:08 -0800, jiing.deng@gmail.com (jiing) wrote:

>Thanks Michele, it's good to get your response. 
>Let me restate my question again.
>I want to manage the accounts of phpBB (someone said it just need to
                                  ^^^
                                  ^^^

>modify the database of phpBB, I am not quite sure), accounts of
                        ^^^
                        ^^^

Well, phpBB is a CMS written in php. So a priori it is doubtful that
"native support" for Perl is provided. I don't even know if it is
possible, but it may be that someone has written a Perl module to do
what you want anyway. In that case search CPAN. Did you find anything?

>Windows 2003 server, and accounts of FreeBSD.
>I have tried to find out some CPAN modules that may be useful:
[snip]

In that case, OK: there are probably modules to do what you want.

>But I am just a newbie of Perl, and not very sure what I should do,
>what information I should find.

If you are willing to listen to my humble opinion, then you should
first become familiar at least with the very basics of Perl. Then and
only then you can even *begin* to think of using whatever module to
manage complex tasks, let alone potentially risky ones like those
you're dealing with.

>in fact, I do not know the account management at all, either in
>FreeBSD or in Windows 2003 server.

Ditto as above.

Please note that dealing with such delicate areas is a kind of
activity that even many Perl (or other languages FWIW) experts will
handle with MUCH, MUCH care. So... be careful. And patient!

>Can anyone give me some suggestion?
>thanks a lot.

I'm afraid I can't give you any beyond what I wrote above. Sorry!


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: 1 Dec 2004 00:52:05 -0800
From: madhav_a_kelkar@hotmail.com
Subject: Is this possible in perl?
Message-Id: <338e571.0412010052.31782b0f@posting.google.com>

Hi all,

          I am doing XML processing in perl,  i want to read a
function name from the XML file and call a function with that name at
runtime. Can I use the "require" statement for it? I was wondering if
it is possible in perl. Please help me.

 
                                                              Thanks,
                                                                    
Madhav.


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

Date: Wed, 01 Dec 2004 04:12:03 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Is this possible in perl?
Message-Id: <4cKdnSlUKPl4FzDcRVn-gQ@adelphia.com>

madhav_a_kelkar@hotmail.com wrote:

>           I am doing XML processing in perl,  i want to read a
> function name from the XML file and call a function with that name at
> runtime.

Use a dispatch table. Construct a hash of code refs:

my %dispatch = (
     do_this   => \&this,
     do_that   => \&that,
     do_other  => \&other,
);

And then make your function call by way of the dispatch table:

# Assuming $func has been read from XML input,
if (exists $dispatch{$func}) {
     $dispatch{$func}->();
} else {
     # No function found for $func, so handle the error
}

See 'perldoc perlref' for lots of details. There is also an example in 
'perldoc perlfaq7', at the end of the answer for "How do I create a 
switch or case statement?"

> Can I use the "require" statement for it?

What leads you to believe that require() has anything to do with calling 
a function? See 'perldoc -f require'.

sherm--

-- 
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org


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

Date: Wed, 01 Dec 2004 12:30:21 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Is this possible in perl?
Message-Id: <xPird.4240$wr6.932@trnddc04>

madhav_a_kelkar@hotmail.com wrote:
>          I am doing XML processing in perl,  i want to read a
> function name from the XML file and call a function with that name at
> runtime.

Typically you would use a dispatch table.

You could also use eval(), but of course depending upon where your XML file 
is coming from this may open a major security hole.

> Can I use the "require" statement for it?

Maybe in some convoluted way. require() is certainly not something that 
would come to my mind for calling a function.

jue 




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

Date: 1 Dec 2004 01:44:55 -0800
From: kean@kean.de (Kean)
Subject: Monitor a Serial Port (Win2k)
Message-Id: <11f488f.0412010144.582ed9ef@posting.google.com>

I have a Barcode-Scanner wich is connected to a com-port. When i start
the Hyperterminal and set the comport, i see the data that sends the
Scanner when i scan a label. This works fine.
Yet i will use the Scanner with this PerlScript:

use Win32::API; 
use Win32::SerialPort; 

my $Port = 'com7'; 
$Configuration_File_Name = 'config.sys'; 

$handle = new Win32::SerialPort ($Port, $quiet) 
       || die "Can't open $PortName: $^E\n"; 

$handle->baudrate(9600); 
$handle->parity('none'); 
$handle->databits(8); 
$handle->stopbits(1); 
$handle->handshake('rts'); 
$handle->write_settings || die "Can't initialize Handle\n"; 

$handle->save($Configuration_File_Name) 
       || warn "Can't save $Configuration_File_Name: $^E\n"; 

$handle->restart($Configuration_File_Name) 
       || warn "Can't reread $Configuration_File_Name: $^E\n"; 


open (LOG,">barcode.log") || die "Can't open 'barcode.log': $!\n"; 

while (1) { 

my $reply = HardwareReply($handle,100); 
print LOG "> Rx: $reply\n"; 

} 
close LOG; 

sub HardwareReply { 
my ($Port,$timeout) = @_; 

$Port->purge_all; 

    my $in; 
    my $max = 500; 
    my $count = 0; 
    my $return; 
    my $to_read; 
    my $readcount; 
    my $input; 
    my $counter=0; 

    $timeout ||= '100'; 

    do { 
        select(undef,undef,undef, 0.1); 
        $to_read = $max - $count; 

        ($readcount, $input) = $Port->read($to_read); 
        $in.=$input; 
        $count+=$readcount; 

if ( $in=~/[\n\r]$/ ) { 
$return=$in; 
} 

        $counter++; 
    } while ((!$return) && ($counter<$timeout)); 

$return=~s/[\r\n]//g; 
return $return; 
}

The Script opens the comport, but the sub HardwareReply doesnt work.
Have anyone an idea what the problem is?
Thanks


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

Date: Wed, 01 Dec 2004 09:04:34 GMT
From: burlo.stumproot@gmail.com
Subject: Re: PAR problems Win32 (Can't Spawn, line 372) (solved)
Message-Id: <uvfbm9yo5.fsf@notvalid.se>

John Bokma <postmaster@castleamber.com> writes:

> ASPerl: v5.8.3 built for MSWin32-x86-multi-thread
> 
   <snip trying to install PAR 0.85>
> 
> After many attempst, I kept getting 0.75, so I did the following:

Had the same problem, but I had to remove PAR 0.75 with
ppm> remove PAR-Dist
ppm> remove PAR

first to get it to work.
And then the following worked as expected.
 
> ppm> install http://www.bribes.org/perl/ppm/PAR-Dist.ppd
<snipped ppm output>
> ppm> install http://www.bribes.org/perl/ppm/PAR.ppd
<snipped ppm output>

/Stumproot



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

Date: Wed, 1 Dec 2004 07:29:01 +0100
From: "Tassilo v. Parseval" <tassilo.von.parseval@rwth-aachen.de>
Subject: Re: parse tr socket $buf
Message-Id: <slrncqqp5d.s4.tassilo.von.parseval@localhost.localdomain>

Also sprach Tad McClellan:

> dogdog@noemail.com <dogdog@noemail.com> wrote:
>
>
>> read($socket,$buf,100);
>
>
> Wouldn't you like to know if you actually got what you asked for?
>
>
>    die "couldn't read 100 bytes $!" unless read($socket,$buf,100) == 100;

This isn't quite right. read() may return fewer bytes than specified (in
that it behaves just like the read(2) system call). That is not an error, 
it just means that fewer bytes were available. A return value of zero
means end of file.

One would have to check for definedness. But then read() is one of those
functions where I rarely, if ever, check for errrors. The only one I
ever got was EIO and I am not even sure that can happen with a socket.

Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 01 Dec 2004 10:21:46 GMT
From: dogdog@noemail.com
Subject: Re: parse tr socket $buf
Message-Id: <pan.2004.12.01.10.21.47.957996@noemail.com>

On Wed, 01 Dec 2004 07:29:01 +0100, Tassilo v. Parseval wrote:

> Also sprach Tad McClellan:
> 
>> dogdog@noemail.com <dogdog@noemail.com> wrote:
>>
>>
>>> read($socket,$buf,100);
>>
>>
>> Wouldn't you like to know if you actually got what you asked for?
>>
>>
>>    die "couldn't read 100 bytes $!" unless read($socket,$buf,100) == 100;
> 
> This isn't quite right. read() may return fewer bytes than specified (in
> that it behaves just like the read(2) system call). That is not an error, 
> it just means that fewer bytes were available. A return value of zero
> means end of file.
> 
> One would have to check for definedness. But then read() is one of those
> functions where I rarely, if ever, check for errrors. The only one I
> ever got was EIO and I am not even sure that can happen with a socket.
> 
> Tassilo

I can understand the concerns however I'm using ethereal and I'm
seeing the correct amount of bytes returning. I can also currently
post it using
print "Content-type: text/html";
So I guess the answer to this is that I know I'm getting the
right data back, I just am not sure how I can use tr in the
script before posting the data to the webpage. I would like
to remove the XXX before the 123456 and just post the 123456
to the webpage.

thanks for the input 
dogdog



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

Date: Wed, 01 Dec 2004 10:41:34 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: parse tr socket $buf
Message-Id: <9o7rq0d3pc1i920nn4dcdh4l3v70r23q5s@4ax.com>

dogdog@noemail.com wrote:

>I can understand the concerns however I'm using ethereal and I'm
>seeing the correct amount of bytes returning. I can also currently
>post it using
>print "Content-type: text/html";
>So I guess the answer to this is that I know I'm getting the
>right data back, I just am not sure how I can use tr in the
>script before posting the data to the webpage. I would like
>to remove the XXX before the 123456 and just post the 123456
>to the webpage.

You don't want to use tr, believe me. Use a regex. Describe exactly what
kind of data you want to extract, and make a pattern out of it. For now,
it would seem to me that you want a substring of consecutive digits:

	my($digits) = $buf =~ /(\d+)/;

$digits now holds that number. 

For example:

	my $buf = "XXX 123456 lalalala";
	my($digits) = $buf =~ /(\d+)/;
	print $digits;

-- 
	Bart.


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

Date: 01 Dec 2004 12:19:36 GMT
From: unacceptable@gmail.com (Mitchell Hulscher)
Subject: Perl Timer
Message-Id: <41adb6d8$0$9463$ba620dc5@nova.planet.nl>

Hello all,

Lately I've been "trying" to create a certain program 
consisting of a free and a paid version.
The paid version includes several new options and 
features which won't impress anyone here though.

However, the free version should have a startup timer.
At the beginning it should count from 5 'till 0 seconds, 
and when it reaches 0, it will continue with the next block
of code. 

Has anyone got an idea of how I could do this?

Thanks in advance,
Mitch.

----------------------------------------------
Posted with NewsLeecher v2.0 Beta 5
 * Binary Usenet Leeching Made Easy
 * http://www.newsleecher.com/?usenet
----------------------------------------------



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

Date: Wed, 01 Dec 2004 12:35:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Perl Timer
Message-Id: <DUird.4241$wr6.4172@trnddc04>

Mitchell Hulscher wrote:
> However, the free version should have a startup timer.
> At the beginning it should count from 5 'till 0 seconds,
> and when it reaches 0, it will continue with the next block
> of code.
>
> Has anyone got an idea of how I could do this?

What about

use warnings; use strict;
for (0..5) {
    print 5-$_, "\n";
    sleep 1;
}


jue 




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

Date: Wed, 1 Dec 2004 13:37:45 +0100
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: Perl Timer
Message-Id: <Xns95B28AA492F45elhber1lidotechnet@62.89.127.66>

unacceptable@gmail.com (Mitchell Hulscher) wrote:

[...]

> At the beginning it should count from 5 'till 0 seconds, 
> and when it reaches 0, it will continue with the next block
> of code. 
> 
> Has anyone got an idea of how I could do this?


perldoc -f sleep


-- 
Cheers,
Bernard


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

Date: 01 Dec 2004 12:45:24 GMT
From: unacceptable@gmail.com (Mitchell Hulscher)
Subject: Re: Perl Timer
Message-Id: <41adbce4$0$9463$ba620dc5@nova.planet.nl>

Thanks :D

PS. I've never even heard of the sleep command, shame on me.

----------------------------------------------
Posted with NewsLeecher v2.0 Beta 5
 * Binary Usenet Leeching Made Easy
 * http://www.newsleecher.com/?usenet
----------------------------------------------



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

Date: Wed, 1 Dec 2004 07:39:09 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl Timer
Message-Id: <slrncqribt.7ef.tadmc@magna.augustmail.com>

Mitchell Hulscher <unacceptable@gmail.com> wrote:


> At the beginning it should count from 5 'till 0 seconds, 
> and when it reaches 0, it will continue with the next block
> of code. 


   foreach my $second ( reverse 1..5 ) {
      print "$second\n";
      sleep 1;
   }


or if you don't really need to see the seconds as they expire:

   sleep 5;


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


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

Date: Tue, 1 Dec 2004 08:52:59 GMT
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Redirecting STDOUT to Scalar behaves not as expected. Why?
Message-Id: <dnqwy0efzikd55i3fhqfebkf5cece7dwbe@4ax.com>

to do,
*   and I knew someone who had their hand blown off, but I am
*   adamantly against censoring such material."
*
*   "And unlike a library, a parent can buy a program that uses keyword
*   monitoring to disallow Internet traffic per the parents' wishes.
*   Such a program is available now, and costs only $29."

I think I looked at it for all of 30 seconds before putting in my bookshelf.
I don't remember the bomb-making details in it. I have a vague impression of a
lot of squiggly lines, suitable for a really bad coloring book. I also
purchased a variety of odd privacy-related publications from Eden Press.

What is the Official Federal Dangerous Book List?
What books did they check on for their 'Library Awareness Program'?
How was it determined these books made people dangerous?
Who approved this Fahrenheit 451 persecuted-for-books program?


The Thought Police had testified in court against Ed Cummings.


The judge rules on whether Ed is guilty of probation violation:

>   The judge determined that a probation violation had indeed taken place
>   and that Cummings should be held and a sentencing date scheduled within
>   60 days. The judge had just done the same thing for a man who had just
>   committed his third DWI offense. In fact, he had killed someone. The
>   judge ordered that person held on $50,000 bail. Ed Cummings, however,
>   was another matter. The judge ordered Cummings held on $250,000.
>    
>   So Cummings was being held on a quarter of a million dollars because he
>   was thought to have taken batteries out of a tone dialer years ago. He's
>   in a 5 by 8 holding cell 22 hours a day with no windows and no clock.
>   He never knows what time it is or whether it's day or night.
>   
>   The temperature reaches a maximum of sixty degrees and he has only one
>   layer of thin cotton clothing and one blanket. To add to his misery,
>   he was just notified that the Hav




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

Date: Tue, 1 Dec 2004 10:02:43 GMT
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Redirecting STDOUT to Scalar behaves not as expected. Why?
Message-Id: <a35ev20m0aevybek2e8yprcx1daua6laob@4ax.com>

government access was
: *   reinforced by comments made by FBI Director Freeh at a 1994 Washington
: *   conference on cryptography. "The objective for us is to get those
: *   conversations...wherever they are, whatever they are", he said in
: *   response to a question.
: *   
: *   Freeh indicated that if five years from now the FBI had solved the
: *   access problem but was only hearing encrypted messages, further
: *   legislation might be required.
: *   
: *   The obvious solution: a federal law prohibiting the use of any
: *   cryptographic device that did not provide government access.
: *   
: *   Freeh's hints that the government might have to outlaw certain kinds
: *   of coding devices gradually became more explicit. "The drug cartels
: *   are buying sophisticated communications equipment", he told Congress.
: *   "Unless the encryption issue is RESOLVED soon, criminal conversations
: *   over the telephone and other communications devices will become
: *   indecipherable by law enforcement. This, as much as any issue,
: *   jeopardizes the public safety and national se




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

Date: Wed, 1 Dec 2004 19:09:52 +1300
From: "Tintin" <tintin@invalid.invalid>
Subject: Re: Regarding Usage on Perl
Message-Id: <3155emF36rsumU1@individual.net>


<azbycx_47@yahoo.com> wrote in message 
news:8de10490.0411300125.e33f986@posting.google.com...
> Hello All,
>  I heard that perl has lot many features within it some of which
> specifically cater to the windows operating system, the Win32 API
> series. I had specific question relating to the Win32 API sets
> supported through it and so thought of posting a query to this mailing
> list.

This is a newsgroup.

>
>  First thing, I wanted to know is that, Can Perl scripting be used in
> an Embedded Windows Platform like WinCE? If so, can it be supported
> for all versions of WinCE till the latest release(WinCE-5.0 i.e.
> Macallan)?

Have a look at http://perlce.sourceforge.net/





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

Date: Wed, 01 Dec 2004 13:55:14 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: SMPT Connection Errors
Message-Id: <cokiao$e3n$1@south.jnrs.ja.net>

I have a strange strange problem setting up some CGI scripts on a new 
webserver which seem to boil down to the way that different modules 
connect to an SMTP server.

I have two scripts which send email.  One uses Mail::Sendmail and the 
other uses MIME::Lite (which itself uses Net::SMTP for the connection). 
  The Mail::Sendmail script works fine, both from a commandline and when 
run as a CGI script.  The MIME::Lite script works fine from the command 
line, but fails when run as a CGI.

Both scripts are pointing to the same SMTP server and both work fine 
when run from our old webserver.

I am at a complete loss to debug this problem.  The Net::SMTP connect 
fails during the new() statement, and I don't get any debugging output. 
Since both scripts are just opening a socket on port 25 I can't see what 
could be set in the webserver configuration which would stop one from 
working.

The symptoms suggest this must be a webserver configuration problem but 
I don't know how to get any more details about the failed connection so 
I can try to track down exactly what's failing.

I've included the test scripts I used.  The first one fails, but the 
second one works.  Beyond the test in the die statement I get nothing in 
the log file when the first script fails.

###############################################
#!perl
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use NET::SMTP;

$NET::SMTP::Debug = 1;

open (STDERR,'>','E:\Errors\smtp_log.txt') or die "Can't write to 
logfile: $!";

my $q = new CGI;

print $q -> header();
print $q -> start_html();
print "<pre>";

print "Connecting to smtp server\n";

my $smtp = Net::SMTP->new('our.mail.server',Debug => 1) or die "Can't 
connect to mail server";

$smtp -> mail('simon.andrews@bbsrc.ac.uk');

$smtp -> to('simon.andrews@bbsrc.ac.uk');
$smtp -> data();
$smtp -> datasend("To: simon.andrews\@bbsrc.ac.uk\n\n");
$smtp -> datasend("Test message\n\n");
$smtp -> dataend();

$smtp -> quit();

print "Finished connecting\n";


print "</pre>";
print $q -> end_html();

##################################################

#!perl
use warnings;
use strict;
use CGI;
use CGI::Carp qw(fatalsToBrowser);
use Mail::Sendmail;

open (STDERR,'>','E:\Errors\sendmail_log.txt') or die "Can't write to 
logfile: $!";


my $q = new CGI;

print $q -> header();
print $q -> start_html();
print "<pre>";

print "Connecting to smpt server\n";

$Mail::Sendmail::mailcfg{debug} = 6;

my %mail = (To => 'simon.andrews@bbsrc.ac.uk',
	    From => 'simon.andrews@bbsrc.ac.uk',
	    Message => 'This is a test',
	    smtp => 'our.mail.server',);

sendmail(%mail) or die "Can't send mail $Mail::Sendmail::error";

print "Log says:\n";
print $Mail::Sendmail::log;

print "Finished connecting\n";

print "</pre>";
print $q -> end_html();


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

Date: Wed, 01 Dec 2004 12:49:03 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: split function syntax
Message-Id: <tmbrq0tvo1malisrs35d9gqtqvq836n90j@4ax.com>

On 1 Dec 2004 03:59:23 GMT, "A. Sinan Unur" <1usa@llenroc.ude.invalid>
wrote:

>>     $Name{name} = $_;
             ^^^^
             ^^^^
>>     $Phone{$number} = $_;
>>     $Email{$email} = $_;
>> }
>> close(PH);
>
>...
>
>> i did but it's not working
>
>That is not a helpful description of the problem you are experiencing. have 
>you read the posting guidelines posted here regularly?

I think he means "that" (^^^^). Seems reasonable...


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Wed, 01 Dec 2004 09:26:19 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: SQLite - problem connecting to database (or doing a select)
Message-Id: <ng3rq0pfiv3tqbngat4rf8snkjn2brgaoo@4ax.com>

Alex Hunsley wrote:

>Firstly, just to demonstrate that I really do have a live database which 
>is running:
>
>$ mysql -h 127.0.0.1
>Welcome to the MySQL monitor.  Commands end with ; or \g.
>Your MySQL connection id is 16 to server version: 4.0.20a-debug-log

>Now, I've installed SQLite and am running this perl code:

You're tryng to connect to a mysql database with DBD::SQLite?!? *boggle*

Try DBD::mysql instead.

-- 
	Bart.


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

Date: Wed, 1 Dec 2004 12:37:10 +0000
From: chris-usenet@roaima.co.uk
Subject: suid-perl deprecated... why?
Message-Id: <mgq082-r66.ln1@moldev.cmagroup.co.uk>

Hi folks,

Perl 5.6.1 from debian "testing" (aka "sarge" for those who like
to know). According to debian's package installation manager, the
corresponding suid-perl is deprecated and is likely to be removed in some
(unspecified) later release.

perlsec doesn't appear to explain why it's deprecated, although it
does give the expected dire warnings about writing secure scripts,
and it offers a sample C wrapper (see the section "Security Bugs").
Google has a couple of threads from which I infer that it may be related
to a vulnerability with no-suid filesystems. However, I cannot find any
concrete details.

What's the score with perl scripts that really do need to be setuid? Do
I go back to using a C wrapper for each, or is there a supported secure
but "more elegant" solution?

This is perl. I don't want to have to go back to writing C :-P

Thanks,
Chris


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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


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