Re: help with making an sftp connection

2023-04-17 Thread Dermot
Hi,

Can you edit the constructor to include `more => [ -v ]` so we can get more
feedback from the SSH connection and send the output from that.

$sftp = Net::SFTP::Foreign->new($host,
user => $user,
password => $pass,
more => [
qw(
-v
-o PreferredAuthentications=password
-o PasswordAuthentication=yes
-o BatchMode=yes
)
   ]
)  or $sftp->error;

The clue to what is going wrong will be in the output from ssh.
Thanks,
Dermot

On Mon, 17 Apr 2023 at 10:13, Brent Wood via beginners 
wrote:

> More detail, thanks for your time...
>
>
> This is to test the Perl script on a local (Linux) system, copying a file
> from /tmp to another directory.
>
> I can use command line sftp to copy a file fine with the user/password
> connection, so there is not a problem with sftp, user/password etc on the
> system.
>
> This Perl script executes without error, but hangs on $sftp = Net::...
> (prints start, never prints done)
>
> If I take out the password assignment, I'm prompted for a password and it
> then works fine. With it there, it hangs.
>
> Can anyone help me get this working with a password passed as a parameter?
>
> use Net::SFTP::Foreign;
> use IO::Pty;
> use feature say;
>
> $host = "127.0.0.1";
> $user = "baw";
> $pass = "..";
>
> say "start";
>
> $sftp = Net::SFTP::Foreign->new($host,
> user => $user,
> password => $pass,
> more => [qw(-o PreferredAuthentications=password
> -o PasswordAuthentication=yes -o BatchMode=yes)]
> );
>
> say "done";
>
>


Re: Virtualmin and Webmin web hosting control panel are written in Perl 5

2022-08-03 Thread Dermot
++Kang-min Liu

It looks like you can get (paid) support [1] for Virtualmin so if it's not
practical for you to take on the entire task, you might consider that route.

[1] https://www.virtualmin.com/documentation/system/support/

On Mon, 1 Aug 2022 at 08:27, Turritopsis Dohrnii Teo En Ming <
tdtemc...@gmail.com> wrote:

> Maybe if I want to modify Virtualmin/Webmin code, I will need to hire
> a Perl programmer :)
>
> Mr. Turritopsis Dohrnii Teo En Ming
> Targeted Individual in Singapore
>
> On Mon, 1 Aug 2022 at 15:22, Olivier  wrote:
> >
> > Turritopsis Dohrnii Teo En Ming  writes:
> >
> > > If I want to learn Perl programming language from scratch having
> > > totally no knowledge of it, how long (in terms of months or years)
> > > would it take before I can confidently and proficiently modify
> > > Virtualmin and Webmin code?
> >
> > Learning how to program in Perl is easy, it is like Basic or C or any
> > procedural language. There is no major trick, especially because it is
> > very flexible so iot will adapt to many style of programming.
> >
> > But because iof it'sd flexibility, it can also be challenging to read
> > the coded written by another programmer, because they can have use a
> > syntax that you are not familiar with: Perl can be straight forward,
> > verbose and readable or can be short, compressed and very obscure.
> >
> > Programmning is easy, modifying someone else code, not that much.
> >
> > Good luck,
> >
> > Olivier
> >
> > > Hopefully there is no steep learning curve.
> > >
> > > Thank you.
> > >
> > > Regards,
> > >
> > > Mr. Turritopsis Dohrnii Teo En Ming
> > > Targeted Individual in Singapore
> > > 1 Aug 2022 Mon
> > > Blogs:
> > > https://tdtemcerts.blogspot.com
> > > https://tdtemcerts.wordpress.com
> >
> > --
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: What is the mean of the following syntax?

2022-08-03 Thread Dermot
On Wed, 3 Aug 2022 at 11:45, armando perez pena 
wrote:

> Hello William,
>
> Perl is a programming language easy to use an relative easy to learn. But
> is very very tricky.
>
>
I, personally, don't think perl is any trickier than any other language.
Larry, who studied linguistics, borrowed a lot of syntax from C and the
unix shell to keep things familiar. For regexes there was no blueprint and
the grammar is a little terse. I like to think that is out of necessity
rather than design. If you're new to programming/scripting, it will not
take you long to figure out ! mean negation.

I do agree with you that a recent edition of Learning Perl [1] is a good
starting place.

What surprises me about this thread, and others on this list, is that there
is little or no reference to the excellent documentation that Perl has.

use `perldoc perlretut`  from the command line for a quick regex tutorial.
`perldoc toc` to see the full and vast amount of POD available at your
finger-tips on your local PC.
Or visit https://perldoc.perl.org [2] and see it all in technicolor.

If we are concerned about advocacy, we should direct people to the official
documentation that the Perl Foundation has invested heavily in, and
perhaps, not describe this beautiful, powerful and expressive language as
very tricky.
Apologies for the mini rant,
Dermot

[1]  https://www.oreilly.com/library/view/learning-perl-6th/9781449311063/
[2] https://perldoc.perl.org/perlretut


Re: No decode delegate for this image format `PNG'

2022-01-26 Thread Dermot
`convert --version` should display a list of delegates known to
imagemagick. What does your say?

On Tue, 25 Jan 2022 at 16:35, William Torrez Corea 
wrote:

> I write a code but the result I expected is wrong.
>
> #!/usr/local/bin/perl
>> use Image::Magick;
>>
>> # The script reads three images, crops them, and writes a single image as
>> a GIF animation sequence
>> my($image, $x);
>>
>> $image = Image::Magick->new;
>> $x =
>> $image->Read('Bugs_Bunny.svg.png','png-clipart-bugs-bunny-witch-hazel-drawing-looney-tunes-cartoon-bugs-and-lola-bunny.png','png-transparent-bugs-bunny-in-double-trouble-looney-tunes-others.png');
>> warn "$x" if "$x";
>>
>> $x = $image->Crop(geometry=>'100x100+100+100');
>> warn "$x" if "$x";
>>
>> $x = $image->Write('x.png');
>> warn "$x" if "$x";
>>
>
> The following error was:
>
> Exception 420: no decode delegate for this image format `PNG' @
>> error/constitute.c/ReadImage/572 at gifaninmation.pl line 9.
>> Exception 410: no images defined `Crop' @
>> error/Q16HDRI.xs/XS_Image__Magick__Q16HDRI_Mogrify/7824 at
>> gifaninmation.pl line 12.
>> Exception 410: no images defined `Image::Magick::Q16HDRI' @
>> error/Q16HDRI.xs/XS_Image__Magick__Q16HDRI_Write/15195 at
>> gifaninmation.pl line 15.
>>
>
> According to this article I have installed * libpng *but the error is
> present.
> https://legacy.imagemagick.org/discourse-server/viewtopic.php?t=14301
>
>
>
> --
>
> With kindest regards, William.
>
> ⢀⣴⠾⠻⢶⣦⠀
> ⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
> ⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
> ⠈⠳⣄
>
>


Re: controlling Firefox using Perl

2021-03-12 Thread Dermot
In the past I have opted to use Webdriver::Tiny. However I've only ever
used it with Chromium browser but the documentation says it can work with
Geckodriver.

The API for Webdriver::Tiny is slightly different from Selenium::Firefox
 so your code will need to be
modified.

https://metacpan.org/pod/distribution/WebDriver-Tiny/lib/WebDriver/Tiny.pod#geckodriver


On Fri, 12 Mar 2021 at 15:28, Vlado Keselj  wrote:

>
> That is a very interesting problem.  I was also researching it and noticed
> this package Selenium but did not try it.  I would be interested to know
> what kind of problem you are trying to solve.
>
> Vlado
>
> On Fri, 12 Mar 2021, Gary Stainburn wrote:
>
> > Can anyone please point me to decent documentation for controlling
> Firefox
> > using perl?
> >
> > I am open to any solution, but I have already looked at both
> > Selenium::Firefox, and Selenium::Remote::Driver.
> >
> > I have Selenium::Firefox working on a Centos 7 box, but I can't find any
> > documentation on how to use it. So far, all I have managed to do is open
> a web
> > browser window, and get a web page and extract it's contents.
> >
> > I also have a working Selenium::Remote::Driver setup with a perl script
> on a
> > Centos 7 box controlling IE11 on a Win10 box.
> >
> > I have spent all day going round in circles with Google finding out of
> date
> > articles, and links pointing back to each other without success. I can't
> even
> > find any doc's on using Selenium::Firefox on the cpan pages for the
> module.
> >
> > I have gone through dependency hell installing Selenium::Remote::Driver
> on a
> > new Centos 7 box.  I then  installed Java and
> > selenium-server-standalone-2.53.1.jar. However, when I try to run a
> script to
> > open a local Firefox window I get the error below on the selenium-server.
> >
> > Again, most of the articles relating this problem are old, circa 2016,
> and
> > refer to version compatibility issues.
> >
> > Any advice welcome.
> >
> > Gary
> >
> > 13:30:25.459 INFO - Executing: [new session: Capabilities
> > [{acceptSslCerts=true, browserName=firefox, javascriptEnabled=true,
> version=,
> > platform=ANY}]])
> > 13:30:25.469 INFO - Creating a new session for Capabilities
> > [{acceptSslCerts=true, browserName=firefox, javascriptEnabled=true,
> version=,
> > platform=ANY}]
> > org.openqa.selenium.firefox.NotConnectedException: Unable to connect to
> host
> > 127.0.0.1 on port 7055 after 45000 ms. Firefox console output:
> >
> > at
> >
> org.openqa.selenium.firefox.internal.NewProfileExtensionConnection.start(NewProfileExtensionConnection.java:112)
> > at
> >
> org.openqa.selenium.firefox.FirefoxDriver.startClient(FirefoxDriver.java:271)
> > at
> >
> org.openqa.selenium.remote.RemoteWebDriver.(RemoteWebDriver.java:119)
> > at
> > org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:218)
> > at
> > org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:211)
> > at
> > org.openqa.selenium.firefox.FirefoxDriver.(FirefoxDriver.java:129)
> > at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native
> > Method)
> > at
> >
> sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
>
> > at
> >
> sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
>
> > at
> java.lang.reflect.Constructor.newInstance(Constructor.java:423)
> > at
> >
> org.openqa.selenium.remote.server.FirefoxDriverProvider.callConstructor(FirefoxDriverProvider.java:91)
>
> > at
> >
> org.openqa.selenium.remote.server.FirefoxDriverProvider.newInstance(FirefoxDriverProvider.java:68)
>
> > at
> >
> org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance(DefaultDriverFactory.java:60)
>
> > at
> >
> org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:222)
>
> > at
> >
> org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call(DefaultSession.java:1)
>
> > at java.util.concurrent.FutureTask.run(FutureTask.java:266)
> > at
> >
> org.openqa.selenium.remote.server.DefaultSession$1.run(DefaultSession.java:176)
>
> > at
> >
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>
> > at
> >
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>
> > at java.lang.Thread.run(Thread.java:748)
> > 13:31:10.967 WARN - Exception thrown
> > java.util.concurrent.ExecutionException:
> > org.openqa.selenium.WebDriverException:
> > java.lang.reflect.InvocationTargetException
> > Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30
> > 17:37:03'
> > System info: host: 'study.stainburn.com', ip: '192.168.1.193', os.name:
> > 'Linux', os.arch: 'amd64', os.version: '3.10.0-1160.15.2.el7.x86_64',
> > java.version: '1.8.0_282'
> > 

Re: about package method returns

2019-11-01 Thread Dermot
Hello,

You don't need to setup $!. It is a global variable.

In the documentation I referenced it says:
"When referenced, $! retrieves the current value of the C errno integer
variable. If $! is assigned a numerical value, that value is stored in errno
. When referenced as a string, $! yields the system error string
corresponding to errno
...
Mnemonic: What just went bang?
"

https://perldoc.perl.org/perlvar.html#Error-Variables


On Fri, 1 Nov 2019 at 00:47, Maggie Q Roth  wrote:

> Thank you. how to setup $! in module, and how can I get the $! in caller?
>
> regards.
>
> On Fri, Nov 1, 2019 at 4:56 AM Dermot  wrote:
>
>> Hi,
>>
>> You cannot return `die`, die is a fatal exception that causes`test.pl`
>> to exit immediately.
>> One option would be to use warn to emit a warning to STDERR and return to
>> the caller and let them handle the failure. You may as well add the $! to
>> the output so the caller gets a copy of the last error.
>>   ...
>>$p->close();
>>warn "can't ping $host: $!";
>>return 0;
>>   }
>>
>>
>>
>> https://perldoc.perl.org/functions/die.html
>> https://perldoc.perl.org/functions/warn.html
>> https://perldoc.perl.org/perlvar.html#Error-Variables
>>
>> On Thu, 31 Oct 2019 at 09:42, Maggie Q Roth  wrote:
>>
>>> Hello
>>>
>>> Sorry I am new to perl, I was reading the charter about package.
>>>
>>> I tried to write the code below:
>>>
>>> use strict;
>>> use Net::Ping;
>>>
>>> package A;
>>>
>>> sub mytest {
>>>
>>>my $host = shift;
>>>my $p = Net::Ping->new();
>>>unless ($p->ping($host)) {
>>>$p->close();
>>>die "can't ping $host";
>>>}
>>> }
>>>
>>> 1;
>>>
>>> package B;
>>>
>>> sub mytest {
>>>
>>>my $host = shift;
>>>my $p = Net::Ping->new();
>>>unless ($p->ping($host)) {
>>>$p->close();
>>>return 0;
>>>}
>>> }
>>>
>>> 1;
>>>
>>> package main;
>>>
>>> A::mytest('www.google.com');
>>>
>>> print B::mytest('www.google.com');
>>>
>>>
>>>
>>> When I run it, always get:
>>> $ perl test.pl
>>> can't ping www.google.com at test.pl line 12.
>>>
>>>
>>> Shouldn't I return die() in package's method?
>>> How do I let the caller know what happens when the method fails to run?
>>>
>>> Thanks in advance.
>>>
>>> Yours
>>> Maggie
>>>
>>


Re: about package method returns

2019-10-31 Thread Dermot
Hi,

You cannot return `die`, die is a fatal exception that causes`test.pl` to
exit immediately.
One option would be to use warn to emit a warning to STDERR and return to
the caller and let them handle the failure. You may as well add the $! to
the output so the caller gets a copy of the last error.
  ...
   $p->close();
   warn "can't ping $host: $!";
   return 0;
  }



https://perldoc.perl.org/functions/die.html
https://perldoc.perl.org/functions/warn.html
https://perldoc.perl.org/perlvar.html#Error-Variables

On Thu, 31 Oct 2019 at 09:42, Maggie Q Roth  wrote:

> Hello
>
> Sorry I am new to perl, I was reading the charter about package.
>
> I tried to write the code below:
>
> use strict;
> use Net::Ping;
>
> package A;
>
> sub mytest {
>
>my $host = shift;
>my $p = Net::Ping->new();
>unless ($p->ping($host)) {
>$p->close();
>die "can't ping $host";
>}
> }
>
> 1;
>
> package B;
>
> sub mytest {
>
>my $host = shift;
>my $p = Net::Ping->new();
>unless ($p->ping($host)) {
>$p->close();
>return 0;
>}
> }
>
> 1;
>
> package main;
>
> A::mytest('www.google.com');
>
> print B::mytest('www.google.com');
>
>
>
> When I run it, always get:
> $ perl test.pl
> can't ping www.google.com at test.pl line 12.
>
>
> Shouldn't I return die() in package's method?
> How do I let the caller know what happens when the method fails to run?
>
> Thanks in advance.
>
> Yours
> Maggie
>


Re: Help me with a regex problem

2019-10-26 Thread Dermot
You might consider using Regexp::Common::net. It provides a convenient set
of functions for matching IP v4, v6 and mac addresses.


https://metacpan.org/pod/Regexp::Common::net

On Fri, 25 Oct 2019 at 19:43, John W. Krahn  wrote:

> On 2019-10-25 3:23 a.m., Maggie Q Roth wrote:
> >   Hello
>
> Hello.
>
> > There are two primary types of lines in the log:
>
> What are those two types?  How do you define them?
>
>
> > 60.191.38.xx/
> > 42.120.161.xx   /archives/1005
>
>  From my point of view those two lines have two fields, the first looks
> like an IP address and the second looks like a file path.  In other
> words I can't distinguish the difference between these two "types".
>
>
> > I know how to write regex to match each line, but don't get the good
> result
> > with one regex to match both lines.
> >
> > Can you help?
>
> Perhaps if you could describe the problem better?
>
>
> John
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: Website Files Preview as Thumbnail

2019-04-26 Thread Dermot
I suspect these sites you refer to are storing of the document's title and
are using that populate the icons.

On Fri, 26 Apr 2019 at 08:51, James Kerwin  wrote:

> Hi All,
>
> I promise this question is about Perl. I've googled this a lot and still
> can't find where to start.
>
> I run a publications repository/website that uses Perl on its back end. On
> each page I have a series of files. At the moment they display a thumbnail
> as the file icon (different for file type such as .doc, .jpg, .pdf etc.).
>
> I have seen some similar websites that appear to have the file content as
> the icon, admittedly with PDFs usually. For example the thumbnail would be
> the title page of the document. Does anybody know what I would search for
> for this functionality and is there a helpful Perl module/library that I
> can use?
>
> Thanks,
> James
>


Re: Is perl user specific

2016-01-06 Thread Dermot
Hi Ankita,

Is is possible for there to be several Perl binaries installed. Features
such as perlbrew will allow you to have multiple versions installed in your
home directory. You could try the `which` command if you are using a *nix
based OS. For instance;

>which perl
/usr/bin/perl

Then try perl -v to find our what version you are actually running.
Good luck,
Dermot.


On 6 January 2016 at 15:34, Ankita Rath <ankitarath2...@gmail.com> wrote:

> Hi all,
>
> I am trying to execute some perl scripts. I am getting following error.
> But other user in the same server are not getting the error. So can anybody
> help me understanding this problem. And why other user are not getting the
> error.
>
> Perl 5.008003 required--this is only version 5.00503, stopped at
> ../Modules/Modules_64/5.8.5/x86_64-linux-thread-multi/YAML/XS.pm line 26.
> BEGIN failed--compilation aborted at
> ../Modules/Modules_64/5.8.5/x86_64-linux-thread-multi/YAML/XS.pm line 26.
>
> Regards,
> Ankita
>
>
>
>
>
>


Re: sure would be nice if Perl had trace command built-in

2015-12-22 Thread Dermot
I tend to use Strawberry perl these days and would certainly recommend it.

Regarding the file paths you mentioned, the double back slash is correct
but also difficult to read. I change my windows scripts to use File::Spec
paths whenever I have to revisit them. This makes paths portable and easy
on the eye. I also find Test::Vars a useful tool for cleaning up code. It
will find unused variables.

Good luck,
Dermot.
On 12 Dec 2015 14:22, "Mike Flannigan" <mikef...@att.net> wrote:

>
>
> On 12/10/2015 5:40 AM, beginners-digest-h...@perl.org wrote:
>
>
>
>
>
> On Mon, Dec 7, 2015 at 6:33 PM, Brock Wilcox <awwa...@thelackthereof.org> 
> <awwa...@thelackthereof.org> wrote:
>
> > Give devel::trace or devel::tracemore a try :)
>
> Is it possible to install this from Active State repository without
> having an-up-date ActiveState Perl DevKit license?
>
> Thanks,
> Ken Wolcott
>
>
>
> FYI, my ActiveState PPM ver 4.17 pointed to repository:
> http://ppm4.activestate.com/MSWin32-x64/5.16/1603/package.xml
> does list Devel-Trace version 0.12.
> I did not try to install it.
>
> I have never had an ActiveState Perl DevKit license, or
> certainly didn't pay for it.
>
>
>
> Mike
>
>
>


Re: How does opendir/readdir process files

2015-01-09 Thread Dermot
I think John has answered your immediate question.

If you want to get the files back in a particular order you should include
a sort between and grep readdir. An example might be

my @files = sort { $a cmp $b }
   grep { ! /^\./  -f $dir/$_ } readdir($dh);
for (0..$#files) {
print $_) $files[$_]\n;
}


Alternatively, if you want the files in size order you could use something
like this

my @files = map { $_-[0] }
   sort { $a-[1] = $b-[1] }# numeric sort
   map { [$_,  -s $dir/$_] }
   grep { ! /^\./  -f $dir/$_ } readdir($dh);

for (0..$#files) {
print $_) $files[$_]\n;
}

If you want to get them back in an order based on the file modification
time, you would need to stat the file,

my @files = map { $_-[0] }
   sort { $a cmp $b }
   map {[$_, (stat($dir/$_))[9] ] }
   grep { ! /^\./  -f $dir/$_ } readdir($dh);


Hope that helps,
Dermot.



On 9 January 2015 at 01:52, Harry Putnam rea...@newsguy.com wrote:

 Opening a directory and readdir with a grep in there to find specific
 filenames, how does that process collect the files?

 I mean will the generated @ar of files be oldest first or someother
 reliable order?

 Using an example paraphrased from perldoc -f readdir:
 (I changed the regex)

   opendir(my $dh, $some_dir) || die can't opendir $some_dir: $!;
   my @a_ar = grep { /^a/  -f $some_dir/$_ } readdir($dh);
   closedir $dh;

 Will all the files beginning with `a' that make it to @a_ar, always be
 in order of modtime, oldest first? Or some other reliable order?

 Also, is there a similar reliable way files are processed when using
 File::Find?

 The perldoc page mentions that its depth first, but then what. What
 factors are considered in choosing a file to process?

 Of course, I mean beyond whatever specifications the script imposes.





 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Re: Installing Perl and CPAN local

2014-03-04 Thread Dermot
Hi Yosef,

As a Windows user , you will first need to decide what distribution to use.
Two options are Strawberry Perl (http://strawberryperl.com/) or ActiveState
Perl (http://www.activestate.com/activeperl/downloads). Both are available
for your architecture. Download the necessary installation files and the
rest should be straight-forward.

Good luck,
Dermot.



On 4 March 2014 10:42, Yosef Levy yosi.lev...@gmail.com wrote:

 Hello All,

 I am interesting install Perl and CPAN modules in custom location folders.
 I am using WIN7 64bit.
 Pls. provide me step by step in depended installation from scratch.

 Rgds.



Re: Programming Help Needed

2013-10-02 Thread Dermot
Your post to jobs.perl.org will likely result in some solicitations from
recruiters. You also likely to get a some queries about tele-working. At
least that has been our experience. I'm not saying that either is good or
bad but it's worth making it clear in the description what your after. You
may also ask around at your local Perl Mongers group. They may be able to
offer some advise also.
Good luck,
Dermot.



On 2 October 2013 01:12, Angela Barone ang...@italian-getaways.com wrote:

 On Oct 1, 2013, at 2:45 PM, John SJ Anderson wrote:

 jobs.perl.org is the definitive place to post Perl jobs.

 good luck in your search.


  Thank you, John!  I mentioned this link and was told that the last time
 we used it, we got a lot of responses from people who really didn't know
 there craft.  :(   If need be, we'll try it again, but hopefully there's a
 better solution for us.

 We're not looking for an individual to do some coding.  We would like an
 actual company, or a team of programmers, who can write a modern, large
 scale e-commerce solution from the ground up.

 Does anyone know of a Perl shop - an actual company of developers that can
 handle bigger jobs like this (from Perl to web design)?

 Thanks again,
 Angela



Re: Help on saving and retrieving data structures

2013-09-14 Thread Dermot
++Storable


On 14 September 2013 09:39, Shlomi Fish shlo...@shlomifish.org wrote:

 Hi Shaji,

 On Sat, 14 Sep 2013 16:19:26 +0800 (SGT)
 *Shaji Kalidasan* shajiin...@yahoo.com wrote:

  Dear David,
 
  Thanks for throwing light on the topic by citing the security
 implications of
  executing eval and also suggesting the industry standard 'JSON' for
  interoperability.
 

 One should note that JSON is not the only sane option for serialisation and
 deserialisation in Perl. There are also:

 * https://metacpan.org/release/Storable - a binary format that is
 specific for
 Perl, which works very well. Using it avoids some JSON-specific limitations
 such as no references to scalars. Make sure you use nstore and friends
 instead of store.

 * http://blog.booking.com/the-next-sereal-is-coming.html - there's also
 this,
 but I have no experience with it.

 * There are other formats such as YAML, but YAML should be avoided because
 it's
 too complex and quirky (at least for serialisation).

 Regards,

 Shlomi Fish

 --
 -
 Shlomi Fish   http://www.shlomifish.org/
 Optimising Code for Speed - http://shlom.in/optimise

 Whitespace in Python is not a problem: just lay out all the whitespace
 first,
 then add the code around it.
 — sizz on Freenode’s #perl

 Please reply to list if it's a mailing list post - http://shlom.in/reply .

 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Re: Array iterator count

2013-08-09 Thread Dermot
my $counter = 0;
foreach my $e ( a .. z ) {
  $counter++;
  if ( $counter == 5 ) {
   
  }
}

I know this is a perl idiom but I, and I suspect others, would find a perl
variable useful for the keeping the count when iterating. The draw back
with the above is that $counter has scope outside of the block and that
seems messy. I am not sure why the C style loop, EG:

for (my $i = 0; $i = $#items; ++$i)
{}

is so unpopular. Probably because it does look nice. It does have the
advantage of keeping all the variables in the immediate block so you don't
need to worry about $counter 100 lines down the code.
A feature request perhaps but I'm sure there are good reasons why the
maintainers haven't added such a perlvar.
Dermot.



On 8 August 2013 18:11, jbiskofski jbiskof...@gmail.com wrote:

 my $counter = 0;
 foreach my $e ( a .. z ) {
   $counter++;
   if ( $counter == 5 ) {

   }
 }


 On Thu, Aug 8, 2013 at 12:11 PM, jbiskofski jbiskof...@gmail.com wrote:

 my $counter = 0;
 foreach my $e ( a .. z ) {
   $counter++;



 On Thu, Aug 8, 2013 at 12:05 PM, Unknown User knowsuperunkn...@gmail.com
  wrote:


 Hello,


 If i am iterating through the elements in an array, at any point is it
 possible to say which element i am handling without using a counter? Are
 there any builtins that i can use for it?

 ie
 foreach my $element (a..z) {
...
if ( i am the 5th element ) { handle me special }

 }

 Thanks,






Re: Email::Sender on Centos 6

2013-07-17 Thread Dermot
I have noticed (correct me if I'm wrong) that Email::Sender depends on
Moose. I'm not aware of any CentOS 5 or 6 issues (I lean towards CentOS
6.x) with Moose but Moose does have a large number of dependencies. A  lot
of modern perl modules require antlers (Moose) and the dependency list is
long. As a result, un-attended installs can be problematic. I have ventured
into local-lib and PerlBrew to try and ensure that the system perl remains
un-compromised. I guess the point is, now that you've standardised on an
OS, you need to be aware of the eccentricities that that choice may have
and the options available.
Best.
Dermot.


On 17 July 2013 19:01, Steven Buehler st...@ibushost.com wrote:

 Ok, this is just stupid.  LOL.  Not you.I was installing this on about
 40 systems yesterday, 5 of which were CentOS 6.x the rest were CentOS 5.x.
  It would fail on all of the CentOS 6.x systems.  Today, I ran the same
 commands so that I could get the errors and it installed on all of them
 just perfectly.  Below is all I did, plus hitting yes when it asked about
 installing dependencies.

 ]# perl -MCPAN -e shell
 cpan shell -- CPAN exploration and modules installation (v2.00)
 Enter 'h' for help.
 cpan[1] install Email::Sender

 Thanks Anyway
 Steve


 On Wednesday, July 17, 2013 12:40:08 PM, Jim Gibson wrote:


 On Jul 17, 2013, at 9:59 AM, Steven Buehler wrote:

  I am trying to use CPAN to install Email::Sender on all of our systems
 for use in a perl script.  Most of our systems use CentOS 5.x, but I have a
 couple that are now on CentOS 6.x.  When trying to install it here, it
 keeps coming up with dependency issues and no matter how many of those
 dependencies I install, or attempt to install (because those need
 dependencies too), I can't get it installed.  Is there a version for CentOS
 6.x?  Or a replacement for it?  Or instructions somewhere for installing it
 on CentOS 6.x?


 I don't have access to a CentOS system, so I won't be able to help you
 with specific details unique to CentOS. However, I do have some questions
 that might help you or allow others to help you better:

 1. What version of Perl are you using?
 2. How was it installed (i.e., from a source distribution or through some
 CentOS package manager)?
 3. How are you attempting to install Email::Sender (from a source
 distribution or a cpan client)?

 There are CPAN installation programs that will install required
 prerequisite modules. Are you using one of these? The ones I know about are
 cpan and cpanm. I was able to install Email::Sender version 1.36 in a
 Perl 5.12 installation under Mac OS X with no problem using cpan.

 Please post the specific commands you are using to install Email::Sender
 and the error messages you get when it fails.

 Have you read the advice here: http://www.cpan.org/modules/**
 INSTALL.html http://www.cpan.org/modules/INSTALL.html, which mentions
 difficulty with RedHat and CentOS systems.

 Good luck!


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Perlbrew and Apache2::Request

2013-06-20 Thread Dermot
Hi,

OS CentOS 6.3
perl=/home/dermot/perl5/perlbrew/perls/perl-5.16.0/bin/perl,
  %ENV:
PERLBREW_BASHRC_VERSION=0.64
PERLBREW_HOME=/home/dpaikkos/.perlbrew
PERLBREW_MANPATH=/home/dpaikkos/perl5/perlbrew/perls/perl-5.16.0/man

PERLBREW_PATH=/home/dpaikkos/perl5/perlbrew/bin:/home/dpaikkos/perl5/perlbrew/perls/perl-5.16.0/bin
PERLBREW_PERL=perl-5.16.0
PERLBREW_ROOT=/home/dpaikkos/perl5/perlbrew
PERLBREW_VERSION=0.64
  @INC:

/home/dpaikkos/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0/x86_64-linux
/home/dpaikkos/perl5/perlbrew/perls/perl-5.16.0/lib/site_perl/5.16.0
/home/dpaikkos/perl5/perlbrew/perls/perl-5.16.0/lib/5.16.0/x86_64-linux
/home/dpaikkos/perl5/perlbrew/perls/perl-5.16.0/lib/5


I have installed perlbrew and cpanm. I have been trying to get a number of
modules installed but have come un-stuck with Apache2::Request. I have
posted the buildlog from the cpanm build below.

I have tried to manually ./configure the package but I am fairly certain
that I am not using the correct options that will get the package installed
where my perl binary can see it. The last configure options I gave where:

./configure
--with-perl=/home/dermot/perl5/perlbrew/perls/perl-5.16.0/bin/perl
--enable-perl-glue --with-apache2-apxs=/usr/sbin/apxs
--with-apache2-httpd=/usr/sbin/http

When I make install, I get permission denied and have to use sudo which
should not be happening.

Below are the configure , can anyone offer any advice?
Thanks in advance,
Dermot.

=== Configure options 
Configuration:
  -h, --help  display this help and exit
  --help=shortdisplay options specific to this package
  --help=recursivedisplay the short help of all the included
packages
  -V, --version   display version information and exit
  -q, --quiet, --silent   do not print `checking...' messages
  --cache-file=FILE   cache test results in FILE [disabled]
  -C, --config-cache  alias for `--cache-file=config.cache'
  -n, --no-create do not create output files
  --srcdir=DIRfind the sources in DIR [configure dir or `..']

Installation directories:
  --prefix=PREFIX install architecture-independent files in PREFIX
  [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
  [PREFIX]

By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc.  You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.

For better control, use the options below.

Fine tuning of the installation directories:
  --bindir=DIR   user executables [EPREFIX/bin]
  --sbindir=DIR  system admin executables [EPREFIX/sbin]
  --libexecdir=DIR   program executables [EPREFIX/libexec]
  --sysconfdir=DIR   read-only single-machine data [PREFIX/etc]
  --sharedstatedir=DIR   modifiable architecture-independent data
[PREFIX/com]
  --localstatedir=DIRmodifiable single-machine data [PREFIX/var]
  --libdir=DIR   object code libraries [EPREFIX/lib]
  --includedir=DIR   C header files [PREFIX/include]
  --oldincludedir=DIRC header files for non-gcc [/usr/include]
  --datarootdir=DIR  read-only arch.-independent data root
[PREFIX/share]
  --datadir=DIR  read-only architecture-independent data
[DATAROOTDIR]
  --infodir=DIR  info documentation [DATAROOTDIR/info]
  --localedir=DIRlocale-dependent data [DATAROOTDIR/locale]
  --mandir=DIR   man documentation [DATAROOTDIR/man]
  --docdir=DIR   documentation root [DATAROOTDIR/doc/libapreq2]
  --htmldir=DIR  html documentation [DOCDIR]
  --dvidir=DIR   dvi documentation [DOCDIR]
  --pdfdir=DIR   pdf documentation [DOCDIR]
  --psdir=DIRps documentation [DOCDIR]

Program names:
  --program-prefix=PREFIXprepend PREFIX to installed program
names
  --program-suffix=SUFFIXappend SUFFIX to installed program
names
  --program-transform-name=PROGRAM   run sed PROGRAM on installed program
names

System types:
  --build=BUILD configure for building on BUILD [guessed]
  --host=HOST   cross-compile to build programs to run on HOST [BUILD]

Optional Features:
  --disable-FEATURE   do not include FEATURE (same as
--enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --disable-dependency-tracking  speeds up one-time build
  --enable-dependency-tracking   do not reject slow dependency extractors
  --enable-shared[=PKGS]  build shared libraries [default=yes]
  --enable-static[=PKGS]  build static libraries [default=yes]
  --enable-fast-install[=PKGS]
  optimize for fast installation [default=yes]
  --disable-libtool-lock  avoid locking (might break parallel builds)
  --enable-maintainer-mode  enable make rules and dependencies not useful
  (and sometimes confusing

Re: Database interface

2013-02-04 Thread Dermot
This will do what you want but alas I do not think it's really suitable for
a beginner.
http://search.cpan.org/~oliver/Catalyst-Plugin-AutoCRUD-2.123610/lib/Catalyst/Plugin/AutoCRUD.pm

Good luck,
Dp.
On 4 Feb 2013 22:16, Simon Alfredsson simon.alfredsson0...@gmail.com
wrote:

 Hi,

 I'm looking for a database management system + a way of writing an user
 interface for it in perl, preferably presented as html for the user, and
 with capabilities similar to what I could accomplish with the program
 FileMaker. As simple as possible, as I am a beginner.

 Is there a way to write a perl script that upon opening it in locally in
 web browser would present a interface to a database that is also stored
 locally? What modules (beyond DBI) would be easy to use?
 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/





Encoding problem

2012-07-18 Thread Dermot
Hi,

I am trying to create a HTML page (using TT). The data may include
exotic characters. My efforts to output the characters correctly seem
to be hitting a problem. So I wrote a (kinda) test to help me narrow
down the problem but I'm still not getting the correct result. I can
only hope that the characters make it to the list correctly.

In the script below, the key on the hash is the string literal, the
value is what I would expect the return from encoded_entities to look
like. Instead I seem to get a lot of Atilde returned. I have checked
my version of HTML::Entities and the entities are in the file so I
must be doing something wrong but I can't see what. Can anyone offer
any advise?

Thanks in advance,
Dermot.



use strict;
use warnings;

use HTML::Entities;
use Encode::Encoder qw(encoder);

my %tests = (
'Barré' = 'Barreacute;', # also tried #233;
'Mickaël'   = 'Michaeuml;l',   # small e, umlaut mark
'frédéric'  = 'freacute;dacute;ric',
'Benoît'= 'Beniicirc;t',
'Jérôme'= 'Jeacute;rocirc;me',
);


for (keys %tests) {
print encoder($_)-iso_8859_1.\n;
print $_:  . encode_entities($_) . == $tests{$_}  or  .
decode_entities($tests{$_}) .\n;
}


 Output 

Jérôme
Jérôme: JAtilde;copy;rAtilde;acute;me == Jeacute;rocirc;me  or J�r�me
Mickaël
Mickaël: MickaAtilde;laquo;l == Michaeuml;l  or Micha�l
Benoît
Benoît: BenoAtilde;reg;t == Beniicirc;t  or Beni�t
Barré
Barré: BarrAtilde;copy; == Barreacute;  or Barr
frédéric
frédéric: frAtilde;copy;dAtilde;copy;ric == freacute;dacute;ric
or fr�d�ric

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Encoding problem

2012-07-18 Thread Dermot

 That's done the trick. Thank you Shlomi.

 You're welcome. Next time, please reply to the list (see the bottommost line
 of my signature).

Schoolboy error on my part. Dammed Gmail defaults.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PDL

2012-03-05 Thread Dermot
On 4 March 2012 23:03, Patrick Dupre patrick.du...@york.ac.uk wrote:
 Hello,

 After an upgrade from fedora 13 to fedora 14, my application fails
 with:
 PDL::LinearAlgebra::Real needs to be recompiled against the newly installed
 PDL at /usr/lib64/perl5/DynaLoader.pm line 223

 I just reinstall perl::LinearAlgebra
 which contains Real.
 PDL has also been recompiled.

 How can I debug this issue?


You might want to supply a little more detail here. It sounds
suspiciously like your perl binary was upgraded between f13 and f14
but the old modules under @INC were not. I guess that is one of the
reasons for not using the system perl but that's a topic for another
thread. Have you tried `yum search linearalegra`? If you are going to
use the system-installed perl then it might be wise to use the OS
supplied modules as well. You could of course simply try to cpan the
module again.

HTH,
Dermot

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: DBIx::Class add rows to table, confusion in perldoc example....

2012-02-05 Thread Dermot
On 5 February 2012 03:29, Rajeev Prasad rp.ne...@yahoo.com wrote:


 Author says:

 Adding and removing rows
 To create a new record in the database, you can use the create method. It 
 returns an instance of My::Schema::Result::Album that can be used to access 
 the data in the new record:

 my $new_album = $schema-resultset('Album')-create({ title = 'Wish You Were 
 Here', artist = 'Pink Floyd' });


 Now you can add data to the new record:

 $new_album-label('Capitol'); $new_album-year('1975'); $new_album-update;

 But the tables album has only three columns which are: album table with 
 three columns: albumid, artist, and title

 so what does year and label stand for? sorry i am confused. do i have to run 
 update after running create?


I think your right. It is confusing. At a guess, I would say label and
year are relations/accessors to other tables. If that were the case,
your album table class would define accessors to another tables that
has attributes label and year.

Perhaps a better place to start with DBIx::Class is the example[1].
Also it is worth pointing out that there is a specific mail list for
DBIx::Class [2]. I should also point out that the DBIx mailing list is
not a list for asking about perl beginners questions. There is an
expectation that you will have read the documentation and have an
understanding of OO perl. Having said that, they are always keen to
make their documentation clear and I think you have found an paragraph
that could use some revision.

HTH,
Dp.

1) http://search.cpan.org/dist/DBIx-Class/lib/DBIx/Class/Manual/Example.pod
2) http://lists.scsys.co.uk/mailman/listinfo/dbix-class

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Help in search concept

2011-12-20 Thread Dermot
On 20 December 2011 13:45, Saravanan Murugaiah
saravanan.muruga...@gmail.com wrote:
 Dear All,

Hello

 I am a learner in Perl and this is my first post in this group. I need to
 search a word Test 1.2.1 in my file. I am using $_ =~m/Test \d+, but it
 searched only Test 1 not the full content. I need to check whether it is
 Test 1 or Test 1.2 or Test 1.2.1. Kindly help me in this regard

Your search expression says match the work 'Test' then some literal
whitespace the any number of digits. But you have not accounted for
the periods/dots/full stops.
I think an regular expression like this would help.

/test\s+\d+(?=\.\d+)*/i

/s+ matches whitespace including tabs
?= means look ahead from the match just found EG: 'Test 1' and see if
you can find a literal . followed by one or more digits. The * mean
zero or more times.
the i flags means make the search case-insensitive.

Have a look at perldoc perlretut
(http://perldoc.perl.org/perlretut.html) for more tips.
Good luck,
Dermot.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: multi-column array

2011-12-01 Thread Dermot
On 30 November 2011 23:06, Jeswin phillyj...@gmail.com wrote:
 I've been trying to figure out how to print 2 arrays into 2 columns. I
 came across this code and it works but gives me a problem in the
 output.

 *BEGIN 
 CODE*
 sub transpose {
    map { my $i = $_; [ map $_-[ $i ], @_ ] } 0 .. $#{ $_[0] }
 }
 print @$_\n for transpose \( @unknown_abs, @unknown_conc  );

 *END
 CODE

 *BEGIN 
 OUTPUT**

 0.1
  0.729843646443355
 0.2
  1.47255203636502
 0.35
  2.58661462124751
 0.33
  2.43807294326318
 0.41 3.03223965520051

 *END 
 OUTPUT*

 So 0.1, 0.2, 0.35, 0.33, 0.41 should be in one column and the other
 values next to it. I'm trying to figure out how to reduce precision
 with printf but not really sure about that.

Have a look perldoc -f sprintf (http://perldoc.perl.org/functions/sprintf.html)

I'm not too keen on that print statement but then I'm not massively
happy with my own version either because it fixes the number of
elements in the array.

use strict;
use warnings;

my @unknown_abs = ( 0.1, 0.2, 0.35, 0.33, 0.41);
my @unknown_conc = ( 0.729843646443355, 1.47255203636502,
2.58661462124751, 2.43807294326318, 3.03223965520051);

sub transpose {
   return [ map { my $i = $_; [ map $_-[ $i ], @_ ] } 0 .. $#{ $_[0] } ];
}

my $arrayref = transpose ( \@unknown_abs, \@unknown_conc  ) ;
for (@$arrayref) {
printf %.4f %.4f\n, $_-[0], $_-[1];
}

The precision here is a floating point number with 4 places after
after the decimal point.
HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Plus Plus operator

2011-11-24 Thread Dermot
On 24 November 2011 03:40, samjesse rev...@gmail.com wrote:
 Hi

 what does this mean
  foreach $msg (@subjects) {
     $subjects{$msg}++;
  }

 thx

http://perldoc.perl.org/perlop.html#Auto-increment-and-Auto-decrement

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Customizing vi/vim for Perl

2011-11-20 Thread Dermot
On 18 November 2011 18:44, Juan Luis Aranda dasma...@gmail.com wrote:
 2011/11/18 Parag Kalra paragka...@gmail.com:
 Hi,

 I generally use vi/vim for my day to day Perl scripts.

 What are different packages I can use to make vi/vim extensively customized
 for Perl.  For example -  it should be able inform me about the known
 syntax errors like - variables not declared, missing braces or semicolons
 etc something which Eclipse done.

 And who has more customization packages for Perl - vi or Emacs?

 Parag


 Take a look to http://www.vim.org/scripts/script.php?script_id=556

I'd second this endorsement for these perl support script. I never use
the menus but I've find the braces and syntax hight-lighting really
useful.
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Customizing vi/vim for Perl

2011-11-20 Thread Dermot
On 20 November 2011 20:13, Phil Dobbin phildob...@gmail.com wrote:
 On 20/11/11 19:25, Dermot paik...@gmail.com wrote:

 Take a look to http://www.vim.org/scripts/script.php?script_id=556

 I'd second this endorsement for these perl support script. I never use
 the menus but I've find the braces and syntax hight-lighting really
 useful.

 I installed perl-support as per instructions but no go.

 This on OS X 10.6.8  vim 7.3.

What I'd suggest is that you put a syntax error in you .vimrc
(somthing like ':foobarbaz') to see if your vimrc is being used. Your
OS may set things up differently. It may use $home/.vimrc or
/etc/something. Once you know that which initialisation file vim is
using, the rest should be straight forward.
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Hash in a class

2011-10-28 Thread Dermot
On 28 October 2011 12:40, Gary listgj-gc...@yahoo.co.uk wrote:
 Thanks.

 Sh1t. How do I use this in a foreach, please?

 Trying
  foreach my $key (sort keys $self-{_cfg} ) {
 I get Type of arg 1 to keys must be hash (not hash element)



foreach my $key (sort keys %{ $self-{_cfg} } ) {
# do stuff
}

%{ $reference } makes it clear to `keys` that the item at the end of
the reference is a hash and not the scalar $self. The braces {} around
the reference are optional.
Hth,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl locale issue

2011-10-27 Thread Dermot
On 27 October 2011 02:39, Dave Stevens g...@uniserve.com wrote:
 Hi,

 I have a Virtualmin  GPL install under openvz on Ubuntu 10.4.2. Periodically
 I'd like to be able to send myself a logwatch report. When I do this is the
 result:

 # logwatch --mailto=g...@uniserve.com
 perl: warning: Setting locale failed.
 perl: warning: Please check that your locale settings:
  LANGUAGE = (unset),
    LC_ALL = (unset),
  LANG = en_CA.UTF-8
    are supported and installed on your system.
 perl: warning: Falling back to the standard locale (C).
 Killed
 Killed
 Killed
 system 'cat '/var/log/messages'  | /usr/bin/perl
 /usr/share/logwatch/scripts/shared/expandrepeats ''| /usr/bin/perl
 /usr/share/logwatch/scripts/shared/removeservice
 'talkd,telnetd,inetd,nfsd,/sbin/mingetty,netscreen,netscreen'| /usr/bin/perl
 /usr/share/logwatch/scripts/shared/applystddate
 ''/tmp/logwatch.85OCq98X/messages' failed: 35072 at /usr/sbin/logwatch line
 870.


I had this error on the same OS. I don't recall if it was from running
perl from the command-line or running something like logwatch. The
answer is exactly as the error reads.  You need to set-up you
environment to include a LANGUAGE, LC_ASS and LANG variable (I'm not
sure if you need all three but why not do things by half) . Put them
somewhere like /etc/profile or .bashrc depending on your shell or
environment needs. I have a maverick unit with export
LANG=en_GB.UTF-8 in the /etc/profile.

HTH,
Dermot.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: don't know where to start??? comparing files

2011-10-13 Thread Dermot
On 13 October 2011 03:07, Randal L. Schwartz mer...@stonehenge.com wrote:
 Shawn == Shawn H Corey shawnhco...@gmail.com writes:

 Shawn #!/usr/bin/env perl

 Please.  Don't.

This is quite relevant for me at the moment. I have a couple of
projects  where I will not be using the system perl and I was under
the impression that using `env perl` was the preferred method. So it
you using perlbrew, local::lib or just build a perl in some exotic
directory, are you suggested we give the path to the perl you want to
use? What's the reasoning?
Thanks,
Dermot

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Introducing myself...

2011-10-05 Thread Dermot
On 4 October 2011 20:44, John SJ Anderson geneh...@genehack.org wrote:
 Hi everybody --

 As Casey announced the other day, I recently volunteered to take over
 list moderation duties. I think this list is a really important
 resource for the Perl community, and I think it's important that
 people new to Perl can start to get an understanding of how great that
 community can be via their interactions on this list.

...

 Again, I think this list is a valuable part of the Perl community, and
 I think everybody for their participation -- the questioners and the
 answerers both. I'm happy to be able to play a small part in
 maintaining the list.

 thanks,
 john.

Is a quick congratulations too OT? If so excuse me.
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: install the prerequisite module automatically

2011-08-05 Thread Dermot
On 5 August 2011 02:12, Feng He short...@gmail.com wrote:
 Hi,

 I have wrote a module and released it with module-starter.
 (http://search.cpan.org/~xsawyerx/Module-Starter-1.58/lib/Module/Starter.pm)

 When I install it from the CPAN shell, how can I make the shell
 install the prerequisite modules automatically?

 for example, my module:

 package ABC;
 use MIME::Lite;

 ...
 1;

If the Makefile.PL for you module has requires MIME::Lite in then
the end user will get a warning about the lack of a dependency. You
can not force the required modules to install on an end user's
machine. That will be down to how the end user configured their CPAN.
Their cpan config will have a line for 'prerequisites_policy'.
Possible values include ask or follow. If it follow, then the
prerequisites are downloaded and installed. Otherwise it will ask the
user if they want to install the required modules.

HTH,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: install the prerequisite module automatically

2011-08-05 Thread Dermot
On 5 August 2011 10:28, Feng He short...@gmail.com wrote:
 On Fri, Aug 5, 2011 at 4:36 PM, Dermot paik...@googlemail.com wrote:

 Thanks.
 Do you mean this section in Makefile.PL?

    PREREQ_PM = {
        'Test::More' = 0,
    },

 Regards.

Yes. That's the form you will see if you use module-starter. You may
also come across this form

requires 'SomeMod::Foo' = [an optional version number];

hth,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: String Formatting by Column

2011-06-24 Thread Dermot
On 24 June 2011 08:45, Wernher Eksteen wekst...@gmail.com wrote:
 Hi,

 I've attached a text file containing the original and required format and
 avoid the format
 being lost by just pasting it in the email body.

 The original format is separated by a space, but need to replace the space
 with a comma,
 so it will become a comma delimited csv file which I will then import to MS
 Excel.

 I'm not sure how to parse the Connection and Sync'ed-as-of-time columns
 since the dates
 there in is in this format Fri Jun 24 06:37 which also separated by space,
 but the spaces in
 those columns shouldn't be replaced by a comma. The date format in those
 columns should
 remain the same.

 Also, is it possible to convert this directly into a MS Excel document using
 Perl?

Yes, you can achieve all your goals with perl. Have a look and
Text::CSV_XS[1] or Text::CSV[2]. They will read the file correctly and
write the file out for you with any separator you want. BTW, you want
quotes around each field so as not to confuse you spreadsheet program.
Writing the file into XLS format would require another module but I'll
leave others to make that recommendation.

Perhaps you could have a look at those, try and write something and
when, or if, you get stuck, come back to the list showing the code
you've got and get some pointers.

Thanks,
Dermot.


1) http://search.cpan.org/~hmbrand/Text-CSV_XS-0.82/CSV_XS.pm
2) http://search.cpan.org/~makamaka/Text-CSV-1.21/lib/Text/CSV.pm

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: String Formatting by Column

2011-06-24 Thread Dermot
On 24 June 2011 09:53, Wernher Eksteen wekst...@gmail.com wrote:
 Hi,

 Thanks for the tip, will try to figure it out on the weekend and come back
 if I'm
 stuck.

 Just a few questions before I try this...

 Does these modules have the ability to add the commas in the way I need them
 to be?

Yes. When you construct a new Text::CSV_XS object, set the sep_char to
the tab character so that when you read the file in, each value from
each column is stored correctly. They reset sep_char to ',' when you
want to send the output to a file.

 The CVS_XS.pm module seems more flexible/powerful than the CVS.pm one
 or am I wrong?


The _XS means that this module uses C code under the bonnet so it runs
really fast. If you are on a *nix based PC and have all the necessary
libraries and a compiler this is probably a better option. It's the
one I generally use. This module also has a _PP (pure perl) version[1]
in case you do not have a compiler on your PC.


1) http://search.cpan.org/perldoc?Text%3A%3ACSV_PP

HTH,
Dermot.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Relative URIs in served pages

2011-06-01 Thread Dermot
On 1 June 2011 16:20, John Delacour johndelac...@gmail.com wrote:

 I have a script in cgi-bin which gathers information from the user and
 replaces placeholders in a pre-written html page with the data collected via
 a different html interface.  Since the script needs to run from various
 servers I don't want to use absolute URIs for the images, css file etc. and
 I can't work out how to get relative pathnames to work.  I'd be grateful for
 the solution to this problem, which I imagine will appear very obvious once
 I know the answer.

I'd imagine URI's rel method would work well for you in this situation.

http://search.cpan.org/dist/URI/URI.pm

HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Ten Years of Considerate Help

2011-05-31 Thread Dermot
On 30 May 2011 01:57, Casey West ca...@geeknest.com wrote:
 On Fri, Apr 22, 2011 at 12:59 AM, Casey West ca...@geeknest.com wrote:


 I received three unsolicited recommendations for moderators to this list,
 one volunteer, and three unsolicited requests to deny moderatorship from
 some individuals. Some of these lists intersected one another. The response
 from those recommended to me was underwhelming or non-existant. Very few
 seem to be particularly keen for this task. This is not a very good
 response.

 Further, one member pointed out my lack of aggressively pursuing new
 leadership on this list, which is a valid and constructive criticism. In
 truth I lack the drive to seek out new, interested, and appropriately
 mindful moderators. Open source and open communities are built to adapt and
 self-heal when members come and go. Indeed, I have been away from this
 community for more than half a decade.

 I'm proud of what has been accomplished by this list and its members over
 the many, many years. I leave it in your hands to generate new and
 meaningful leadership in the void my absence has created. I'm confident you
 can, though it may take some work.

 Good luck, may the force be with you, and so on.

I'd like to put an idea out to see what the list thinks, what if Casey
asked for a moderator to take on the role for one year and then the
list hold an electon[1] in 12 months time for another moderator.

My reason for suggesting this is because I suspect that the lack of
enthusiastic responses may be because many of the more proficient
coders on the list are also busy with other commitments and don't
relish taking on another. I also wonder what level of proficiency the
moderator would need. There are several very proficient, regular
responders on the list as well as very proficient responders that dip
in from time to time. Does the moderator necessarily need to be highly
skilled with perl? Presumably being good with perl is required but
ensuring the points in the Administriva is the purpose of moderating.

Ultimately we need to allow Casey to move on, so a consensus of some
kind is needed.

[1] Terms to be decided.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Help with indentation

2011-04-23 Thread Dermot

 I have been trying to follow one of code indentation guidelines from
 wikipedia, but I have some questions that I can find answers, I would
 appreciate if someone could help me or point me towards better references.

 No. The indentation should provide a visual clue as to where the loop begins
 and ends. Once the loop has ended, the indentation should return to what it
 was at the start of the loop.


A lot of text editors, especially the command-lines [0], provide a
syntax checker. One of the features of these syntax checkers is their
ability to pair up curly braces. So when you get the dreaded Missing
braces on... error you can put your cursor on a end brace and it
shows you were it starts. This can save you a lot of time.

HTH,
Dp.

[0] http://vimdoc.sourceforge.net/htmldoc/syntax.html

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Nature of this list

2011-04-20 Thread Dermot
On 19 April 2011 16:00, Peter Scott pe...@psdt.com wrote:
...
 :[...]
 : * If you think what you are writing may be taken in a way you didn't
 : intend, please add a smiley :-) Many flame wars are stopped by a simple
 : smiley!
 : * No flames. If your fingers are burning as you are typing the email, it
 :  would likely be best not to send it.

 If anything is clear from that FAQ it is that the intention is to avoid
 flames on this list.  Casey and Kevin appear to have stopped monitoring
 this group some time ago, though.

 There is no shortage of lists, groups, or forums where people can get
 flamed for not following the rules, and people who want to flame them
 have an outlet for doing so.  I've already stopped reading most of them
 because it's not worth my time when most of the content is arguments
 about conduct.  I don't know whether communities inevitably fall into
 that mode after a while but this one at least had a good run and I'll be
 sorry if I end up leaving it too.

 Andy Lester had a good article about this: http://perlbuzz.com/2010/11/
 think-for-perls-sake.html.  But judging from the responses it seems he
 and I may be in a minority.


Is it time for our annual Be nice thread? I didn't realise a year
had passed so soon. I missed what triggered this one. Can someone post
a link to the thread please ( I did ask nicely ).
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: @INC problem with ssh

2011-04-07 Thread Dermot
On 7 April 2011 00:24, C.DeRykus dery...@gmail.com wrote:
 On Apr 6, 7:45 am, paik...@gmail.com (Dermot) wrote:
 Hello All,

 I have a issue when I attempt to run a script on one host (B) that is
 called by ssh from other host (A).

 On host B, I have the script in /usr/local/bin/stuff.pl. The script
 has the following near the top:

 use strict;
 use warnings;
 use lib qw(/etc/perl);

 use MyApp::Image;
 use MyApp::Schema;   # Schema will attempt to dbi:SQLite connect to a
 local db file.
 ...
 ...
 ...

 On host A I run a script that does:

 use FindBin qw($Bin);
 use lib qq($Bin/../lib);
 ...
 ...
 ...
 my $cmd = qq(ssh -i $Bin/../lib/.ssh/someuser_id.rsa someuser\@) .
             $self-config('imageing_server') .
             qq( /usr/local/bin/stuff.pl );
 my $res = qx($cmd);

 When I run the script, I get:
 Can't locate MyApp/Schema.pm in @INC (@INC contains:
 /usr/local/bin/../../ /etc/perl
 /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
 /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
 /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
 at /usr/local/bin/stuff.pl line 15.

 The @INC mentioned in the error looks like the @INC on host A, or at
 least perl is looking for the files locally. I fear that, worse than
 simply having problem with @INC, other paths, including the path to
 local files will try and reference stuff on host A and not host B.
 There may be some very good security reasons for this (perldoc
 perlsec) but I hoping there is a way to make this work.

 Does anyone know if or how I can make the script on host B execute
 it's commands and look locally for files?

 How's the script on host B invoked... standalone via
 shebang line or externally as in  'perl stuff.pl'?
 If the latter, is the invoking perl distro identical with
 that on the shebang line?


Hi,
Yes it does.

#!/usr/bin/perl

use Digest::SHA2;
use DateTime::Format::Strptime;
use DateTime::Format::SQLite;
use Getopt::Long;

use strict;
use warnings;
use lib qw(/etc/perl);

use MyApp::Image;
use MyApp::Schema;


The script on host B uses a shebang (!#/usr/bin/perl), the version on
that host is perl, v5.8.8 built for i386-linux-thread-multi

The perl on host A, the caller, is perl, v5.8.6 built for
i386-linux-thread-multi.

When I attempt to invoke the script from the command line of host A, I
get the same error:

[dermot@hosta]$ ssh -i lib/.ssh/someuser_id.rsa someuser@hostb
/usr/local/bin/stuff.pl record_number=651500447
Can't locate MyApp/Schema.pm in @INC (@INC contains:
/usr/local/bin/../../ /etc/perl
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
at /usr/local/bin/stuff.pl line 15.
BEGIN failed--compilation aborted at /usr/local/bin/stuff.pl line 15

user@hostb is not the same user that invokes the script on host A

The big mystery for me is that I have other scripts, albeit that do
not use MyApp::Schema, that work fine between the two hosts. EG:

ssh -i lib/.ssh/someuser_id.rsa someuser@hostb
/usr/local/bin/make_thumbnail.pl --record_number=651500447
Can't set owner to 48 on
/var/media/images/65/15/00/447/651500447-thumb.jpg: Operation not
permitted

Ok, it has it's issues too but it works locally. So I added the `use
MyApp::Schema` to the above script and.dam got the same error:

Can't locate MyApp/Schema.pm in @INC (@INC contains:
/usr/local/bin/../../ /etc/perl
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
at /usr/local/bin/make_thumbnail.pl line 11

Still more baffling is that fact the above script uses MyApp::Image,
that package only resides on host B.

So I'm a little confused but I think there are enough clues here. Thanks,
Dermot.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: @INC problem with ssh

2011-04-07 Thread Dermot
On 7 April 2011 12:33, C.DeRykus dery...@gmail.com wrote:
 On Apr 7, 2:07 am, paik...@gmail.com (Dermot) wrote:
 On 7 April 2011 00:24, C.DeRykus dery...@gmail.com wrote:

  On Apr 6, 7:45 am, paik...@gmail.com (Dermot) wrote:
  Hello All,

  I have a issue when I attempt to run a script on one host (B) that is
  called by ssh from other host (A).

  On host B, I have the script in /usr/local/bin/stuff.pl. The script
  has the following near the top:

  use strict;
  use warnings;
  use lib qw(/etc/perl);

  use MyApp::Image;
  use MyApp::Schema;   # Schema will attempt to dbi:SQLite connect to a
  local db file.
  ...
  ...
  ...

  On host A I run a script that does:

  use FindBin qw($Bin);
  use lib qq($Bin/../lib);
  ...
  ...
  ...
  my $cmd = qq(ssh -i $Bin/../lib/.ssh/someuser_id.rsa someuser\@) .
              $self-config('imageing_server') .
              qq( /usr/local/bin/stuff.pl );
  my $res = qx($cmd);

  When I run the script, I get:
  Can't locate MyApp/Schema.pm in @INC (@INC contains:
  /usr/local/bin/../../ /etc/perl
  /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
  /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
  /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
  /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
  /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
  at /usr/local/bin/stuff.pl line 15.

  The @INC mentioned in the error looks like the @INC on host A, or at
  least perl is looking for the files locally. I fear that, worse than
  simply having problem with @INC, other paths, including the path to
  local files will try and reference stuff on host A and not host B.
  There may be some very good security reasons for this (perldoc
  perlsec) but I hoping there is a way to make this work.

  Does anyone know if or how I can make the script on host B execute
  it's commands and look locally for files?

  How's the script on host B invoked... standalone via
  shebang line or externally as in  'perl stuff.pl'?
  If the latter, is the invoking perl distro identical with
  that on the shebang line?

 Hi,
 Yes it does.

 #!/usr/bin/perl

 use Digest::SHA2;
 use DateTime::Format::Strptime;
 use DateTime::Format::SQLite;
 use Getopt::Long;

 use strict;
 use warnings;
 use lib qw(/etc/perl);

 use MyApp::Image;
 use MyApp::Schema;

 The script on host B uses a shebang (!#/usr/bin/perl), the version on
 that host is perl, v5.8.8 built for i386-linux-thread-multi

 The perl on host A, the caller, is perl, v5.8.6 built for
 i386-linux-thread-multi.

 When I attempt to invoke the script from the command line of host A, I
 get the same error:

 [dermot@hosta]$ ssh -i lib/.ssh/someuser_id.rsa someuser@hostb
 /usr/local/bin/stuff.pl record_number=651500447
 Can't locate MyApp/Schema.pm in @INC (@INC contains:
 /usr/local/bin/../../ /etc/perl
 /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
 /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
 /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
 at /usr/local/bin/stuff.pl line 15.
 BEGIN failed--compilation aborted at /usr/local/bin/stuff.pl line 15

 user@hostb is not the same user that invokes the script on host A

 The big mystery for me is that I have other scripts, albeit that do
 not use MyApp::Schema, that work fine between the two hosts. EG:

 ssh -i lib/.ssh/someuser_id.rsa someuser@hostb
 /usr/local/bin/make_thumbnail.pl --record_number=651500447
 Can't set owner to 48 on
 /var/media/images/65/15/00/447/651500447-thumb.jpg: Operation not
 permitted

 Ok, it has it's issues too but it works locally. So I added the `use
 MyApp::Schema` to the above script and.dam got the same error:


 /usr/local/bin/../../ /etc/perl
 /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
 /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
 /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
 /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
 at /usr/local/bin/make_thumbnail.pl line 11

 Still more baffling is that fact the above script uses MyApp::Image,
 that package only resides on host B.

 So I'm a little confused but I think there are enough clues here. Thanks,
 Dermot.

 Ok,  that does seem confusing especially since
 @INC is host A's rather than B's. For a sanity
 check, you might add ssh's verbose switch to
 see what's actually occurring:

  my $cmd =
     qq(ssh -v -i $Bin/../lib/.ssh/someuser_id.rsa )
       .   'someuser@'
       .   $self-config('imageing_server')
       .   '/usr/local/bin/stuff.pl';

  print remote cmd: $cmd\n;   #  debug
  my $res = qx($cmd);

 Also, note, even if you've confirmed that the
 MyApp/Schema.pm  file actually exists in @INC
 on Host  B, Perl generates the  same error:

   Can't locate MyApp/Schema.pm in @INC

@INC problem with ssh

2011-04-06 Thread Dermot
Hello All,

I have a issue when I attempt to run a script on one host (B) that is
called by ssh from other host (A).

On host B, I have the script in /usr/local/bin/stuff.pl. The script
has the following near the top:

use strict;
use warnings;
use lib qw(/etc/perl);

use MyApp::Image;
use MyApp::Schema;   # Schema will attempt to dbi:SQLite connect to a
local db file.
...
...
...


On host A I run a script that does:


use FindBin qw($Bin);
use lib qq($Bin/../lib);
...
...
...
my $cmd = qq(ssh -i $Bin/../lib/.ssh/someuser_id.rsa someuser\@) .
$self-config('imageing_server') .
qq( /usr/local/bin/stuff.pl );
my $res = qx($cmd);

When I run the script, I get:
Can't locate MyApp/Schema.pm in @INC (@INC contains:
/usr/local/bin/../../ /etc/perl
/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl
/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi
/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl
/usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8 .)
at /usr/local/bin/stuff.pl line 15.

The @INC mentioned in the error looks like the @INC on host A, or at
least perl is looking for the files locally. I fear that, worse than
simply having problem with @INC, other paths, including the path to
local files will try and reference stuff on host A and not host B.
There may be some very good security reasons for this (perldoc
perlsec) but I hoping there is a way to make this work.

Does anyone know if or how I can make the script on host B execute
it's commands and look locally for files?
Thanks,
Dp..

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Creating PDF/FDF files

2011-03-01 Thread Dermot
On 1 March 2011 15:58, Mike Blezien mick...@frontiernet.net wrote:
 Hello,

 I'm working on a small project that will require us to parse data submitted 
 from an Adobe Reader form, i.e questionaires. Then we'll need to generate 
 either a PDF or FDF temp file, attach it to an email, and send it to use. Now 
 parsing the data from the Adobe Form with a Perl script shouldn't be a 
 problem. My question is what is the best Perl module to use to create the 
 PDF(needed for digital siginatures) or a FDF file for this type of 
 application? I've been looking at CPAN for possible solutions but not real 
 clear which is the best to handle this type of application for both PDF or 
 FDF formats.

 any suggestions or tips would be appreciated.

 TIA,


Well I love PDF::API2 but I have to admit that it's documentation is a
bit tricky at timesI was about to write a paragraph about how it's
no longer being maintained but I see that someone (2011-01-24 - New
Maintainer: Steve Simms) has taken it over. Cool. I have never used
PDF::API2 for forms though.

Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: about the message queue server

2010-12-09 Thread Dermot
On 9 December 2010 14:38, practicalperl practicalp...@gmail.com wrote:
 Hi,

 Would you please recommend me a high performance message queue server?
 Currently I'm looking up at:
 http://search.cpan.org/~dsnopek/POE-Component-MessageQueue-0.2.10/lib/POE/Component/MessageQueue.pm

 But I know nothing about its performance stuff.

 Thanks.

I have never used it but I have heard this is a decent module.

http://search.cpan.org/~sixapart/TheSchwartz-1.10/lib/TheSchwartz.pm

In the same thread there was mention of this Apache project.

http://activemq.apache.org/advisory-message.html

HTH,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: [cgiapp] Why perl lost steam...

2010-09-23 Thread Dermot Paikkos
 -Original Message-
 My interest in peeking at Boulder was really OT, but let me explain a
 little more about why it intrigues me. It seems to offer some simple
 ways to search for data in sets of simple data files like those 
created
 when using the CGI-save method, almost an SQL like way of retrieving
 data from this format. And HTML5 supports a client side data storage
 function that uses the same format, so the two should be easily shared
 and synced between the client and server. And it may be worth looking
 into how the functionality of Boulder might be recreated with JS for
 the client side.
 
 I would offer that there is a difference between something being
 obsolete and being ignored. Certainly when Mr. Stein created Boulder
 he was aware that MySQL existed. What was his motivation? Is Boulder
 still being used to suit those purposes and more? If so, it's not
 really obsolete is it?

[DP] I can't comment on Boulder as I have never used it. I am a big fan 
of SQLite because it has a small foot-print, it lightening fast and very 
portable.

 And I am certainly not arguing that CGI::App and other Frameworks are
 not appropriate for small apps, what I am thinking is there may be a
 good reason for a simpler, ultralight, framework for small apps to
 exist.
 
 I suppose most of the functionality of that framework I imagine 
already
 resides in CGI.pm. I just don't think it's been integrated into an
 approach that's easy for beginners to excited about.

[DP] I would say you are using CGI very appropriately, for a small, 
self-contained app. 
Dp.



--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




RE: Why perl lost steam...

2010-09-22 Thread Dermot Paikkos
 -Original Message-
 From: Bill Stephenson [mailto:bi...@ezinvoice.com]
 Sent: 20 September 2010 21:40
 To: beginners cgI
 Subject: Why perl lost steam...
 
 This email list used to bustle. It was active and vibrant.
 
 No more. Now it is practically dead.
 
 It would seem that right now, when Web Apps are really coming into
 their own, CGI scripts written in Perl would be the place that
 Beginners would start looking.
 
 But there are no beginners here anymore.
 
 Why is that?

[DP] The perl beginners list is still very active and I think that's 
where all the traffic tends to be. If you were writing a Web App 
though, you would be better served by a perl framework like Catalyst or 
CGI::Application. Personally I only use CGI for smaller tasks.
Dp.



--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Encoding issues.

2010-08-13 Thread Dermot
On 13 August 2010 13:35, Kwaku Addo Ofori kayof...@gmail.com wrote:
 Hi Guys,

 I just wrote a script that retrieves some records from a MYSQL database.
 These records contain a lot of the special characters from the French
 language. I need a way to decode these characters properly before sending
 them on to a third party.

 For example, retrieving this from the database:

 La C�te d'Ivoire a battu hier l'Italie en match amical 1-0. But de Kolo
 Tour� (55)
 Les Elephants pr�parent les �liminatoires de la CAN 2012.

 And then send it on without all those � characters which are in actual fact
 special characters from the french language.

 Any ideas? Anyone?

You will need to use the Encode[1] module and it's decode function.
The trick is working out what encoding the data is in. You will need
to check the settings on your MySQL database table(s) to see what
encoding it's storing the strings in but sometimes it's not as simple
as that. That why there is the Text::GuessEncoding[2] module because
data is not always stored in the same encoding that arrived in.

Good luck,
Dp.

[1] http://search.cpan.org/~dankogai/Encode-2.39/Encode.pm
[2] http://search.cpan.org/~jnw/Text-GuessEncoding-0.07/GuessEncoding.pm

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Accessing array from Perl DBI using Template Toolkit

2010-08-10 Thread Dermot
On 9 August 2010 13:25, me @ m...@psybermonkey.net wrote:
 Hi,

Hi,

Not sure why you had to send this twice.

I'm trying to pickup CGI web application programming using Perl, DBI 
...
...

 start of list.tt 
 Content-type: text/html


 [% PROCESS header %]
 Form strongList/strong
 p
 ul
    [% FOREACH kar IN kars.values %]
    li[% kar.reg_no %], [% kar.brand %], [% kar.cc %]/li
    [% END %]
 /ul
 /p
 [% PROCESS footer %]
 end of list.tt 

 My question :
 - I suppose the above code convert array into hash and pass it to TT, is
 there any other way then this because I find that the line noise is a bit
 too much.

Line noise? What is it you want to cut out?

You are iterating over the values of your hash. You don't need to
specify values here, you could omit the values and, according to the
TT man page[1] do:

[% FOREACH kars %]
   li[% reg_no %]/li
[% END %]


 - I've read about some where on some website that arrays passing to TT
 should always use array reference ($sth-fetchrow_arrayref) instead of the
 above, using arrays ($sth-fetchrow_array). If this were to use array
 reference, can someone show some codes to me so that i may check it out and
 try to understand.

I think you might be getting a bit confused here. TT requires
references for it's parameters variable, so yes array, hash references
(or any reference that returns a list) but that is different from how
you retrieve data from the DBI. You turned that data into a hash of
hash references when you did this:

   while (($reg_no, $brand, $cc) = $sth-fetchrow_array()) {
   $kar{$reg_no} = {
   reg_no  = $reg_no,
   brand   = $brand,
   cc  = $cc
   }
   }


If you want to use the DBI directly within TT then you should look at
using the TT DBI plugin[2]. you may get more help on TT matter from
the TT list[3].

Good luck,
Dp.


[1] http://template-toolkit.org/docs/manual/Directives.html#section_FOREACH
[2] http://search.cpan.org/~rehsack/Template-DBI-2.65/lib/Template/DBI.pod
[3] http://mail.template-toolkit.org/mailman/listinfo/templates

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: META - Bounces from the list

2010-07-23 Thread Dermot
On 22 July 2010 01:38, Jeff Pang pa...@arcor.de wrote:
 A basic concept:

 For people the address of f...@gmail.com and f...@googlemail.com are the same 
 one.
 But for the list admin program they are really two different ones.

 Also people may know that something like f...@aol.com and f...@aim.com,
 b...@netzero.com and b...@netzero.net are the alias to each other.
 But for mailing list daemon program, they are not smart enough to know
 that they are the same stuff.

 So you should have the need to re-subscribe to the list using your
 email address with the new TLD.

The problem with that solution is I would receive each message twice
since I can't un-subscribe my old address. When I try to un-subscribe
it says:

Hi! This is the ezmlm program. I'm managing the
beginners@perl.org mailing list.

I'm working for my owner, who can be reached
at beginners-ow...@perl.org.

I'm sorry, I've been unable to carry out your request,
since the address

  f...@gmail.com

was not on the beginners mailing list when I received
your request and is not a subscriber of this list.


So I hope someone is picking up the beginners-ow...@perl.org emails.

Thanx,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: META - Bounces from the list

2010-07-22 Thread Dermot
n 22 July 2010 18:05, Brandon McCaig bamcc...@gmail.com wrote:
 On Wed, Jul 21, 2010 at 5:38 AM, Dermot paik...@gmail.com wrote:
 I suspect this might be because I recently changed my email address
 domain from googlemail.com to gmail. I can't now un-subscribe because
 the mailer program will not recognise my new address if I send an
 email to beginners-unsubscr...@perl.org and there not longer seems
 to be an admin page for the list.

 You can specify which E-mail address to subscribe or unsubscribe if
 you aren't sending the request from the same address.

 http://learn.perl.org/faq/beginners.html#1.2%20%20how%20do%20i%20unsubscribe

Ah, that did it.
Thanx,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




META - Bounces from the list

2010-07-21 Thread Dermot
Hi All,

Is it just me or have others received bounces from replies to this
list recently? I have had 3 in the last 24 hours that look like this:

 Hi. This is the qmail-send program at la.mx.develooper.com.
I'm afraid I wasn't able to deliver your message to the following addresses.
This is a permanent error; I've given up. Sorry it didn't work out.

beginners@perl.org:
This message is looping: it already has my Delivered-To line. (#5.4.6)

--- Below this line is a copy of the message.

Return-Path: f...@gmail.com
Received: (qmail 31204 invoked by alias); 21 Jul 2010 09:11:41 -
X-Spam-Status: No, hits=-4.2 required=8.0
   
tests=DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_HI,SPF_NEUTRAL,T_DKIM_INVALID
X-Spam-Check-By: la.mx.develooper.com
Received: from rtp-iport-2.cisco.com (HELO rtp-iport-2.cisco.com)
(64.102.122.149)
   by la.mx.develooper.com (qpsmtpd/0.28) with ESMTP; Wed, 21 Jul 2010
02:11:38 -0700
Authentication-Results: rtp-iport-2.cisco.com; dkim=hardfail (body
hash did not verify [final]) header...@gmail.com
Received: from rcdn-core-5.cisco.com ([173.37.93.156])
 by rtp-iport-2.cisco.com with ESMTP; 21 Jul 2010 09:11:31 +
Received: from xbh-sjc-221.amer.cisco.com (xbh-sjc-221.cisco.com
[128.107.191.63])
   by rcdn-core-5.cisco.com (8.14.3/8.14.3) with ESMTP id o6L9BJCs019504
   for beginners@perl.org; Wed, 21 Jul 2010 09:11:31 GMT
Received: from mail pickup service by xbh-sjc-221.amer.cisco.com with
Microsoft SMTPSVC;
Tue, 20 Jul 2010 12:14:34 -0700
Received: from xbh-rcd-202.cisco.com ([72.163.62.201]) by
xbh-sjc-221.amer.cisco.com with Microsoft SMTPSVC(6.0.3790.3959);
Tue, 20 Jul 2010 04:25:36 -0700
Received: from sj-iport-4.cisco.com ([171.68.10.86]) by
xbh-rcd-202.cisco.com with Microsoft SMTPSVC(6.0.3790.4675);
Tue, 20 Jul 2010 06:21:10 -0500
Received: from sj-core-5.cisco.com ([171.71.177.238])
 by sj-iport-4.cisco.com with ESMTP; 20 Jul 2010 11:21:00 +
Received: from sj-inbound-f.cisco.com (sj-inbound-f.cisco.com [128.107.234.207])
   by sj-core-5.cisco.com (8.13.8/8.14.3) with ESMTP id o6KBKrGf008285
   for jtr...@cisco.com; Tue, 20 Jul 2010 11:20:59 GMT
X-from-outside-Cisco: 207.171.7.86
X-IronPort-Anti-Spam-Filtered: true
X-IronPort-Anti-Spam-Result:
AusAAMIjRUzPqwdWlGdsb2JhbACgBAEBAQEJCwgJEQYcpGqJb4IQhiouiFQBAQMFgwWCKASIWQ
X-IronPort-AV: E=Sophos;i=4.55,231,1278288000;
  d=scan'208;a=205333590
Received: from x6.develooper.com (HELO lists-nntp.develooper.com)
([207.171.7.86])
 by sj-inbound-f.cisco.com with SMTP; 20 Jul 2010 11:20:59 +
Received: (qmail 3542 invoked by uid 514); 20 Jul 2010 11:20:40 -
Mailing-List: contact beginners-h...@perl.org; run by ezmlm
Precedence: bulk
List-Post: mailto:beginners@perl.org
List-Help: mailto:beginners-h...@perl.org
List-Unsubscribe: mailto:beginners-unsubscr...@perl.org
List-Subscribe: mailto:beginners-subscr...@perl.org
List-Id: beginners.perl.org
Delivered-To: mailing list beginners@perl.org
Delivered-To: moderator for beginners@perl.org
Received: (qmail 12717 invoked from network); 20 Jul 2010 08:58:13 -
Delivered-To: beginners@perl.org
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
   d=gmail.com; s=gamma;
   h=domainkey-signature:mime-version:received:received:in-reply-to
:references:date:message-id:subject:from:to:content-type
:content-transfer-encoding;
   bh=G5brfQJ1OO3O0nc+v0rmJ/Dy0WYobqXTZD4xbXom/oU=;
   b=YbaropIqRtN1VG2SckO5bSyE7U0ih/0XpdcwMvlAJA8xZ5hjsnJeNBVv5D2qYONf58
OuQKlHiq05PJGr1OVihFjtjr09hNI9prJ2waa1wKjiIzMHJl+0JPdtXM0cylUGa1k7sA
d9NQlQ2HBfb76HwgKKCpLjuY2kkJYpVGNhKBk=
DomainKey-Signature: a=rsa-sha1; c=nofws;
   d=gmail.com; s=gamma;
   h=mime-version:in-reply-to:references:date:message-id:subject:from:to
:content-type:content-transfer-encoding;
   b=F30CpGpa14kgAsnExZJhnXAIc5CWoMzTAxdD5h64uEiaMGCzSh8cwaDn5BaIHBBHce
EOWHXjkGaXzj1Yc/ZJ2J5xNHtS8Z6heSBvuhyC+51ObJ/jtdJtNJNG//5UXWQy0s+0rB
7OqXZMyOWw1EEbQRsvyJgGFpVZXrrs7S1yefA=
MIME-Version: 1.0
In-Reply-To: 000301cb27bd$53b0a9a0$fb11fc...@com
References: 839597.75875...@web95616.mail.in.yahoo.com
   4c447d64.10...@shaw.ca
   000301cb27bd$53b0a9a0$fb11fc...@com
Date: Tue, 20 Jul 2010 09:58:07 +0100
Message-ID: aanlktikd8ref3amgjwlitpnzyxsqon8e63zjr2c08...@mail.gmail.com
Subject: Re: Can't use string 1 as HASH ref while strict refs in use
From: Dermot f...@gmail.com
To: Perl Beginners beginners@perl.org
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-OriginalArrivalTime: 20 Jul 2010 11:21:10.0081 (UTC)
FILETIME=[A7837310:01CB27FD]
X-Old-Spam-Check-By: la.mx.develooper.com
X-Old-Spam-Status: No, hits=-0.1 required=8.0


I suspect this might be because I recently changed my email address
domain from googlemail.com to gmail. I can't now un-subscribe because
the mailer program will not recognise my new address if I send an
email to beginners-unsubscr...@perl.org

Re: DBI under SOAP/mod_perl

2010-07-20 Thread Dermot
Hi Octavian,

On 19 July 2010 06:07, Octavian Rasnita orasn...@gmail.com wrote:
 Does the $dsn contain the full path to the database?

Yes. The dsn line is declared like this:

 DBI SQLite3 ###
my $dsn = 'dbi:SQLite:dbname=/var/db/MyApp/myapp.db';



It's outside the constructor which I am not sure is good practise. I
created the /var/db/MyApp directory and made it's owner apache:apache
with permissions at 0777:

drwxrwxrwx 2 apache apache 4096 Jul 16 16:38 /var/db/MyApp/
-rwxrwxrwx 1 apache apache 97907712 Jul 16 11:30 myapp.db


I have tried in enable trace but I am not getting any the details to
the httpd log. This is all I see in the logs:

7:24:1 [19/7/2010] About to updateDB for c006/9219
[Mon Jul 19 17:24:01 2010] -e: DBD::SQLite::db prepare failed: not an
error at /etc/perl/Foo.pm line 186.
[Mon Jul 19 17:24:01 2010] -e: Use of uninitialized value in
concatenation (.) or string at /etc/perl/Foo.pm line 187.
STH=  DBH=DBI::db=HASH(0x9d175c8)

Which refers to these lines:

my $sql = qq(SELECT * FROM lowres where path = ?);
my $sth = $self-dbh-prepare($sql) or cluck Error happening\n .
$self-dbh-errstr . DBI-errstr\n;# line 187
print STDERR STH=$sth  DBH=.$self-dbh.\n;
$sth-execute($self-file) or confess Can't prepare: .
$self-dbh-errstr.\n;
while (my $href = $sth-fetchrow_hashref ) {
print STDERR Record found $href-{id} Rows=. $sth-rows.\n
if $self-{debug};
$self-{image} = $href;
}


I did finally manage to get my DBI trace to appear in the logs (needed
to restart the server) but the details are not much more revealing.
Still the statement handler is undef before execution and I can't not
see any reference to the dbname file. The most telling messge is 
DBI::st=HASH(0x9d7002c) ignored - handle not initialised

   dbih_setup_attrib(DBI::st=HASH(0x9d7002c), FetchHashKeyName,
DBI::db=HASH(0x9d6fd5c)) 'NAME' (already defined)
dbih_setup_attrib(DBI::st=HASH(0x9d7002c), HandleSetErr,
DBI::db=HASH(0x9d6fd5c)) undef (not defined)
dbih_setup_attrib(DBI::st=HASH(0x9d7002c), HandleError,
DBI::db=HASH(0x9d6fd5c)) undef (not defined)
dbih_setup_attrib(DBI::st=HASH(0x9d7002c), ReadOnly,
DBI::db=HASH(0x9d6fd5c)) undef (not defined)
dbih_setup_attrib(DBI::st=HASH(0x9d7002c), Profile,
DBI::db=HASH(0x9d6fd5c)) undef (not defined)
sqlite trace: prepare statement: SELECT * FROM lowres where path = ?
at dbdimp.c line 425
sqlite error 21 recorded: not an error at dbdimp.c line 435
 DESTROY DISPATCH (DBI::st=HASH(0x9d7008c) rc1/1 @1 g0
ima10004 pid#1086) at /etc/perl/Foo.pm line 187 via  at
/etc/perl/Foo.pm line 187
 DESTROY(DBI::st=HASH(0x9d7008c)) ignored for outer handle
(inner DBI::st=HASH(0x9d7002c) has ref cnt 1)
 DESTROY DISPATCH (DBI::st=HASH(0x9d7002c) rc1/1 @1 g0
ima10004 pid#1086) at /etc/perl/Foo.pm line 187 via  at
/etc/perl/Foo.pm line 187
- DESTROY for DBD::SQLite::st (DBI::st=HASH(0x9d7002c)~INNER) thr#8a2fb48
 DESTROY for DBI::st=HASH(0x9d7002c) ignored - handle not initialised
   ERROR: '21' 'not an error' (err#1)
- DESTROY= undef at /etc/perl/Foo.pm line 187 via  at
/etc/perl/Foo.pm line 187
DESTROY (dbih_clearcom) (sth 0x9d7002c, com 0x9f25b28, imp DBD::SQLite::st):
   FLAGS 0x100111: COMSET Warn PrintError PrintWarn
   ERR '21'
   ERRSTR 'not an error'
   PARENT DBI::db=HASH(0x9d6fd5c)
   KIDS 0 (0 Active)
   NUM_OF_FIELDS -1
   NUM_OF_PARAMS 0
dbih_clearcom 0x9d7002c (com 0x9f25b28, type 3) done.

!! ERROR: '21' 'not an error' (err#0)
- prepare= undef at /etc/perl/Foo.pm line 187 via  at
/etc/perl/Foo.pm line 149
DBD::SQLite::db prepare failed: not an error at /etc/perl/Foo.pm line 187.
- errstr in DBD::_::common for DBD::SQLite::db
(DBI::db=HASH(0x9d6fdbc)~0x9d6fd5c) thr#8a2fb48
   ERROR: '21' 'not an error' (err#0)
- errstr= 'not an error' at /etc/perl/Foo.pm line 187 via  at
/etc/perl/Foo.pm line 149
Error happening
not an error DBI-errstr
 at /etc/perl/Foo.pm line 187
SPL::Image::get_record('SPL::Image=HASH(0x9c00cc8)') called at
/etc/perl/Foo.pm line 149
SPL::Image::_verify('SPL::Image=HASH(0x9c00cc8)') called at
/etc/perl/Foo.pm line 142
SPL::Image::verify('SPL::Image=HASH(0x9c00cc8)') called at
/etc/perl/Foo.pm line 110
SPL::Image::update_or_create('Foo=HASH(0x9c00cc8)') called at
/var/www/soap/ProcessImage.pl line 123
Images::updateDB('spl_number', 'c006/9219') called at
/var/www/soap/ProcessImage.pl line 84
Images::ProcessTiff('Images', '/transfer/c0069219.tif') called at
/usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 2569
eval {...} called at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 
2557
eval {...} called at /usr/lib/perl5/site_perl/5.8.8/SOAP/Lite.pm line 
2526
SOAP::Server::handle('SOAP::Transport::HTTP::CGI=HASH(0x9af7094)',
'?xml version=1.0 encoding=UTF-8?soap:Envelope xmlns:xs...')
called at /usr/lib/perl5/site_perl/5.8.8/SOAP/Transport/HTTP.pm 

Re: Can't use string 1 as HASH ref while strict refs in use

2010-07-20 Thread Dermot
On 20 July 2010 04:40, Mimi Cafe mimic...@googlemail.com wrote:
 I passed a has reference to my sub and tried dereferencing it within the sub
 and get an exception Can't use string (1) as HASH ref while strict refs in
 use.


 my %mail_parameters = (
        'Fname' = $nickname_db_exist[1],
        'Lname' = $nickname_db_exist[2],
        'E-mail' = $reset_email,
        'Subject' = Your $site_name Password Reset,

    );

    # Send the requested information.
    Mail_worker(\%mail_parameters);


 Sub mail_worker {

    $received_arg = @_;
    %params = %$received_arg;# Can't use string 1 as HASH ref while strict
 refs in use
    .
    ..


I hope Uri will forgive me but I will expand a little.

 $received_arg = @_;

You want to shift the argument list but you are actually assigned the
argument array to a scalar value and that will render it's size (1).
You passed Mail_worker a reference to a hash so that hash is now a
single scalar value. Then in your subroutine (called mail_worker, you
dropped the case in your example) after assigning the length of the
argument list to $recieved_arg you attempt to deference it, causing
the error. You could have kept the hash as a reference

sub Mail_worker {
my $recieved_arg = shift;
   
print User first name is $recieved_arg-{Fname}\n;
   .
}

You could have kept it as a hash but that's passing by value and
considered slightly poor practice as your passing more data that you
need. One more option would be to use a named parameter list

Mail_worker(Fname = $nickname_db_exist[1],
  Lname = $nickname_db_exist[2],
  'E-mail' = $reset_email,
  'Subject' = Your $site_name Password Reset,
  );

sub Mail_worker {
my %args = @_
print User first name is $recieved_arg{Fname}\n
}

I hope that helps,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




DBI under SOAP/mod_perl

2010-07-18 Thread Dermot
Hello All,

(This is perl, v5.8.8). Sorry if this is a bit specialised (EG not v.
beginner) but I'm getting rather frustrated and could use some help.


I have a strange issue with a DBI/DBD::SQLite. I have a class that
creates an instance of DBI, EG:

package Foo;

use strict;
use warnings;
use DBI;
use Carp;

my $DEBUG = 1

sub new {
my $class = shift;
my %args = @_;
my $self = {};
$self-{debug} = $args{debug} || $DEBUG;
.
.
$self-{dbh} = DBI-connect($dsn,'','', { PrintError=1,
PrintWarn=1} ) or confess Can't connect: DBI-errstr: $!\n;

bless $self, $class;
return $self;
}

sub dbh {
return $_[0]-{dbh};
}

sub get_record {
my $self = shift;

my $sql = q(SELECT * FROM records WHERE path = ?);
my $sth = $self-dbh-prepare($sql);
print STDERR STH=$sth  DBH=.$self-dbh.\n;
$sth-execute($self-file) or confess Can't prepare: .
$self-dbh-errstr.\n;
while (my $href = $sth-fetchrow_hashref ) {
print STDERR Record found $href-{id} Rows=. $sth-rows.\n
if $self-{debug};
$self-{record} = $href;
}
}

...

1;
###

When I create an instance from a command-line script all works fine.

my $foo = Foo-new();
$foo-get_record();

This prints: STH=DBI::st=HASH(0x92b3f2c)  DBH=DBI::db=HASH(0x92b1ee4)


The problem arise when I create an instance under a SOAP::Lite
package. The package is running under mod_perl's Registry. In the
HTTPD logs I see:

DBD::SQLite::db prepare failed: not an error at /etc/perl/Foo.pm line 190.
Use of uninitialized value in concatenation (.) or string at
/etc/perl/Foo.pm line 191 (#2)
STH=  DBH=DBI::db=HASH(0x8a1568c)


I suspect this is an oddity with mod_perl and SOAP but I can't see a
why through. Does anyone have any ideas what I might try? I can't
change the architecture and have to make this work within what's
installed.


Any ideas appreciated.
Thanx,
Dp,

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Inverting a hash

2010-05-09 Thread Dermot
On 9 May 2010 14:26, Harry Putnam rea...@newsguy.com wrote:
 I have an example from Shawn C. from another thread, presented here
 out of context.  The code does just what he meant it to do.
 It inverts a hash.

 I'm trying to understand what is going on inside the sub function
 `invert()'.

 ---        -       ---=---       -      

 my %hash  = (
           './b/fb'        = 'fb',
           './b/c/fd'      = 'fd',
           './b/l/c/f2'    = 'f2',
           './b/g/f/r/fc'  = 'fc',
           './b/g/h/r/fb'  = 'fb'

       );

 ## %hash is sent to an inversion sub function
  my %inv_hash = invert( \%hash );

 sub invert {
  my $h = shift @_;
  my %inv = ();

  while( my ( $k, $v ) = each %{ $h } ){
    push @{ $inv{$v} }, $k;
  }
  return %inv;
 }

 ---        -       ---=---       -      

 What is actually being sent at
  my %inverse_hash = invert( \%hash );


my %inverse_hash = invert( \%hash );

invert() is being passed a reference to the hash. References are a
useful and efficient way to pass data around [1]. You can create a
reference by putting a back-slash in front of your data. EG:

my %foo_hash = ( foo = 1, bar = 2); # A hash
my $reference_to_foo_hash = \%foo_hash;   # Reference to the hash.

 sub invert {
  my $h = shift @_;

References are scalars. So when you pass it to invert(), instead of
passing in lots of keys and values, you pass in a single scalar
reference to the hash. You shift off the single reference from the
argument list. Any operation you perform on that reference will effect
the original hash.

In the interests of completeness I think I should also point out that
you could have passed in the whole hash by not shifting off of the
argument list. EG:

my %inverse_hash = invert( %hash );
...
...
sub invert {
my %original_hash = @_;


But that's not a habit you want to get into as you are passing lots of
values, passing by reference is saves memory and is faster.

Good luck,
Dp.


1) Apart from perdoc perlref, there is also the reference quick
tutorial at http://perldoc.perl.org/perlreftut.html

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Still pondering working with hashs

2010-05-04 Thread Dermot
On 3 May 2010 19:47, Dr.Ruud rvtol+use...@isolution.nl wrote:
 Harry Putnam wrote:

 Yes, files that exist on multiple paths, but there are also
 many matched names that are not actually the same file.

 Then use md5, or a similar tool.


Seconded. If you want to find duplicate files you will need to use MD5
or a SHA tool.
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Too many arguments for OneTickUtil::getFilesFromDir at G:\workspace1\scripts\fooPackage.pl line 4, near $pattern)

2010-04-28 Thread Dermot
On 27 April 2010 15:39, dbtouch dbto...@gmail.com wrote:
 Hi, Perl Folks

Hello.

 I am getting error Too many arguments for
 OneTickUtil::getFilesFromDir at G:\workspace1\scripts\fooPackage.pl
 line 4, near $pattern) when running a small script calling a package
 routine. Could you give some ideas on what I did wrong?

 Thanks,

 db

 # OneTickUtil.pm
 use File::Find;
 use Date::Calc qw(:all);
 use File::Path;

 ##
 #      OneTickUtil
 #
 # Some classes and functions to use in omd examples
 ##

 package OneTickUtil;

 our $Dir;
 our $searchPattern;

 sub getFilesFromDir()

This is the cause of that error. Your have, I imagine unwittingly,
created a prototype. This says I want a function called getFileFromDir
and have it accept no argument (). You are passing in 2 arguments,
$dir and $patten. If you remove the brackets, it will remove that
error. If you want to use prototypes you would have done sub
getFilesFromDir($$) but I would not recommend that approach.

Another major concern is that you have created a package and not used
strict or warning. If you are going to create a package, you should
make your variables private, particualrly as you have already declared
some variables (EG: our $Dir).

Have a read of perlsub (perldoc perlsub) for information on perl
subroutines. It also talks about private variables.

Good luck.
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl setuid/suid and use MODULE

2010-04-28 Thread Dermot
On 28 April 2010 09:45, David Lee david@ecmwf.int wrote:
 Briefly:

Hi,

Unfortunately I can't offer you any inspired way to open that port.


 I have tried to put as much as reasonably possible of the application into
 local CPAN-like modules, with just the initial C wrapper and small perl
 script outside that framework.  So that is:
   user-called appname: setuid-C-wrapper in PATH
   setuid-C-wrapper: execv(...) of similarly named small script
   that script does various use MODULE-1

 The problem:

 Although written in a CPAN-like way, the application and its modules are
 installed in a /usr/local/application which is external to the main perl
 installation on the various systems.  When run non-setuid it works well
 (apart from an expected failure opening the reserved port).  Fine.

 But when run via the C-wrapper, the small perl script (els.qx) immediately
 fails:
   Insecure dependency in require while running setuid at \
      /usr/local/ecfs/test/.scripts/els.qx line 49.
   BEGIN failed--compilation aborted at \
      /usr/local/ecfs/test/.scripts/els.qx line 49.

 That line 49 is the first of the local use MODULE::NAME commands. Just
 above this is:
   use FindBin;
   use lib $FindBin::Bin/..;
 so that those MODULE::NAME things can be found.  These modules belong to
 the application so are not in the perl installation's '@INC'.

 Question:  How do I proceed?

Would perlsec help?[1] I'm asking because it looks to me like taint
checks are on so every path you use will need to be un-tainted before
it's used. I'm not if it would improve matters to explicitly import
$Bin from FindBin, EG:

use FindBin qw($Bin);
use lib qq($Bin/../);

If not I'd guess you will need to launder the $FindBin::Bin before you
use it and that would probably have to happen in a BEGIN block.[2]


Good luck,
Dp.


1) perldoc perlsec.
2) perldoc perlmod.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Need help to resove..... ExtUtils-Makemaker comilationS

2010-04-23 Thread Dermot
On 23 April 2010 17:04, Raheel Hassan raheel.has...@gmail.com wrote:
 Hi Shlomi and Owen,
 On Thu, Apr 22, 2010 at 5:37 PM, Shlomi Fish shlo...@iglu.org.il wrote:

2.6.27.24-2 is the kernel version (which is kinda old - I'm using
 2.6.33.2). I
need the Mandriva version - please do:
[shell]
shlomi:~$ cat /etc/mandriva-release
Mandriva Linux release 2010.1 (Cooker) for i586
shlomi:~$
[/shell]

 Here is the version number
 [r...@localhost ExtUtils-MakeMaker-6.56]# cat /etc/mandriva-release
 Mandriva Linux release 2009.0 (Official) for i586


You can install most of them using urpmi. Not that there are several
 modules
that start with ExtUtils. See:
http://perl-begin.org/topics/cpan/ http://perl-begin.org/topics/cpan/

 I am unable to install these,
...
...


Can you tell us what happens when you type the command `make`?
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Precision laser printing

2010-04-21 Thread Dermot
On 21 April 2010 04:10, keithvb keit...@email.com wrote:

  Hi,

 I need to create a grid, 24 cols, 16 rows on 4.5 cm centers
 on an HP laser printer. Some of the cells will be filled, some empty.
 Is there a way to do this in Perl?

You going to have to break this project down. The actual document will
need to be created, possibly using PCL symbols
(http://pcl.to/reference/). Once you have a document assembled, you'll
need some means of sending it to the printer. Perl can help with both
tasks but you'll have to fill in the blanks.

Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: [Was XS linker]

2010-04-08 Thread Dermot
On 8 April 2010 18:51, Mike McClain mike.j...@nethere.com wrote:

 Current list volume is a fraction of what it has been.

 Amen and it seems a shame to me.

 I'm simply suggesting that your idea of what is welcome here is more
 narrow than has traditionally been the case.  And in the end it doesn't
 really matter what you, I or anyone else thinks.

 After watching how the activity on this list drops off dramatically after
 somebody gets squashed by one of the 'experts' quoting 'the LAW' at them
 I suggest that what one thinks does matter here if they're willing to
 push their beliefs in a judgmental manner.
 When the experts act like they 'own' the beginners list it appears to me
 that the beginners suffer.

Indeed. Patience and a willingness to repeat one's self was one of
this list assets but that seems to be in short supply these days. We
also seem to have lost one or two regular contributors.

On a more positive note, I think the decrease in volume might be
because there are a lot of other lists that deal with specific Perl
projects. These seem busy. I'm speculating but hopefully the volume
has shifted off to these.

Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Ternary operator: Am I missing something?

2010-03-29 Thread Dermot
On 29 March 2010 14:02, Jeff Soules sou...@gmail.com wrote:
 Hi all,

Hiya,


 Am I missing something?  I have the following chunks of code:

 EX 1:
    if ($foo == 1){
        $bar = 0;
    }else{
        $bar = 1;
    }

 EX 2:
    ($foo == 1) ?
        $bar = 0 :
        $bar = 1;

 These are logically equivalent, right?  But when I've run the latter,
 $bar always comes away with a value of 0, regardless of the value of
 $foo.

 This is particularly confusing, as the following snippet:
 EX 3:
    ($foo == 1) ?
        warn Got 0\n :
        warn Got 1\n;

 is producing the results I expect.

 Am I doing something stupid or missing something obvious?

There must be something else going on within your code.

perl -e '$foo=1; printf(%d\n, ($foo==1)? 1 : 0);'
1
perl -e '$foo=0; printf(%d\n, ($foo==1)? 1 : 0);'
0

I'm puzzled by the list context Jeff has mentioned. I use ($foo == 1)
in ternary expressions and always get the expected results. I may have
to go and re-visit some code to find out what I've done.
Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Perl Reference Books.

2010-03-22 Thread Dermot
On 22 March 2010 15:31,  prasad.prabhak...@aps.com wrote:
 Hi, I am a new to Perl programming, please can anyone advice me right book to 
 understand Perl.

Hello and Welcome,

 Thanks,
 Prasad Prabhakara
 Infrastructure Applications
 Cell:480-889-4171
 Phone:83-6041

If you checkout the footer that it appened to yours and every other
email on this list, (learn.perl.org) you'll find your way to all the
resources you need.
Good luck,
Dp.


 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Lingua::Stem 0.83 module installation problem

2010-03-17 Thread Dermot
On 17 March 2010 02:13, Doug Cacialli doug.cacia...@gmail.com wrote:
 On Tue, Mar 16, 2010 at 4:36 AM, Dermot paik...@googlemail.com wrote:
 On 16 March 2010 00:29, Doug Cacialli doug.cacia...@gmail.com wrote:
 Hello list,


 Building Lingua-Stem
 Can't locate Lingua/Stem.pm in @INC (@INC contains:
 C:/strawberry/perl/lib C:strawberry/perl/site/lib
 c:\strawberry\perl\vendor\lib .) at lib/Lingua/test.pl line 2.
 BEGIN failed--compilation aborted at lib/Lingua/test.pl line 3.
 lib/Lingua/test.pl failed at
 C:/strawberry/perl/lib/Module/Build/Base.pm line 2795.
 --
 To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/




 Thank you for the help, Dermot.  Could you (or someone else on the
 list) provide some detail regard how to set PERL5LIB to include the
 path to the to-be-installed Lingua-Stem/lib, or edit the test.pl and
 use lib?  I tried manually installing; perl Build.PL worked fine,
 build choked and produced the same error as above.  I was able to find
 Lingua/Stem.pl ... it's in the Lingua-Stem-0.83 directory
 (./lib/Lingua/Stem.pl) I extracted from the compressed install file I
 got from CPAN.  Is that helpful?

 I poked around through some online documentation for about 45 minutes
 - I've reached the end of my present skill.


This may be a bit tricky to replicate under windows. PERL5LIB is an
environment variable you can set so that perl will look in that path
for libraries. It's akin to @INC. See perldoc perlrun for more
details. There are a number of ways to set environment variables under
windows, under XP one way would be system
properties/advanced/Enviroment variables.

It sounds like the test is, well not complete, because it has not told
perl where to look and it's in a not standard place.


 lib/Lingua/test.pl ==
#!/usr/bin/perl

use Lingua::Stem qw (stem);
my @words = qw(a list of words to be stemmed for testing purposes);
my $stemmed_words = stem(@words);
print join(\n,@$stemmed_words)




Try modifying test.pl so it reads:

#!/usr/bin/perl

use FindBin qw($Bin);
use lib q($Bin/../lib)

use Lingua::Stem qw (stem);
...
...

Hopefully that will allow the test to work. Looking at the test, I
would say that it's not critical to the installation and you could
force install.

I hope that helps,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Lingua::Stem 0.83 module installation problem

2010-03-16 Thread Dermot
On 16 March 2010 00:29, Doug Cacialli doug.cacia...@gmail.com wrote:
 Hello list,


 Building Lingua-Stem
 Can't locate Lingua/Stem.pm in @INC (@INC contains:
 C:/strawberry/perl/lib C:strawberry/perl/site/lib
 c:\strawberry\perl\vendor\lib .) at lib/Lingua/test.pl line 2.
 BEGIN failed--compilation aborted at lib/Lingua/test.pl line 3.
 lib/Lingua/test.pl failed at
 C:/strawberry/perl/lib/Module/Build/Base.pm line 2795.


I'm not familiar with Strawberry perl but the error says it can't find
Lingua::Stem. It looks like this is happening during the testing
process. Is it possible to download the package and attempt to install
in manually? You could then set PERL5LIB to include the path to the
to-be-installed Lingua-Stem/lib or edit the test .pl and use lib.

HTH,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Dereferencing hash with array value

2010-02-13 Thread Dermot
On 13 February 2010 06:42, Owen rc...@pcug.org.au wrote:
 The program below works, but I don't believe I have to make the
 reference  #  my $svgs = \...@svgs;     to get it into the hash;

 I think I should be able to do something like

  $folders{$folder} = @svgs;
  print $folders{Ztyx}-[3]\n;


You want a array reference there so

$folders{$folder} = \...@svgs;

Saving you from having to make this assignment;

   my $svgs = \...@svgs;
   $folders{$folder} = $svgs;

HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: LWP error returned

2010-02-10 Thread Dermot
On 10 February 2010 15:47, Mike Blezien mick...@frontiernet.net wrote:
 Hello,

 I've run into an error while using the LWP module which I haven't come
 accross before and was wondering what is means. This is the coding I'm
 using:

 --
 use LWP::UserAgent;

 my $USERNAME = XX;
 my $PASSWORD = XX;

 my $URL =
 http://technet.rapaport.com/HTTP/RapLink/download.aspx?Polish=I,EX,VG,G,F,PSymm=I,EX,VG,G,F,PSortBy=ownerWhite=1Fancy=1Programmatically=yes;;
 my $URL =
 qq~https://technet.rapaport.com/HTTP/RapLink/download.aspx?Shape=BCaratSizeFrom=0.4CaratSizeTo=3.5ColorFrom=DColorTo=JClarityFrom=FLClarityTo=SI1CutFrom=ICutTo=GGradeReport=GIA,AGSPolish=I,EX,VG,GSymmetry=I,EX,VG,GFluorescenceIntensity=N,VSL,F,M,SSellerLogin=67155,60745,32235,39321,43460,28426,43412,67000,68708,50841SortBy=ownerWhite=1Programmatically=yes~;

 my $ua = LWP::UserAgent-new();
     $ua-timeout(60);
 #create request
 my $req = new HTTP::Request 'POST' = $URL;
         $req-content_type(application/x-www-form-urlencoded);

 #add creadentials to request
 $req-authorization_basic($USERNAME,$PASSWORD);
 my $res = $ua-request($req);

 my $content = $res-content();

 ---

 The error/content is returns is Length Required  not exactly sure what
 that means.

A pure guess would be that the host requires a 'content-length' header
OR the web service requires a length parameter.

Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: LWP error returned

2010-02-10 Thread Dermot
On 10 February 2010 17:01, Mike Blezien mick...@frontiernet.net wrote:

 - Original Message - From: Dermot paik...@googlemail.com
 To: Perl List beginners@perl.org
 Sent: Wednesday, February 10, 2010 10:14 AM
 Subject: Re: LWP error returned


 On 10 February 2010 15:47, Mike Blezien mick...@frontiernet.net wrote:

 Hello,

 I've run into an error while using the LWP module which I haven't come
 accross before and was wondering what is means. This is the coding I'm
 using:


 --
 use LWP::UserAgent;

 my $USERNAME = XX;
 my $PASSWORD = XX;

 my $URL =

 http://technet.rapaport.com/HTTP/RapLink/download.aspx?Polish=I,EX,VG,G,F,PSymm=I,EX,VG,G,F,PSortBy=ownerWhite=1Fancy=1Programmatically=yes;;
 my $URL =

 qq~https://technet.rapaport.com/HTTP/RapLink/download.aspx?Shape=BCaratSizeFrom=0.4CaratSizeTo=3.5ColorFrom=DColorTo=JClarityFrom=FLClarityTo=SI1CutFrom=ICutTo=GGradeReport=GIA,AGSPolish=I,EX,VG,GSymmetry=I,EX,VG,GFluorescenceIntensity=N,VSL,F,M,SSellerLogin=67155,60745,32235,39321,43460,28426,43412,67000,68708,50841s~;

 my $ua = LWP::UserAgent-new();
 $ua-timeout(60);
 #create request
 my $req = new HTTP::Request 'POST' = $URL;
 $req-content_type(application/x-www-form-urlencoded);

 #add creadentials to request
 $req-authorization_basic($USERNAME,$PASSWORD);
 my $res = $ua-request($req);

 my $content = $res-content();

 ---

 The error/content is returns is Length Required  not exactly sure
 what
 that means.

 A pure guess would be that the host requires a 'content-length' header
 OR the web service requires a length parameter.


 Is there something else I need to add to the coding the to pass this
 parameter ??


I doubt that it is the HTTP header that it's after but the docs for
setting HTTP headers with LWP are here.

http://search.cpan.org/~gaas/libwww-perl-5.834/lib/HTTP/Headers.pm

I suspect you will need to add a parameter to your url

...SortBy=ownerWhite=1Programmatically=yeslength=n

but you will need to get more details from the web-service before you
can be sure what format the length should be in and what it refers to.

Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PERL binary conversion

2010-01-19 Thread Dermot
2010/1/19 Shan shanmugasundara...@tessolve.com:
 - Original Message - From: Dermot paik...@googlemail.com
 To: Perl Beginners beginners@perl.org
 Sent: Monday, January 18, 2010 5:42 PM
 Subject: Re: PERL binary conversion
 2010/1/18 Shan shanmugasundara...@tessolve.com:

 Thank u for your quick reply.

 How to install following module.or How to install following module in
 my
 system.I'm working in WINDOWS NT.
 Convert::Binary::C;Thanks and Regards,Shan

 BTW, it's perl or Perl, but never PERL.
 I am guessing your new to this list because your making a few common fau
 pau's.

 Send you emails to the list so that others can offer advice and learn
 from your experience. Can you put your message at the bottom of the
 last-reply. And try and cut out the disclaimers if you can.

 Back to your question:

 I'm using ActiveState.May I use CPAN module for that.If so how it would
 be.

 In that case you should have a program called PPM in the program group
 or if you open up a command prompt and type ppm you should get a new,
 cpan shell.
 cpan

 If you don't there is something wrong. If you type help it will give
 you some advice on the commands. To install Convert you would type
 `install Convert::Binary::C`

 You should be aware that not all modules from cpan are available to
 activestate and I didn't see Convert::Binary::C in the list at

 http://aspn.activestate.com/ASPN/Modules?module_name=Corder=namequery_start=211.
 That's one of the reason some users prefer Strawberry Perl, it has
 better support[1] for cpan modules.
 Hi Dermot,

  Thank you for ur help.Now I have installed Convert::Binary::C.

 But my ppm is installed this as 0.68 version.But I need 0.74.

 I don't know where it(0.68) takes.But CPAN archives have 0.74 version

Try to remember to hit reply-to-all when you reply Shan.

Unfortunately the versions of lots of modules on ActiveState lag
behind CPAN.  That's one of the reasons some users prefer Strawberry
Perl. Refer to Rob's email (Sisyphus) on how to install a module from
CPAN.

Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Searching First Array in Second Array

2010-01-19 Thread Dermot
2010/1/19 Parag Kalra paragka...@gmail.com:
 Hello All,

 I have 2 arrays. I have written a script that searches each and every value
 of first array in the second array. Each  every value of Source Array
 should occur only once in the target array but it can occur anywhere.

 If any of the source value doesn't occur or occur multiple times then the
 script reports to the user.

 This script is working fine for small arrays.

 But I tried executing the script for 2 arrays each of which containing
 around 7,00, elements and it is taking very long time.
 I am using nested 'for' loops to make this search. How can I optimize it
 further to search source array in target array.


Have a look at List::Util, it's a part of the standard distribution. I
think 'first' will do what you want. There is also List::MoreUtils
available at CPAN. Randal has created some nice articles[1] that will
help you along.

Good luck,
Dp.


[1] http://www.stonehenge.com/merlyn/LinuxMag/col97.html

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Geeky way to wish Happy Birthday through Perl

2010-01-18 Thread Dermot
2010/1/17 Parag Kalra paragka...@gmail.com:
So common folks give me some ideas.

 I meant - Come on Folks :P

 Cheers,
 Parag




 On Sun, Jan 17, 2010 at 11:34 PM, Parag Kalra paragka...@gmail.com wrote:

 Hello All,

 I am looking for a geeky way to wish someone on his Birthday with the help
 of Perl.

 Condition is - It should be one liner which I can directly execute from the
 command line.

 EG: perl -e print 'Happy Birthday Larry!!!'

 But this is very simple and you can directly make out without even
 executing. I want some really nerdy way of wishing for which the Birthday
 Boy has to execute it without which he cannot understand the message. :)

 So common folks give me some ideas.

You could try this, don't know if it's obscure enough for you though

perl -e 'print \x48\x61\x70\x70\x79\x20\x42\x69\x72\x74\x68\x64\x61\x79\xa'

Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PERL binary conversion

2010-01-18 Thread Dermot
2010/1/18 Shan shanmugasundara...@tessolve.com:

 Hi All,


 How to install following module.or How to install following module in my 
 system.I'm working in WINDOWS NT.
 Convert::Binary::C;Thanks and Regards,Shan

Hi Shan,

What Perl have you got installed? ActiveState's or Strawberry's? They
will have their own means of installing modules, PPM for Activestate
and the cpan shell for Strawberry. If you can provide a bit more
information we can tell you how to get that module installed.

BTW, it's perl or Perl, but never PERL.
Good luck,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PERL binary conversion

2010-01-18 Thread Dermot
2010/1/18 Shan shanmugasundara...@tessolve.com:
 Thank u for your quick reply.


 Thanks,
 Shan

 - Original Message - From: Dermot paik...@googlemail.com

 2010/1/18 Shan shanmugasundara...@tessolve.com:

 Hi All,


 How to install following module.or How to install following module in my
 system.I'm working in WINDOWS NT.
 Convert::Binary::C;Thanks and Regards,Shan

 Hi Shan,

 What Perl have you got installed? ActiveState's or Strawberry's? They
 will have their own means of installing modules, PPM for Activestate
 and the cpan shell for Strawberry. If you can provide a bit more
 information we can tell you how to get that module installed.

 BTW, it's perl or Perl, but never PERL.
 Good luck,
 Dp.

I am guessing your new to this list because your making a few common fau pau's.

Send you emails to the list so that others can offer advice and learn
from your experience. Can you put your message at the bottom of the
last-reply. And try and cut out the disclaimers if you can.

Back to your question:

 I'm using ActiveState.May I use CPAN module for that.If so how it would be.

In that case you should have a program called PPM in the program group
or if you open up a command prompt and type ppm you should get a new,
cpan shell.
cpan

If you don't there is something wrong. If you type help it will give
you some advice on the commands. To install Convert you would type
`install Convert::Binary::C`

You should be aware that not all modules from cpan are available to
activestate and I didn't see Convert::Binary::C in the list at
http://aspn.activestate.com/ASPN/Modules?module_name=Corder=namequery_start=211.
That's one of the reason some users prefer Strawberry Perl, it has
better support[1] for cpan modules.

Good luck,
Dp.

[1] I can't be arsed to go into the some module will, some module
won't compile

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: hash of Arrays

2010-01-18 Thread Dermot
2010/1/17 Johnson, Reginald (GTS) reggie.john...@bankofamerica.com:
 I am trying to place the date of each day of the week for each month
 that has 5 weeks into a hash. For instance my hash key 'Monday' would
 point to an array that has all the dates where Monday is in the fifth
 week of the month.
 I've got that part going. My problem is I am having a problem accessing
 the hash. Data dumper shows me the data is there, but when I try to
 access I am doing something wrong.


It looks like you have gone to a lot of effort but I fear that you
might be trying to re-invent the wheel here. The DateTime family of
modules will probably do all you need. It also has it own site with
useful FAQs. http://datetime.perl.org/?FAQ the SampleCalculations
section looks relevant to you needs.

As for the accessing the value of $fifthday_hash{Monday}, you appear
to have tried to create a subroutine reference for each key.  I
modified it a bit to see what was going on but I didn't want to spend
too much time on it for the reasons stated above;

   #sub day_in_a_month; #predeclare
   #sub day_in_a_month_driver; #predeclare
   foreach $weekday (@day_Array){
   print this is weeekday $weekday\n;
   $fifthday_hash{$weekday} = sub
{day_in_month($weekday,$mon,$year) };
   }

 #print Dumper( \%fifthday_hash);
  while ( my ($key,$value)= each %{fifthday_hash} ) {
   if ($key =~/Monday/) {
   print this is key =$key= $key $value\n;
   my $val = $value-($key,1 , 2010);
   print Val=.join ', ',@$val,\n
.

We I ran the above I get this. Not sure if that what you expected.

this is weeekday Monday
this is weeekday Tuesday
this is weeekday Wednesday
this is weeekday Thursday
this is weeekday Friday
this is weeekday Saturday
this is weeekday Sunday
this is key =Monday= Monday CODE(0x83c5ce8) CODE
Val=, , 3/29/2010, , 5/31/2010, , , 8/30/2010, , , 11/29/2010, ,
1/31/2011, , , , 5/30/2011, , , 8/29/2011, , 10/31/2011, , ,
1/30/2012, , , 4/30/2012, , , 7/30/2012, , , 10/29/2012, , 12/31/2012,
, , , 4/29/2013, , , 7/29/2013, , 9/30/2013, , , 12/30/2013, , ,
3/31/2014, , , 6/30/2014, , , 9/29/2014, , , 12/29/2014, , ,
3/30/2015, , , 6/29/2015, , 8/31/2015, , , 11/30/2015, , , 2/29/2016,
, , 5/30/2016, , , 8/29/2016, , 10/31/2016, , , 1/30/2017, , , ,
5/29/2017, , 7/31/2017, , , 10/30/2017, , , 1/29/2018, , , 4/30/2018,
, , 7/30/2018, , , 10/29/2018, , 12/31/2018, , , , 4/29/2019, , ,
7/29/2019, , 9/30/2019, , , 12/30/2019, , , 3/30/2020, , , 6/29/2020,
, 8/31/2020, , , 11/30/2020, , , , 3/29/2021, , 5/31/2021, , ,
8/30/2021, , , 11/29/2021, , 1/31/2022, , , , 5/30/2022, , ,
8/29/2022, , 10/31/2022, , , 1/30/2023, , , , 5/29/2023, , 7/31/2023,
, , 10/30/2023, , , 1/29/2024, , , 4/29/2024, , , 7/29/2024, ,
9/30/2024, , , 12/30/2024, , , 3/31/2025, , , 6/30/2025, , ,
9/29/2025, , , 12/29/2025, , , 3/30/2026, , , 6/29/2026, , 8/31/2026,
, , 11/30/2026, , , , 3/29/2027, , 5/31/2027, , , 8/30/2027, , ,
11/29/2027, , 1/31/2028, , , , 5/29/2028, , 7/31/2028, , , 10/30/2028,
, ,


Good luck,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Email does not send attachment ...

2009-12-09 Thread Dermot
2009/12/9 Robert H sigz...@gmail.com:
 On 12/8/09 3:56 PM, Tony Esposito wrote:

 Hello,
Hi

   use MIME::Lite;
  use Net::SMTP;

  unless (-e 'C:/my_file.log'  -s 'C:/my_file.log' ) { print file not
 found\n; }

   my $msg = MIME::Lite-new (
     From =  'my_em...@yahoo.com',
     To =  'your_em...@yahoo.com',
     Subject =  'Testing error email',
     Type ='multipart/mixed'
   ) or die Error creating multipart container: $!\n;

  $msg-attach (
     Type =  'TEXT',
     Data =  'Error in the module that caused this email',
   ) or die Error adding the body text to email message: $!\n;

    $msg-attach (
      Type =  'TEXT',
      Path =  'C:/my_file.log',
      Filename =  'my_file.log',
      Disposition =  'attachment'
      ) or die Error adding file attachment: $!\n;

   MIME::Lite-send('smtp', 'smtp.server.net', Timeout=60);
   $msg-send;

 I see why you do that now. Sorry.

I don't see why. I would just do $msg-send (or send_by_smtp). Perhaps
I have missed something in the docs.

The part that I'd be concerning about (and would alter) are
Type='text/plain', I would make the 3rd attachment conditional (if -e
$path_to_log) { $msg-attach...} and yes I'd drop the MIME::Lite-send
and stick with the $msg-send.

HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: learning perl scripting

2009-12-06 Thread Dermot
2009/12/6 Agnello George agnello.dso...@gmail.com:
 Hi

Welcome

 i am basically a  a system administrator, and i have just joined this new
 company where my entire team are a group pf developers + system admins and i
 am the only system admin with out programming knowledge . i know a little of
 shell scripting from my previous company and i thought shell scripting was
 king ... but having joined this company every one is using a lot of persl to
 do a lot of log parsing ... DB interaction and lot of cool hashes related
 stuff ... but last one year i am trying to learn this language but dont seem
 to get a hold of it . sometimes i fell shell-scripting a is a lot more
 better and easier .. but my aim is to learn perl scripting ... i mean how
 does one get a real hold of this language ... !!


I came to Perl because I am a sys-admin. I started with awk and sed
but, like your colleagues, found Perl far more far-reaching (ahh
awk2perl).  I started with moving and renaming files around the file
system, taking disk-space stats then later putting those stats on a
web interface. I'm still no expert. I regularly suffer from days where
I crave to know more and understanding, seems tantalizingly, out of
reach. You are going to have to leave the safety of shell-scripting
that you are comfortable with and force yourself to do the
un-comfortable and perform all your tasks with perl. You may even have
to do a little work at home at times :)
Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: return {}-{'name'};

2009-12-03 Thread Dermot
2009/12/3 Peter Scott pe...@psdt.com:
 On Mon, 30 Nov 2009 14:36:44 +, Dermot wrote:
 Does it have a name?

 It's called the Orcish Maneuver (or-cache).  See: Effective Perl
 Programming, Hall with Schwartz.

Thank you.

Interesting there's a edition published in 1998 by Hall/Schwartz and
an edition to be published in 2010 by Hall/McAdams/d Foy . That should
give me enough time to wade through all my existing reading material
by the time it's gone to press.

Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: ERROR: malformed header

2009-12-02 Thread Dermot
2009/12/2 Rene Schickbauer rene.schickba...@gmail.com:
 Raheel Hassan wrote:

 HI,

 I have an error in opening one of my perl script, could any one tell me
 where i look for resolving this problem. This error i looked in the apache
 error logs. Thanks in advance.

 * malformed header from script. Bad header=\tPUBLIC -//W3C//DTD XHTML
 1.0:
 dashboard.pl, referer: http://localhost/index.pl*;

 Hard to say exactly without the actual code. Looks like you're printing
 something in the wrong order (maybe a warning).

 Can you give us the relevant code snippet?


Oh dear. We have a bit of a cross-posting here. Reply-all is sending
the mail to the cgi-list as well. Raheel, please post your questions
to one list or the other.

I've sent my reply from the cgi list.
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: About the uninstall the new perl version

2009-12-02 Thread Dermot
2009/12/2 Majian jian...@gmail.com:
 Hi, guys:

  I have a problem about the perl uninstall , my laptop's system is CentOS
 5.3 x86_64, and the default perl version is perl -5.8.8;

     I installed the newer version called perl -5.11.1by the tar.gz package
 , but now I don't want it ~

        In other worlds , I want to uninstall it from my laptop

       How   could I do ?  Maybe it is a stupid problem .So please forgive
 me ~I am a perl newbie~~

Didn't you get lots of warning messages when you tried to install it?
I did. Odd numbered Perl's (5.9, 5.11) are development releases.

If this is a source installation and you kept the source, I think you
can do `make uninstall` from source the directory.
Hope that works.
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: return {}-{'name'};

2009-11-30 Thread Dermot
2009/11/24 Randal L. Schwartz mer...@stonehenge.com:
 Dermot == Dermot  paik...@googlemail.com writes:


 ...

 Dermot I guess the question is: Will the declaration of our %cache within a
 Dermot function-orientated sub-routine render it always uninitialized?

 I believe what you are seeing is that %cache is per-child, so it has
 to compute it *once* for each child, not once for the server overall.

Actually I've made a bobo. This program doesn't run within modperl but
from the command-line. It updates a DB. But it worked really well. A
few print statements show that the hash is initialised once at the
first invocation of the get_cached_val_or_lookup().

package MyPack::Handlers;

our %cache;

...
..
sub get_cached_val_or_lookup {
my $val = shift;
return $cache{$val} ||= do {
print STDERR Having to lookup value for $val as the hash key
didn't exist\n;
my $sql = qq(SELECT DISTINCT price_code, price_id FROM prices);
my $dbq = dbiQuery($sql);
if ($dbq-success  $dbq-rows) {   # DBI sub-classed methods
while ( $dbq-fetch() ) {
my $code = ($dbq-row())[0];
$cache{$code} = ($dbq-row())[1];
}
return $cache{$val};
}
}
}

1;

One more question If I can. Chas pointed me to
http://perldesignpatterns.com/?PerlDesignPatterns some time ago. I
suspect that the above is a form of design pattern. Does it have a
name? Is there a reference to it at
http://perldesignpatterns.com/?PerlDesignPatterns

Thanx,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: die unless match is successful

2009-11-29 Thread Dermot
2009/11/29 raphael() raphael.j...@gmail.com:
 Hi,

 I want the below if loop to end if it cannot find any match  print the die
 message.
 However it just exit without hitting my die

 As you can see in the code below I have tried many foolish ways to make the
 script say
 that it cannot find the number searched in while loop.

    while ( my $line = $FH-readline ) {
        chomp;
        next if ( $line =~ m/return/i );
        if ( $line =~ m/^$number\s+(\S+)\s+(.*)$/ ) {

             get_info($number, $1, $2); # if ( $1, $2 ); # -- don't
 execute sub get_info unless a match

             die \nNo Entries Found By Number: [$number]\n unless ($1);
                          # print $1; exit;

             last;
        }
    }
    $FH-close();

 Any Ideas?

perldoc -f last

or

http://perldoc.perl.org/functions/last.html

HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: Loading results (via ajax) from a CGI

2009-11-28 Thread Dermot Paikkos
This is of course a javascript/ajax question to a perl list

 -Original Message-
 From: bu...@alejandro.ceballos.info
 [mailto:bu...@alejandro.ceballos.info]
 Sent: 27 November 2009 13:59
 To: beginners-cgi@perl.org
 Subject: Loading results (via ajax) from a CGI
 
 Any idea where is going this?
 
 
 If this help, here is my ajax routine:
 
 function ShowInstallInfo (int_value)
{
var ajax_this;
if (window.XMLHttpRequest) { ajax_this = new XMLHttpRequest(); }
else { ajax_this = new ActiveXObject(Microsoft.XMLHTTP); }
ajax_this.onreadystatechange = function ()


Take out the if clause and see what you get.

  { if (ajax_this.readyState==4 || 
ajax_this.readyState==complete)
{ alert(Results: +ajax_this.status+
 text:+ajax_this.responseText); }
  };

//   { if (ajax_this.readyState==4 || ajax_this.readyState==complete)
   { alert(Results: +ajax_this.status+
 text:+ajax_this.responseText); }
//  };

Good luck,
Dp.
 



--
To unsubscribe, e-mail: beginners-cgi-unsubscr...@perl.org
For additional commands, e-mail: beginners-cgi-h...@perl.org
http://learn.perl.org/




Re: Separating DB operations out of program code

2009-11-28 Thread Dermot
2009/11/27 Steve Bertrand st...@ibctech.ca:
 Dermot wrote:
 2009/11/26 Scott Pham scott.p...@gmail.com:
 Have you looked at DBIx::Class?


 I'd 2nd that. DBIx is the way forward. You should be looking to stop
 writing SQL statements and moving towards ORM. Try the example at
 http://search.cpan.org/~frew/DBIx-Class-0.08114/lib/DBIx/Class/Manual/Example.pod

 I want to thank those who responded on list, and off-list.
...

 Thanks for the recommendations, and if there are any contributors to
 this project or its derivatives on the list, cheers!

 Only a single business day of learning the basic in and outs, and I can
 see already how I've wasted thousands of man hours doing it the 'old'
 way in the past :)

I see you truly hooked. I haven't seen a maintainer for DBIx on this
list. They have a pretty active mailing list[1] and a IRC[2]. I,
personally, find other lists less friendly than beginners. Your
expected to know your stuff but if you have issues with DBIx that's
the place to go.


1) http://lists.scsys.co.uk/mailman/listinfo/dbix-class/
2) irc.perl.org#dbix-class

Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PRINT LAST ENTRY IN A FILE

2009-11-28 Thread Dermot
2009/11/28 raphael() raphael.j...@gmail.com:
 Hi,
Hi,

 # records.txt
  25.11.2009 NAME_0
  15.12.2006 NAME_3
  20.10.2007 NAME_1
  01.01.2008 NAME_3    -- This whole line should be printed.
  10.10.2008 NAME_4

 Using while in a while loop matching ( m// ) I get all the entries
 having .

What is distinctive about the line you are trying to print? Do you
want the 4th line every time or is there some combination of  and
NAME_ that you need? Once you determine what is unique about the line
your after, you'll be on the way.
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: PRINT LAST ENTRY IN A FILE

2009-11-28 Thread Dermot
2009/11/28 raphael() raphael.j...@gmail.com:
 2009/11/28 raphael() raphael.j...@gmail.com:
  Hi,
 Hi,

  # records.txt
   25.11.2009 NAME_0
   15.12.2006 NAME_3
   20.10.2007 NAME_1
   01.01.2008 NAME_3    -- This whole line should be printed.
   10.10.2008 NAME_4
 
  Using while in a while loop matching ( m// ) I get all the entries
  having .

 What is distinctive about the line you are trying to print? Do you
 want the 4th line every time or is there some combination of  and
 NAME_ that you need? Once you determine what is unique about the line
 your after, you'll be on the way.
 Dp.

 No combination! Just the last entry of the record   which is given
 through user input and changes each time the script is called.
 The whole line then is parsed and given to another subroutine as shown in
 the subroutine code.


Here one option. Stick the hits into an array and print out the last element.


#!/bin/perl

use strict;
use warnings;

chomp (my $input = STDIN); #111

my @hits;
while (DATA) {
push @hits, $_ if /$input/;
}

print $hits[-1]; # prints  01.01.2008 NAME_3


__DATA__
 25.11.2009 NAME_0
 15.12.2006 NAME_3
 20.10.2007 NAME_1
 01.01.2008 NAME_3
 10.10.2008 NAME_4



Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: calc time elapsed in days

2009-11-27 Thread Dermot
2009/11/27 Rob Coops rco...@gmail.com:
 On Fri, Nov 27, 2009 at 5:43 AM, raphael() raphael.j...@gmail.com wrote:

 HOW CAN I COUNT ELAPSED DAYS ?

 I tried in localtime() days value like

 my @array_date = localtime();
 my $current_dayofyear = @array_date[7];


 But this would break on New year as $current_dayofyear would be reset.


 SO HOW CAN I COUNT ELAPSED DAYS IF THE DATE FORMAT IS  01.01.2009?



 Hi,

 This is a very old problem pretty much every single programmer has bumped
 into this one... So looking on CPAN http://search.cpan.org should be able
 to provide you literally tens of modules used for date calculations in all
 sorts and forms. I would advise having a look at Date::Manip which I found
 very helpful for these kinds of problems. But if you are stubborn and like
 to reinvent the wheel that is no problem of course but might be a little
 more difficult...

I don't want to be controversial but I attended a Perl course this
week where the tutor came down firmly in the DataTime camp. It has
it's own site (http://datetime.perl.org/) as well as providing all the
features of Date::Calc (my favourite) and Date::Manip in a unified
manor.

In the case above you would create a Duration object
(http://search.cpan.org/~drolsky/DateTime-0.51/lib/DateTime/Duration.pm)
and apply that to you existing DataTime object.

HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: a simple question about the line

2009-11-27 Thread Dermot
2009/11/27 John W. Krahn jwkr...@shaw.ca:

 Hello,


 $ echo 12
 23
 34
 45
 56
 67
 78 | perl -lpe'$\=--$|?$,:$/'
 1223
 3445
 5667
 78

For the benefit of this Luddite, please explain?
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Separating DB operations out of program code

2009-11-26 Thread Dermot
2009/11/26 Scott Pham scott.p...@gmail.com:
 Have you looked at DBIx::Class?


I'd 2nd that. DBIx is the way forward. You should be looking to stop
writing SQL statements and moving towards ORM. Try the example at
http://search.cpan.org/~frew/DBIx-Class-0.08114/lib/DBIx/Class/Manual/Example.pod

Good luck,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: How to toggle a variable with each iteration?

2009-11-25 Thread Dermot
2009/11/25 kusuma ramaswamy rkus...@gmail.com:
 Hello, I am new to perl. I would like to know how to toggle a variable with
 each iteration in a loop ??

Hi,

I'm not entirely sure that I understand your requirements but this
might get you started.

You want to scope your variables with the keyword `my`, so

#!/path/to/perl
use strict;
use warnings;
...
foreach my $colour (qw/red green yellow blue/) {
 print $var\n
}

red
green
yellow
blue

The variable $colour will be changed with each iteration of the loop.
Have a look at
http://perldoc.perl.org/perlsyn.html#Foreach-Loops

for more details.
HTH,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Code issue with perl5.10

2009-11-25 Thread Dermot
2009/11/25 Steve Bertrand st...@ibctech.ca:


 ${$self-{__pb_template_list}}[...@{$self-{__PB__TEMPLATE_LIST}}}]-param(
 $param, $value );

 As I understand it, $# has been deprecated in 5.10.

Ouch! Really. That's a shame.

Can someone please
 help me understand the above line of code? What does $# represent in
 this context?

 Well, I finally trudged through it. In order to make it work:

 my $elem = �...@{ $self-{__PB_TEMPLATE_LIST} };
 $elem--;
 ${$self-{__PB_TEMPLATE_LIST}}[$elem]-param( $param, $value );

 Not the most elegant solution, but it works for now!

Could you use -1 instead, a bit like this (untested):

${$self-{__pb_template_list}...@{$self-{__PB__TEMPLATE_LIST}}} -1 ]-param(
$param, $value );

Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Regex to get last 3 digits of a number.

2009-11-24 Thread Dermot
2009/11/23 Dave Tang d.t...@imb.uq.edu.au:
 On Tue, 24 Nov 2009 09:39:09 +1000, Dermot paik...@googlemail.com wrote:

 2009/11/23 Dave Tang d.t...@imb.uq.edu.au:

 On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey shawnhco...@gmail.com

 Hi Shawn et al.,

 I am also intrigued by the \z anchor. I had a look at perldoc perlreref
 and
 found

 \z  Match absolute string end

 My question is what is the difference between \z and $? And when should I
 use \z rather than $ ? From the same documentation:

 $   Matches at the end of the string (or line, if /m is used)


 From perlre

 The \A  and \Z  are just like ^ and $, except that they won't
 match multiple times when the /m modifier is used, while ^ and $
 will match at every internal line boundary. To match the actual end of
 the string and not ignore an optional trailing newline, use \z .

 Thanks Dermot! I guess I should RTFM a bit more next time, before posting a
 question.

 Lesson learnt :P

Lol, I only know because I asked the same question myself (on a
different list) and got pretty much the same style answer. I wouldn't
have found it on my own.
Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: return {}-{'name'};

2009-11-24 Thread Dermot
2009/11/18 Randal L. Schwartz mer...@stonehenge.com:

 I prefer a pattern that looks more like this:

 sub expensive_to_calculate {

  my $self = shift;
  my $input = shift; # cache on this scalar

  our %cache_for_expensive_to_calculate;
  return $cache_for_expensive_to_calculate{$input} ||= do {
    expensive calculation here;
    more things based on $input;
    last expression is value;
  };

 }

 Yes, in 5.10, this can be simplified, but I find 5.8 to still be
 the dominant Perl.

 This also presumes that a false value is never needed to be cached.

Hi,

Re-hashing an old thread here.

I've tried to borrow the above pattern for something I'm doing but I'm
wondering if this is going to work in the environment I working in.

It' is perl, v5.6.2, on a modperl 1, and the although the package is a
class, somehow the package/file I'm working with is being used in a
function-orientated way. Yes, it all needs updating but I need to get
this last feature in before I move it to new architecture.

sub get_prices_from_code {
my $code = shift;
our %cache;
return $cache{$code} ||= do {
my $sql = qq(SELECT DISTINCT price_code, price_id FROM prices);
my $dbq = dbiQuery($sql);
if ($dbq-success  $dbq-rows) {
while ( $dbq-fetch() ) {
if ($code eq ($dbq-row())[0] ) {
$code = ($dbq-row())[0];
$cache{$code} = ($dbq-row())[1];
}
}
return $cache{$code};
}
}
}

I guess the question is: Will the declaration of our %cache within a
function-orientated sub-routine render it always uninitialized?
Thanx,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Regex to get last 3 digits of a number.

2009-11-23 Thread Dermot
2009/11/23 Dave Tang d.t...@imb.uq.edu.au:
 On Mon, 23 Nov 2009 23:14:51 +1000, Shawn H Corey shawnhco...@gmail.com

 Hi Shawn et al.,

 I am also intrigued by the \z anchor. I had a look at perldoc perlreref and
 found

 \z  Match absolute string end

 My question is what is the difference between \z and $? And when should I
 use \z rather than $ ? From the same documentation:

 $   Matches at the end of the string (or line, if /m is used)


From perlre

The \A  and \Z  are just like ^ and $, except that they won't
match multiple times when the /m modifier is used, while ^ and $
will match at every internal line boundary. To match the actual end of
the string and not ignore an optional trailing newline, use \z .

HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Looking for advise on storring a complex array

2009-11-18 Thread Dermot
2009/11/18 Rob Coops rco...@gmail.com:
 On Mon, Nov 16, 2009 at 10:09 PM, Rene Schickbauer 
 rene.schickba...@magnapowertrain.com wrote:

 Rob Coops wrote:

 Thank you for the advise, I'll certainly be using a DB should this tool ever
 get upgraded to a web based one.

You'd be hard pressed to find a *nix machine without SQLite
pre-installed. It's often used by the package manager. It's bloody
fast too.

Just a thought.
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Regular expressions question

2009-11-18 Thread Dermot
2009/11/17 mangled...@yahoo.com mangled...@yahoo.com:
 Hi,

Hello,


 Can anyone tell me hoq to write a regular expression which matches
 anything _except_ a litteral string ?

 For instance, I want to match any line which does not begin with
 Nomatch.  So in the following :

 Line1 
 Line2 
 Nomatch 
 Line3 
 Line 4 

 I would match every line except the one containing Nomatch 


You would negate the pattern. Something like this:

#!/usr/bin/perl


use strict;
use warnings;

while (DATA) {
print if ! /^Nomatch/;
}

__DATA__
Line1 
Line2 
Nomatch 
Line3 
Line 4 
~

Output:
Line1 
Line2 
Line3 
Line 4 

see
perldoc perlop  #Logical-Not
and
perldoc perlsyn
and of course
perldoc perlrequick


HTH,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: mkdir in the mounted partition,please help me ,thanks

2009-11-17 Thread Dermot
2009/11/17 gaochong zjgaoch...@gmail.com:
 #!/usr/bin/perl -w



 #Auther:gaochong



 use strict;



 my @list = (3 .. 9);

 my @FA=(FA0001..FA2000);

 sub mk_fa {

        my ($f) = @_;

        foreach my $p (@list) {

                mkdir /data$p/NRU/$f,0755 or warn mkdir /data$p/NRU/$f
 err:$!;


You should use warnings.

Are you getting a warning from this line? What dies $! say. There
should be getting an error message and that will tell you exactly what
the problem is. 10/1 says it's file permissions.
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: 答复: mkdir in the mounted partition,please help me,thanks

2009-11-17 Thread Dermot
2009/11/17 gaochong zjgaoch...@gmail.com:
 but I have uses perl -w。
 any other problem ?

Did you receive and error message?
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: Emailing all pdf files in a directory

2009-11-17 Thread Dermot
2009/11/16 Tiffany tiffany.vi...@gmail.com:
 Hello,

Hi,


 I am not very familiar with Perl, but I am trying to use it to email
 all files within a directory that have a .pdf extension using the anex
 command within the Mail::SendEasy module.  I have created an array
 with my filenames using @files = *.pdf; but I am not sure how to
 translate that array into email attachments using anex.  Any
 suggestions would be appreciated!


My reading of the documentation suggests that Mail::SendEasy does not
handle attachments. Have a look at MIME::Lite instead.

Good luck,
Dp.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: redirecting to a file in perl

2009-11-13 Thread Dermot
2009/11/13 Subhashini subhashinibasavar...@gmail.com:
 i am trying to execute unix commands using perl.I am doing this using *System
 command.*
 Could i know how i could r*edirect the output of that command onto a log
 file either by using a perl script or may be using command line arguments.*
 Please do help me.

See perldoc -q STDERR
 or
http://perldoc.perl.org/perlfaq8.html#How-can-I-capture-STDERR-from-an-external-command?

HTH,
Dp.

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




  1   2   3   4   >