Re: about cron and perl

2005-11-04 Thread Shawn Corey

ZHAO, BING wrote:

Hi,
  I was advised to check out man cron for how to use cron. Set 
off do_it.pl using cron. But that's about it , all I can get from web 
help. I have no clue:
  1. what should I include in the do_it.pl, say to delete 
certain old files?
  2. this is a more unix problem, how should I exactly invoke 
"crontab do_it.pl", say I want cron to run do_it.pl everyday?

   thank you all.

best,



You should also check:

man crontab
man 5 crontab

cron is started at boot time and normally you have nothing to do with 
it. Also:


1. Your crontab is ran under your userid but not in the same 
environment. Do not rely on the environment variables PATH, MANPATH, 
HOME, or USER to have any values.


2. All output to STDOUT and STDERR is collected and sent to your mail. 
This may or may not be connected to your GUI email application. Consult 
your sysadmin on how to do this.



--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: hash of hash - copy

2005-11-04 Thread Frank Bax

At 03:17 PM 11/4/05, Jeff 'japhy' Pinyan wrote:


On Nov 4, Frank Bax said:


$aSuit{0}{'a'} = 'A';
$aSuit{0}{'b'} = 'B';
$aSuit{0}{'c'} = 'C';
$aSuit{1}{'a'} = 'D';
$aSuit{1}{'b'} = 'E';
$aSuit{1}{'c'} = 'F';

Now I want to make $aSuit{1} a copy of $aSuit{0}
%aSuit{1} = %aSuit{0};


Well, $aSuit{1} = $aSuit{0} would make $aSuit{1} and $aSuit{0} IDENTICAL. 
Meaning, when $aSuit{0}{a}, $aSuit{1}{a} changes too.  If you don't want 
that, you can do:


  %{ $aSuit{1} } = %{ $aSuit{0} };

But that only works one level deep.



One level deep works for me!  But IDENTICAL does not.  Thanks for quick 
response (David too).



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Which Module for XPath on HTML?

2005-11-04 Thread Siegfried Heintze
I'm looking at CPAN searching for XPath and feeling lost. In Java I can use
jtidy to read html into a standard XML DOM (org.w3c.dom to be exact) and
search that DOM with Xpath.

Can I do that in perl? If so, which modules do I want?

Thanks,
Siegfried



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: hash of hash - copy

2005-11-04 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Frank Bax wrote:
> #!/usr/bin/perl -w
> use strict;
> 
> my  %aSuit = ();
> 
> $aSuit{0}{'a'} = 'A';
> $aSuit{0}{'b'} = 'B';
> $aSuit{0}{'c'} = 'C';
> $aSuit{1}{'a'} = 'D';
> $aSuit{1}{'b'} = 'E';
> $aSuit{1}{'c'} = 'F';
> 
> Now I want to make $aSuit{1} a copy of $aSuit{0}
>   %aSuit{1} = %aSuit{0};
> This doesn't work (syntax error), what's the proper statement for
> this? 

I used this:

%{$aSuit{1}} = %{$aSuit{0}};

Printed out using Data::Dumper and aSuit 1 now had the same elements of ASuit 0

Wags ;)


***
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
***


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: hash of hash - copy

2005-11-04 Thread Jeff 'japhy' Pinyan

On Nov 4, Frank Bax said:


$aSuit{0}{'a'} = 'A';
$aSuit{0}{'b'} = 'B';
$aSuit{0}{'c'} = 'C';
$aSuit{1}{'a'} = 'D';
$aSuit{1}{'b'} = 'E';
$aSuit{1}{'c'} = 'F';

Now I want to make $aSuit{1} a copy of $aSuit{0}
%aSuit{1} = %aSuit{0};


Well, $aSuit{1} = $aSuit{0} would make $aSuit{1} and $aSuit{0} IDENTICAL. 
Meaning, when $aSuit{0}{a}, $aSuit{1}{a} changes too.  If you don't want 
that, you can do:


  %{ $aSuit{1} } = %{ $aSuit{0} };

But that only works one level deep.  For generic copying of data 
structures, see the Storable module (comes with Perl):


  use Storable;
  $aSuit{1} = dclone($aSuit{0});

--
Jeff "japhy" Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




hash of hash - copy

2005-11-04 Thread Frank Bax

#!/usr/bin/perl -w
use strict;

my  %aSuit = ();

$aSuit{0}{'a'} = 'A';
$aSuit{0}{'b'} = 'B';
$aSuit{0}{'c'} = 'C';
$aSuit{1}{'a'} = 'D';
$aSuit{1}{'b'} = 'E';
$aSuit{1}{'c'} = 'F';

Now I want to make $aSuit{1} a copy of $aSuit{0}
%aSuit{1} = %aSuit{0};
This doesn't work (syntax error), what's the proper statement for this?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: How do i create a basic form that can be emailed to a database?

2005-11-04 Thread JupiterHost.Net



Misty Kesler wrote:


I Just would like to know a lot of those already made forms, just don't 
work. Any help is appreciated


I'd say just take the form (use CGI) and put it in a database (use DBI) 
instead of emailing (use Mail::Sender) it to and address that is setup 
to pipe it to a scripts (ask your server admin how to do that) that then 
has to parse the email (see search.cpan.org for modules that can parse 
mail) and put it in a database (use DBI).


But here's how:

print the form
when submitted check the submitted input and redop the fom if it bad and 
send to email and/or put in database otherwise


Assuming email is properly setup on the server to send the mail your 
other script:


accept email
parse email (That is not a small task)
insert into DB

If you want help doing this send some code about what you tried and what 
problems you're having and we can help out.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Checking pixel sizes

2005-11-04 Thread Mike Blezien

Thanks, apprecite it. that worked fine.

zentara wrote:

On Thu, 03 Nov 2005 15:29:33 -0600, [EMAIL PROTECTED] (Mike
Blezien) wrote:



Hello,

I'm using ImageMagick to create thumbnails and other image manipulation with a 
upload script. And was wondering if the actual pixel size can be checked with 
ImageMagick ?? I've used Image::Size to do this, but was wondering it can be 
done using ImageMagick without having to install a separate module for this.


A simple example would be appreciated if you know how this is done.

TIA


Here are the 2 ways. Use the Ping method.


#!/usr/bin/perl -w
use Image::Magick;

my $x = $ARGV[0];
my $image;
$image = Image::Magick->new;
$image->Read($x);
my ($w,$h)= $image->Get('columns','height');
print $x,' is ',$w.'x'.$h,"\n";
#this is very inneficient memory wise, use Ping 


($width, $height, $size, $format) = $image->Ping($x);
print $width,"\n", $height,"\n" ,$size,"\n", $format,"\n";





--
Mike(mickalo)Blezien
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
Thunder Rain Internet Publishing
Providing Internet Solutions that work!
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Dates

2005-11-04 Thread Jeff 'japhy' Pinyan

On Nov 4, Scott Taylor said:


I have a date in UT that looks like this:
"2005-11-02 01:36:00.0"

Can anyone tell me the best way to subtract 8 hours from it, or to convert
it to PDT?

I'm reading up on Date::Manip, but I don't know if that is going to help,
yet.


Date::Manip can probably do it, and it can also cook you a three-course 
meal and help you find your wallet.  For a slightly lighter-weight 
solution, consider the simple Date::Parse (which comes with Perl).  It can 
handle the format you've provided:


  use Date::Parse;
  my $gmtime = str2time("2005-11-02 01:36:00.0", "UTC");

Now you have the number of seconds in $gmtime.  Subtract 8 hours by 
subtracting 60*60*8 seconds from that.


--
Jeff "japhy" Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: Dates

2005-11-04 Thread Timothy Johnson

Check out the Time::Local module.  It will let you convert your text
date into Perl time() format.

-Original Message-
From: Scott Taylor [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 04, 2005 11:36 AM
To: beginners@perl.org
Subject: Dates


Hello,

I have a date in UT that looks like this:
"2005-11-02 01:36:00.0"

Can anyone tell me the best way to subtract 8 hours from it, or to
convert
it to PDT?





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Dates

2005-11-04 Thread Scott Taylor

Hello,

I have a date in UT that looks like this:
"2005-11-02 01:36:00.0"

Can anyone tell me the best way to subtract 8 hours from it, or to convert
it to PDT?

I'm reading up on Date::Manip, but I don't know if that is going to help,
yet.

Cheers.

--
Scott

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: about cron and perl

2005-11-04 Thread Steve Bertrand

>1. what should I include in the do_it.pl, say to 
> delete certain old files?

I don't understand what you are getting at here. Are you asking us how
to write a script to perform this certain task? What have you tried so
far?

>2. this is a more unix problem, how should I 
> exactly invoke "crontab do_it.pl", say I want cron to run 
> do_it.pl everyday?

# crontab -e

...and add a similar line to the crontab that reflects the path to and
including your script. This entry will run my perl script once a day at
11:59PM:

59 23 * * * /home/steveb/devel/smtpweb/createvirttable.pl

Steve


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: about cron and perl

2005-11-04 Thread Ryan Frantz


> -Original Message-
> From: ZHAO, BING [mailto:[EMAIL PROTECTED]
> Sent: Friday, November 04, 2005 2:16 PM
> To: beginners@perl.org
> Subject: about cron and perl
> 
> Hi,
>I was advised to check out man cron for how to use cron.
Set
> off do_it.pl using cron.
> But that's about it , all I can get from web help. I have no clue:
>1. what should I include in the do_it.pl, say to delete
certain
> old files?

Admin caveat:  whenever deleting files via script, have your script
verify that it is in the _correct_ directory before performing any
delete operations.  _correct_ directory means wherever you want to
operate.  If you happen to be running the script as root (especially
automatically), this will save you much agony.  It's no fun having to
rebuild your system because a directory didn't exist and your script
defaulted to wherever the user's home directory is (in some *NIXes,
root's home dir is /).

>2. this is a more unix problem, how should I exactly invoke
> "crontab do_it.pl", say I
> want cron to run do_it.pl everyday?
> thank you all.

Well, cron reads crontab every minute.  man crontab will tell you this.

--snip--
   cron(8) examines cron entries once every minute.

   The time and date fields are:

  field  allowed values
  -  --
  minute 0-59
  hour   0-23
  day of month   1-31
  month  1-12 (or names, see below)
  day of week0-7 (0 or 7 is Sun, or use names)

   A  field  may  be an asterisk (*), which always stands for
   ``first-last''.
--end snip--

An example for you may be:

# run do_it.pl every 5 minutes, every day, every month, etc...
*/5 * * * * /some/path/do_it.pl

Note that your version of cron may not support the contracted steps such
as */5 so you may be forced to type out all the minutes that it would
run (i.e. 0,5,10,15, etc).  See your docs for more info.

ry

> 
> best,
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  
> 


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




about cron and perl

2005-11-04 Thread ZHAO, BING

Hi,
  I was advised to check out man cron for how to use cron. Set off do_it.pl using cron. 
But that's about it , all I can get from web help. I have no clue:

  1. what should I include in the do_it.pl, say to delete certain old 
files?
  2. this is a more unix problem, how should I exactly invoke "crontab do_it.pl", say I 
want cron to run do_it.pl everyday?

   thank you all.

best,

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




How do i create a basic form that can be emailed to a database?

2005-11-04 Thread Misty Kesler
I Just would like to know a lot of those already made forms, just don't 
work. Any help is appreciated

Thanks-

Misty P Kesler
misty.tcfn.org


Re: conditional use()

2005-11-04 Thread JupiterHost.Net



Jeff 'japhy' Pinyan wrote:


On Nov 4, JupiterHost.Net said:

I'm beating my head against the wall trying to remember where I saw 
this / how to do this:


In some documentation I remember seeing a use statement that had some 
sort of condition.



  use if ...;

perldoc if


YES Jeff you rock, if you're ever in town (Houston, TX) I owe you a 
brew ;p




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: conditional use()

2005-11-04 Thread Jeff 'japhy' Pinyan

On Nov 4, JupiterHost.Net said:

I'm beating my head against the wall trying to remember where I saw this 
/ how to do this:


In some documentation I remember seeing a use statement that had some sort of 
condition.


  use if ...;

perldoc if

--
Jeff "japhy" Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




conditional use()

2005-11-04 Thread JupiterHost.Net

Howdy Perl Studs

I'm beating my head against the wall trying to remember where I saw this 
/ how to do this:


In some documentation I remember seeing a use statement that had some 
sort of condition.


Its the same idea as how:

 use Foo if $WE_DO_WANT_FOO;

reads (but of course that doesn't work)

It seemed to involve a comma but my old age is sucking away the brain 
cells faster than I can count...


It did not involve an eval, and it was like:

use Foo, ???;

I seem to think is was in documentation for a pragma or diagnostic/devel 
 type module...


Any memory jogs would be most appreciated!

TIA

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: XML Help

2005-11-04 Thread Scott Taylor

Bob Showalter said:
> Scott Taylor wrote:
>> Hi All,
>>
>> I'm using XML::Simple to parse a very simple XML file and dump the data
>> into hashes of hashes.
>>
>> The problem I'm getting, is sometimes information is blank in the XMl
>> file; it looks like this:
>> 
>> instead of
>> 1234
>>
>> and when I print the hash:
>>
>> print "$x->{VEHICLE}->{STREETNUM} ";
>>
>> it returns: "HASH(blahblah)";
>>
>> How do I test for this so it prints blank?  I've tried many things, the
>> most logical I could think of was:
>>
>> if ($x->{VEHICLE}->{STREETNUM}){ print ... }
>> else { print ""; }
>
> Two ways to do this:
>
> 1) use SuppressEmpty option. This will simply exclude the STREETNUM
> element if it is empty (no attributes and no content)

Thanks.  That works, and I don't even have to test it in my output. :)

> 2) use ForceContent option. This will treat the STREETNUM element as a
> hash even if it is empty or contains only text. In this case you would
> use $x->{VEHICLE}{STREETNUM}{content} in your code.
>
> #2 would probably be safer, because it would handle attributes to
> STREETNUM elements properly.

I tried that an all I got was a bunch of trouble; the program seem to go
into a forever loop.  :(

I'm just using the data from the file, no attributes, does that matter?

> You can read more about these options in the XML::Simple documentation.

Of course I did, it just doesn't make a lot of sense. :)

--
Scott

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: XML Help

2005-11-04 Thread Scott Taylor

Bob Showalter said:
> Scott Taylor wrote:
>> Dermot Paikkos said:
>>>I would also say that the source file is wrong, it should read
>>>
>>
>>
>> I read somewhere that  is correct syntax (same as )
>
> You are correct. The two forms are exactly equivalent. see:
> http://www.w3.org/TR/REC-xml/#sec-starttags

Yeah, that's where I read it.  Still doesn't help me validate the hash
though. :(

--
Scott

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: What am I doing wrong?

2005-11-04 Thread Jeff 'japhy' Pinyan

#!/usr/bin/perl
#
#   webstore-rijselect-5-werkt.pl 
#

use warnings;
use strict;

use integer;
use DBI;

my ($dbh, $sth, $sta, $sql_een, $sql_twee, $i, $n, @sku, 
@qty, @t_qty);


You've just made a bunch of "global" variables.  Sure, they're lexicals, 
but you've declared them all to exist in the uppermost scope of your 
program.  Surely they don't all deserve such wide range, do they?



# create a statement in $sth
$dbh = DBI->connect('dbi:mysql:webstore-2','gabala','',  {
   PrintError => 1, ### rapporteer fouten via warn()
   RaiseError =>1  ### rapporteer fouten via die() });


Unless this was a code-wrapping error, you've got a problem here.  Your 
second comment hides the '});' part of your code.


  $dbh = DBI->connect('DSN', 'user', 'pass', {
PrintError => 1,  # comment
RaiseError => 1,  # comment
  });

$sql_een = 'SELECT num FROM nra_produkten'; # prepare a SQL 
query with placeholder $sth=$dbh->prepare($sql_een); 
$sth->execute; $sth->fetchrow_array(); $n = $DBI::rows;


Ugh.  More wrapping errors.

  $sql_een = 'SELECT num FROM nra_produkten';  # NO PLACEHOLDERS!!!
  $sth = $dbh->prepare($sql_een);
  $sth->execute;
  $sth->fetchrow_array;
  $n = $DBI::rows;


for ($i = 1; $i <= $n+1; ++$i ) {


Why $n + 1?  I'd think 1 .. $n is sufficient.

  for my $i (1 .. $n) {


  $sql_twee = 'SELECT sku_srs, aantal FROM nra_slim WHERE num = ?';


I don't speak your native tongue, but have you just named two variables 
$sql_een and $sql_twee, meaning $sql_1 and $sql_2?  If so, that's pretty 
dwaas.  Give you variables more descriptive names!



  $sth=$dbh->prepare($sql_twee);
  $sth->bind_param(1, "$i");


You don't need to quote $i here.


  $sth->execute;


And you could've just done:  $sth->execute($i).  That would've used $i to 
fill in the placeholder.



  foreach (my @result = $sth->fetchrow_array) {


That is certainly incorrect.  I think you just want to do:

  my @result = $sth->fetchrow_array;

and dispense with the loop entirely.  Otherwise, you're running the same 
code TWICE (once for each element in @result).



1989, totaalaantal is 5
1989, totaalaantal is 5
4121, totaalaantal is 1
4121, totaalaantal is 1


Yup.  Tweemaal.

--
Jeff "japhy" Pinyan%  How can we ever be the sold short or
RPI Acacia Brother #734%  the cheated, we who for every service
http://www.perlmonks.org/  %  have long ago been overpaid?
http://princeton.pm.org/   %-- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




RE: What am I doing wrong?

2005-11-04 Thread Steve Bertrand
It's very early in the morning yet, so forgive any oversight or mistakes
I haven't noticed in this post. Here goes some things I saw...again
though, without the actual data, it's hard to read into it properly:

> > HERE'S MY SCRIPT:
> #!/usr/bin/perl
> #
> #   webstore-rijselect-5-werkt.pl   
> #
> use warnings;
> use strict;
> 
> use integer;
> use DBI;
> 
> my ($dbh, $sth, $sta, $sql_een, $sql_twee, $i, $n, @sku, 
> @qty, @t_qty);
> 
> 
> 
> # create a statement in $sth
> $dbh = DBI->connect('dbi:mysql:webstore-2','gabala','',  {
>PrintError => 1, ### rapporteer fouten via warn()
>RaiseError =>1  ### rapporteer fouten via die() });
> 
> 
> $sql_een = 'SELECT num FROM nra_produkten'; # prepare a SQL 
> query with placeholder $sth=$dbh->prepare($sql_een); 
> $sth->execute; $sth->fetchrow_array(); $n = $DBI::rows;
> 

# Here, it appears as though you are using $n, but did not assign it a
value. Along with that, you are incrementing $i before the for statement
begins. This may be intended, but I thought I'd point it out.

We'll need to know how many times you are intending to perform the
select statement, what the value of $n is supposed to represent etc. It
is certainly apparent that you are performing something twice, but I
just can't put my finger on where.

Perhaps throw an extra print statements into each if and else statement
describing which one it is to see what is running twice etc.

Sorry to be so undescriptive, but I hope I gave some sort of decent
idea.

Steve

> for ($i = 1; $i <= $n+1; ++$i ) {
>   $sql_twee = 'SELECT sku_srs, aantal FROM nra_slim WHERE 
> num = ?';
>   $sth=$dbh->prepare($sql_twee);
>   $sth->bind_param(1, "$i");
>   $sth->execute;
> 
>   foreach (my @result = $sth->fetchrow_array) {
>   $sku[$i]=$result[0];
>   $qty[$i]=$result[1];
>   $t_qty[$i]=0;
>   if ($i < 2) {
>   $t_qty[$i]=$qty[$i];
>   }
>   else {
>   if ($sku[$i]==$sku[$i-1]){
>   $t_qty[$i]= $t_qty[($i-1)] + $qty[$i];
>   if($i==$n){
>   print "$sku[$i]",', 
> totaalaantal is ', "$t_qty[$i]\n";
>   }
>   }
>   else {
>   $t_qty[$i]=$qty[$i];
>   if($i==$n){
>   print "$sku[$i]",', 
> totaalaantal is ', "$t_qty[$i]\n";
>   }
>   else {  
>   print "$sku[$i-1]",', 
> totaalaantal is ', "$t_qty[$i-1]\n";
>   }
>   }
>   }
>   }
> }
> 
> 
> $sth->finish;
> $dbh->disconnect;
> 
> > HERE's MY OUTPUT
> 1989, totaalaantal is 5
> 1989, totaalaantal is 5
> 4121, totaalaantal is 1
> 4121, totaalaantal is 1
> 4122, totaalaantal is 1
> 4122, totaalaantal is 1
> 4123, totaalaantal is 2
> 4123, totaalaantal is 2
> 4959, totaalaantal is 11
> 4959, totaalaantal is 11
> 5337, totaalaantal is 25
> 5337, totaalaantal is 25
> 5338, totaalaantal is 1
> 5338, totaalaantal is 1
> 5938, totaalaantal is 10
> 5938, totaalaantal is 10
> 18164, totaalaantal is 1
> 18164, totaalaantal is 1
> 21505, totaalaantal is 7
> 21505, totaalaantal is 7
> 29765, totaalaantal is 1
> 29765, totaalaantal is 1
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED] For 
> additional commands, e-mail: [EMAIL PROTECTED] 
>  
> 
> 
> 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regex search/replace syntax

2005-11-04 Thread John W. Krahn
Gary Stainburn wrote:
> Hi folks I've got the following code which generates 
> 
> Parse error: parse error in /home/httpd/html/consumables.html on line 
> 290

That message did not come from perl.

perldoc perldiag


> when I try to run it. The script doesn't run because of the parse error
> 
> $orderSQL=~s/TOTAL/$or_total/;
> 
> $orderSQL is a string containing a number of SQL statements with the 
> placeholder &total; and $or_total has a value of '695.76'
> 
> I've done this many times in the past without a problem.  If I add a 
> modifier, such as 
> 
> $orderSQL=~s/TOTAL/$or_total/g;
> 
> the script runs, but the error changes to a runtime error:
> 
> Warning: Division by zero in /home/httpd/html/consumables.html on line 
> 290

Again, that message did not come from perl.


> which for some reason it displays twice.
> 
> Anyone got any ideas?

Try to determine what program is generating those messages.


John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regex search/replace syntax

2005-11-04 Thread Xavier Noria


On Nov 4, 2005, at 13:58, Gary Stainburn wrote:


On Friday 04 November 2005 12:20 pm, Xavier Noria wrote:

On Nov 4, 2005, at 13:03, Gary Stainburn wrote:

Hi folks I've got the following code which generates

Parse error: parse error in /home/httpd/html/consumables.html on
line 290

when I try to run it. The script doesn't run because of the parse
error

$orderSQL=~s/TOTAL/$or_total/;

$orderSQL is a string containing a number of SQL statements with
the placeholder &total; and $or_total has a value of '695.76'


 % perl -wle '$or_total="695.76"; \
  $orderSQL="TOTAL"; \
  $orderSQL=~s/TOTAL/$or_total/; \
  print $orderSQL'
 695.76

The error is somewhere else.

-- fxn


I see your point, but if I comment out the line the script works fine.
I've not manages to fix it, but have re-structured the script so it
works differently but does the job.


Yes, but the working assumption is that the code is broken, not the  
parser. So I would try to be sure I understand where's the problem.  
Otherwise, seeing it just disappear by blind code manipulation, you  
cannot be sure the program is not still broken.


-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regex search/replace syntax

2005-11-04 Thread Gary Stainburn
On Friday 04 November 2005 12:20 pm, Xavier Noria wrote:
> On Nov 4, 2005, at 13:03, Gary Stainburn wrote:
> > Hi folks I've got the following code which generates
> >
> > Parse error: parse error in /home/httpd/html/consumables.html on
> > line 290
> >
> > when I try to run it. The script doesn't run because of the parse
> > error
> >
> > $orderSQL=~s/TOTAL/$or_total/;
> >
> > $orderSQL is a string containing a number of SQL statements with
> > the placeholder &total; and $or_total has a value of '695.76'
>
>  % perl -wle '$or_total="695.76"; \
>   $orderSQL="TOTAL"; \
>   $orderSQL=~s/TOTAL/$or_total/; \
>   print $orderSQL'
>  695.76
>
> The error is somewhere else.
>
> -- fxn

I see your point, but if I comment out the line the script works fine.  
I've not manages to fix it, but have re-structured the script so it 
works differently but does the job.
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




regex search/replace syntax

2005-11-04 Thread Gary Stainburn
Hi folks I've got the following code which generates 

Parse error: parse error in /home/httpd/html/consumables.html on line 
290

when I try to run it. The script doesn't run because of the parse error

$orderSQL=~s/TOTAL/$or_total/;

$orderSQL is a string containing a number of SQL statements with the 
placeholder &total; and $or_total has a value of '695.76'

I've done this many times in the past without a problem.  If I add a 
modifier, such as 

$orderSQL=~s/TOTAL/$or_total/g;

the script runs, but the error changes to a runtime error:

Warning: Division by zero in /home/httpd/html/consumables.html on line 
290

which for some reason it displays twice.

Anyone got any ideas?


-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regex search/replace syntax

2005-11-04 Thread Xavier Noria

On Nov 4, 2005, at 13:03, Gary Stainburn wrote:


Hi folks I've got the following code which generates

Parse error: parse error in /home/httpd/html/consumables.html on line
290

when I try to run it. The script doesn't run because of the parse  
error


$orderSQL=~s/TOTAL/$or_total/;

$orderSQL is a string containing a number of SQL statements with the
placeholder &total; and $or_total has a value of '695.76'


% perl -wle '$or_total="695.76"; \
 $orderSQL="TOTAL"; \
 $orderSQL=~s/TOTAL/$or_total/; \
 print $orderSQL'
695.76

The error is somewhere else.

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Checking pixel sizes

2005-11-04 Thread Dermot Paikkos

On 3 Nov 2005 at 15:29, Mike Blezien wrote:

> Hello,
> 
> I'm using ImageMagick to create thumbnails and other image manipulation with 
> a 
> upload script. And was wondering if the actual pixel size can be checked with 
> ImageMagick ?? I've used Image::Size to do this, but was wondering it can be 
> done using ImageMagick without having to install a separate module for this.
> 
> A simple example would be appreciated if you know how this is done.

>From perlmagick docs:

($width, $height, $size, $format) = $image->Ping('logo.png');

This is the quickest method as it reads the information from the file 
header rather than opening/reading the entire file. This doesn't tell 
you how many pixel per inch there are. You need to use the depth 
method for that.

You should check out 
http://www.cit.gu.edu.au/~anthony/graphics/imagick6/.

It is an excellent source of information on IM including a section on 
creating thumbnails.
HTH.
Dp




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: regex search/replace syntax

2005-11-04 Thread Gary Stainburn
On Friday 04 November 2005 12:03 pm, Gary Stainburn wrote:
[snip]
> $orderSQL is a string containing a number of SQL statements with the
> placeholder &total; and $or_total has a value of '695.76'
>

Sorry, the placeholder is TOTAL not &total.  I changed it to see if it 
made a difference, which it didn't.

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: What am I doing wrong?

2005-11-04 Thread Gary Stainburn
On Friday 04 November 2005 12:12 pm, jean wrote:
> hello there,
>
> Being new to PERL, I've found this very informative list and I've
> been playing around with PERL a bit.
>
> Right now I'm working on some code that picks up items from my
> database and calculates the total stock for identical items. I've
> created a small database to try out my script.
>
> Now I've probably made more stupid mistakes than anyone on this list
> has ever made. Also I bet there are different and more efficient ways
> to write code that performs this function. However my main problem is
> that the script does not do what I expect and I can't figure out why.
> In the output all the lines are printed twice, where I expect them to
> appear only once. The totals are calculated correctly.
>
> So if anyone here can help me, that would be very much appreciated
>
> thanks, jean
>

Hi Jean

I'm struggling to see what you're trying to do.  Could you give me an 
examle of the schema/data you're working from.  I'd like to have a go 
at rewriting this one to see how well I do.

Gary

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: What am I doing wrong?

2005-11-04 Thread Gary Stainburn
On Friday 04 November 2005 12:12 pm, jean wrote:
[snip]
>
>   foreach (my @result = $sth->fetchrow_array) {
>   $sku[$i]=$result[0];
>   $qty[$i]=$result[1];
>   $t_qty[$i]=0;
>   if ($i < 2) {
>   $t_qty[$i]=$qty[$i];
>   }
>   else {
>   if ($sku[$i]==$sku[$i-1]){
>   $t_qty[$i]= $t_qty[($i-1)] + $qty[$i];
>   if($i==$n){
>***print "$sku[$i]",', totaalaantal is ', 
>"$t_qty[$i]\n";
>   }
>   }
>   else {
>   $t_qty[$i]=$qty[$i];
>   if($i==$n){
>   print "$sku[$i]",', totaalaantal is ', 
> "$t_qty[$i]\n";
>   }
>   else {
>***print "$sku[$i-1]",', totaalaantal is ', 
>"$t_qty[$i-1]\n";
>   }
>   }
>   }
>   }
> }
>
[snip]

Looks like you're printing while you're still on the record and then 
you're printing it again once you've moved to the next.
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




What am I doing wrong?

2005-11-04 Thread jean
hello there,

Being new to PERL, I've found this very informative list and I've been playing 
around with PERL a bit. 

Right now I'm working on some code that picks up items from my database and 
calculates the total stock for identical items. I've created a small database 
to try out my script. 

Now I've probably made more stupid mistakes than anyone on this list has ever 
made. Also I bet there are different and more efficient ways to write code 
that performs this function. However my main problem is that the script does 
not do what I expect and I can't figure out why. In the output all the lines 
are printed twice, where I expect them to appear only once. The totals are 
calculated correctly.

So if anyone here can help me, that would be very much appreciated

thanks, jean


> HERE'S MY SCRIPT:
#!/usr/bin/perl
#
#   webstore-rijselect-5-werkt.pl   
#
use warnings;
use strict;

use integer;
use DBI;

my ($dbh, $sth, $sta, $sql_een, $sql_twee, $i, $n, @sku, @qty, @t_qty);



# create a statement in $sth
$dbh = DBI->connect('dbi:mysql:webstore-2','gabala','',  {
   PrintError => 1, ### rapporteer fouten via warn()
   RaiseError =>1  ### rapporteer fouten via die()
});



$sql_een = 'SELECT num FROM nra_produkten';
# prepare a SQL query with placeholder
$sth=$dbh->prepare($sql_een);
$sth->execute;
$sth->fetchrow_array();
$n = $DBI::rows;

for ($i = 1; $i <= $n+1; ++$i ) {
$sql_twee = 'SELECT sku_srs, aantal FROM nra_slim WHERE num = ?';
$sth=$dbh->prepare($sql_twee);
$sth->bind_param(1, "$i");
$sth->execute;

foreach (my @result = $sth->fetchrow_array) {
$sku[$i]=$result[0];
$qty[$i]=$result[1];
$t_qty[$i]=0;
if ($i < 2) {
$t_qty[$i]=$qty[$i];
}
else {
if ($sku[$i]==$sku[$i-1]){
$t_qty[$i]= $t_qty[($i-1)] + $qty[$i];
if($i==$n){
print "$sku[$i]",', totaalaantal is ', 
"$t_qty[$i]\n";
}
}
else {
$t_qty[$i]=$qty[$i];
if($i==$n){
print "$sku[$i]",', totaalaantal is ', 
"$t_qty[$i]\n";
}
else {  
print "$sku[$i-1]",', totaalaantal is ', 
"$t_qty[$i-1]\n";
}
}
}
}
}


$sth->finish;
$dbh->disconnect;

> HERE's MY OUTPUT
1989, totaalaantal is 5
1989, totaalaantal is 5
4121, totaalaantal is 1
4121, totaalaantal is 1
4122, totaalaantal is 1
4122, totaalaantal is 1
4123, totaalaantal is 2
4123, totaalaantal is 2
4959, totaalaantal is 11
4959, totaalaantal is 11
5337, totaalaantal is 25
5337, totaalaantal is 25
5338, totaalaantal is 1
5338, totaalaantal is 1
5938, totaalaantal is 10
5938, totaalaantal is 10
18164, totaalaantal is 1
18164, totaalaantal is 1
21505, totaalaantal is 7
21505, totaalaantal is 7
29765, totaalaantal is 1
29765, totaalaantal is 1

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]