[24390] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6578 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 18 14:05:43 2004

Date: Tue, 18 May 2004 11: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)

Perl-Users Digest           Tue, 18 May 2004     Volume: 10 Number: 6578

Today's topics:
    Re: Can't build GD.pm on Solaris8 <ahc@jhu.edu>
    Re: how to clear the terminal <egoist99NO@SPAMyahoo.de>
    Re: how to clear the terminal (Bryan Castillo)
    Re: how to clear the terminal <bob.lockie.NOSPAM@mail.com>
    Re: How to open a socket through a proxy server? (Marcelo)
        My Example - Regex for "not any words(lines) preceeded  <ewijaya@singnet.com.sg>
    Re: My Example - Regex for "not any words(lines) precee (Anno Siegel)
        New module FDF::Simple good for CPAN? <schwigon@webit.de>
    Re: New module FDF::Simple good for CPAN? <uri@stemsystems.com>
        object oriented perl ? <linh@chello.no>
    Re: object oriented perl ? (Anno Siegel)
    Re: Parsing a text file..... (Sundaram Ramasamy)
    Re: Parsing a text file..... (Sundaram Ramasamy)
        Passing variables from Perl to other programs (Efialtis)
    Re: perl 5.8.3 problem (laszlo)
    Re: perlmagick and image size <rosszNOSPAM@sonic.net>
    Re: perlmagick and image size <rosszNOSPAM@sonic.net>
    Re: perlmagick and image size <rosszNOSPAM@sonic.net>
    Re: print all combinations (Anno Siegel)
        random IP <bob.lockie.NOSPAM@mail.com>
    Re: random IP (Walter Roberson)
    Re: random IP <jurgenex@hotmail.com>
    Re: random IP <bob.lockie.NOSPAM@mail.com>
    Re: random IP <bob.lockie.NOSPAM@mail.com>
    Re: random IP <erutiurf@web.de>
    Re: recursive closures? <nobull@mail.com>
    Re: Regex for "not any words(lines) preceeded by spaces <noreply@gunnar.cc>
    Re: Regex for "not any words(lines) preceeded by spaces <mark.clements@kcl.ac.uk>
    Re: Regex for "not any words(lines) preceeded by spaces (Anno Siegel)
        validating IP addresses <bob.lockie.NOSPAM@mail.com>
    Re: Writing a module comprised of several files? (Anno Siegel)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 18 May 2004 10:50:16 -0400
From: Andrew Crabb <ahc@jhu.edu>
Subject: Re: Can't build GD.pm on Solaris8
Message-Id: <c8d7fa$j5g$1@news.hcf.jhu.edu>

Jure Simsic wrote:
[ I cant't build GD-1.41 on Solaris 8. ]

I can't replicate your problem, but I got GD to build on Solaris 8.  My 
sequence was:

1. libiconv 1.8 from sunfreeware (pkgadd format).
2. libgd 2.0.0 from boutell.conv (source code).
3. GD 2.12 from CPAN

I'm running Solaris 8, gcc 3.2.2, perl 5.8.0.

Sometimes I've found you have to watch the make and configure output, to 
  see where it's picking up libraries.  pkgadd will install to 
/usr/local, pkg-get installs to /opt/csw, libraries that came with 
Solaris will be in /usr, source code packages can install anywhere 
(sometimes in /usr/local/whatever).  Maybe it's finding your old glib.

Sorry not more help

Andy


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

Date: Tue, 18 May 2004 12:29:38 +0200
From: Robert Meyer <egoist99NO@SPAMyahoo.de>
Subject: Re: how to clear the terminal
Message-Id: <pan.2004.05.18.10.29.38.433809@SPAMyahoo.de>

Am Mon, 17 May 2004 16:41:48 +0000 schrieb Ben Morrow:

> 
> Quoth Robert Meyer <egoist99NO@SPAMyahoo.de>:
>> sorry for my question, but i didn't found anything about how to clear
>> the terminal.
>> I try `clear`; in the script but this does not work.
> 
> See Term::ANSIScreen from CPAN.
> 
> Ben


thx - it works fine

greets
Robert

-- 
There are only 10 types of people in the world:
Those who understand binary, and those who don't.
http://www.one-m.de
http://www.lugbz.org/documents/smart-questions_de.html



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

Date: 18 May 2004 07:23:36 -0700
From: rook_5150@yahoo.com (Bryan Castillo)
Subject: Re: how to clear the terminal
Message-Id: <1bff1830.0405180623.23d7cec3@posting.google.com>

Robert Meyer <egoist99NO@SPAMyahoo.de> wrote in message news:<pan.2004.05.17.16.16.02.824151@SPAMyahoo.de>...
> Hi NG,
> 
> sorry for my question, but i didn't found anything about how to clear the
> terminal.
> I try `clear`; in the script but this does not work.
> 

system("clear"); # would probably work for you

I imagine that the clear command is printing ansi control characters
to stdout, so the back ticks would keep the control characters from
actually going to the terminal.

> Any ideas?
> 
> thx
> Robert


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

Date: Tue, 18 May 2004 10:44:40 -0400
From: Bob <bob.lockie.NOSPAM@mail.com>
Subject: Re: how to clear the terminal
Message-Id: <rjpqc.32118$325.819572@news20.bellglobal.com>

On 05/18/04 10:23 Bryan Castillo spoke:
> Robert Meyer <egoist99NO@SPAMyahoo.de> wrote in message news:<pan.2004.05.17.16.16.02.824151@SPAMyahoo.de>...
> 
>>Hi NG,
>>
>>sorry for my question, but i didn't found anything about how to clear the
>>terminal.
>>I try `clear`; in the script but this does not work.
>>
> 
> 
> system("clear"); # would probably work for you
> 
> I imagine that the clear command is printing ansi control characters
> to stdout, so the back ticks would keep the control characters from
> actually going to the terminal.
> 
> 
>>Any ideas?
>>
>>thx
>>Robert

Is there a cross OS solution?


-- 
-------------------------------------------------------
Remove .NOSPAM from my email address to reply directly.


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

Date: 18 May 2004 10:30:15 -0700
From: mnarvaja@yahoo.com (Marcelo)
Subject: Re: How to open a socket through a proxy server?
Message-Id: <b1570347.0405180930.33f49f00@posting.google.com>

Ben Morrow <usenet@morrow.me.uk> wrote in message news:<c8b763$7ki$1@wisteria.csv.warwick.ac.uk>...
> Quoth mnarvaja@yahoo.com (Marcelo):
> What sort of proxy server? HTTP? SOCKS?
> 
> If you're talking about SOCKS, you can use IO::Socket::Socks. If HTTP,
> then you need to make a CONNECT request.
> 
> Ben

I have both proxies, HTTP and SOCKS proxy servers.
I tried using IO::Socket::Socks, but it fails by timeout. The original
version of this module uses IO::Socket::INET that is timeout
customizable.

Any suggestion?

Thanks,
Marcelo


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

Date: Tue, 18 May 2004 21:01:39 -0000
From: Edward Wijaya <ewijaya@singnet.com.sg>
Subject: My Example - Regex for "not any words(lines) preceeded by spaces"
Message-Id: <opr77rc1fvuj0cst@news.singnet.com.sg>

Hi,
This is the example of the input (verbatim).

AGATTAGT
GCATTAGT
AGGGTAGT
GGAGTAGG
   A C G T Info Ptn Pattern
   TOTAL INFORMATION CONTENT


I just want to remove the last two lines (that comes
with spaces before it).

Regards
Edward WIJAYA


On 18 May 2004 11:01:45 GMT, Anno Siegel 
<anno4000@lublin.zrz.tu-berlin.de> wrote:

> Edward Wijaya  <ewijaya@singnet.com.sg> wrote in comp.lang.perl.misc:
>> Hi,
>>
>> [^\s.] or [^\s[a-zA-z]] doesn't seem to work.
>> Anything wrong with my regex?
>
> Hard to say before *you* say what exactly you expect it to do.  The
> statement in your subject is ambiguous (and you should have re-stated
> it in the body of your text).
>
> Meanwhile it would be a good idea to acquaint yourself with the
> function of character classes "[...]" in regular expressions.
> Those you are using above don't make much sense.  In particular
> you don't seem to understand that a character class matches a
> single character, not many.  Also, "^" has a different meaning
> in character classes (negation) and outside (anchor to the beginning
> the string).
>
> Anno



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/


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

Date: 18 May 2004 13:42:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: My Example - Regex for "not any words(lines) preceeded by spaces"
Message-Id: <c8d3s3$es9$1@mamenchi.zrz.TU-Berlin.DE>

Edward Wijaya  <ewijaya@singnet.com.sg> wrote in comp.lang.perl.misc:

[please don't to-post]

> This is the example of the input (verbatim).
> 
> AGATTAGT
> GCATTAGT
> AGGGTAGT
> GGAGTAGG
>    A C G T Info Ptn Pattern
>    TOTAL INFORMATION CONTENT
> 
> 
> I just want to remove the last two lines (that comes
> with spaces before it).

    grep /^\S/, @input;

[fullquote snipped]

Anno


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

Date: Tue, 18 May 2004 15:49:16 +0200
From: Steffen Schwigon <schwigon@webit.de>
Subject: New module FDF::Simple good for CPAN?
Message-Id: <873c5xdew3.fsf@lamebrain.teufelkommraus.webit.de>

[It seems I'm to be ignored in c.l.p.modules. So here's my next try.]

Hi!

We developed a module currently called FDF::Simple. It can read and
write FDF files into/from hashes. FDF is the file format for PDF
forms.

The module is meant to be a simple replacement for Adobe's
FdfToolkit. Files generated with this modules can be used to
feed tools from the Acrobat world, e.g., FdfMerge.

Could someone please have a look at this module.

Would this be useful for CPAN? If yes, I need it to be reviewed
because it would be my first time for a module on CPAN and I feel
quite unsure, although we tried to do it right.

I'm especially interested in these points:

 * useful/useless for CPAN
 * name/namespace
 * use of Module::Build (or must I use MakeMaker?)
 * overall ok'ness

You can download the distribution here:

  http://renormalist.net/~nobody/perl/FDF-Simple-0.01.tar.gz


(Greeti+Tha)nX
Steffen 
-- 
Steffen Schwigon <schwigon@webit.de>
Dresden Perl Mongers <http://dresden-pm.org/>


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

Date: Tue, 18 May 2004 17:26:27 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: New module FDF::Simple good for CPAN?
Message-Id: <x7y8npsl30.fsf@mail.sysarch.com>

>>>>> "SS" == Steffen Schwigon <schwigon@webit.de> writes:

  SS> The module is meant to be a simple replacement for Adobe's
  SS> FdfToolkit. Files generated with this modules can be used to
  SS> feed tools from the Acrobat world, e.g., FdfMerge.

  SS> Would this be useful for CPAN? If yes, I need it to be reviewed
  SS> because it would be my first time for a module on CPAN and I feel
  SS> quite unsure, although we tried to do it right.

there is no rule as to what is useful on CPAN. check out the Acme::
namespace if you want to see what i mean. :)

if you think it is useful and you want to share it, then cpan is fine
for it. as to the quality of the module and its code, that is another
story. cpan has not QA/QC but there is a rating system now.

  SS> I'm especially interested in these points:

  SS>  * useful/useless for CPAN
  SS>  * name/namespace

there is a modules list (not the newsgroup) where you can propose and
discuss namespace issues.

  SS>  * use of Module::Build (or must I use MakeMaker?)

i use both. for simple(r) single file modules, i tend to stick to basic
Makefile.PL as generated by h2xs. for more complex modules which need
special build/install stuff i am using Module::Build as i can manage the
special stuff with a simple and clean extension api.

  SS>  * overall ok'ness

hard to test that unless you know pdf forms well. i don't.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Tue, 18 May 2004 13:22:15 +0200
From: ngoc <linh@chello.no>
Subject: object oriented perl ?
Message-Id: <aomqc.2201$eH3.48055@news4.e.nsc.no>

Hi
This code does not work. It only creates test.xls, but write nothing in 
it.I don't know why. Please help me. Thanks a lot.
test.pl
#/usr/bin/perl
use Test;
new Test('/home/my/test.xls');



Test.pm
package Test;
use strict;
use Spreadsheet::WriteExcel;
use Spreadsheet::WriteExcel::Big;
use vars qw {$workbook $sheet1 $title_format};

sub new {
     my $self = {};
     my ($class,$file_name) = @_;
     bless $self, "Test";
     $workbook = Spreadsheet::WriteExcel::Big -> new ($file_name);
     &sheet;
     &format;
     &title ('test_sid', 'test_project');
     return $self;
}

sub sheet {
     $sheet1 = $workbook  ->  add_worksheet("test");
     #Set the width of the first column in Sheet1
     $sheet1 -> set_column('A:A', 30);
     $sheet1 -> set_column('B:M', 20);

     #Set Sheet1 as the active worksheet
     $sheet1 -> activate();
}

sub format {
     # title format
     $title_format = $workbook  ->  add_format();
     $title_format -> set_bold ();
     $title_format -> set_size (16);
     $title_format -> set_color ('blue');
     $title_format -> set_align ('left');

}

sub title {
     my $sid_name = shift;
     my $project_name = shift;
     $sheet1 -> write(0, 0, $sid_name, $title_format);
     $sheet1 -> write(0, 1, $project_name, $title_format);
     $sheet1 -> write(1, 0, "TEST1", $title_format);
     $sheet1 -> write(2, 0, "TEST2", $title_format);
}

1;


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

Date: 18 May 2004 12:03:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: object oriented perl ?
Message-Id: <c8cu23$bha$1@mamenchi.zrz.TU-Berlin.DE>

ngoc  <linh@chello.no> wrote in comp.lang.perl.misc:
> Hi
> This code does not work. It only creates test.xls, but write nothing in 
> it.I don't know why. Please help me. Thanks a lot.

For one, your code is devoid of "warnings".  Switch them on, at least
when code gives you trouble.

> test.pl
> #/usr/bin/perl
> use Test;
> new Test('/home/my/test.xls');

That is the "indirect object" syntax of method calls.  While it looks
nice, it can lead to ambiguities and is better avoided.

Also, normally you keep the result of a call to new().  In a productive
program, this should read

    my $test_sheet = Test->new( '/home/my/test.xls');

> Test.pm
> package Test;
> use strict;
> use Spreadsheet::WriteExcel;
> use Spreadsheet::WriteExcel::Big;
> use vars qw {$workbook $sheet1 $title_format};

You seem to use these global variables to hand objects from one
routine to another.  That isn't how objects are supposed to work.
They are passed as the first parameter in a method call, and that
is how methods should learn about them.

> sub new {
>      my $self = {};
>      my ($class,$file_name) = @_;
>      bless $self, "Test";

Bless it into $class instead of fixed "Test", or no-one will be
able to inherit from your class.  In OO it is almost always an
error (or a deliberate cop-out) to bless into a fixed class.

>      $workbook = Spreadsheet::WriteExcel::Big -> new ($file_name);

Here you are using $workbook to communicate the current object to
sheet().  Instead, "sheet" should be a method and called as

    $workbook->sheet;

>      &sheet;
>      &format;
>      &title ('test_sid', 'test_project');


Apart from the method/object issue, the ampersand in front of the
sub calls shouldn't be there.  That form is a special case and should
only be used when its features (suppression of prototypes, use of
the current @_) are wanted.

>      return $self;
> }
> 
> sub sheet {
>      $sheet1 = $workbook  ->  add_worksheet("test");
>      #Set the width of the first column in Sheet1
>      $sheet1 -> set_column('A:A', 30);
>      $sheet1 -> set_column('B:M', 20);
> 
>      #Set Sheet1 as the active worksheet
>      $sheet1 -> activate();
> }
> 
> sub format {
>      # title format
>      $title_format = $workbook  ->  add_format();
>      $title_format -> set_bold ();
>      $title_format -> set_size (16);
>      $title_format -> set_color ('blue');
>      $title_format -> set_align ('left');
> 
> }
> 
> sub title {
>      my $sid_name = shift;
>      my $project_name = shift;
>      $sheet1 -> write(0, 0, $sid_name, $title_format);
>      $sheet1 -> write(0, 1, $project_name, $title_format);
>      $sheet1 -> write(1, 0, "TEST1", $title_format);
>      $sheet1 -> write(2, 0, "TEST2", $title_format);
> }
> 
> 1;

I suppose, "sheet", "format" and "title" should be methods as well.

I don't know why your program doesn't write to the output file,
but the way you are handling parameters isn't OO, it isn't even
good functional programming.  Global variables should be restricted
as much as possible.  They are not a good argument passing mechanism,
far less an object passing mechanism for methods.

Anno


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

Date: 18 May 2004 10:47:53 -0700
From: sundaram@sfg.homeunix.com (Sundaram Ramasamy)
Subject: Re: Parsing a text file.....
Message-Id: <b029225f.0405180947.3803486a@posting.google.com>

Here is the perl one-line, I tested this in Linux

cat test.txt  | perl -ne 'if( $_ =~ /^_xml\w+\s+x?merge/) {
s/cleardiff|xmldiffmrg/cleardiffmrg/g; print } else { print }'
test.txt

_rose   annotate   ..\..\bin\tfdmgr.exe
_html2   xmerge    ..\..\bin\htmlmgr.exe
_html2   annotate   ..\..\bin\bdtm.exe
_html2   get_cont_info   ..\..\bin\bdtm.exe
_xml2   construct_version  ..\..\bin\bdtm.exe
_xml2   create_branch   ..\..\bin\bdtm.exe
_xml2   compare    ..\..\bin\cleardiff.exe
_xml2   xcompare   ..\..\bin\xmldiffmrg.exe
_xml2   merge    ..\..\bin\cleardiffmrg.exe
_xml2   xmerge    ..\..\bin\cleardiffmrg.exe
_xml2   annotate   ..\..\bin\bdtm.exe
_xml2   get_cont_info   ..\..\bin\bdtm.exe
_rose2   construct_version  ..\..\bin\bdtm.exe
_rose2   create_branch   ..\..\bin\bdtm.exe

-Sundaram


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

Date: 18 May 2004 11:01:04 -0700
From: sundaram@sfg.homeunix.com (Sundaram Ramasamy)
Subject: Re: Parsing a text file.....
Message-Id: <b029225f.0405181001.6eed3d21@posting.google.com>

Josef Moellers <josef.moellers@fujitsu-siemens.com> wrote in message news:<c8catl$1dm$1@nntp.fujitsu-siemens.com>...
> John Smith wrote:
> > Hi expert,
> > 
> > I have the below scenario.
> > 
> > I have a text file called test.txt with quite a few lines. Then I need
> > to replace only two words("cleardiff" and "xmldiffmrg") with a common
> > word, "cleardiffmrg" in a few lines that start with " xml". I need to
> > save the same file, test.txt after the replacement is done:
> > 
> > Below is the code:
> > ------------------
> > open (FILE1, "C:\\test.txt") || die "Can not open the file: $!\n";
> > 
> > @array = <FILE1>;
> > close FILE1;
> > 
> > open (FILE2, ">C:\\test.txt") || die "Can not write to the merge file:
> > $!\n";
> > 
> > foreach (@array)
> >   {
> >     if (($  =~ /^ xml\s+merge/) or ($  =~ /^ xml\s+xmerge/))
> >       {
> >         s/cleardiff/cleardiffmrg/g;
> >         s/xmldiffmrg/cleardiffmrg/g;
> >         
> >         print FILE2;
> >       } 
> >         
> >   }
> 
> A hint to get you on track:
> Under what condition do you change a line?
> Under what condition do you print to the new file?
> Under what condition do you want to print to the new file?

Here is the script, to write on the same file:

perl -i.old -ne 'if( $_ =~ /^_xml\w+\s+x?merge/) {
s/cleardiff|xmldiffmrg/cleardiffmrg/g; print } else { print }'
test.txt


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

Date: 18 May 2004 10:23:13 -0700
From: efialtis@efialtis.com (Efialtis)
Subject: Passing variables from Perl to other programs
Message-Id: <8a4d8b33.0405180923.2fa4e8e7@posting.google.com>

I have a fun situation using a testing tool with VBA.  However, to do
some of the things in VBA it would take too long, and it wouldn't work
right with this particular application...

I am passing in to perl, a chunck of HTML.  VBA has a really easy
command for this "getHTML"...

In perl, I am parsing out some necessary items from the
HTML...standard, easy, and working.

What I don't know how to do is pass the results back out to VBA
without using a TEMP file, which will not work with this
application...

Is there a way to pass out a string from perl back into vba?


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

Date: 18 May 2004 05:35:18 -0700
From: GlgAs@Netscape.net (laszlo)
Subject: Re: perl 5.8.3 problem
Message-Id: <945e4584.0405180435.5270747f@posting.google.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote in message news:<0flfa05gohmu6iqgflfve6i63bvlqo7183@4ax.com>...
> On 16 May 2004 08:28:06 -0700, GlgAs@Netscape.net (laszlo) wrote:
> 
> >In the comp.lang.perl.Tk list somone complained similar problem in
> >Linux.
> >
> >I suppose something is wrong with the rounding process used by the Tk
> >module.
> 
> <OT>
> Since you seem to know about clptk, I wonder why you posted this
> *only* to clpmisc, whereas this is a question that could have been
> either asked there or crossposted to both groups...
> </OT>
> 
> 
> Michele

Because someone else recently complained about the problem and got no
resolving answer. The problem is definitelly not Tk problem, both
activestate perl 5.8.0 and activestate perl 5.8.3 is using the same Tk
8.024 version, and scale w/ fractional resolution works with 5.8.0
doesn't work with 5.8.3

The problem is some change in the rounding process in the perl,
independent of Tk, I hoped that someone else found it too.


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

Date: Tue, 18 May 2004 16:10:48 GMT
From: Rossz <rosszNOSPAM@sonic.net>
Subject: Re: perlmagick and image size
Message-Id: <cAqqc.11865$Fo4.154144@typhoon.sonic.net>

gnari wrote:
> "rossz" <rosszNOSPAM@vamos-wentworth.org> wrote in message
> news:nqgqc.11804$Fo4.153620@typhoon.sonic.net...
> 
> [ problem resizing image to fixed size without distortion]
> 
> 
>>"Exception 410: reference is not my type `Image::Magick' at ./img.pl
>>line 23."
> 
> 
> [ snip code ]
> 
>>$z = $new->Composite(image=>$p, compose=>atop, gravity=>"SouthEast",
>>x=>$x, y=>$y);
> 
> 
> what is this image=>$p ?
> should there not be $img there ?

Oops, that should have been:

$z = $new->Composite(image=>$img, compose=>atop, gravity=>"SouthEast", 
x=>$x, y=>$y);

The (limited) docs say it should be the image handle.

I'll see what I can do with your suggestions.

--
Rossz


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

Date: Tue, 18 May 2004 16:57:50 GMT
From: Rossz <rosszNOSPAM@sonic.net>
Subject: Re: perlmagick and image size
Message-Id: <igrqc.11879$Fo4.154164@typhoon.sonic.net>

gnari wrote:

> "rossz" <rosszNOSPAM@vamos-wentworth.org> wrote in message
> news:nqgqc.11804$Fo4.153620@typhoon.sonic.net...
> 
> [ problem resizing image to fixed size without distortion]
> 
> 
>>"Exception 410: reference is not my type `Image::Magick' at ./img.pl
>>line 23."
> 
> 
> [ snip code ]
> 
>>$z = $new->Composite(image=>$p, compose=>atop, gravity=>"SouthEast",
>>x=>$x, y=>$y);
> 
> 
> what is this image=>$p ?
> should there not be $img there ?
> 
> also, you still need to resize the image.
> 
> you should:
> a) determine needed scaling factor
>    $sf=$min/max($width,$height);
> b) resize image to $width*$sf,$height*$sf
> c) create blank image size $min,$min
> d) calculate offsets, as you did
> e) paint resized image into new image at
>    appropriate offsets. (can't be bothered
>    to look at the docs to see if Composite()
>    is the correct method, but it sounds familiar)

The error message has gone away, but the image is distored, so I guess 
I'm not handling the resize and scaling properly.  Is resizing necessary 
since I'm going to copy the image onto another, anyway?

Also, the "gravity" doesn't seem to be working, either.  The image is 
stuck at 0x0 instead of the offset.  Am I misunderstanding the purpose 
of gravity?

Here's the situation.  Images tend to be ABOUT 100x100, but some are 
less and some are more.  If the image is <100 on an axis, increase the 
axis size to 100.  If it is more than 100, leave ias is.  All without 
modifying the actual image (we're just adding padding).  So a 75x75 
becomes 100x100.  A 50x150 becomes 100x150, etc.

I've searched everywhere for some kind of howto on perlmagick, but what 
I've found has been of very limited use.

I don't really understand your use of the scaling factor.  Where do you 
get $min, and why are we choosing the larger of $width and $height?

Sorry if I'm being dense.

--
Rossz


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

Date: Tue, 18 May 2004 17:09:12 GMT
From: Rossz <rosszNOSPAM@sonic.net>
Subject: Re: perlmagick and image size
Message-Id: <Yqrqc.11882$Fo4.154014@typhoon.sonic.net>

Never mind, I got it working.  Thanks for your suggestions, it did the job.

--
Rossz


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

Date: 18 May 2004 11:21:21 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: print all combinations
Message-Id: <c8crjh$8mj$2@mamenchi.zrz.TU-Berlin.DE>

Dan Jacobson  <jidanni@jidanni.org> wrote in comp.lang.perl.misc:
> Thanks. It seems these
> perl -wle '$"=",";print for      <B{V,X}{@{[1..8]}}{@{[A..Z]}}>'
> perl -wle '$"=",";print for glob "B{V,X}{@{[1..8]}}{@{[A..Z]}}"'
> are about as simple as it gets for me to print out that section of
> Taiwan amateur radio callsigns.  <> it turns out is merely the
> filename expander described on man perlop I/O Operators section.

> I find ranges needn't have quotes for capital letters.

Only when you are running without full strictures.  Under strict "subs",
barewords must be keywords or sub names, everything else is a syntax
error.  Switch on strict and quote them.

Anno


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

Date: Tue, 18 May 2004 10:00:24 -0400
From: Bob <bob.lockie.NOSPAM@mail.com>
Subject: random IP
Message-Id: <XFoqc.18062$qJ5.471120@news20.bellglobal.com>

I need to generate an IP address based on a random number.
How would I take the current time "1084887295" and put "." every two 
characters and throw away any digits left after I use 8?

So keep the last 8 and put a "." every 2.


-- 
-------------------------------------------------------
Remove .NOSPAM from my email address to reply directly.


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

Date: 18 May 2004 14:28:35 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: random IP
Message-Id: <c8d6ij$5dt$1@canopus.cc.umanitoba.ca>

In article <XFoqc.18062$qJ5.471120@news20.bellglobal.com>,
Bob  <bob.lockie.NOSPAM@mail.com> wrote:
:I need to generate an IP address based on a random number.
:How would I take the current time "1084887295" and put "." every two 
:characters and throw away any digits left after I use 8?

:So keep the last 8 and put a "." every 2.

time

  Returns the number of non-leap seconds since
  whatever time the system considers to be the epoch
  (that's 00:00:00, January 1, 1904 for Mac OS, and
  00:00:00 UTC, January 1, 1970 for most other systems).

That's usually a 32 bit number, which is the same number of bits
as for an IPv4 address. But just in case it isn't...

  my @t = unpack "C*", pack "L", time;
  my $ip = join ".", @t[-4..-1];
-- 
Is "meme" descriptive or perscriptive? Does the knowledge that
memes exist not subtly encourage the creation of more memes?
   -- A Child's Garden Of Memes


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

Date: Tue, 18 May 2004 14:28:39 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: random IP
Message-Id: <r4pqc.215078$L31.93535@nwrddc01.gnilink.net>

Bob wrote:
> I need to generate an IP address based on a random number.
> How would I take the current time "1084887295" and put "." every two
> characters

perldoc -q comma: "How can I output my numbers with commas added?"

> and throw away any digits left after I use 8?

perldoc -f substr

Of course you realize that the current time is not random at all, are you?

jue




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

Date: Tue, 18 May 2004 10:46:20 -0400
From: Bob <bob.lockie.NOSPAM@mail.com>
Subject: Re: random IP
Message-Id: <_kpqc.32196$325.820139@news20.bellglobal.com>

On 05/18/04 10:28 Jürgen Exner spoke:
> Bob wrote:
> 
>>I need to generate an IP address based on a random number.
>>How would I take the current time "1084887295" and put "." every two
>>characters
> 
> 
> perldoc -q comma: "How can I output my numbers with commas added?"
> 
> 
>>and throw away any digits left after I use 8?
> 
> 
> perldoc -f substr
> 
> Of course you realize that the current time is not random at all, are you?
> 
> jue

I meant different each time to program is run.


-- 
-------------------------------------------------------
Remove .NOSPAM from my email address to reply directly.


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

Date: Tue, 18 May 2004 10:46:57 -0400
From: Bob <bob.lockie.NOSPAM@mail.com>
Subject: Re: random IP
Message-Id: <Alpqc.32236$325.820201@news20.bellglobal.com>

On 05/18/04 10:28 Walter Roberson spoke:
> In article <XFoqc.18062$qJ5.471120@news20.bellglobal.com>,
> Bob  <bob.lockie.NOSPAM@mail.com> wrote:
> :I need to generate an IP address based on a random number.
> :How would I take the current time "1084887295" and put "." every two 
> :characters and throw away any digits left after I use 8?
> 
> :So keep the last 8 and put a "." every 2.
> 
> time
> 
>   Returns the number of non-leap seconds since
>   whatever time the system considers to be the epoch
>   (that's 00:00:00, January 1, 1904 for Mac OS, and
>   00:00:00 UTC, January 1, 1970 for most other systems).
> 
> That's usually a 32 bit number, which is the same number of bits
> as for an IPv4 address. But just in case it isn't...
> 
>   my @t = unpack "C*", pack "L", time;
>   my $ip = join ".", @t[-4..-1];

Thanks.



-- 
-------------------------------------------------------
Remove .NOSPAM from my email address to reply directly.


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

Date: Tue, 18 May 2004 19:00:13 +0200
From: Richard Voss <erutiurf@web.de>
Subject: Re: random IP
Message-Id: <c8dfep$cbp$05$1@news.t-online.com>

Bob wrote:
> On 05/18/04 10:28 Jürgen Exner spoke:
> 
>> Bob wrote:
>>
>>> I need to generate an IP address based on a random number.
>>> How would I take the current time "1084887295" and put "." every two
>>> characters
>>
>> perldoc -q comma: "How can I output my numbers with commas added?"
>>
>>> and throw away any digits left after I use 8?
>>
>> perldoc -f substr
>>
>> Of course you realize that the current time is not random at all, are 
>> you?
>>
>> jue
> 
> I meant different each time to program is run.
> 

Today's computers can start a program more than once within a second. (Seriuos!) 
You might get closer to unique values using more exact times than just seconds. 
Time::HiRes provides a time() function that returns floats. Still, that's not 
strictly unique.

HTH

-- 
sub{use strict;local$@=sub{select($,,$,,$,,pop)};unshift@_,(45)x 24,split q=8==>
55.52.56.49.49.55.56.49.49.53;do{print map(chr,@_[0..(@_/2-1)]),"\r";$@->(1/6)=>
push@_=>shift}for@_,++$|}->(map{$_+=$_%2?-1:1}map ord,split//,'u!`onuids!Qdsm!'.
'i`bjds') #my email-address is reversed!      <http://fruiture.de>


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

Date: 18 May 2004 12:59:12 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: recursive closures?
Message-Id: <u9brkmx7xr.fsf@wcl-l.bham.ac.uk>

In a distant thread long ago I wrote...

[ Of memory leaks in recursive closures ]

> Of course if you want $sub to be a variable that is forcably undefined
> implicitly at the end of a scope scope then Perl has just such a thing
> - the local() variable!

>    our $sub;
>    local $sub = sub{ blah; $sub->() }

For the sake of the archives I think I should correct this...

The SV pointed to be *sub{SCALAR} that holds the CODE ref will _not_
get undefined (restored to its previous value) on exit from the scope.  

It remains untouched.  What happens is that the scalar reference held
in *sub{SCALAR} is restored to its previous value.  In this way the
reference count of SV containing the CODE ref falls to zero and it is
garbage collected (and hense so it the closure).

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Tue, 18 May 2004 12:13:05 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Regex for "not any words(lines) preceeded by spaces"
Message-Id: <2gu5tcF6ut86U1@uni-berlin.de>

Mark Clements wrote:
> [^\s.] will match non-whitespace or non-anything

No. A dot is not special within brackets. It matches any 
non-whitespace character except a dot.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Tue, 18 May 2004 11:15:37 +0100
From: Mark Clements <mark.clements@kcl.ac.uk>
Subject: Re: Regex for "not any words(lines) preceeded by spaces"
Message-Id: <40a9e24a@news.kcl.ac.uk>

Gunnar Hjalmarsson wrote:
> Mark Clements wrote:
> 
>> [^\s.] will match non-whitespace or non-anything
> 
> 
> No. A dot is not special within brackets. It matches any non-whitespace 
> character except a dot.
> 
er - yeah. schoolboy error :)


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

Date: 18 May 2004 11:01:45 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Regex for "not any words(lines) preceeded by spaces"
Message-Id: <c8cqep$8mj$1@mamenchi.zrz.TU-Berlin.DE>

Edward Wijaya  <ewijaya@singnet.com.sg> wrote in comp.lang.perl.misc:
> Hi,
> 
> [^\s.] or [^\s[a-zA-z]] doesn't seem to work.
> Anything wrong with my regex?

Hard to say before *you* say what exactly you expect it to do.  The
statement in your subject is ambiguous (and you should have re-stated
it in the body of your text).

Meanwhile it would be a good idea to acquaint yourself with the
function of character classes "[...]" in regular expressions.
Those you are using above don't make much sense.  In particular
you don't seem to understand that a character class matches a
single character, not many.  Also, "^" has a different meaning
in character classes (negation) and outside (anchor to the beginning
the string).

Anno


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

Date: Tue, 18 May 2004 13:36:09 -0400
From: Bob <bob.lockie.NOSPAM@mail.com>
Subject: validating IP addresses
Message-Id: <bQrqc.38375$325.865838@news20.bellglobal.com>

I need a function to accept an IP address (V4 or V6) and return if it is 
valid or not.

-- 
-------------------------------------------------------
Remove .NOSPAM from my email address to reply directly.


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

Date: 18 May 2004 12:32:27 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Writing a module comprised of several files?
Message-Id: <c8cvor$bha$2@mamenchi.zrz.TU-Berlin.DE>

Andrew Crabb  <ahc@jhu.edu> wrote in comp.lang.perl.misc:
> I'm making a module that I'd like to put into CPAN eventually.  The code 
> does not lend itself to being in one file - for instance, there is a 
> data dictionary 2,000 lines long that seems it should be in its own 
> file.

That should probably go in a file by itself, yes.  It is quite common
for Perl modules to consist of multiple files.  CPAN has the notion
of "distribution" to support this.

>       Also I'm trying to make it as OO as possible, and there are 
> subclasses that have no real utility outside of the context of being 
> used in the main module.  So they're extra files, too.

That could be taken as a reason to keep them with the main module,
but you can separate them out as well.

> Question: Say my module is called Image::Munge.  So my main file is 
> called Image/Munge.pm.  Where do I put the other files - in 
> Image/Munge/UtilityFile.pm etc?  And if my module (class) Image::Munge 
> uses a utility class UtilityClass, it'd be called 
> Image::Munge::UtilityClass right?  And its file would be 
> Image/Munge/UtilityClass.pm.

That's how it's usually done.   Once the main module "splits off"
support modules, create an additional directory named like the main
module minus ".pm" and put the auxiliaries there.

There is no technical reason for this, it is a mere convention.
Unlike exporting modules, for classes there is no connection between
their name and the file they are loaded from.

>                              But this utility class is not useful on 
> its own - can I prevent it from being 'visible' so that people do not 
> inadvertantly try to use it?

Ben Morrow (?) has answered this already.  Put it in the documentation.

Anno


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

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


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