[29999] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1242 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 30 09:09:45 2008

Date: Wed, 30 Jan 2008 06:09:07 -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, 30 Jan 2008     Volume: 11 Number: 1242

Today's topics:
        C's gotoxy() equivalent in Perl <yogeshkagrawal@gmail.com>
    Re: C's gotoxy() equivalent in Perl <someone@example.com>
    Re: C's gotoxy() equivalent in Perl <yogeshkagrawal@gmail.com>
    Re: C's gotoxy() equivalent in Perl <ben@morrow.me.uk>
    Re: C's gotoxy() equivalent in Perl <invalid@invalid.net>
    Re: CRLF problem. <adrian.popa.gh@gmail.com>
        new CPAN modules on Wed Jan 30 2008 (Randal Schwartz)
    Re: Odd (undocumented?) behavior of RAM file within a l <1usa@llenroc.ude.invalid>
    Re: Odd (undocumented?) behavior of RAM file within a l <ben@morrow.me.uk>
        Restrict IP access to a Perl application <barramundi9@hotmail.com>
    Re: Restrict IP access to a Perl application <someone@example.com>
    Re: Restrict IP access to a Perl application <m@rtij.nl.invlalid>
    Re: Restrict IP access to a Perl application <zen13097@zen.co.uk>
    Re: Restrict IP access to a Perl application <abigail@abigail.be>
    Re: Restrict IP access to a Perl application <barramundi9@hotmail.com>
    Re: ssh into remote nodes, do mulitple commands <zentara@highstream.net>
    Re: Using Imager module to resample images <zentara@highstream.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 30 Jan 2008 02:14:54 -0800 (PST)
From: Yogi <yogeshkagrawal@gmail.com>
Subject: C's gotoxy() equivalent in Perl
Message-Id: <38acbdc7-0116-44e3-92f6-e3f1366387cd@h11g2000prf.googlegroups.com>

Hi,
I am trying to print something on my screen at specific location.  Do
we have anything equivalent to gotoxy() , as we have in C language, in
Perl?  I tried using Term::Cap but not getting any success.
Getting an error message : "TERM not set at...".

I am trying to run my perl script on Windows envt.
Perl version = v5.8.8 built for MSWin32-x86-multi-thread

Any pointers/help?


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

Date: Wed, 30 Jan 2008 10:24:08 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: C's gotoxy() equivalent in Perl
Message-Id: <cfYnj.1606$cc3.1561@edtnps82>

Yogi wrote:
> Hi,
> I am trying to print something on my screen at specific location.  Do
> we have anything equivalent to gotoxy() , as we have in C language, in
> Perl?  I tried using Term::Cap but not getting any success.
> Getting an error message : "TERM not set at...".
> 
> I am trying to run my perl script on Windows envt.
> Perl version = v5.8.8 built for MSWin32-x86-multi-thread

gotoxy() is not a C language function, it is a Curses function:

http://search.cpan.org/~giraffed/Curses-1.20/gen/make.Curses.pm


John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Wed, 30 Jan 2008 02:43:34 -0800 (PST)
From: Yogi <yogeshkagrawal@gmail.com>
Subject: Re: C's gotoxy() equivalent in Perl
Message-Id: <7bb7b711-0fbb-423a-9d5a-f134a1e78133@k2g2000hse.googlegroups.com>

On Jan 30, 3:24 pm, "John W. Krahn" <some...@example.com> wrote:
> Yogi wrote:
> > Hi,
> > I am trying to print something on my screen at specific location.  Do
> > we have anything equivalent to gotoxy() , as we have in C language, in
> > Perl?  I tried using Term::Cap but not getting any success.
> > Getting an error message : "TERM not set at...".
>
> > I am trying to run my perl script on Windows envt.
> > Perl version = v5.8.8 built for MSWin32-x86-multi-thread
>
> gotoxy() is not a C language function, it is a Curses function:
>
> http://search.cpan.org/~giraffed/Curses-1.20/gen/make.Curses.pm
>
> John
> --
> Perl isn't a toolbox, but a small machine shop where you
> can special-order certain sorts of tools at low cost and
> in short order.                            -- Larry Wall

Thanks John for providing me link.  I believe, I will have to install
Curses as its not available in perl version I am using.
Regards,
-YK


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

Date: Wed, 30 Jan 2008 12:48:47 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: C's gotoxy() equivalent in Perl
Message-Id: <fa8675-j62.ln1@osiris.mauzo.dyndns.org>


Quoth Yogi <yogeshkagrawal@gmail.com>:
> Hi,
> I am trying to print something on my screen at specific location.  Do
> we have anything equivalent to gotoxy() , as we have in C language, in
> Perl?  I tried using Term::Cap but not getting any success.
> Getting an error message : "TERM not set at...".
> 
> I am trying to run my perl script on Windows envt.
> Perl version = v5.8.8 built for MSWin32-x86-multi-thread

Term::Cap won't work under Windows. I would recommend Term::ANSIScreen
for what you're trying to do; you could also look at Win32::Console.

Ben



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

Date: Wed, 30 Jan 2008 06:42:38 -0700
From: "Gerry Ford" <invalid@invalid.net>
Subject: Re: C's gotoxy() equivalent in Perl
Message-Id: <1201700640_539@sp12lax.superfeed.net>


"Yogi" <yogeshkagrawal@gmail.com> wrote in message 
news:7bb7b711-0fbb-423a-9d5a-f134a1e78133@k2g2000hse.googlegroups.com...
> On Jan 30, 3:24 pm, "John W. Krahn" <some...@example.com> wrote:
>> Yogi wrote:
>> > Hi,
>> > I am trying to print something on my screen at specific location.  Do
>> > we have anything equivalent to gotoxy() , as we have in C language, in
>> > Perl?  I tried using Term::Cap but not getting any success.
>> > Getting an error message : "TERM not set at...".
>>
>> > I am trying to run my perl script on Windows envt.
>> > Perl version = v5.8.8 built for MSWin32-x86-multi-thread
>>
>> gotoxy() is not a C language function, it is a Curses function:
>>
>> http://search.cpan.org/~giraffed/Curses-1.20/gen/make.Curses.pm
>>
>> John
>> --
>> Perl isn't a toolbox, but a small machine shop where you
>> can special-order certain sorts of tools at low cost and
>> in short order.                            -- Larry Wall
>
> Thanks John for providing me link.  I believe, I will have to install
> Curses as its not available in perl version I am using.
Maybe one way to get what you want is to install Ruby and borrow the curses. 
I frankly don't know a curse from a gem or a rake, but since Ruby was 
created using MVC++6, it might be better for windows stuff than the 
equivalent from perl.

PDCurses            2.60-1
--
Gerry Ford




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

Date: Wed, 30 Jan 2008 05:28:53 -0800 (PST)
From: mad_ady <adrian.popa.gh@gmail.com>
Subject: Re: CRLF problem.
Message-Id: <1cf5adba-bdcb-4fdc-aeee-a42e29af2cbf@m34g2000hsf.googlegroups.com>

On Jan 28, 7:54 pm, "John" <john1...@yahoo.com> wrote:
> <jl_p...@hotmail.com> wrote in message
>
> news:38c5c2ea-4e75-443e-8358-f83e57514e90@y5g2000hsf.googlegroups.com...
>
>
>
> > On Jan 28, 4:19 am, "John" <john1...@yahoo.com> wrote:
>
> >> Both servers are on Linux platforms.  How can I automatically convert
> >> CRLF
> >> to LF on server B.  Or, what is server A doing that server B is not.
>
> >   On a Unix/Linux platform, you can remove all the CRs from a script
> > (or any file, really) with the following:
>
> >      perl -pi.bak -e 's/\cM//g' script.pl
>
> > This removes all the CRs from the file named "script.pl", converting
> > all CRLFs to just LFs.  (A copy of the original file will be saved as
> > "script.pl.bak".)
>
> >   Also, how are you uploading the file to servers A and B?  If you're
> > using ftp, I recommend using "ascii" mode before "send"ing or
> > "put"ting.  This will convert your Windows line endings to Unix line
> > endings (so that you won't have to do it yourself later).
>
> >   Another thing you might try is to call the script with "perl" in
> > the command line, like this:
>
> >      perl script.pl
>
> > instead of just:
>
> >      ./script.pl
>
> > Not using "perl" in the command line will call whatever's specified in
> > the shebang line, and if the shebang line ends with a CR, like this:
>
> >   #!/usr/bin/perl^M
>
> > the "perl^M" interpreter will be called, which can cause unexpected
> > things to happen.
>
> >   (To confuse matters, some text editors will automatically hide the
> > "^M" characters, making you think they don't exist when in fact they
> > do.)
>
> >   Calling your script with "perl" in front of it avoids several other
> > problems as well (like ones related to executable permissions and
> > $PATH issues), so I usually recommend that people run Perl scripts as
> > "perl script.pl" instead of just "script.pl".
>
> >   So if you aren't already, call your script with "perl" before it
> > and see if that makes any difference.
>
> >   I hope this helps, John.
>
> >   -- Jean-Luc
>
> Hi
>
> Problem solved.  The clue was 'ascii mode'.  Server B uses vsftpd as the ftp
> program.
> Once I added ascii_enabled_download=YES and ascii_enabled_upload=YES all was
> well.
> Many thanks for pointing me in that direction.
> Regards
> John

 ... or you could use dos2unix which is on most unix platforms. It
converts CRLFs to LFs.


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

Date: Wed, 30 Jan 2008 05:42:20 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Jan 30 2008
Message-Id: <JvFzuK.LDx@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

BSD-Resource-1.2901
http://search.cpan.org/~jhi/BSD-Resource-1.2901/
BSD process resource limit and priority functions 
----
CatalystX-CRUD-Controller-RHTMLO-0.10
http://search.cpan.org/~karman/CatalystX-CRUD-Controller-RHTMLO-0.10/
Rose::HTML::Objects CRUD controller 
----
CatalystX-CRUD-Model-RDBO-0.10
http://search.cpan.org/~karman/CatalystX-CRUD-Model-RDBO-0.10/
Rose::DB::Object CRUD 
----
CatalystX-Controller-Tabs-0.01
http://search.cpan.org/~jasonk/CatalystX-Controller-Tabs-0.01/
Automatically build tab sets for a controller 
----
Cogwheel-0.01
http://search.cpan.org/~perigrin/Cogwheel-0.01/
A Client/Server Networking Framework based on Moose and Sprocket 
----
Continuity-0.96
http://search.cpan.org/~awwaiid/Continuity-0.96/
Abstract away statelessness of HTTP, for stateful Web applications 
----
Continuity-Widget-0.01
http://search.cpan.org/~awwaiid/Continuity-Widget-0.01/
Handy Moose-based Widget Thingie for Continuity Apps 
----
Cvs-Simple-v0.0.5
http://search.cpan.org/~stephenca/Cvs-Simple-v0.0.5/
Perl interface to cvs 
----
DBD-ODBC-1.15
http://search.cpan.org/~mjevans/DBD-ODBC-1.15/
ODBC Driver for DBI 
----
DBICx-AutoDoc-0.04
http://search.cpan.org/~jasonk/DBICx-AutoDoc-0.04/
Generate automatic documentation of DBIx::Class::Schema objects 
----
DBIx-Class-DigestOnSet-0.000001_02
http://search.cpan.org/~groditi/DBIx-Class-DigestOnSet-0.000001_02/
Automatically encode columns with Digest 
----
DBIx-Class-EncodedColumn-0.00001_01
http://search.cpan.org/~groditi/DBIx-Class-EncodedColumn-0.00001_01/
Automatically encode columns 
----
DBIx-Log4perl-0.10
http://search.cpan.org/~mjevans/DBIx-Log4perl-0.10/
Perl extension for DBI to selectively log SQL, parameters, result-sets, transactions etc to a Log::Log4perl handle. 
----
Data-Toolkit-0.4
http://search.cpan.org/~afindlay/Data-Toolkit-0.4/
----
Data-Toolkit-0.5
http://search.cpan.org/~afindlay/Data-Toolkit-0.5/
----
Devel-PerlySense-0.0142
http://search.cpan.org/~johanl/Devel-PerlySense-0.0142/
IntelliSense for Perl 
----
Geo-Direction-Name-0.0.1
http://search.cpan.org/~kokogiko/Geo-Direction-Name-0.0.1/
Transform direction name and degree each other. 
----
Getopt-Long-Descriptive-0.070
http://search.cpan.org/~hdp/Getopt-Long-Descriptive-0.070/
Getopt::Long with usage text 
----
Gungho-0.09007
http://search.cpan.org/~dmaki/Gungho-0.09007/
Yet Another High Performance Web Crawler Framework 
----
GunghoX-FollowLinks-0.00006
http://search.cpan.org/~dmaki/GunghoX-FollowLinks-0.00006/
Automatically Follow Links Within Responses 
----
HTML-BBCode-2.02
http://search.cpan.org/~blom/HTML-BBCode-2.02/
Perl extension for converting BBcode to HTML. 
----
HTML-WikiConverter-DokuWikiFCK-0.09
http://search.cpan.org/~turnermm/HTML-WikiConverter-DokuWikiFCK-0.09/
A WikiConverter Dialect supporting the FCKeditor in DokuWiki 
----
HTTP-MobileAgent-Plugin-Location-0.0.3
http://search.cpan.org/~kokogiko/HTTP-MobileAgent-Plugin-Location-0.0.3/
Add location fuctions to HTTP::MobileAgent 
----
Locale-Maketext-Pseudo-v0.0.5
http://search.cpan.org/~dmuey/Locale-Maketext-Pseudo-v0.0.5/
give localized code a pseudo language obj if a real one does not exist. 
----
Math-Complex-1.48
http://search.cpan.org/~jhi/Math-Complex-1.48/
complex numbers and associated mathematical functions 
----
Module-CPANTS-Analyse-0.77
http://search.cpan.org/~domm/Module-CPANTS-Analyse-0.77/
Generate Kwalitee ratings for a distribution 
----
Module-CPANTS-ProcessCPAN-0.73
http://search.cpan.org/~domm/Module-CPANTS-ProcessCPAN-0.73/
Generate Kwalitee ratings for the whole CPAN 
----
Module-CPANTS-Site-0.73
http://search.cpan.org/~domm/Module-CPANTS-Site-0.73/
Catalyst based application 
----
POE-Component-Client-RADIUS-0.01
http://search.cpan.org/~bingos/POE-Component-Client-RADIUS-0.01/
a flexible POE-based RADIUS client 
----
POE-Component-Server-Syslog-1.14
http://search.cpan.org/~bingos/POE-Component-Server-Syslog-1.14/
syslog services for POE 
----
POE-Loop-EV-0.06
http://search.cpan.org/~agrundma/POE-Loop-EV-0.06/
a bridge that supports EV from POE 
----
Parallel-Forker-1.222
http://search.cpan.org/~wsnyder/Parallel-Forker-1.222/
Parallel job forking and management 
----
Params-Clean-v0.9.4
http://search.cpan.org/~plato/Params-Clean-v0.9.4/
(Parse A Routine Allowing Modest Syntax--Casually List Explicit Arg Names): Process @_ as positional/named/flag/list/typed arguments 
----
Parse-Flash-Cookie-0.07
http://search.cpan.org/~aff/Parse-Flash-Cookie-0.07/
A flash cookie parser. 
----
Parse-Flash-Cookie-0.08
http://search.cpan.org/~aff/Parse-Flash-Cookie-0.08/
A flash cookie parser. 
----
QtCore-4.002
http://search.cpan.org/~vadiml/QtCore-4.002/
----
QtCore-4.003
http://search.cpan.org/~vadiml/QtCore-4.003/
----
QtGui-4.002
http://search.cpan.org/~vadiml/QtGui-4.002/
----
QtGui-4.003
http://search.cpan.org/~vadiml/QtGui-4.003/
----
Rose-DB-Object-0.7661
http://search.cpan.org/~jsiracusa/Rose-DB-Object-0.7661/
Extensible, high performance RDBMS-OO mapper. 
----
String-CaseProfile-0.04
http://search.cpan.org/~enell/String-CaseProfile-0.04/
Get/Set the letter case profile of a string 
----
Template-Like-0.07
http://search.cpan.org/~askadna/Template-Like-0.07/
Lightweight Template Engine. 
----
Template-Like-0.08
http://search.cpan.org/~askadna/Template-Like-0.08/
Lightweight Template Engine. 
----
Template-Plugin-ByDate-0.04
http://search.cpan.org/~dmcbride/Template-Plugin-ByDate-0.04/
Keeps/removes included text based on whether the current date is within range. 
----
Text-Multi-0.01
http://search.cpan.org/~jasonk/Text-Multi-0.01/
Transform a file containing a mixture of markup types into HTML 
----
Tk-Pgplot-0.40
http://search.cpan.org/~rkackley/Tk-Pgplot-0.40/
Draw PGPLOT graphics in a Perl/Tk window 
----
WWW-CPAN-0.007
http://search.cpan.org/~ferreira/WWW-CPAN-0.007/
CPAN as a web service 
----
WWW-HatenaDiary-0.02
http://search.cpan.org/~kentaro/WWW-HatenaDiary-0.02/
CRUD interface to Hatena::Diary 
----
WWW-HatenaLogin-0.01
http://search.cpan.org/~yappo/WWW-HatenaLogin-0.01/
login/logout interface to Hatena 
----
WWW-HatenaLogin-0.02
http://search.cpan.org/~yappo/WWW-HatenaLogin-0.02/
login/logout interface to Hatena 
----
WWW-PAUSE-RecentUploads-0.01
http://search.cpan.org/~zoffix/WWW-PAUSE-RecentUploads-0.01/
get the list of the recent uploads to PAUSE 
----
WWW-Search-TheITJobBoard-0.04
http://search.cpan.org/~lgoddard/WWW-Search-TheITJobBoard-0.04/
Search TheITJobBoard.com 
----
WWW-Search-TheITJobBoard-0.04b
http://search.cpan.org/~lgoddard/WWW-Search-TheITJobBoard-0.04b/
Search TheITJobBoard.com 
----
Win32-FindWindow-0.03
http://search.cpan.org/~pia/Win32-FindWindow-0.03/
find windows on Win32 systems 
----
Win32-Mock-0.03
http://search.cpan.org/~saper/Win32-Mock-0.03/
Mock Win32 modules 
----
Win32-Mock-0.04
http://search.cpan.org/~saper/Win32-Mock-0.04/
Mock Win32 modules 
----
XML-LibXML-1.66
http://search.cpan.org/~pajas/XML-LibXML-1.66/
Perl Binding for libxml2 
----
XML-LibXSLT-1.66
http://search.cpan.org/~pajas/XML-LibXSLT-1.66/
Interface to the gnome libxslt library 
----
XML-Validator-Schema-1.09
http://search.cpan.org/~samtregar/XML-Validator-Schema-1.09/
validate XML against a subset of W3C XML Schema 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
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: Wed, 30 Jan 2008 11:05:26 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Odd (undocumented?) behavior of RAM file within a loop
Message-Id: <Xns9A353DF535BFCasu1cornelledu@127.0.0.1>

Ben Morrow <ben@morrow.me.uk> wrote in
news:8v2575-srt.ln1@osiris.mauzo.dyndns.org: 

> 
> Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
>> 
>> I found it curious that the warning disappears if I commented out the
>> close statement (on AS Perl 5.10 on Win32).

 ...

>> Use of uninitialized value $buffer in open at C:\Temp\t.pl line 8.
>> SCALAR(0x182b04c)
> 
> This seems to be an bug in PerlIO::scalar. 

<explanation snipped for brevity>

Thank you for your explanation.

 ...

> I've done up a patch, which I'll send to p5p when I've tested it.

Great.

> 
>> With the close statement commented out, I get:
>> 
>> C:\Temp> t
>> Pass #1
>> SCALAR(0x182b04c)
>> Pass #2
>> SCALAR(0x22ae14)
> 
> This makes less sense... I suspect what's happening here is that the
> filehandle isn't being closed until *after* $buffer gets allocated for
> the next iteration, so it is forced to allocate a new scalar since the
> old one's still in use.

That is my gut feeling, too.

> This is arguably wrong, since the whole point is to reuse the old
> scalar if we can, for efficiency.

In fact, I would argue that it is wrong. I don't foresee myself being 
able to first find where this is occurring and fix it without messing up 
anything else. 

On the other hand, when I used an infinite loop to see if this behavior 
caused a leak, it seemed to just cycle through the same three locations 
and memory usage did not increase at all.

C:\Temp> cat leak.pl
#!/usr/bin/perl

use strict;
use warnings;

while ( 1 ) {
    open my $fh, '>', \(my $buffer) or die $!;
    print \$buffer, "\n";
    print $fh "test\n";
    sleep 1;
}


C:\Temp> leak
SCALAR(0x182aeb4)
SCALAR(0x22acb4)
SCALAR(0x22ad04)
SCALAR(0x182aeb4)
SCALAR(0x22acb4)
SCALAR(0x22ad04)
SCALAR(0x182aeb4)
SCALAR(0x22acb4)
SCALAR(0x22ad04)
SCALAR(0x182aeb4)
SCALAR(0x22acb4)
SCALAR(0x22ad04)
SCALAR(0x182aeb4)
Terminating on signal SIGINT(2)

C:\Temp> perl -v

This is perl, v5.10.0 built for MSWin32-x86-multi-thread
(with 3 registered patches, see perl -V for more detail)

Copyright 1987-2007, Larry Wall

Binary build 1002 [283697] provided by ActiveState 
http://www.ActiveState.com
Built Jan 10 2008 11:00:53

And:

> perl leak.pl
SCALAR(0x1002eabc)
SCALAR(0x1002ea98)
SCALAR(0x1002eabc)
SCALAR(0x1002ea98)
SCALAR(0x1002eabc)
SCALAR(0x1002ea98)
SCALAR(0x1002eabc)

> perl -v

This is perl, v5.8.8 built for cygwin-thread-multi-64int
(with 8 registered patches, see perl -V for more detail)

Copyright 1987-2006, Larry Wall



-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Wed, 30 Jan 2008 12:53:55 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Odd (undocumented?) behavior of RAM file within a loop
Message-Id: <3k8675-j62.ln1@osiris.mauzo.dyndns.org>


Quoth "A. Sinan Unur" <1usa@llenroc.ude.invalid>:
> Ben Morrow <ben@morrow.me.uk> wrote in
> news:8v2575-srt.ln1@osiris.mauzo.dyndns.org: 
> 
> > This makes less sense... I suspect what's happening here is that the
> > filehandle isn't being closed until *after* $buffer gets allocated for
> > the next iteration, so it is forced to allocate a new scalar since the
> > old one's still in use.
> 
> That is my gut feeling, too.
> 
> > This is arguably wrong, since the whole point is to reuse the old
> > scalar if we can, for efficiency.
> 
> In fact, I would argue that it is wrong. I don't foresee myself being 
> able to first find where this is occurring and fix it without messing up 
> anything else. 
> 
> On the other hand, when I used an infinite loop to see if this behavior 
> caused a leak, it seemed to just cycle through the same three locations 
> and memory usage did not increase at all.

No, I wouldn't expect that. The filehandle should still be getting
closed, just not until after $buffer has been reallocated. At that point
the old value of $buffer will be freed, so it's likely that some scalar
will 'soon' reuse its memory.

Ben



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

Date: Tue, 29 Jan 2008 23:04:26 -0800 (PST)
From: barramundi9 <barramundi9@hotmail.com>
Subject: Restrict IP access to a Perl application
Message-Id: <210eef7f-8725-4418-a5eb-f7947470d6cc@s37g2000prg.googlegroups.com>

Dear all:

I am a newbie to Perl and have an application written in Perl.  I put
IPs that are "allowed" to access the application into a file called
"ip.allow".

I then tried to compare the $ENV{REMOTE_ADDRESS} to the IPs in
"ip.allow" to determine the access right which looks like the
following:

10.0.0.1
10.0.0.2
10.0.0.3

And the code is:

$address=$ENV{'REMOTE_ADDR'};

open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
flock(FILE,2);
while ($line=<FILE>) {
   $line=~s/\./\\\./g;
   if ($line =~ /$address/) {
       print "IP matched!!\n";
       last;
   }
}
flock(FILE,8);
close(FILE);

But it doesn't seem to work because when I take out 10.0.0.1 from the
ip.allow file, 10.0.0.1 can still access the application.

Any suggestions are appreciated, thanks.

barramundi9


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

Date: Wed, 30 Jan 2008 07:45:15 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Restrict IP access to a Perl application
Message-Id: <fWVnj.179$w57.52@edtnps90>

barramundi9 wrote:
> 
> I am a newbie to Perl and have an application written in Perl.  I put
> IPs that are "allowed" to access the application into a file called
> "ip.allow".
> 
> I then tried to compare the $ENV{REMOTE_ADDRESS} to the IPs in
> "ip.allow" to determine the access right which looks like the
> following:
> 
> 10.0.0.1
> 10.0.0.2
> 10.0.0.3
> 
> And the code is:

Don't forget:

use warnings;
use strict;

> $address=$ENV{'REMOTE_ADDR'};
> 
> open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
> flock(FILE,2);
> while ($line=<FILE>) {
>    $line=~s/\./\\\./g;
>    if ($line =~ /$address/) {
>        print "IP matched!!\n";
>        last;
>    }
> }
> flock(FILE,8);
> close(FILE);
> 
> But it doesn't seem to work because when I take out 10.0.0.1 from the
> ip.allow file, 10.0.0.1 can still access the application.
> 
> Any suggestions are appreciated, thanks.

You probably don't want to use a regular expression.  This should work 
better:

while ( my $line = <FILE> ) {
     chomp $line;
     if ( $line eq $address ) {
         print "IP matched!!\n";
         last;
     }
}



John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Wed, 30 Jan 2008 08:56:59 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Restrict IP access to a Perl application
Message-Id: <pan.2008.01.30.07.56.58@rtij.nl.invlalid>

On Tue, 29 Jan 2008 23:04:26 -0800, barramundi9 wrote:

> Dear all:
> 
> I am a newbie to Perl and have an application written in Perl.  I put
> IPs that are "allowed" to access the application into a file called
> "ip.allow".
> 
> I then tried to compare the $ENV{REMOTE_ADDRESS} to the IPs in
> "ip.allow" to determine the access right which looks like the following:
> 
> 10.0.0.1
> 10.0.0.2
> 10.0.0.3
> 
> And the code is:
> 
> $address=$ENV{'REMOTE_ADDR'};
> 
> open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
> flock(FILE,2);
> while ($line=<FILE>) {
>    $line=~s/\./\\\./g;
>    if ($line =~ /$address/) {
>        print "IP matched!!\n";
>        last;
>    }
> }
> flock(FILE,8);
> close(FILE);
> 
> But it doesn't seem to work because when I take out 10.0.0.1 from the
> ip.allow file, 10.0.0.1 can still access the application.

1) You don't chomp the input line, so it still contains a \n
2) You can just compare strings, no need for the regexp
3) You forgot to anchor your regexp (/^$address$/), but see 2)

HTH,
M4


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

Date: 30 Jan 2008 08:26:02 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: Restrict IP access to a Perl application
Message-Id: <47a0349a$0$8429$db0fefd9@news.zen.co.uk>

barramundi9 <barramundi9@hotmail.com> wrote:
> 
>  open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
>  flock(FILE,2);
>  while ($line=<FILE>) {
>     $line=~s/\./\\\./g;

You replace '.' with '\.' in $line...

>     if ($line =~ /$address/) {

 ...so now you're matching:  "10\\.0\\.0\\.1\n' =~ /10.0.0.1/
which obviously fails since there are no backslashes in $address.

I suspect you meant this to be:
       if ( $address =~ /$line/ ) {
which would still fail since there is no "\n" in $address.

In which case you could use chomp and also get rid of the s/// 
and use \Q in your match:
       chomp $line;
       if ( $address =~ /\Q$line/ ) {

or, better yet, use chomp() and eq
       chomp $line;
       if ( $line eq $address ) {



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

Date: 30 Jan 2008 09:20:23 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Restrict IP access to a Perl application
Message-Id: <slrnfq0gan.bfu.abigail@alexandra.abigail.be>

                                               _
barramundi9 (barramundi9@hotmail.com) wrote on VCCLXV September MCMXCIII
in <URL:news:210eef7f-8725-4418-a5eb-f7947470d6cc@s37g2000prg.googlegroups.com>:
))  Dear all:
))  
))  I am a newbie to Perl and have an application written in Perl.  I put
))  IPs that are "allowed" to access the application into a file called
))  "ip.allow".
))  
))  I then tried to compare the $ENV{REMOTE_ADDRESS} to the IPs in
))  "ip.allow" to determine the access right which looks like the
))  following:
))  
))  10.0.0.1
))  10.0.0.2
))  10.0.0.3
))  
))  And the code is:
))  
))  $address=$ENV{'REMOTE_ADDR'};
))  
))  open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
))  flock(FILE,2);
))  while ($line=<FILE>) {
))     $line=~s/\./\\\./g;
))     if ($line =~ /$address/) {
))         print "IP matched!!\n";
))         last;
))     }
))  }
))  flock(FILE,8);
))  close(FILE);
))  
))  But it doesn't seem to work because when I take out 10.0.0.1 from the
))  ip.allow file, 10.0.0.1 can still access the application.

That seems odd. In fact, I find it odd that, assuming $ENV {REMOTE_ADDR}
actually contains an IP address, anything matches at all. Say, for instance
$ENV {REMOTE_ADDR} contains "10.0.0.1", and ip.allow contains the three
addresses listed above. Then you do the following tests:

    "10\\.0\\.0\\.1\n" =~ /10.0.0.1/
    "10\\.0\\.0\\.2\n" =~ /10.0.0.1/
    "10\\.0\\.0\\.3\n" =~ /10.0.0.1/

There's no way this is going to match.

*Unless* $ENV {REMOTE_ADDR} is empty, then you'd be comparing the addresses
in ip.allow to //, which will always match.

))  Any suggestions are appreciated, thanks.

Why are you rolling your own security? This is a task that should be done
by the webserver.



Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


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

Date: Wed, 30 Jan 2008 01:57:34 -0800 (PST)
From: barramundi9 <barramundi9@hotmail.com>
Subject: Re: Restrict IP access to a Perl application
Message-Id: <47f165f0-4022-49ac-84a6-387ae08693d0@e23g2000prf.googlegroups.com>

On 1$B7n(B30$BF|(B, $B2<8a(B5$B;~(B20$BJ,(B, Abigail <abig...@abigail.be> wrote:
>                                                _
> barramundi9 (barramun...@hotmail.com) wrote on VCCLXV September MCMXCIII
> in <URL:news:210eef7f-8725-4418-a5eb-f7947470d6cc@s37g2000prg.googlegroups.com>:
> ))  Dear all:
> ))  
> ))  I am a newbie to Perl and have an application written in Perl.  I put
> ))  IPs that are "allowed" to access the application into a file called
> ))  "ip.allow".
> ))  
> ))  I then tried to compare the $ENV{REMOTE_ADDRESS} to the IPs in
> ))  "ip.allow" to determine the access right which looks like the
> ))  following:
> ))  
> ))  10.0.0.1
> ))  10.0.0.2
> ))  10.0.0.3
> ))  
> ))  And the code is:
> ))  
> ))  $address=$ENV{'REMOTE_ADDR'};
> ))  
> ))  open(FILE,"/path/to/ip.allow") or die ("Cannot open file!");
> ))  flock(FILE,2);
> ))  while ($line=<FILE>) {
> ))     $line=~s/\./\\\./g;
> ))     if ($line =~ /$address/) {
> ))         print "IP matched!!\n";
> ))         last;
> ))     }
> ))  }
> ))  flock(FILE,8);
> ))  close(FILE);
> ))  
> ))  But it doesn't seem to work because when I take out 10.0.0.1 from the
> ))  ip.allow file, 10.0.0.1 can still access the application.
>
> That seems odd. In fact, I find it odd that, assuming $ENV {REMOTE_ADDR}
> actually contains an IP address, anything matches at all. Say, for instance
> $ENV {REMOTE_ADDR} contains "10.0.0.1", and ip.allow contains the three
> addresses listed above. Then you do the following tests:
>
>     "10\\.0\\.0\\.1\n" =~ /10.0.0.1/
>     "10\\.0\\.0\\.2\n" =~ /10.0.0.1/
>     "10\\.0\\.0\\.3\n" =~ /10.0.0.1/
>
> There's no way this is going to match.
>
> *Unless* $ENV {REMOTE_ADDR} is empty, then you'd be comparing the addresses
> in ip.allow to //, which will always match.
>
> ))  Any suggestions are appreciated, thanks.
>
> Why are you rolling your own security? This is a task that should be done
> by the webserver.
>
> Abigail
> --
> perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'

Thanks for all your replies.

John, you are right, it can be done without regex.

Thanks again.

barramundi9


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

Date: Wed, 30 Jan 2008 14:07:41 GMT
From: zentara <zentara@highstream.net>
Subject: Re: ssh into remote nodes, do mulitple commands
Message-Id: <0o01q31dj2mqbjgbfavc0bukuu5o6qjdai@4ax.com>

On Tue, 29 Jan 2008 17:32:41 -0800 (PST), Nene <rodbass63@gmail.com>
wrote:

>Hello,
>
>I'm trying to use Net::SSH to ssh into 3 nodes and move/copy files
>with File::Copy. For now, I scripted it  to find files of a certain
>age and move them.
>The $cmd variable is working, but when I try to move the files, it
>errors with copy failed. Please critique or suggest a better way.
>Thanks in advance!!!!

Try Net::SSH2 , its better.  Sftp is incorporated
into it, and you probably want to use it for file transfers.

See:
 http://perlmonks.org?node_id=569657

also ask on the SSH maillist
http://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users

zentara

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

Date: Wed, 30 Jan 2008 08:58:30 -0500
From: zentara <zentara@highstream.net>
Subject: Re: Using Imager module to resample images
Message-Id: <5vv0q3pv3rlejqakudc6te8okfqdbpb6df@4ax.com>

On 29 Jan 2008 14:45:42 GMT, Abigail <abigail@abigail.be> wrote:

>                                          _
>zentara (zentara@highstream.net) wrote on VCCLXIV September MCMXCIII in
><URL:news:vv6up3521ho9pu3io1l4qvsk0nag72mgvg@4ax.com>:
>@@  On Tue, 29 Jan 2008 03:08:11 -0800 (PST), Jason Carlton
>@@ <jwcarlton@gmail.com> wrote:
>@@  
>@@ >2. How do I recognize an animated GIF from a static GIF?
>@@  
>@@  I believe it's safe to assume a static gif begins with GIF87, and
>@@  an animated with GIF89. But I'm not sure it's an absolute.
>
>While it is true that a GIF87a image is static, and that any animated
>gif image is a GIF89a one, it does not mean that GIF89a forbids static
>images. GIF89a is an enhancement of GIF87a. It allows animated images,
>but it also allows interlaced images and other features. It doesn't
>mandate one.
>
>Abigail

Yeah, it's not an absolute..... but the gif isn't 89a, then it won't
animate. So if it says 87a you can be sure it's a single image.
If it's  89a, then you test for multiple files 

################################################
from perldoc Imager::Files:

read_multi
  If you're reading from a format that supports multiple images per
  file, use the "read_multi()" method:

    my @imgs = Imager->read_multi(file=>$filename, type=>$type)
       or die "Cannot read $filename: ", Imager->errstr;

   As with the read() method, Imager will normally detect the "type"
   automatically.
#################################################

So it seems like you can attempt to open the 89a with read_multi(),
and if you get an errstr, open it as a single file.

I havn't poured over every Imager perldoc, but there is a section on
GUESSSING TYPES in Imager::Files.


zentara


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


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

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 V11 Issue 1242
***************************************


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