[25761] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 8000 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Apr 21 06:10:24 2005

Date: Thu, 21 Apr 2005 03:10:17 -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           Thu, 21 Apr 2005     Volume: 10 Number: 8000

Today's topics:
    Re: Perl and vmstat <tadmc@augustmail.com>
    Re: Perl and vmstat <josef.moellers@fujitsu-siemens.com>
    Re: perl execution speed <glex_nospam@qwest.invalid>
    Re: Perl on Rails? <bigiain@mightymedia.com.au>
        PerlMagick Cropping Help hoyoul@gmail.com
    Re: regex showdown <pilkowsk@informatik.uni-marburg.de>
    Re: regular expression meaning <bernard.el-haginDODGE_THIS@lido-tech.net>
    Re: Set a variable from a substring of another variable <tadmc@augustmail.com>
    Re: VIRUS W32.Goldun.M (Re: hotmail password request to <Ilgaz@spamcop.net>
    Re: VIRUS W32.Goldun.M (Re: hotmail password request to <gneuner2/@comcast.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 20 Apr 2005 19:07:22 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Perl and vmstat
Message-Id: <slrnd6drlq.5rd.tadmc@magna.augustmail.com>

usaims <usaims@yahoo.com> wrote:

> my @memusage = system("vmstat -n 1 | awk '{print \$14}'");


Read up on the return value that you get from system().

Why do you want to save that to an array?


> I have googled for "vmstat" in the perl group, but
> didn't come up with anything.  


Of course not, since you would have the same problem if you
were running a program that was not named "vmstat".


> I have searched perldoc, didn't see
> anything. 


   perldoc -f system


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


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

Date: Thu, 21 Apr 2005 08:41:19 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: Perl and vmstat
Message-Id: <d47i6t$57q$2@nntp.fujitsu-siemens.com>

usaims wrote:
> Hello:
>=20
> I am trying to write a small perl script that parses the "us"
> column of the vmstat command and if that number is greater or equal to
> 3, it will notify me.  The script does run, but I'm not getting any
> output.
>=20
> #!/usr/bin/perl
> use strict;
> use warnings;
> my $test =3D 3;
> my @memusage =3D `vmstat -n 1 | awk '{print \$14}'`;

awk: cmd. line:1: {print \$14}
awk: cmd. line:1:        ^ backslash not last character on line

The single quotes will prevent the \ from preventing the $ to be a=20
special character.

All other comments nonewithstanding,

Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett



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

Date: Wed, 20 Apr 2005 17:42:07 -0500
From: "J. Gleixner" <glex_nospam@qwest.invalid>
Subject: Re: perl execution speed
Message-Id: <3VA9e.103$pm5.3457@news.uswest.net>

surfunbear@yahoo.com wrote:
>  We have a wrapper language for C someone wrote which basicaly
> reads files and operates on the fields. It formats the fields, adding
> commas, removing spaces,checking for valid values and many similar
> types of operations.
> I am wondering if perl would run nearly as fast as such a thing, and
> suspect it would. If the kind of processing you are doing could be done
> in a 100 lines or so of perl code and the overall issue is how fast the
> I/O is and moving one field to another, some pattern matching,
> inserting data, I would expect perl would be fairly fast. Any comments
> on that ?
> 

Well, why not try it and see?  How would anyone be able to say yes or no 
to "nearly as fast" or have any idea what your "wrapper language for C" 
does or how well it does it?  The only way you're going to answer it is 
to benchmark it yourself, or hire someone.  Also, the number of lines of 
code has no relevance. It sounds like something perl would be able to 
handle rather easily, however you're asking a question that only you can 
answer.


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

Date: Thu, 21 Apr 2005 13:19:33 +1000
From: Iain Chalmers <bigiain@mightymedia.com.au>
Subject: Re: Perl on Rails?
Message-Id: <bigiain-0116A3.13193321042005@individual.net>

In article <d420m7$gvv$1@iruka.swcp.com>,
 "Michael W. Folsom" <mwfolsom@swcp.com> wrote:

> Iain Chalmers wrote:
> > In article <42565f7d_2@x-privat.org>,
> >  Gregory Toomey <nospam@bigpond.com> wrote:
> > 
> > 
> >>I've been playing around with Ruby of Rails for a day so I wonder if
> >>somebody has been working on a Perl equivalent.
> >>
> >>It consists of
> >>- an application generator, which generates for web front end to a
> >>relational database.
> >>Basic add/insert/delete web forms are generated by default, and you can add
> >>your own logic as classes.
> >>- automatic object-relations mapping. Database tables are seen as objects
> >>inside the framework.
> >>- automated data modelling eg you can specify 1:many relationships & the
> >>code is automaticly generated
> > 
> > 
> > You might want to look at Simon Cozens' "Maypole"
> > 
> > (though I don't seem to be able to get to 
> > http://maypole.simon-cozens.org/ right now)
> > 
> > (full disclosure, I've read about it and downloaded it, but haven't 
> > actually made the time to play with it yet...)
> > 
> > big
> 
> You might try:
> 	http://maypole.perl.org/

And (as I just found yesterday) 

http://catalyst.perl.org/ 

which is built on (amongst other things) Maypole...

big
-- 
On my tombstone they will carve, "IT NEVER GOT FAST 
ENOUGH FOR ME."' - Hunter S Thompson, 1937-2005 RIP


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

Date: 21 Apr 2005 02:17:10 -0700
From: hoyoul@gmail.com
Subject: PerlMagick Cropping Help
Message-Id: <1114075030.446390.190210@f14g2000cwb.googlegroups.com>

Hi,

I am using ImageMagick 6.2.0.7-2 and PerlMagick to create thumbnails
from images. Basically I am reading in an image with ImageMagick,
resizing it so either the width or the height is 100 pixels (depending
on which is smaller) and then cropping it to 100 by 100 pixels. So for
instance, I have an image that is 325 by 500 pixels. After the process
above, instead of ending up with a thumbnail that's 100 by 100 pixels
(centered), I get an image that's 100 by 154 (basically resized from
325 by 500) and the top and bottom of the image is white while the
middle 100 by 100 is the image. So instead of cropping the image, it's
just turning the cropped areas into a white background. Any clues as to
why? Here is the code:

sub createThumbnail {
  my $this = shift;

  if (!$this->{'image'} || !$this->{'size'}) { return; }

  my $image = Image::Magick->new;
  #$image->Read(blob => $this->{'image'});
  $image->BlobToImage($this->{'image'});

  my ($width, $height) = $image->Get('width', 'height');
  my $offsetx = 0;
  my $offsety = 0;

  # Resize image before attempting to crop the image
  if ($width <= $height) {
    my $h = $this->round(($height / $width) * $this->{'_thumb_width'});
    $offsety = $this->round(($h - $this->{'_thumb_height'}) / 2);
    $image->Resize(width => $this->{'_thumb_width'}, height => $h);
  }
  else {
    my $w = $this->round(($width / $height) *
$this->{'_thumb_height'});
    $offsetx = $this->round(($w - $this->{'_thumb_width'}) / 2);
    #$image->Resize(width => $w, height => $this->{'_thumb_height'});
    $image->Resize(geometry => $w.'x'.$this->{'_thumb_height'});
  }

  # Croping image with a re-adjusted offset
 $image->Crop(
   width => $this->{'_thumb_width'},
   height => $this->{'_thumb_height'},
   x => $offsetx, y => $offsety);

print "Content-type: image/gif\n\n";
print $image->ImageToBlob;
exit;
}

I tried $image->Chop but that function doesn't seem to work at all with
my version. Any help would greatly be appreciated!

Thanks
Hoyoul



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

Date: Thu, 21 Apr 2005 10:28:09 +0200
From: Fabian Pilkowski <pilkowsk@informatik.uni-marburg.de>
Subject: Re: regex showdown
Message-Id: <3cp6foF6pai7cU1@individual.net>

* Steven Kuo schrieb:
> On 20 Apr 2005, si wrote:
>> 
>> i was trying to avoid a while loop to populate @friends and %pairs but
>> i couldn't figure this out from my Friedl book
> 
> Assuming you can reliably use space, the equal sign, and parentheses
> as delimiters, you can try:
> 
> use Data::Dumper;
> 
> $_ = 'aa (b c d) ee ff=1.7e-006 gg=4.1 hh=1 ii=on';
> my $count_hash_elements = 0;
> @_ = $_ =~ /([^ ()=]+)(?==(?{++$count_hash_elements}))?/g;
> my ($alias, %hash)   = splice(@_, -1 - 2 * $count_hash_elements);
> my ($name, @friends) = @_;
> 
> print <<"__QED__";
> NAME    => $name
> FRIENDS => @{[ Dumper \@friends]} 
> ALIAS   => $alias
> HASH    => @{[ Dumper \%hash ]}
> __QED__
> 
> 
> What's wrong with using a while loop?  If well written, it's much 
> easier to read and understand than what I've written.

The idea behind your code looks good. But, why counting the equal signs
inside your regex and why splitting to @_. I'd write instead:


    $_ = 'aa (b c d) ee ff=1.7e-006 gg=4.1 hh=1 ii=on';

    my( $name, @friends ) = split /[ ()=]+/;
    my( $alias, %pairs )  = splice @friends, -1 - 2 * tr/=//;


That's all. Splitting is done by split(), counting by tr/// and splice()
is asked to isolate the hash %pairs. I don't think, that avoiding a
while loop must be harder to read (btw, which loop at all? I haven't
seen one in this thread yet). Sure, one has to know what the used
functions will do, but therefor the docs are written.

regards,
fabian


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

Date: Thu, 21 Apr 2005 09:30:13 +0200
From: "Bernard El-Hagin" <bernard.el-haginDODGE_THIS@lido-tech.net>
Subject: Re: regular expression meaning
Message-Id: <Xns963F60AD1EA74elhber1lidotechnet@62.89.127.66>

Tad McClellan <tadmc@augustmail.com> wrote:

> nicolas-laurent <nicolas_laurent545@hotmail.com> wrote:
> 
>> Could you explain to me what this regular expression means
>> 
>> =~ m,([^;]+);([^\n]+)\n?,g) {
>  ^^                        ^^^
>  ^^                        ^^^
> 
> The underlined parts are NOT part of a regular expression.


Neither is m,,g.


:-)


-- 
Cheers,
Bernard


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

Date: Wed, 20 Apr 2005 18:57:48 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Set a variable from a substring of another variable using Regular Expression
Message-Id: <slrnd6dr3s.5rd.tadmc@magna.augustmail.com>

Tony <t_carbon@yahoo.com> wrote:

> Here's my problem, I am reading in a file which contains lines of
> different lengths.  I need to set the last word 


You need to set the last word to _what_?


> $START="dogs are:";

> while( $_=<FILE> ) {
> 	$CURRENT_LINE=$_;
> 	$CURRENT_LINE_DUPE=$CURRENT_LINE;
> 
> # Above I have setup two variables to hold the value
> # of the current line.


You have set up *three* variables to hold the value of the current line.


> # If and only if the current line contains the phrase "dogs Are:"


That string does NOT match the pattern that you put 
into $START, case matters.

(UPPER CASE variable names suck, BTW.)


>           if ($CURRENT_LINE = /$START/) {


I'm guessing you are missing a tilde character on that line:

   if ($CURRENT_LINE =~ /$START/) {


> # What I want to do next is set the variable DOGSARE to the
> # last word in this line.
> 
> 		$DOGSARE=~ m|(\w$)|;


If you think that is how you set the value of $DOGSARE, you
should stop coding and do some more reading before proceeding.

How many characters will your pattern put into $1 ?

   $dogs_are = $1 if /(\w+)$/;


> 		print "$RDOGSARE";


Sheesh!

You have a typo on the variable name.

(Which is precisely the reason why UPPERCASE variable names suck.)

You should always enable "use strict" when developing Perl code.

(Most especially when you are going to ask hundreds of people
 around the world to help you with it.)

You should not use useless double quotes like that, see:

   perldoc -q vars


> In short - this doesn't work.  


Of course not, it has a whole boatload of problems.


> Thanks in advance,


It is demeaning to be asked to do the work of a machine, please
don't do that to us again, enable "strict" (and "warnings" too).


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


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

Date: Thu, 21 Apr 2005 10:45:40 +0300
From: Ilgaz <Ilgaz@spamcop.net>
Subject: Re: VIRUS W32.Goldun.M (Re: hotmail password request tool (intranet   usage)
Message-Id: <3cp414F6qdakpU1@individual.net>

On 2005-04-21 00:46:54 +0300, Ulrich Hobelmann <u.hobelmann@web.de> said:

> Ilgaz wrote:
>> Its a mac antivirus, Intego Virusbarrier for OS X. Interesting really.
>> 
>> But don't expect anything good from stuff like that (password crack)
> 
> WTH do you run an antivirus on your Mac??
> 
> I've heard that in some cases they even do harm (was it Norton?), and 
> they definitely don't do any good.  Where should you get a Mac virus 
> from (except by running a script that wipes your home directory...)?
> 
> My Mac stays clean :)

My plan was buying MS office, so bought antivirus. Nothing else, no.. 
There is no virus currently on mac except some evil scripts you mention.

Whatever

Ilgaz



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

Date: Thu, 21 Apr 2005 04:24:41 -0400
From: George Neuner <gneuner2/@comcast.net>
Subject: Re: VIRUS W32.Goldun.M (Re: hotmail password request tool (intranet usage)
Message-Id: <inoe611ouq7uaqe3lc7fmgcjbvp25ra3pb@4ax.com>

On Wed, 20 Apr 2005 20:18:11 +0200, "Matthias Hoys"
<idmwarpzone_NOSPAM_@yahoo.com> wrote:

>
>"Ilgaz" <Ilgaz@spamcop.net> wrote in message 
>>
>> W32.Goldun.M virus, Intego virus barrier reports.
>>

>Strange ... my up-to-date AVG freeware anti-virus didn't detect any virus in 
>the rar file. What anti-virus software do you use ?

McAfee doesn't detect anything either.

George
-- 
for email reply remove "/" from address


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

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


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