Re: solved - controlling Firefox using Perl

2021-03-15 Thread Gary Stainburn

On 12/03/2021 13:34, 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.
After two days of internet research I have finally found documentation - 
on my PC.


One of the things I was disappointed with was the quality of the POD 
contents for the modules.  At the weekend I decided that I would have to 
read the source code to learn how to proceed. While looking for the 
locations of the source files I also found the following excellent man 
pages.


In answer to Vlado, I have two uses for this.  Firstly, I have a web 
site where I generate data in real time for a large number of objects 
which I need to test regularly. Second I use somone else's web site and 
I need to collect data on a daily basis.


Gary

/usr/local/share/man/man3/Selenium::Remote::Mock::Commands.3pm
/usr/local/share/man/man3/Selenium::Remote::Commands.3pm
/usr/local/share/man/man3/Selenium::Firefox::Profile.3pm
/usr/local/share/man/man3/Selenium::Remote::Driver::CanSetWebdriverContext.3pm
/usr/local/share/man/man3/Selenium::Remote::Finders.3pm
/usr/local/share/man/man3/Selenium::CanStartBinary.3pm
/usr/local/share/man/man3/Selenium::CanStartBinary::ProbePort.3pm
/usr/local/share/man/man3/Selenium::ActionChains.3pm
/usr/local/share/man/man3/Selenium::Waiter.3pm
/usr/local/share/man/man3/Selenium::Remote::ErrorHandler.3pm
/usr/local/share/man/man3/Selenium::CanStartBinary::FindBinary.3pm
/usr/local/share/man/man3/Selenium::PhantomJS.3pm
/usr/local/share/man/man3/Selenium::Firefox::Binary.3pm
/usr/local/share/man/man3/Selenium::Remote::WDKeys.3pm
/usr/local/share/man/man3/Selenium::Remote::Driver::Firefox::Profile.3pm
/usr/local/share/man/man3/Selenium::Chrome.3pm
/usr/local/share/man/man3/Selenium::Remote::WebElement.3pm
/usr/local/share/man/man3/Selenium::Remote::Driver.3pm
/usr/local/share/man/man3/Selenium::Edge.3pm
/usr/local/share/man/man3/Selenium::Remote::Spec.3pm
/usr/local/share/man/man3/Selenium::Firefox.3pm
/usr/local/share/man/man3/Selenium::Remote::RemoteConnection.3pm
/usr/local/share/man/man3/Selenium::Remote::Mock::RemoteConnection.3pm
/usr/local/share/man/man3/Selenium::InternetExplorer.3pm


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




Re: controlling Firefox using Perl

2021-03-12 Thread Gary Stainburn

On 12/03/2021 15:52, Dermot wrote:
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

I've just had a go at installing WebDriver::Tiny but it appears to need 
Perl >= 5.20. An fully up to date Centos 7 only has 5.16.3. I've no idea 
how to upgrade to 5.20 safely without breaking what is already installed.


I do find it frustrating that I have a working Selenium::Firefox setup, 
but can't find usable documentation.


controlling Firefox using Perl

2021-03-12 Thread Gary Stainburn
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'

Driver info: driver.version: unknown
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at 
org.openqa.selenium.remote.server.DefaultSession.execute(DefaultSession.java:183)
    at 
org.openqa.selenium.remote.server.DefaultSession.(DefaultSession.java:119)
    at 
org.openqa.selenium.remote.server.DefaultSession.createSession(DefaultSession.java:95)
    at 
org.openqa.selenium.remote.server.DefaultDriverSessions.newSession(DefaultDriverSessions.java:124)
    at 
org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:59)
    at 
org.openqa.selenium.remote.server.handler.NewSession.handle(NewSession.java:1)
    at 
org.openqa.selenium.remote.server.rest.ResultConfig.handle(ResultConfig.java:111)
    at 
org.openqa.selenium.remote.server.JsonHttpCommandHandler.handleRequest(JsonHttpCommandHandler.java:79)
    at 
org.openqa.selenium.remote.server.DriverServlet.handleRequest(DriverServlet.java:2

use string in "use"

2020-12-14 Thread Gary Stainburn
I've written my first re-usable modules in Perl, and all goes well. 
However, I want to know if / how I can use a string variable in the 
'use' clause.


In PHP I have a simple system of turning on/off debugging and version 
control.  Any file *1.html is development version.  I then have


$DEBUG=(preg_match('/1.htm/',$_SERVER['REQUEST_URI'])) ? '1' : '';
include_once("sql$DEBUG.inc");
include_once("security$DEBUG.inc");

This way I have a live and a development version of every HTML and every 
inc file, and putting any one file is simply a case of copying that file 
over.


I'm looking to replicate  this in Perl.  How can I do the following?

#!/usr/bin/perl -w

use warnings;
use strict;

my $DEBUG=($0=~/1$/) ? '1' : '';
use RW::Sql$DEBUG;
use RW::Docs$DEBUG;

I've found that you can use "require" and pass a path.  I understand 
that require is run time, while use is compile time.  Are there any 
down-sides to using require?


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




Re: regex help - only one value returned

2020-12-02 Thread Gary Stainburn

On 02/12/2020 13:56, Vlado Keselj wrote:

Well, it seems that the first one is what you want, but you just need to
use $1 and ignore $2.

You do need parentheses in '(mr|mrs|miss|dr|prof|sir)' but if you do not
want for them to be captured in $2, you can use:
'(?:mr|mrs|miss|dr|prof|sir)'.  For example:

print "match3='$1' '$2'\n" if
($T=~/^((?:mr|mrs|miss|dr|prof|sir) .{5,}?)\n/smi);

would give output:

match3='Miss Jayne Doe' ''

Perfect, thank you.

I can't ignore $2 as it's in a loop with other regex that genuinely 
returns multiple matches.  The amendment to the REGEX worked perfectly.


Gary

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




regex help - only one value returned

2020-12-02 Thread Gary Stainburn
I have an array of regex expressions that I apply to text returned from 
tesseract.


Each match that I get then gets stored for future processing. However, 
I'm struggling with one regex.


The problem is that:

1) with brackets round the titles it returns two matches.
2) without brackets, it returns nothing.

Can anyone point me at the correct syntax please.

Gary

[root@dev dev]# ./t
match1='Miss Jayne Doe' 'Miss'
[root@dev dev]# cat t
#!/usr/bin/perl

use strict;
use warnings;

my $T=

Re: CPAN not working, or is it?

2019-03-12 Thread Gary Stainburn
On Tuesday 12 March 2019 06:16:59 Magnus Woldrich wrote:
>  $ perl -E 'say for @INC'
>  $ echo $PERL5LIB
>  # echo $PERL5LIB
>
> I'd suggest to set the PERL5LIB environment variable in your shell
> config to something like ~/lib/perl5/.
>
> If you need the modules to be available globally and not only for a
> specific user, a better place would be e.g /usr/lib/perl5/*

Hi Magnus,

I had already started looking into this option.  I have done as you said:

[root@lou ~]# perl -E 'say for @INC'
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.
[root@lou ~]#echo $PERL5LIB

[root@lou ~]

I then amended my .bashrc to amend the two existing lines and added the 
PERL5LIB line:

PERL_MB_OPT="--install_base \"/usr/local/share/perl5\""; export PERL_MB_OPT;
PERL_MM_OPT="INSTALL_BASE=/usr/local/share/perl5"; export PERL_MM_OPT;
PERL5LIB="/usr/local/share/perl5"; export PERL5LIB;

I then logged out, back in, and checked everything looked good.  I then tried 
the new setup by using CPAN to 'install CPAN'. At the end I got 'OK' but when 
I tried to 'reload cpan' it still loaded 1.9800 when it should have installed 
2.6

[root@lou ~]# perl -E 'say for @INC'
/usr/local/share/perl5
/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
/usr/lib64/perl5
/usr/share/perl5
.
[root@lou ~]# echo $PERL5LIB
/usr/local/share/perl5
[root@lou ~]# cpan

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.

cpan[1]> install CPAN
Reading '/root/.cpan/Metadata'
  Database was generated on Mon, 11 Mar 2019 11:57:00 GMT
Running install for module 'CPAN'
Running make for A/AN/ANDK/CPAN-2.25.tar.gz
Checksum for /root/.cpan/sources/authors/id/A/AN/ANDK/CPAN-2.25.tar.gz ok
Scanning cache /root/.cpan/build for sizes
..--DONE
DEL(1/7): /root/.cpan/build/Module-CoreList-5.20190220-NXpphv 
DEL(2/7): /root/.cpan/build/Module-CoreList-5.20190220-NXpphv.yml 
DEL(3/7): /root/.cpan/build/Module-Load-Conditional-0.68-owZpE0.yml 
DEL(4/7): /root/.cpan/build/Module-Load-Conditional-0.68-owZpE0 
DEL(5/7): /root/.cpan/build/IPC-Cmd-1.02-1B6cBN 
DEL(6/7): /root/.cpan/build/ExtUtils-CBuilder-0.280230-w3Bagt.yml 
DEL(7/7): /root/.cpan/build/IPC-Cmd-1.02-1B6cBN.yml 

  CPAN.pm: Building A/AN/ANDK/CPAN-2.25.tar.gz

Importing PAUSE public key into your GnuPG keychain... done!
(You may wish to trust it locally with 'gpg --lsign-key 450F89EC')
Checking if your kit is complete...
Looks good
Writing Makefile for CPAN
Writing MYMETA.yml and MYMETA.json
cp lib/CPAN.pm blib/lib/CPAN.pm
cp lib/CPAN/CacheMgr.pm blib/lib/CPAN/CacheMgr.pm
cp lib/CPAN/FTP/netrc.pm blib/lib/CPAN/FTP/netrc.pm
cp lib/CPAN/LWP/UserAgent.pm blib/lib/CPAN/LWP/UserAgent.pm
cp lib/CPAN/FTP.pm blib/lib/CPAN/FTP.pm
cp lib/CPAN/Queue.pm blib/lib/CPAN/Queue.pm
cp lib/CPAN/Distroprefs.pm blib/lib/CPAN/Distroprefs.pm
cp lib/CPAN/Kwalify/distroprefs.yml blib/lib/CPAN/Kwalify/distroprefs.yml
cp lib/App/Cpan.pm blib/lib/App/Cpan.pm
cp lib/CPAN/Kwalify.pm blib/lib/CPAN/Kwalify.pm
cp lib/CPAN/Module.pm blib/lib/CPAN/Module.pm
cp lib/CPAN/Author.pm blib/lib/CPAN/Author.pm
cp lib/CPAN/Debug.pm blib/lib/CPAN/Debug.pm
cp lib/CPAN/HTTP/Credentials.pm blib/lib/CPAN/HTTP/Credentials.pm
cp lib/CPAN/API/HOWTO.pod blib/lib/CPAN/API/HOWTO.pod
cp lib/CPAN/Complete.pm blib/lib/CPAN/Complete.pm
cp lib/CPAN/HTTP/Client.pm blib/lib/CPAN/HTTP/Client.pm
cp lib/CPAN/FirstTime.pm blib/lib/CPAN/FirstTime.pm
cp lib/CPAN/Exception/blocked_urllist.pm 
blib/lib/CPAN/Exception/blocked_urllist.pm
cp lib/CPAN/Distrostatus.pm blib/lib/CPAN/Distrostatus.pm
cp lib/CPAN/Admin.pm blib/lib/CPAN/Admin.pm
cp lib/CPAN/Tarzip.pm blib/lib/CPAN/Tarzip.pm
cp lib/CPAN/Prompt.pm blib/lib/CPAN/Prompt.pm
cp lib/CPAN/URL.pm blib/lib/CPAN/URL.pm
cp lib/CPAN/Version.pm blib/lib/CPAN/Version.pm
cp lib/CPAN/DeferredCode.pm blib/lib/CPAN/DeferredCode.pm
cp lib/CPAN/Distribution.pm blib/lib/CPAN/Distribution.pm
cp lib/CPAN/Nox.pm blib/lib/CPAN/Nox.pm
cp lib/CPAN/Exception/RecursiveDependency.pm 
blib/lib/CPAN/Exception/RecursiveDependency.pm
cp lib/CPAN/Bundle.pm blib/lib/CPAN/Bundle.pm
cp lib/CPAN/Plugin/Specfile.pm blib/lib/CPAN/Plugin/Specfile.pm
cp lib/CPAN/Shell.pm blib/lib/CPAN/Shell.pm
cp lib/CPAN/InfoObj.pm blib/lib/CPAN/InfoObj.pm
cp lib/CPAN/HandleConfig.pm blib/lib/CPAN/HandleConfig.pm
cp lib/CPAN/Exception/yaml_process_error.pm 
blib/lib/CPAN/Exception/yaml_process_error.pm
cp lib/CPAN/Plugin.pm blib/lib/CPAN/Plugin.pm
cp lib/CPAN/Exception/yaml_not_installed.pm 
blib/lib/CPAN/Exception/yaml_not_installed.pm
cp lib/CPAN/Index.pm blib/lib/CPAN/Index.pm
cp lib/CPAN/Kwalify/distroprefs.dd blib/lib/CPAN/Kwalify/distroprefs.dd
cp lib/CPAN/Mirrors.pm blib/lib/CPAN/Mirrors.pm
cp scripts/cpan-mirrors blib/script/cpan-mirrors
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/cpan-mirrors
cp scripts/cpan bl

CPAN not working, or is it?

2019-03-11 Thread Gary Stainburn
I'm replacing a dead F19 box with a new C7 one and I'm trying to get my Perl 
install completed.  Ultimately, I need to get Selenium::Remote::Driver 
working, but I'm struggling before that.

I started off as always by using RPM's for everything I possibly can. I then 
started to use CPAN for everything else.  It looked like CPAN was working and 
things were installing "OK".

However,  as I went for bigger modules, anything that had dependences were 
then failing as the dependencie were installed OK but then did not appear to 
be available.

The last thing I've just tried is to update CPAN as the RPM is 1.9800 and the 
latest is 2.6.  As you can see below, the install worked, but when it 
reloaded, or when I came out and went back in, it still showed 1.9800

Anyone got any ideas what  I need to do?

cpan[2]> install CPAN
Running install for module 'CPAN'
Running make for A/AN/ANDK/CPAN-2.25.tar.gz
Fetching with LWP:
http://mirror.bytemark.co.uk/CPAN/authors/id/A/AN/ANDK/CPAN-2.25.tar.gz
Fetching with LWP:
http://mirror.bytemark.co.uk/CPAN/authors/id/A/AN/ANDK/CHECKSUMS
Checksum for /root/.cpan/sources/authors/id/A/AN/ANDK/CPAN-2.25.tar.gz ok

  CPAN.pm: Building A/AN/ANDK/CPAN-2.25.tar.gz

Importing PAUSE public key into your GnuPG keychain... done!
(You may wish to trust it locally with 'gpg --lsign-key 450F89EC')
Checking if your kit is complete...
Looks good
Writing Makefile for CPAN
Writing MYMETA.yml and MYMETA.json
cp lib/CPAN.pm blib/lib/CPAN.pm
cp lib/CPAN/CacheMgr.pm blib/lib/CPAN/CacheMgr.pm
cp lib/CPAN/FTP/netrc.pm blib/lib/CPAN/FTP/netrc.pm
cp lib/CPAN/LWP/UserAgent.pm blib/lib/CPAN/LWP/UserAgent.pm
cp lib/CPAN/FTP.pm blib/lib/CPAN/FTP.pm
cp lib/CPAN/Queue.pm blib/lib/CPAN/Queue.pm
cp lib/CPAN/Distroprefs.pm blib/lib/CPAN/Distroprefs.pm
cp lib/CPAN/Kwalify/distroprefs.yml blib/lib/CPAN/Kwalify/distroprefs.yml
cp lib/App/Cpan.pm blib/lib/App/Cpan.pm
cp lib/CPAN/Kwalify.pm blib/lib/CPAN/Kwalify.pm
cp lib/CPAN/Module.pm blib/lib/CPAN/Module.pm
cp lib/CPAN/Author.pm blib/lib/CPAN/Author.pm
cp lib/CPAN/Debug.pm blib/lib/CPAN/Debug.pm
cp lib/CPAN/HTTP/Credentials.pm blib/lib/CPAN/HTTP/Credentials.pm
cp lib/CPAN/API/HOWTO.pod blib/lib/CPAN/API/HOWTO.pod
cp lib/CPAN/Complete.pm blib/lib/CPAN/Complete.pm
cp lib/CPAN/HTTP/Client.pm blib/lib/CPAN/HTTP/Client.pm
cp lib/CPAN/FirstTime.pm blib/lib/CPAN/FirstTime.pm
cp lib/CPAN/Exception/blocked_urllist.pm 
blib/lib/CPAN/Exception/blocked_urllist.pm
cp lib/CPAN/Distrostatus.pm blib/lib/CPAN/Distrostatus.pm
cp lib/CPAN/Admin.pm blib/lib/CPAN/Admin.pm
cp lib/CPAN/Tarzip.pm blib/lib/CPAN/Tarzip.pm
cp lib/CPAN/Prompt.pm blib/lib/CPAN/Prompt.pm
cp lib/CPAN/URL.pm blib/lib/CPAN/URL.pm
cp lib/CPAN/Version.pm blib/lib/CPAN/Version.pm
cp lib/CPAN/DeferredCode.pm blib/lib/CPAN/DeferredCode.pm
cp lib/CPAN/Distribution.pm blib/lib/CPAN/Distribution.pm
cp lib/CPAN/Nox.pm blib/lib/CPAN/Nox.pm
cp lib/CPAN/Exception/RecursiveDependency.pm 
blib/lib/CPAN/Exception/RecursiveDependency.pm
cp lib/CPAN/Bundle.pm blib/lib/CPAN/Bundle.pm
cp lib/CPAN/Plugin/Specfile.pm blib/lib/CPAN/Plugin/Specfile.pm
cp lib/CPAN/Shell.pm blib/lib/CPAN/Shell.pm
cp lib/CPAN/InfoObj.pm blib/lib/CPAN/InfoObj.pm
cp lib/CPAN/HandleConfig.pm blib/lib/CPAN/HandleConfig.pm
cp lib/CPAN/Exception/yaml_process_error.pm 
blib/lib/CPAN/Exception/yaml_process_error.pm
cp lib/CPAN/Plugin.pm blib/lib/CPAN/Plugin.pm
cp lib/CPAN/Exception/yaml_not_installed.pm 
blib/lib/CPAN/Exception/yaml_not_installed.pm
cp lib/CPAN/Index.pm blib/lib/CPAN/Index.pm
cp lib/CPAN/Kwalify/distroprefs.dd blib/lib/CPAN/Kwalify/distroprefs.dd
cp lib/CPAN/Mirrors.pm blib/lib/CPAN/Mirrors.pm
cp scripts/cpan-mirrors blib/script/cpan-mirrors
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/cpan-mirrors
cp scripts/cpan blib/script/cpan
/usr/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/cpan
Manifying blib/man1/cpan-mirrors.1
Manifying blib/man1/cpan.1
Manifying blib/man3/CPAN.3pm
Manifying blib/man3/CPAN::Admin.3pm
Manifying blib/man3/CPAN::Tarzip.3pm
Manifying blib/man3/CPAN::Queue.3pm
Manifying blib/man3/CPAN::Distroprefs.3pm
Manifying blib/man3/CPAN::Version.3pm
Manifying blib/man3/App::Cpan.3pm
Manifying blib/man3/CPAN::Kwalify.3pm
Manifying blib/man3/CPAN::Nox.3pm
Manifying blib/man3/CPAN::Plugin::Specfile.3pm
Manifying blib/man3/CPAN::Debug.3pm
Manifying blib/man3/CPAN::HandleConfig.3pm
Manifying blib/man3/CPAN::Plugin.3pm
Manifying blib/man3/CPAN::API::HOWTO.3pm
Manifying blib/man3/CPAN::Mirrors.3pm
Manifying blib/man3/CPAN::FirstTime.3pm
  ANDK/CPAN-2.25.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 
'blib/lib', 'blib/arch')" 
t/*.t
t/00signature.t ... skipped: No Module::Signature found [INC 
= /root/.cpan/build/CPAN-2.25-YZAzWH/blib/lib 
/root/.cpan/build/CPAN-2.25-YZAzWH/blib/arch /usr/local/lib64/perl5 
/usr/local/share/perl5 /usr/lib64/perl5/vendor_perl 
/usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/shar

Replacing 10 year old web server

2018-06-29 Thread Gary Stainburn
I'm replacing my old F9 web server with a new C7 one.  While I've used RPM's 
for most packages there have been times when I've had to use CPAN and PEAR.

For the PEAR items I'm able to do 

pear list -a > pear_list.txt

to get a list of all modules installed that way. Is there an equivelent 
command for CPAN to tell me which modules I've installed that way?

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




Re: can not locate installe module

2018-06-04 Thread Gary Stainburn
On Monday 04 June 2018 10:39:28 Shlomi Fish wrote:
> is there anything in https://en.wikipedia.org/wiki/Environment_variable ?

I do have some interesting perl settings, although I have no idea where they 
have come from.  This is a brand new Centos 7 install, and prior to trying to 
install the three modules everything had been done by installing RPM's

This does seem to corroborate your theory below about it being local only to 
root, and wh 'perl -c' works.  However, shouldn't the perldoc also have 
worked in that instance?

[root@ollie2 ~]# set|grep -i perl
PATH=/root/perl5/bin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
PERL5LIB=/root/perl5/lib/perl5:
PERL_LOCAL_LIB_ROOT=:/root/perl5
PERL_MB_OPT='--install_base /root/perl5'
PERL_MM_OPT=INSTALL_BASE=/root/perl5
if type perl &>/dev/null; then
COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($gid) = 
(getgrent)[2]) { print $gid . "\n" }'"'"' )' -- "$cur" ));
--perl-regexp
if type perl &>/dev/null; then
COMPREPLY=($( compgen -W '$( perl -e '"'"'while (($uid) = 
(getpwent)[2]) { print $uid . "\n" }'"'"' )' -- "$cur" ));
[root@ollie2 ~]#  

> Perhaps you have https://metacpan.org/pod/local::lib enabled or similar.

I have checked and I do indeed have local::lib installed.  It got installed as 
a depencancy of perl-CPAN.rpm.  When I tried to remove it, it wouldn't 
because of the dependancy.  When I removed both that and perl-CPAN that was 
okay, although it didn't remove the Env Vars.

However, when I re-installed the perl-CPAN RPM it pulled perl-local-lib in 
again too.

Looks like I need to move over to the Centos list as this appears to be a 
Centos problem now rather than a perl one.

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




Re: can not locate installe module

2018-06-04 Thread Gary Stainburn
On Monday 04 June 2018 09:36:02 Shlomi Fish wrote:
> what does "perldoc -l MIME::Parser" say? Also see
> http://perl-begin.org/FAQs/ and http://perl-begin.org/topics/cpan/ .

I have tried this for all three modules installed through CPAN and all three 
come up with the same thing:

[root@ollie2 ~]# perldoc -l MIME::Parser
No documentation found for "MIME::Parser".
[root@ollie2 ~]# perldoc -l Net::SCP
No documentation found for "Net::SCP".
[root@ollie2 ~]# perldoc -l Net::SSH
No documentation found for "Net::SSH".
[root@ollie2 ~]# 

If I try to find the perl modules it it looks like they haven't been 
installed, but if that is the case, why does 'perl -c' come up OK?

[root@ollie2 ~]# find / -iname Parser.pm
/root/.cpan/build/MIME-tools-5.509-umkw_d/lib/MIME/Parser.pm
/root/.cpan/build/MIME-tools-5.509-umkw_d/blib/lib/MIME/Parser.pm
/root/ollie/root/.cpan/build/MIME-tools-5.427-bhvQQE/blib/lib/MIME/Parser.pm
/root/ollie/root/.cpan/build/MIME-tools-5.427-bhvQQE/lib/MIME/Parser.pm
/root/perl5/lib/perl5/MIME/Parser.pm
/usr/lib64/perl5/vendor_perl/XML/Parser.pm
/usr/lib64/perl5/vendor_perl/HTML/Parser.pm
/usr/share/perl5/vendor_perl/TAP/Parser.pm
/usr/share/perl5/vendor_perl/Mail/SpamAssassin/Conf/Parser.pm
/usr/share/perl5/vendor_perl/Convert/ASN1/parser.pm
[root@ollie2 ~]# find / -iname SCP.pm
/root/.cpan/build/Net-SCP-0.08-q8mDLD/SCP.pm
/root/.cpan/build/Net-SCP-0.08-q8mDLD/blib/lib/Net/SCP.pm
/root/perl5/lib/perl5/Net/SCP.pm
[root@ollie2 ~]# 

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




can not locate installe module

2018-06-04 Thread Gary Stainburn
I've juts built a new Centos 7 email server and all has gone well.

I have used RPM's where possible, but for some modules I have had to use CPAN.  
One such module was MIME::Parser, which installed without errors.

If I check my program it now says that it's fine.  If I try to re-install the 
module it says it's up to date.

however, when I try to run the program (as a pipe via exim) it complains that 
it cannot locate the module.

 Does anyone have any ideas?


cpan[1]> install MIME::Parser
Reading '/root/.cpan/Metadata'
  Database was generated on Sun, 03 Jun 2018 04:17:03 GMT
MIME::Parser is up to date (5.509).

cpan[2]> Lockfile removed.
[root@ollie2 ~]# perl -c /etc/exim/bin/admin_doc_gateway4
/etc/exim/bin/admin_doc_gateway4 syntax OK
[root@ollie2 ~]# 


-- pipe to |/etc/exim/bin/admin_doc_gateway4 -e >>/var/log/faxgateway 2>&1
       generated by dealpa...@ringways.co.uk --

Can't locate MIME/Parser.pm in @INC (@INC 
contains: /usr/local/lib64/perl5 /usr/local/share/perl5 
/usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 
/usr/share/perl5 .) 
at /etc/exim/bin/admin_doc_gateway4 line 9.
BEGIN failed--compilation aborted at /etc/exim/bin/admin_doc_gateway4 line 9.

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




Re: regex with HEX ascii chars

2018-04-13 Thread Gary Stainburn
On Thursday 12 April 2018 19:53:16 Shlomi Fish wrote:
> Perhaps see http://perldoc.perl.org/perlunitut.html - you may need to read
> the file as binary or iso8859-1 or whatever. Also see

Thanks for this Shlomi. I have looked into that before briefly when doing http 
gets and reading office documents, but this time I didn't think I was going 
to need this.

> https://github.com/shlomif/how-to-share-code-online and read what Andy
> noted.

I thought the problem with my concepts rather than the program itself.  The 
following code shows that I was wrong.

#!/usr/bin/perl 

use strict;
use warnings;

my $line="A û ü  û";
my @arr=($line=~/(\xc3.)/g);
my $tick="\xc3\xbc";
my $cross="\xc3\xbb";

foreach my $c (split //,$line) {
  printf "%s = %X %d\n",$c,ord($c),ord($c);
}
if ($line=~/\xc3\xbb/) { print "true\n";}
foreach my $a (@arr) {
  print "start\n";
  if ($a eq $tick)  { print "tick\n";}
  if ($a eq $cross) { print "cross\n";}
}

[root@lou inet]# ./t1
A = 41 65
  = 20 32
� = C3 195
� = BB 187
  = 20 32
� = C3 195
� = BC 188
  = 20 32
  = 20 32
� = C3 195
� = BB 187
true
start
cross
start
tick
start
cross
[root@lou inet]# 

When I went back to gvim I noticed that it started showing two column values 
as as go past these fields, which should have given me a clue.

My production code now includes the following working code:

my $tick="\xc3\xbc";
my $cross="\xc3\xbb";

my @ticks=($line=~/(\xc3.)/g);
if (scalar(@ticks) == 5) {
  if ($ticks[0] eq $tick) {$job{sj_mot}='true';}
  if ($ticks[1] eq $tick) {$wuw='true'; $job{sj_wait}=20;}
  if ($ticks[2] eq $tick) {$job{sj_c_car}='true';}
  # 3 = advisor which we don't use
  if ($ticks[4] eq $tick) {$job{sj_wait}=30;}
} else {
  debugprint(1,"incorrect tick/cross count returned");
}

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




regex with HEX ascii chars

2018-04-12 Thread Gary Stainburn
I have a text file (created by  pdftotext) that I've imported into my script.

It contains ASCII characters 251 for crosses and 252 for ticks.  If I load the 
file in gvim and do :as

it reports the characters as 

 251, Hex 00fb, Octal 373
 252, hex 00fc, Octal 374

However, when I try to seacch for it using

if ($line=~/[\xfb|\xfc]/) {

or even just 

if ($line=~/\xfb/) { 

it always fails.  What am I doing wrong?

Gary

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




Re: Getting the results of a remote script

2017-11-10 Thread Gary Stainburn
Hi Shlomi,

On Friday 10 November 2017 11:52:12 Shlomi Fish wrote:
>
> While I agree, see http://seriot.ch/parsing_json.php for a roundup of
> security problems and inconsistencies in JSON parsers.

Thanks for this, I'll give it a look when I get the chance. Thankfully, so far 
I haven't seen any problems with it's use.
>
> >It also helps when combining PERL and PHP apps
>
> "Perl" is not an acronym - see
> http://perl-begin.org/learn/Perl-perl-but-not-PERL/ and
> https://github.com/perl-doc-cats/perlfaq/blob/master/lib/perlfaq1.pod#whats
>-the-difference-between-perl-and-perl .

I've given in trying to remember which Perl is the right PERL. While the sun 
is still shining, there are better things to spend my time on :D

>
> Regards,
>
>   Shlomi

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




Re: Getting the results of a remote script

2017-11-10 Thread Gary Stainburn
On Friday 10 November 2017 00:08:09 SSC_perl wrote:
> > On Nov 9, 2017, at 2:06 PM, David Precious  wrote:
> >
> > you'll get whatever the script output to STDOUT.
>
>   Thanks a million, Dave!  STDOUT was what I was missing.  I've never used
> that before, so this was news to me.  The remote script now returns a
> string that I can manipulate and use in the local script.
>
> Thanks again,
> Frank

I would also look at using JSON for anything other than simple examples.  I 
use this technique extensively for custom peer-to-peer apps. 

I have even develope a small xinetd service to accept incoming connections.

This has then enabled me to use Net::telnet in client scripts to generate 
interactive services. JSON is a good, consistent method of transferring data.  
It also helps when combining PERL and PHP apps

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




Re: "Information station" using Perl and Raspberry Pi

2017-07-27 Thread Gary Stainburn
(resent as it never appeared)

I have seen a few projects similar to the one you've linked. This is the first 
one using a Pi Zero that I've seen but there's no reason why this wouldn't 
work. (I've never used Pi Zero's personally)

A RPi2 and 3 both have 4 USB ports, LAN, HDMI, and audio out. His point about 
a Pi2 and a smaller power supply is a good one, but then you lose WiFi.

My monitors are all VGA, so I use the following to provice VGA out and WiFi

(Sorry if advertising isn't allowed but I've tried other products with less 
reliable success)

https://thepihut.com/collections/raspberry-pi-wifi/products/usb-wifi-adapter-for-the-raspberry-pi
https://thepihut.com/collections/cables-leads/products/raspberry-pi-hdmi-to-vga-convertor

The new version of Raspbian is Pixel which includes a very good X GUI.

I've never done any GUI programming on Linux so I can't help there. My 
personal preference would be to use something like Firefox or Chrome in Kiosk 
mode. There is nothing to stop you then using Perl CGI to update the web 
page, although I would probably have a static HTML /JavaScript page with a 
Perl CGI backend providing the content.

You could of course have Apache also running on the Pi

-- 

https://fundraise.cancerresearchuk.org/page/garys-march-march

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




Re: "Information station" using Perl and Raspberry Pi

2017-07-26 Thread Gary Stainburn
I have seen a few projects similar to the one you've linked. This is the first 
one using a Pi Zero that I've seen but there's no reason why this wouldn't 
work. (I've never used Pi Zero's personally)

A RPi2 and 3 both have 4 USB ports, LAN, HDMI, and audio out. His point about 
a Pi2 and a smaller power supply is a good one, but then you lose WiFi.

My monitors are all VGA, so I use the following to provice VGA out and WiFi

(Sorry if advertising isn't allowed but I've tried other products with less 
reliable success)

https://thepihut.com/collections/raspberry-pi-wifi/products/usb-wifi-adapter-for-the-raspberry-pi
https://thepihut.com/collections/cables-leads/products/raspberry-pi-hdmi-to-vga-convertor

The new version of Raspbian is Pixel which includes a very good X GUI.

I've never done any GUI programming on Linux so I can't help there. My 
personal preference would be to use something like Firefox or Chrome in Kiosk 
mode. There is nothing to stop you then using Perl CGI to update the web 
page, although I would probably have a static HTML /JavaScript page with a 
Perl CGI backend providing the content.

You could of course have Apache also running on the Pi

-- 

https://fundraise.cancerresearchuk.org/page/garys-march-march

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




Re: Mail::Sender and Precedence: bulk [solved]

2017-04-21 Thread Gary Stainburn
Sorry to both you all. As usual, having posted asking for help I've managed to 
find the answer.  

In stripping out all the bits that I thought were not required to make this 
post I spotted the syntax error that was causing the issue.

By putting the code exactly as shown into a dummy program it worked fine. By 
fixing the syntax errors the original program now also works.

Gary

On Friday 21 April 2017 09:46:07 Gary Stainburn wrote:
> This is the constructor I (almost) always use when using Mail::Sender.
>
> my $sender=new Mail::Sender {from=>'webmas...@ringways.co.uk',
>  reply=>'webmas...@ringways.co.uk',
>  headers=>'Precedence: bulk',
>  smtp=>'mail.ringways.co.uk',
>  fake_from=>'Webmaster '};
>
> (I can't remember why I had to include the fake_from)
>
> I then send the email using something like:
>
> my $resp=$sender->MailFile({to=>$options{email},
> subject=>"Available stock Report",
> msg=>'Attached is the spreadsheet containing the available stock list',
> file=>$fname});
>
> The problem I have is that the headers line doesn't seem to be working as
> there is no Precedence line in the emails received.
>
> This is an old server which hasn't been updated in a while, so I don't
> think anything has been updated for a while, so presumably it hasn't worked
> for ages (if ever).
>
> I've Google'd this and there is nothing out there that I could find on how
> to use the headers argument properly.
>
> Can anyone suggest what I need to change to get it to work.



-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

https://fundraise.cancerresearchuk.org/page/garys-march-march

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




Mail::Sender and Precedence: bulk

2017-04-21 Thread Gary Stainburn
This is the constructor I (almost) always use when using Mail::Sender.

my $sender=new Mail::Sender {from=>'webmas...@ringways.co.uk',
 reply=>'webmas...@ringways.co.uk',
 headers=>'Precedence: bulk',
 smtp=>'mail.ringways.co.uk',
 fake_from=>'Webmaster '};

(I can't remember why I had to include the fake_from)

I then send the email using something like:

my $resp=$sender->MailFile({to=>$options{email},
subject=>"Available stock Report",
msg=>'Attached is the spreadsheet containing the available stock list',
file=>$fname});

The problem I have is that the headers line doesn't seem to be working as 
there is no Precedence line in the emails received.

This is an old server which hasn't been updated in a while, so I don't think 
anything has been updated for a while, so presumably it hasn't worked for 
ages (if ever).

I've Google'd this and there is nothing out there that I could find on how to 
use the headers argument properly.

Can anyone suggest what I need to change to get it to work.

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




Re: event driven daemon

2016-12-22 Thread Gary Stainburn
Just a quick update on my project.

I am still reading up on AnyEvent, IO::Async, POE etc., and apart from making 
my brain hurt, I've come to the conclusion that these options are far more 
complicated than I want / need.

I'm now leaning towards Chris' advice.

The solution that I'm probably going to use is to have a simple File::Tail 
reader monitor the log file from the Domoticz. This solution seems to be the 
most reliable File::Tail solution as it seems to handle log rotations etc. 
better than the rest.

I haven't managed to get a *reliable* File::Read working any other way, and as 
this is going to be a 24/7 service I need it to be reliable.

All of the actual tasks are now going to be handled by seperate perl scripts, 
which  means I can simply tidy up and utilise existing proof-of-concept 
scripts that I've already started  collecting together (e.g. LED blinker)

Just as an aside, when did this list get so quiet?  I can't believe how few 
posts there have been since my OP

On Wednesday 23 November 2016 23:55:36 Chris Fedde wrote:
> It might not be too bad an idea to just use processes rather than getting
> wrapped up in event loops and asynch IO.
> Forking is cheap and fast in linux.  In my opinion it gets overlooked for
> many cases where it is a perfectly acceptable approach.
>
> There are lots of approaches to work queues.  The main architectural
> approach is how close the coupling needs to be between the requester and
> the worker.
> One of my favorite, simple approaches is to put files into a directory.
> Each file represents a tasks and perhaps contains interesting metadata.
>
> chris
>
> On Wed, Nov 23, 2016 at 7:36 AM, Gary Stainburn <
>
> gary.stainb...@ringways.co.uk> wrote:
> > On Wednesday 23 November 2016 14:05:40 Shlomi Fish wrote:
> > > Aside from named pipes there are also unix-domain sockets and TCP
> >
> > sockets,
> >
> > > both of which are more robust.
> >
> > The closest thing I've got to IPC is writing an xinetd service, which I
> > then
> > called from perl scripts using Net::Telnet.  IPC is therefore one of the
> > things I'm going to have to learn.  The Domoticz service that I'm
> > supporting
> > is itself an event driven service which runs pretty much all of my house.
> > The key requirement of whatever method I use is that I cannot under any
> > circumstance block Domoticz.  That is one reason I'm wary of using a
> > pipe.. If my server dies, then writing to the pipe will block. The
> > benefit of a pipe
> > is that it's very simple to code in however many ways I need, Perl, LUA
> > etc.
> > (LUA is embedded in Domoticz)
> >
> > I have considered using a standard text file rather than a pipe, allowing
> > anything to append to the pipe, then my daemon reading when it's ready.
> > One
> > things I have found to help with this is:
> >
> > https://gist.github.com/sugar84/1198879
> >
> > which is an example of tail -f to a pipe.  As Domoticz already writes to
> > a log
> > file, I should be able to readm input from there too and respond to both
> > (hopefully)
> >
> > > Last time I checked, AnyEvent erred if IO-Async which is a different
> > > alternative was also used, causing some people to avoid using AnyEvent.
> > > I ended up sticking with AnyEvent for
> > > https://metacpan.org/release/App-ManiacDownloader because IO-Async's
> > > support for FTP was lacking.
> >
> > Are you saying that the problem only arrises if I use both AnyEvent and
> > IO-Async?  I haven't had a look at the latter, but I doubt (hope) that my
> > daemon won't get too complicated.
> >
> > > Also see the page I wrote here - http://perl-begin.org/uses/
> >
> > multitasking/ .
> >
> > > There's also https://metacpan.org/release/Reflex which I think is a
> > > Moose-based rethinking of POE .
> >
> > Thanks for the extra links. I'll have a good look at them all before
> > starting.
> >
> > Gary
> >
> > --
> > To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> > For additional commands, e-mail: beginners-h...@perl.org
> > http://learn.perl.org/



-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: event driven daemon

2016-11-23 Thread Gary Stainburn
On Wednesday 23 November 2016 14:05:40 Shlomi Fish wrote:
> Aside from named pipes there are also unix-domain sockets and TCP sockets,
> both of which are more robust.

The closest thing I've got to IPC is writing an xinetd service, which I then 
called from perl scripts using Net::Telnet.  IPC is therefore one of the 
things I'm going to have to learn.  The Domoticz service that I'm supporting 
is itself an event driven service which runs pretty much all of my house.  
The key requirement of whatever method I use is that I cannot under any 
circumstance block Domoticz.  That is one reason I'm wary of using a pipe.. 
If my server dies, then writing to the pipe will block. The benefit of a pipe 
is that it's very simple to code in however many ways I need, Perl, LUA  etc. 
(LUA is embedded in Domoticz)

I have considered using a standard text file rather than a pipe, allowing 
anything to append to the pipe, then my daemon reading when it's ready.  One 
things I have found to help with this is:

https://gist.github.com/sugar84/1198879

which is an example of tail -f to a pipe.  As Domoticz already writes to a log 
file, I should be able to readm input from there too and respond to both 
(hopefully)

> Last time I checked, AnyEvent erred if IO-Async which is a different
> alternative was also used, causing some people to avoid using AnyEvent. I
> ended up sticking with AnyEvent for
> https://metacpan.org/release/App-ManiacDownloader because IO-Async's
> support for FTP was lacking.

Are you saying that the problem only arrises if I use both AnyEvent and 
IO-Async?  I haven't had a look at the latter, but I doubt (hope) that my 
daemon won't get too complicated.

>
> Also see the page I wrote here - http://perl-begin.org/uses/multitasking/ .
> There's also https://metacpan.org/release/Reflex which I think is a
> Moose-based rethinking of POE .

Thanks for the extra links. I'll have a good look at them all before starting.

Gary

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




event driven daemon

2016-11-22 Thread Gary Stainburn
This is a request for opinions rather than an answer to a problem.

I'm looking to write a daemon that can sit on my Domoticz (home automation) 
server and can respond to Domoticz events and can receive commands to run 
tasks that would otherwise block the server.

These will include things like 
1) Turn a LED on or off - straight forward command
2) flashing a LED (timer event), 
3) run a wake-up sequence (slowly fade up a lamp, turn on the radio - stop if 
I click OFF) (timer event), 
4) run external commands without blocking (squeezy to control a Logitech Media 
Server)

I'm looking at using a named pipe for sending commands, and also a tail -f to 
monitor the Domoticz log file so I can respond to device state changes. 
Listening on a socket could be a nice to have too.

I've previously used File::Tail for log file monitoring and Net::Telnet for 
remote command execution, both of which look useful. 

I've had a quick look at AnyEvent as the core for my app and it looks simple 
enough for me to understand. I've also looked briefly at POE which looks more 
comprehensive, but more complex.

What do people think is my best way forward?

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




Re: virus detection - empty DOC or XLS with a macro

2015-10-20 Thread Gary Stainburn
I still haven't worked out how to check for macros yet but the text has been 
sorted


#!/usr/bin/perl

use strict;
use warnings;
use Text::Extract::Word;
use Spreadsheet::ParseExcel;
use Spreadsheet::ParseXLSX;
use File::Basename;

if (!$ARGV[0]) {
  die "Usage: $0 ";
}
if (! -r $ARGV[0]) {
  die "Cannot read file";
}
my ($base,$path,$suffix) = fileparse($ARGV[0],'.doc','.docx','.xls','.xlsx');

print "suffix='$suffix'\n";
if ($suffix eq '.doc') {
  print "Checking doc\n";
  my $file = Text::Extract::Word->new($ARGV[0]);
  if (length($file->get_text()) < 5) {
print "virus found\n";
exit 1;
  }
}
if ($suffix eq '.docx') {
  print "Checking docx\n";
  if (length(`/usr/local/bin/docx2txt.pl $ARGV[0] -`) < 5) {
print "virus found\n";
exit 1;
  }
}
if ($suffix=~/.xls/) {
  print "Checking Excel $suffix\n";

  my $parser;
  if ($suffix eq '.xls') {
$parser = Spreadsheet::ParseExcel->new();
  } else {
$parser = Spreadsheet::ParseXLSX->new();
  }
  my $workbook = $parser->parse($ARGV[0]);

  if ( !defined $workbook ) {
  die $parser->error(), ".\n";
  }

  my $cells=0;
  for my $worksheet ( $workbook->worksheets() ) {

my ( $row_min, $row_max ) = $worksheet->row_range();
my ( $col_min, $col_max ) = $worksheet->col_range();

for my $row ( $row_min .. $row_max ) {
  for my $col ( $col_min .. $col_max ) {

my $cell = $worksheet->get_cell( $row, $col );
if ($cell) {
  $cells++;
}
if ($cells > 1) {
  exit 0;
}
  }
}
  }
  print "virus found\n";
  exit 1;
} # xls

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




Re: virus detection - empty DOC or XLS with a macro

2015-10-20 Thread Gary Stainburn
I already have ClamAV, Spamassassin and exim.filters on my Centos server as 
well as SPAM+Anti-Virus on our firewall.

These are still getting through which is why I'm looking for a way to filter 
this specific problem.

I've got a work-around by using unconv and Libreoffice to convert the 
documents to text but there is a huge ovehead doing it this way.  I was 
hoping for something like Spreadsheet::ParseExcel which would be much 
quicker.

I can use that method for the XLS files, and I've just found Spreadsheet::XLSX 
for XLSX files. However, converting DOC/DOCX is proving harder.

I also haven't managed to find out how to detect macros in the original file

On Tuesday 20 October 2015 02:02:53 Wah Peng wrote:
> Hi,
>
> I think you'd better setup a antivirus/antispam gateway for the incoming
> emails.ClamAV and Spamassassin are what you may want to check.
>
> regards.
>
> On 2015/10/19 星期一 18:35, Gary Stainburn wrote:
> > Is there any way within Perl to examine DOC and XLS files to
> >
> > 1) see if the document is empty, i.e. no text and no cell contents
> > 2) has Macros embedded
> >
> > We're getting lots of virus emails claiming to be invoices, receipts,
> > etc. with documents that match the above criteria which actually contain
> > a virus.
> >
> > I'm trying to stop them.
> >
> > I know I can do the first bit for XLS files using
> > Spreadsheet::ParseExcel, and I'm looking to see how to do this for DOC
> > files.
> >
> > However, I can't find out how to do step 2. The result I need to be able
> > to run on a Centos / Exim setup.
> >
> > Gary



-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




virus detection - empty DOC or XLS with a macro

2015-10-19 Thread Gary Stainburn
Is there any way within Perl to examine DOC and XLS files to

1) see if the document is empty, i.e. no text and no cell contents
2) has Macros embedded

We're getting lots of virus emails claiming to be invoices, receipts, etc. 
with documents that match the above criteria which actually contain a virus.

I'm trying to stop them.  

I know I can do the first bit for XLS files using Spreadsheet::ParseExcel, and 
I'm looking to see how to do this for DOC files.

However, I can't find out how to do step 2. The result I need to be able to 
run on a Centos / Exim setup.

Gary

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




Re: access hash in specific sequence

2015-09-04 Thread Gary Stainburn
On Thursday 03 September 2015 21:50:54 Marius Gavrilescu wrote:
> gary.stainb...@ringways.co.uk (Gary Stainburn) writes:
> > On Thursday 03 September 2015 18:19:57 Marius Gavrilescu wrote:
> >> The above can be shortened using the Sort::Key module.
> >>
> >> use Sort::Key 'nkeysort';
> >> for my $key (nkeysort { $pagetypes{$_} } keys %pagetypes) {
> >> # do stuff with $pagetypes{key} here
> >> }
> >
> > This intrigues me as I can't see where you specify the sequence field.
> > I'll go Googling
>
> You can't see it because I forgot to specify it >_<
>
> Replace '$pagetypes{$_}' with '$pagetypes{$_}{seq}' and it *should* work.
> --
> Marius Gavrilescu

Thanks for that Marius.  I worked that out from the perldocs. However, I 
decided to go with a variant of Slomi's method.

The down side to working this way is that I have to manually maintain the SEQ 
field, and if I need to add a row in the middle, all subsequent rows need 
amending.  Also, changing back from an array of hashes to hash of hashes 
meant lots of code changes elsewhere.

Instead I've achieved what I needed with the following code:

  my %pt_index;
  for (my $i=0;$i<@page_types;$i++) {
$pt_index{$page_types[$i]{'pagetype'}}=$i;
  }

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




Re: access hash in specific sequence

2015-09-03 Thread Gary Stainburn
On Thursday 03 September 2015 18:19:57 Marius Gavrilescu wrote:
> gary.stainb...@ringways.co.uk (Gary Stainburn) writes:
> > I am aware that you cannot define a key sequence when defining a hash.
> > However, if I create a sequence field
> >
> > my %pagetypes=(
> > 'Delivery  Note'=>{'seq'=>1,weight'=>2,.
> > 'Sales Invoice'=>{'seq'=>2,'weight'=>2,.
> > 'Purchase Invoice'=>{'seq'=>3,'weight'=>2,.
> > ..
> >
> > How can I do the foreach statement to access them in the correct
> > sequence?
>
> Use sort.
>
> for my $key (sort { $pagetypes{$a}{seq} <=> $pagetypes{$b}{seq} } keys
> %pagetypes) { # do stuff with $pagetypes{key} here
> }

Hi Marius, I did think that something like this would work.  I think this is 
probably the route I'll take. I did like the hash of index numbers that 
Shlomi suggested. The down side is that it's a two stage init 
>
> The above can be shortened using the Sort::Key module.
>
> use Sort::Key 'nkeysort';
> for my $key (nkeysort { $pagetypes{$_} } keys %pagetypes) {
> # do stuff with $pagetypes{key} here
> }

This intrigues me as I can't see where you specify the sequence field. I'll go 
Googling

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




access hash in specific sequence

2015-09-03 Thread Gary Stainburn
I have a hash of hashes which I converted to an array of hashes because I 
needed to access them in a specific sequence.  It now looks like

my @pagetypes=(
{'pagetype'=>'Delivery  Note','weight'=>2,.
{'pagetype'=>'Sales Invoice','weight'=>2,.
{'pagetype'=>'Purchase Invoice','weight'=>2,.
..

I then access the array using

foreach my $pt (@pagetypes) {


However, I have now lost the ability to access each pagetype by it's name

I am aware that you cannot define a key sequence when defining a hash.  
However, if I create a sequence field

my %pagetypes=(
'Delivery  Note'=>{'seq'=>1,weight'=>2,.
'Sales Invoice'=>{'seq'=>2,'weight'=>2,.
'Purchase Invoice'=>{'seq'=>3,'weight'=>2,.
..

How can I do the foreach statement to access them in the correct sequence?

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




Best way to translate parts of strings

2015-07-24 Thread Gary Stainburn
Hi 

I'm still extracting text from OCR generated documents.  I've managed to 
extract likely fields for registration numbers, stock numbers and VINs.

Unfortunately some strings have a 'S' instead of a 5 or a 'B' instead of a 8

The fields are of the format

RegistrationXX99XXX
Stock noXX9
VIN XX9

I've been experimenting with translate to convert the letters to the correct 
digit, but can't work out an easy way to only translate the digits.  There 
may genuinely be 'B' and 'S' in the 'X' positions



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




Re: script to parse OCR output different between servers

2015-07-22 Thread Gary Stainburn
All I can say is,, I've not had a good day.  This is the correct code for 
getting the most popular value. I'd forgot to update $count with $value


foreach my $field (keys %found) { # foreach field
  my $value='';
  my $count=0;
  foreach my $key (keys %{$found{$field}}) { # foreach field -> value
# if current key's tally is > the previous, store it
if ($found{$field}{$key} > $count) {
  $count=$found{$field}{$key};
  $value=$key;
}
  }
  $values{$field}=$value;
}


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




Re: script to parse OCR output different between servers

2015-07-22 Thread Gary Stainburn
Below is my revised code based on your comments.  It is tidier but more 
importantly it works correctly.  Ironically, it didn't actually work 
correctly before on my dev machine either,– it didn't find all matches. 

It looks like using my original code it was  only using the first element in 
each array.  Using the map syntax you provided  it is now finding matches on 
the second regex for the vin field.

Thank you for your help

Gary


#!/usr/bin/perl 

# searches a series of OCR generated text files - one per page
# looks for sets of regex's for field contents and stores in arrays

use warnings;
use strict;

my %searches=('stock'=>[qr/\b([NU][LD] *\d{5})\b/],
  'regno'=>[qr/\b([A-Za-z]{2}\d{2}[A-Za-z]{3})\b/],
  'vin'=>[qr/\b(WF[0O]XX[A-Z]{6}\d{5}\b)/i,
  qr/\b([A-Z]{6}\d{5}\b)/i]);
my %found;
my %values;
foreach my $fn (glob("*.txt")) {
  print "file.$fn\n";
  my $FH;
  if (!open $FH,"<",$fn ) {
print "file open failed: $!\n";
next;
  }
  my $content = slurp($FH);
  close(FH);

  foreach my $field (keys %searches) {
if (my @matches = map { $content =~ $_ } @{$searches{$field}}) {
  foreach (@matches) {
$_=~s/ //g; # remove spaces
print "match found - '$field': '$_'\n";
  $found{$field}{$_}++;
  }
}
  }
  
} # foreach page

foreach my $field (keys %found) { # foreach field
  my $value='';
  my $count=0;
  foreach my $key (keys %{$found{$field}}) { # foreach field -> value
# if current key's tally is > the previous, store it
$value=$key if ($found{$field}{$key} > $count);
  }
  print "field='$field' value='$value'\n";
  $values{$field}=$value;
}


sub slurp {
  my ($fh)=@_;
  local $/; 
  return <$fh>;
}
  

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




Re: script to parse OCR output different between servers

2015-07-22 Thread Gary Stainburn
On Wednesday 22 July 2015 16:10:18 Shlomi Fish wrote:
> Hi Gary,
>
> some comments about your code.
>
> On Wed, 22 Jul 2015 15:32:33 +0100
>
> Gary Stainburn  wrote:
> > I've written the code below to parse a number of text page files
> > generated by Tesseract OCR software to look for a guess the most likely
> > values for VIN, Reg number and stock number for a vehicle.
> >
> > On my development site it works fine and gives the values it should.
> > However, on my live server it only returns '1' as the value.
> >
> > The only thing I can think of is that my live server is much older than
> > my development server.  My perl versions are:
> >
> > Livev5.10.0
> > Devel   v5.18.4
>
> version 5.10.0 of perl is really old and you should definitely upgrade.
> Even 5.18.4 is somewhat old and was end-of-lifed. That put aside.
>

That is the most recent version of perl installed on my Fedora boxes using yum 
update, which I try to avoid messing with.

I will at some point be building a new server, but that will be long and 
painful as the version changes for Postgresql, Perl and PHP will all be 
significant and need extensive testing with my services.

> > Am I right, and what can I do to get the code to work on my live server
> > (other than upgrage perl)
> >
> >
> > #!/usr/bin/perl -w
>
> Don't use the -w flag:
>
> http://perl-begin.org/tutorials/bad-elements/#the-dash-w-flag

I've removed that. I'm surprised by this though, as when I used to write Perl 
regularly, I'm sure that was the norm.  As you may tell, I haven't written 
perl for a while.

>
> > # searches a series of OCR generated text files - one per page
> > # looks for sets of regex's for field contents and stores in arrays
> >
> > use warnings;
> > use strict;
>
> That's good.
>
> > use Data::Dumper;
> >
> > my %searches=('stock'=>[qr/\b([NU][LD] *\d{5})\b/],
> >   'regno'=>[qr/\b([A-Za-z]{2}\d{2}[A-Za-z]{3})\b/],
> >   'vin'=>[qr/\b(WF[0O]XX[A-Z]{6}\d{5}\b)/i,qr/\b([A-Z]
> > {6}\d{5}\b)/i]);
>
> The regex here got broken into two, possibly by your mailer. I hope it's OK
> in the original code.

Yes, this was a split by the email program. The original is all on one line

>
> > my %found;
> > my %values;
> > foreach my $file (<*.txt>) {
>
> 1. Don't call variables "file":
> http://perl-begin.org/tutorials/bad-elements/#calling-variables-file

Fair enough, but that isn't the problem

>
> 2. It would be safer to do:
>
> my @fns = glob('*.txt');

I can see how this is tidier code.

>
> foreach my $filename (@fns) {
>
> >   print "file.$file\n";
> >   if (!open FH,$file ) {
> > print "file open failed: $!\n";
> > next;
> >   }
>
> 1. Maybe it's just me but I feel an indentation step of 2 spaces is too
> hard to read. I recommend increasing it.

It's just personal preference. I've found that using 2 spaces makes my code 
easier to read when you have 3 or more indents, loops, if's, etc.  Using Tab 
was a farse as the code ended up starting half way across the screen.

>
> 2. See http://perl-begin.org/tutorials/bad-elements/#open-function-style
>
> >   my $content = do { local $/;  };
> >   close(FH);
>
> You really should extract it into its own slurp function or use a slurp
> module such as https://metacpan.org/pod/File::Slurper .

I made the choice to not rely on modules to make the code portable - or so I 
thought.
>
> > # print "*$content*\n";

placing a # in column 1 to remove debug code etc. makes it easier to search in 
gvim. Again, this isn't the issue

>
> You shouldn't put the comments right at the start of the line - indent them
> with the rest of the code.
>
> >   foreach my $field (keys %searches) { # foreach field
>
> What does the comment add?
>

The improvement in variable names made the comment redundant

> > #THe following line is the one with the problem
> > if (my @matches = $content =~ @{$searches{$field}}) {
>
> What do you want to achieve when using an array at the right hand side of
> =~ ? Please use any/all/map/grep/none/notall from either perlfunc or
> https://metacpan.org/pod/List::Util /
> https://metacpan.org/pod/List::MoreUtils
>

This statement was supposed to return an array of matches found by applying 
multiple regex's to the string $content. This is where the problems appear.  
On the devel box this works, whereas on the older box it returns 

script to parse OCR output different between servers

2015-07-22 Thread Gary Stainburn
I've written the code below to parse a number of text page files generated by 
Tesseract OCR software to look for a guess the most likely values for VIN, 
Reg number and stock number for a vehicle.

On my development site it works fine and gives the values it should.
However, on my live server it only returns '1' as the value.

The only thing I can think of is that my live server is much older than my 
development server.  My perl versions are:

Livev5.10.0
Devel   v5.18.4

Am I right, and what can I do to get the code to work on my live server (other 
than upgrage perl)


#!/usr/bin/perl -w

# searches a series of OCR generated text files - one per page
# looks for sets of regex's for field contents and stores in arrays

use warnings;
use strict;
use Data::Dumper;

my %searches=('stock'=>[qr/\b([NU][LD] *\d{5})\b/],
  'regno'=>[qr/\b([A-Za-z]{2}\d{2}[A-Za-z]{3})\b/],
  'vin'=>[qr/\b(WF[0O]XX[A-Z]{6}\d{5}\b)/i,qr/\b([A-Z]
{6}\d{5}\b)/i]);
my %found;
my %values;
foreach my $file (<*.txt>) {
  print "file.$file\n";
  if (!open FH,$file ) {
print "file open failed: $!\n";
next;
  }
  my $content = do { local $/;  };
  close(FH);
# print "*$content*\n";

  foreach my $field (keys %searches) { # foreach field
#THe following line is the one with the problem
if (my @matches = $content =~ @{$searches{$field}}) {
  foreach (@matches) {
$_=~s/ //g;
print STDERR "match found - '$field': '$_'\n";
if ($found{$field}{$_}) {
  $found{$field}{$_}++;
} else {
  $found{$field}{$_}=1;
}
  }
}
  }
  
} # foreach page


foreach my $field (keys %found) { # foreach field
  my $value='';
  my $count=0;
  foreach my $key (keys %{$found{$field}}) { # foreach field -> value
$value=$key if ($found{$field}{$key} > $count);
  }
  print STDERR "field='$field' value='$value'\n";
  $values{$field}=$value;
}

print STDERR Dumper(%found);
print STDERR Dumper(%values);



Development server output

[gary@gary tmp]$ parse_deal_pack 
file.DOC160715-16072015164033.pdf-01.txt
match found - 'stock': 'NL31047'
file.DOC160715-16072015164033.pdf-02.txt
file.DOC160715-16072015164033.pdf-03.txt
match found - 'regno': 'yy15yyy'
file.DOC160715-16072015164033.pdf-04.txt
file.DOC160715-16072015164033.pdf-05.txt
file.DOC160715-16072015164033.pdf-06.txt
match found - 'stock': 'NL31047'
file.DOC160715-16072015164033.pdf-07.txt
file.DOC160715-16072015164033.pdf-08.txt
file.DOC160715-16072015164033.pdf-09.txt
file.DOC160715-16072015164033.pdf-10.txt
match found - 'stock': 'NL31047'
file.DOC160715-16072015164033.pdf-11.txt
match found - 'stock': 'NL01047'
file.DOC160715-16072015164033.pdf-12.txt
match found - 'stock': 'NL31047'
file.DOC160715-16072015164033.pdf-13.txt
match found - 'regno': 'yy15yyy'
file.DOC160715-16072015164033.pdf-14.txt
file.DOC160715-16072015164033.pdf-15.txt
match found - 'regno': 'yy15yyy'
file.DOC160715-16072015164033.pdf-16.txt
file.DOC160715-16072015164033.pdf-17.txt
file.DOC160715-16072015164033.pdf-18.txt
file.DOC160715-16072015164033.pdf-19.txt
match found - 'regno': 'yy15yyy'
field='stock' value='NL31047'
field='regno' value='yy15yyy'
$VAR1 = 'stock';
$VAR2 = {
  'NL01047' => 1,
  'NL31047' => 4
};
$VAR3 = 'regno';
$VAR4 = {
  'yy15yyy' => 4
};
$VAR1 = 'regno';
$VAR2 = 'yy15yyy';
$VAR3 = 'stock';
$VAR4 = 'NL31047';
[gary@gary tmp]$ 





Live server
[root@ollie faxgateway_10734]# parse_deal_pack
file.DOC160715-16072015164033.pdf-01.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-02.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-03.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-04.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-05.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-06.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-07.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-08.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-09.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-10.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-11.txt
match found - 'regno': '1'
match found - 'vin': '1'
match found - 'stock': '1'
file.DOC160715-16072015164033.pdf-12.tx

Re: Can u suggest me the best ide for perl

2015-03-16 Thread Gary Stainburn
On Friday 13 March 2015 17:32:50 Bob goolsby wrote:
> The best IDE that I know of is a properly customized VIM.

That's interesting. How would define customised?

I exclusively use (g)vim for editing and have a number of key bindings etc. 
that help in my style of working, but would still not consider calling it an 
IDE.

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




simple module install via CPAN not working.

2015-02-16 Thread Gary Stainburn
I'm still looking to get WWW::Mechanize::Firefox installed. It looks like I've 
got a more pressing issue. Even simple module installs aren't working 
properly. I'm working through the dependancy list and looking at Test::Tester 
and Test::NoWarnings.

Installing Test::Tester worked fine, but when I try to install Test::NoWarning 
it fails saying that Test::Tester is missing:

cpan[2]> install Test::NoWarnings
Running install for module 'Test::NoWarnings'
Running make for A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz
Checksum 
for /root/.cpan/sources/authors/id/A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz ok

  CPAN.pm: Going to build A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Test::Tester 0.107 not found.
Writing Makefile for Test::NoWarnings
Writing MYMETA.yml and MYMETA.json
 Unsatisfied dependencies detected during 
 ADAMK/Test-NoWarnings-1.04.tar.gz
Test::Tester [build_requires]
Running make test
  Delayed until after prerequisites
Running make install
  Delayed until after prerequisites
Running install for module 'Test::Tester'
Running make for E/EX/EXODIST/Test-Simple-1.001014.tar.gz
  Has already been unwrapped into 
directory /root/.cpan/build/Test-Simple-1.001014-QLKQ6h
  Has already been made
Running make test
  Has already been tested successfully
Running make install
  Already done
Running make for A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz
  Has already been unwrapped into 
directory /root/.cpan/build/Test-NoWarnings-1.04-ug0wFz

  CPAN.pm: Going to build A/AD/ADAMK/Test-NoWarnings-1.04.tar.gz

Warning: Prerequisite 'Test::Tester => 0.107' 
for 'ADAMK/Test-NoWarnings-1.04.tar.gz' already built but the result looks 
suspicious. Skipping another build attempt, to prevent looping endlessly.
cp lib/Test/NoWarnings.pm blib/lib/Test/NoWarnings.pm
cp lib/Test/NoWarnings/Warning.pm blib/lib/Test/NoWarnings/Warning.pm
Manifying blib/man3/Test::NoWarnings.3pm
  ADAMK/Test-NoWarnings-1.04.tar.gz
  /usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 
'blib/lib', 'blib/arch')" 
t/*.t
t/01_compile.t ... ok   
t/02_none.t .. Can't locate Test/Tester.pm in @INC (@INC 
contains: /root/.cpan/build/Test-NoWarnings-1.04-ug0wFz/blib/lib 
/root/.cpan/build/Test-NoWarnings-1.04-ug0wFz/blib/arch /usr/local/lib/perl5 
/usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl 
/usr/lib/perl5 /usr/share/perl5 .) 
at t/02_none.t line 4.
BEGIN failed--compilation aborted at t/02_none.t line 4.
t/02_none.t .. Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/03_end.t ... Can't locate Test/Tester.pm in @INC (@INC 
contains: /root/.cpan/build/Test-NoWarnings-1.04-ug0wFz/blib/lib 
/root/.cpan/build/Test-NoWarnings-1.04-ug0wFz/blib/arch /usr/local/lib/perl5 
/usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl 
/usr/lib/perl5 /usr/share/perl5 .) 
at t/03_end.t line 4.
BEGIN failed--compilation aborted at t/03_end.t line 4.
t/03_end.t ... Dubious, test returned 2 (wstat 512, 0x200)
No subtests run 
t/04_no_tests.t .. ok   
t/05_no_end.t  ok   
t/06_fork.t .. ok   

Test Summary Report
---
t/02_none.t(Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
t/03_end.t (Wstat: 512 Tests: 0 Failed: 0)
  Non-zero exit status: 2
  Parse errors: No plan found in TAP output
Files=6, Tests=9,  1 wallclock secs ( 0.18 usr  0.03 sys +  0.48 cusr  0.08 
csys =  0.77 CPU)
Result: FAIL
Failed 2/6 test programs. 0/9 subtests failed.
make: *** [test_dynamic] Error 255
  ADAMK/Test-NoWarnings-1.04.tar.gz
one dependency not OK (Test::Tester); additionally test harness failed
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports ADAMK/Test-NoWarnings-1.04.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 ADAMK/Test-NoWarnings-1.04.tar.gz: make_test NO one dependency 
not OK (Test::Tester); additionally test harness failed

cpan[3]> install Test::Tester
Running install for module 'Test::Tester'
Running make for E/EX/EXODIST/Test-Simple-1.001014.tar.gz
  Has already been unwrapped into 
directory /root/.cpan/build/Test-Simple-1.001014-QLKQ6h
  Has already been made
Running make test
  Has already been tested successfully
Running make install
  Already done

cpan[4]> 

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




Yum / CPAN install problems - WWW::Mechanize::Firefox

2015-02-16 Thread Gary Stainburn
I've got a Fedora 21 laptop that I'm using to develop a 
WWW::Mechanize::Firefox based app which is going well.

I've tried now to replicate this on two servers ready to put it live but I'm 
having the same install problems. One is F19, and one is F20.  On both 
machines I've done 

 yum install perl-Template-Toolkit perl-JSON.noarch perl-Data-JavaScript \ 
perl-Text-Unidecode.noarch perl-HTML-Selector-XPath.noarch perl-WWW-Mechanize

successfully. Then tried in CPAN

install WWW::Mechanize::Firefox

Below is the end of the output from this, showing the modules that failed. I 
have tried working through some of these but it doesn't seem to improve the 
situation.  As you can see it complains about MRO::Compat being missing, but 
then confirms that it's there.

Any ideas what I need to do to move forward?

The full output is at:

https://www.dropbox.com/s/c8ddvu3tg4ccrdi/perl-CPAN-install.log?dl=0

Gary

Result: FAIL
Failed 82/88 test programs. 14/84 subtests failed.
make: *** [test_dynamic] Error 2
  CORION/WWW-Mechanize-Firefox-0.78.tar.gz
4 dependencies missing 
(Object::Import,Shell::Command,Task::Weaken,MozRepl::RemoteObject); 
additionally test harness failed
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports CORION/WWW-Mechanize-Firefox-0.78.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 AMBRUS/Object-Import-1.004.tar.gz: make_test NO one dependency 
not OK (MRO::Compat)
 BRICAS/Template-Provider-FromDATA-0.13.tar.gz: make_test NO one dependency 
not OK (Class::Accessor); additionally test harness failed
 MRAMBERG/Module-Pluggable-Fast-0.19.tar.gz   : make_test NO one dependency 
not OK (UNIVERSAL::require); additionally test harness failed
 DAGOLDEN/CPAN-Meta-YAML-0.012.tar.gz : make_test NO
 DAGOLDEN/Parse-CPAN-Meta-1.4414.tar.gz   : make_test NO
 DAGOLDEN/CPAN-Meta-2.143240.tar.gz   : make_test NO
 LEONT/Module-Build-0.4211.tar.gz : make_test NO
 EXODIST/Test-Exception-0.36.tar.gz   : make NO
 STBEY/Carp-Clan-6.04.tar.gz  : make_test NO one dependency 
not OK (Test::Exception)
 ADAMK/Data-JavaScript-Anon-1.03.tar.gz   : make_test NO 2 dependencies 
missing (Params::Util,Class::Default); additionally test harness failed
 ZIGOROU/MozRepl-0.06.tar.gz  : make_test NO 9 dependencies 
missing 
(Text::SimpleTable,Module::Pluggable::Fast,Template::Provider::FromDATA,Class::Accessor::Fast,Data::Dump,Carp::Clan,Class::Data::Inheritable,Data::JavaScript::Anon,UNIVERSAL::require);
 
additionally test harness failed
 CORION/MozRepl-RemoteObject-0.39.tar.gz  : make_test NO 3 dependencies 
missing (MozRepl,IPC::Run,Task::Weaken)
 CORION/WWW-Mechanize-Firefox-0.78.tar.gz : make_test NO 4 dependencies 
missing (Object::Import,Shell::Command,Task::Weaken,MozRepl::RemoteObject); 
additionally test harness failed

cpan[3]> install MRO::Compat
Running install for module 'MRO::Compat'
Running make for B/BO/BOBTFISH/MRO-Compat-0.12.tar.gz
  Has already been unwrapped into 
directory /root/.cpan/build/MRO-Compat-0.12-EzGi3j
  Has already been made
Running make test
  Has already been tested successfully
Running make install
  Already done

cpan[4]> 

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




WWW::Mechanize::Firefox not waiting for page loaded

2015-02-10 Thread Gary Stainburn
Hi folks,

I'm porting a WWW::Mechanize based program to WWW::Mechanize::Firefox because 
the web site I access is now much more Javascript based and maintenance is 
getting to be a nightmare.

However, I'm struggling on the basics.  Yesterday I started off with a very 
basic program. I wrote this last night and it worked fine, logging into the 
web site.

This morning it no longer works, returning from the get() before the page is 
complete, which then means that the form fields don't exist.  I didn't change 
the script, just shut my laptop down overnight.

Anyone got any ideas?

I've tried setting syncronize => 1 in the new() but as expected that made no 
difference.

If I add a sleep() it works fine.

Also, if I change the get() line to

$mech->get('https://www.x.com/', 
':content_file'=>'/home/gary/10.login.html');

I don't even get the first page appear in the tab.

I'm running Fedora 20 with everything installed via RPM except 
WWW::Mechanize::Firefox which had to be installed via CPAN. It did include a 
number of other perl modules as part of the install but I didn't see any 
problems during the install.

#!/usr/bin/perl -w
use strict;
use WWW::Mechanize::Firefox;

my $mech = WWW::Mechanize::Firefox->new(
activate => 1 # bring the tab to the foreground
);
$mech->autoclose_tab( 0 );
print "getting login page\n";
$mech->get('https://www..com/');
print "get complete, got status :",$mech->status(),"\n";
#sleep(5);
$mech->form_name('logonForm');
print "form name=",$mech->current_form->{name},"\n";
$mech->field(userid=>'xxx');
$mech->field(Pwd=>'xx');
$mech->submit;


sleep(999);

[gary@gary vista]$ ~/t.pm 
getting login page
get complete, got status :200
No elements found for form name 'logonForm' at /home/gary/t.pm line 13.
[gary@gary vista]$ 


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




Suggestions - printing to ZEBRA credit card printer attached to Win7 PC

2014-09-16 Thread Gary Stainburn
I've got a ZEBRA ZXP Series 1 credit card printer attached to a Win7 PC.
By using Word and creating a paper size of 84mm by 54mm I can printer on a 
card successfully.

The cards we will be using are pre-printed with logo's etc. but I need to 
print a person's name and reference number across the botom of it.

The data is being generated by my LAPP based system. I'm looking at options as 
to how I can implement a system for printing the cards. As I see it, I have a 
number of options.

1) mail-merge using Word. 
Generate a CSV file via PHP for download.
Manual intervention required to download the file and run the mail-merge, but 
simple and easy to set up.

2) Have a process run on my LAPP server to create the document and print using 
a normal windows share.

3) Have a daemon running on the Win7 PC accepting instructions via the network 
and printing the cards. This then goes back to the earlier thread of which 
PERL to use.

4) Any other method you can suggest.

Obviously, options 2 and 3 are the ones I'd prefer. I've Googled "perl Windows 
print" and all I get are various postings, many of them over 10 years old on 
how to print text to PRN or a windows share.

There are posts about generating HTML/CSS and using rundll32 to print it. 
Google on "windows html css print" doesn't give much help. Does anyone know 
how I would be able to get it to print to 84CMx54CM page?

If I don't go down the HTML/CSS route, what other options are available for 
producing the document suitable for sending to the printer.

Going back 20 years to when I used to write in Borland Delphi there was a 
component for creating printer documents and adding contents. Are there 
similar PERL modules? What are people's preferences?

-- 
Gary Stainburn

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




Re: async, non blocking tcp server

2014-08-29 Thread Gary Stainburn
On Friday 29 August 2014 10:33:12 Chris Knipe wrote:
> Unfortunately not (we are talking NNTP specifically here if it isn't
> obvious yet) - and the data rates on the network in terms of the
> stream we're looking at over 1Gbps (generated with the TAKETHIS
> commands).  The other seemingly obvious problem that I am going to
> have by handing the work off to a separate process (or even thread for
> that matter) is that I need to inform the remote client on the socket
> in real time whether I want / do not want / if an error occurred to
> the article in question issued by the command from the client.
>
> It's times like this that I *really* wish I knew how to code in C - no
> offence to anyone, again.  Even in .NET doing something like this is
> almost trivial by using separate event handlers for receiving data
> from the socket - again which is why I firmly believed that something
> like this could have been done via POE (yes, this would be handled via
> threads - but it's done and managed by the .NET modules, and thus
> require -very- little code, or understanding for that matter, from the
> programmer's point of view).
>
> Oh well - it's back to the drawing board for this one then.
>
> --
>
> Regards,
> Chris Knipe

Hi Chris,

I've not read the whole thread in details but what you need seems fairly 
simple.  I think you're wrong when you said about implementing it within POE 
or any NET:: module because what you are after is definitely application 
layer and not module layer.

I think what you want has been covered by Carl. Put very abtractly you need

* one task (process, thread, whatever) to handle communications

This can either be one task per connection which would be easiest to implement 
using the traditional process of forking on each incoming socket connection 
described in the first post, or can be one process handling all concurrent 
connections, possibly using POE.

I believe that the notes your read about avoiding having one task reading a 
socket and another task writing a socket is to do with the actual TCP 
conversation, and I can see how that could cause issues.  By having one 
dispatcher per connection, you can syncronise the sending / receiving per IP 
connection.

* one task per work unit (each article). Have one process accept the job from 
the communications task, work on the article asyncronously, and return the 
status back to the communications task.

There are many different ways within unix / Perl for inter-process comms for 
this part of the job. Depending on the workload, a model similar to Apache 
httpd where there are maximum X processes running, which I believe 
periodicallty die and get replaced to prevent them going stale.


Gary

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




Re: Help with a RE

2014-01-09 Thread Gary Stainburn
On Thursday 09 January 2014 09:53:35 Gary Stainburn wrote:
> On Thursday 09 January 2014 02:01:55 timothy adigun wrote:
> > Hi,
> >
> > On Thu, Jan 9, 2014 at 11:57 AM, Peter Gordon
>
> wrote:
> > > I'm trying do write a one line RE to strip sequence numbers off
> > > filenames.
> >
> >  Something like this?
> >
> > s/^[0-9_-]+//;
>
> Shouldn't that be
>
> s/^[0-9]+[-_]//

Oops, Missed a bit, try

s/^[0-9]+[a-c]{0,1}[-_]//;


Ringways Garages
http://www.ringways.co.uk 

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




Re: Help with a RE

2014-01-09 Thread Gary Stainburn
On Thursday 09 January 2014 02:01:55 timothy adigun wrote:
> Hi,
>
> On Thu, Jan 9, 2014 at 11:57 AM, Peter Gordon 
wrote:
> > I'm trying do write a one line RE to strip sequence numbers off
> > filenames.
>
>  Something like this?
>
> s/^[0-9_-]+//;

Shouldn't that be

s/^[0-9]+[-_]//

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: Tips or Tricks to print out tab-separated data?

2013-06-21 Thread Gary Stainburn
On Friday 21 June 2013 14:04:33 John W. Krahn wrote:

> print join( "\t", @array ), "\n";

Marc

The reason that John's code works and yours doesn't is that with John's code 
the join function only includes the @array which is what I'm guessing you 
meant.

What your code did was to tag the "\n" onto the end of the array then pass the 
whole thing to join.

Gary

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




Spreadsheet::WriteExcel - multi-coloured text in cells

2013-05-15 Thread Gary Stainburn
Hi folks

Is it possible to write text cells where part of the string is highlighted in 
red? If so, how can I do it?

Gary

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




Re: ISO decoding

2012-11-06 Thread Gary Stainburn
On Tuesday 06 November 2012 12:25:27 Shlomi Fish wrote:
>
> Please see:
>
> https://metacpan.org/module/MIME::Words
>
> Regards,
>
>   Shlomi Fish
>

Worked a treat. Thanks

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




ISO decoding

2012-11-06 Thread Gary Stainburn
Hi folks. 

I'm writing a mail filter which accepts emails from our 'fax-to-email' gateway 
and I'm struggling to handle the input. I'm getting the following:


Subject
=?ISO-8859-1?B?UmVjZWl2ZWQgRnJvbSAwMTEzMzk5NzM3MiAgMDYvMTEvMjAx?=
 =?ISO-8859-1?B?MiAxMDo0OA==?=

From
"=?ISO-8859-1?B?UmluZ3dheXMgRG9uY2FzdGVy?=
 =?ISO-8859-1?B?IEtpYSBTaG93cm9vbQ==?="
  

(rmg-copier and faxlist are internal routing emails)

What is the best method of decoding these strings.  Google pointed me to 
Encode.

I've tried variations of

my $from='"=?ISO-8859-1?B?UmluZ3dheXMgRG9uY2FzdGVy?=
 =?ISO-8859-1?B?IEtpYSBTaG93cm9vbQ==?="
  ';
$from=decode('iso-8859-1',$from);
print "from='$from'\n";

but the string doesn't get decoded.

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: SOLVED: inetd vs console calling a script

2012-10-12 Thread Gary Stainburn
On Thursday 11 October 2012 20:53:08 Andy Bach wrote:
> On Thu, Oct 11, 2012 at 4:36 AM, Gary Stainburn
>
>  wrote:
> >> Is there a quick and easy way to detect which method called it?
> >
> > my $xinetd=(defined $ENV{REMOTE_HOST});
>
> MIght be interesting to see what else is set in the environment,
> adding something like:
> warn("$_ -> $ENV{$_}\n") foreach keys %ENV;
>
> will dump them to STDERR (or open a log) so you could compare.

Andy, That's how I found out about REMOTE_HOST. I chose that one because it 
was usefull as I can now log where requests have come from too.

The full list was:

LANGSH_SOURCED : 1
PREVLEVEL  : N
CONSOLETYPE: vt
UPSTART_EVENT  : runlevel
LC_COLLATE : en_US
RUNLEVEL   : 3
LC_ALL : en_US
previous   : N
LC_NUMERIC : en_US
PWD: /
LC_TIME: en_US
LANG   : en_US
LC_MESSAGES: en_US
runlevel   : 3
SHLVL  : 3
UPSTART_JOB_ID : 6
LC_MONETARY: en_US
_  : /usr/sbin/xinetd
PATH   : /sbin:/usr/sbin:/bin:/usr/bin
REMOTE_HOST: ::ffff:10.5.1.2
TERM   : linux
UPSTART_JOB: rc3

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




SOLVED: inetd vs console calling a script

2012-10-11 Thread Gary Stainburn
On Thursday 11 October 2012 10:22:04 Gary Stainburn wrote:
> Hi folks.
>
> I've got a server script that I call via xinetd. I occasionally call it
> from the command line too, but now want it to handle the interactions
> differently depending on how it's called.
>
> Is there a quick and easy way to detect which method called it?

my $xinetd=(defined $ENV{REMOTE_HOST});
print STDERR "called remotely from $ENV{REMOTE_HOST}\n" if $xinetd;

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




inetd vs console calling a script

2012-10-11 Thread Gary Stainburn
Hi folks.

I've got a server script that I call via xinetd. I occasionally call it from 
the command line too, but now want it to handle the interactions differently 
depending on how it's called.

Is there a quick and easy way to detect which method called it?

Gary
-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: Win32::Watir on strawberry Perl

2012-09-04 Thread Gary Stainburn
On Tuesday 04 September 2012 17:45:09 Ron Bergin wrote:
> There is a typo in that line of the module.
>
> my $_ret = Win32::MSgBox($message,$mode,$title)
>
> That line (1370) should be:
> my $_ret = Win32::MsgBox($message,$mode,$title)

Thanks Ron.  That's sorted it, the example now works great.

Does anyone know of more useful examples of using Watir?

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: Win32::Watir on strawberry Perl

2012-09-04 Thread Gary Stainburn
On Tuesday 04 September 2012 13:40:33 Shlomi Fish wrote:
> You're missing strict and warnings:

I copied this straight from the demo page and didn't embelish on it. I would 
normally include these.
>
> This is wrong (even though it is taken from
> https://metacpan.org/module/Win32::Watir 's synopsis. It should be:
>
> my $ie = Win32::Watir->new(
>   visible => 1,
>   maximize =>1
> );
>

Thanks for this. I even thought that it had to have something to do with this 
as the first line of the method is a shift, but I still didn't see it.

> Regards,
>
>   Shlomi Fish
>

I still have a problem, and it seems to be the install of Watir that didn't 
work. Below is the session. Does anyone know what I need to do to get this 
sorted?

C:\Documents and Settings\user1\My Documents>perl watir_test.pl
[3408]: DEBUG: _find_autoitx_dll: 
C:/strawberry/perl/site/lib/Win32/Watir/AutoIt
X3.dll
Undefined subroutine &Win32::MSgBox called at 
C:/strawberry/perl/site/lib/Win32/
Watir.pm line 1370.

C:\Documents and Settings\user1\My Documents>perl -MCPAN -e shell

cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.


cpan> install Win32::Watir
Fetching with LWP:
http://cpan.strawberryperl.com/authors/01mailrc.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/02packages.details.txt.gz
Fetching with LWP:
http://cpan.strawberryperl.com/modules/03modlist.data.gz
Database was generated on Mon, 03 Sep 2012 16:03:10 GMT
Updating database file ...
Done!Win32::Watir is up to date (0.06).


cpan> force install Win32::Watir
Running install for module 'Win32::Watir'
Running make for S/SH/SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
Checksum for C:
\strawberry\cpan\sources\authors\id\S\SH\SHIMI\Win32-Watir-0.06-w
ithoutworldwriteables.tar.gz ok
Scanning cache C:\strawberry\cpan\build for sizes
..--DONE

DEL(1/2): C:\strawberry\cpan\build\Win32-Watir-0.06-GsiIVi
DEL(2/2): C:\strawberry\cpan\build\Win32-Watir-0.06-GsiIVi.yml

  CPAN.pm: Building S/SH/SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Win32::Watir
Writing MYMETA.yml and MYMETA.json
cp lib/Win32/Watir/AutoItX3_x64.dll blib\lib\Win32\Watir\AutoItX3_x64.dll
cp lib/Win32/Watir/Element.pm blib\lib\Win32\Watir\Element.pm
cp lib/Win32/Watir/AutoItX3.dll blib\lib\Win32\Watir\AutoItX3.dll
cp lib/Win32/Watir.pm blib\lib\Win32\Watir.pm
cp lib/Win32/Watir/AutoItX.chm blib\lib\Win32\Watir\AutoItX.chm
cp lib/Win32/Watir/Table.pm blib\lib\Win32\Watir\Table.pm
  SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
  C:\strawberry\c\bin\dmake.EXE -- OK
Running make test
C:
\strawberry\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_harness(0,
'blib\lib', 'blib\arch')" t/*.t
t/01.IE_default.t .. 1/? DEBUG: _check_os_name(): WinXP/.Net
Undefined subroutine &Win32::MSgBox called at C:
\strawberry\cpan\build\Win32-Wat
ir-0.06-hgbf6F\blib\lib/Win32/Watir.pm line 1370.
# Looks like your test exited with 255 just after 1.
t/01.IE_default.t .. Dubious, test returned 255 (wstat 65280, 0xff00)
All 1 subtests passed

Test Summary Report
---
t/01.IE_default.t (Wstat: 65280 Tests: 1 Failed: 0)
  Non-zero exit status: 255
Files=1, Tests=1,  3 wallclock secs ( 0.16 usr +  0.06 sys =  0.22 CPU)
Result: FAIL
Failed 1/1 test programs. 0/1 subtests failed.
dmake.EXE:  Error code 255, while making 'test_dynamic'
  SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
  C:\strawberry\c\bin\dmake.EXE test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
Running make install
Appending installation info to C:\strawberry\perl\lib/perllocal.pod
  SHIMI/Win32-Watir-0.06-withoutworldwriteables.tar.gz
  C:\strawberry\c\bin\dmake.EXE install UNINST=1 -- OK


cpan>


-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Win32::Watir on strawberry Perl

2012-09-04 Thread Gary Stainburn
Hi folks

After a number of weeks I'm returning to my poject to automate some file 
downloads.  I've installed Win32::Watir and typed in the example program.

However, it doesn't run. I've had a look at the code and I can't see why it is 
complaining. Can anyone help

Gary

C:\Documents and Settings\user1\My Documents>type watir_test.pl
use Win32::Watir;

my $ie = Win32::Watir::new(
 visible => 1,
 maximize =>1
);
$ie->goto("http://www.google.co.uk";);
$ie->text_field('name:',"q")->setvalue("Perl Win3::Watir");


C:\Documents and Settings\user1\My Documents>perl watir_test.pl
Odd number of elements in hash assignment at 
C:/strawberry/perl/site/lib/Win32/W
atir.pm line 102.
Can't locate object method "_check_os_name" via package "visible" at 
C:/strawber
ry/perl/site/lib/Win32/Watir.pm line 106.



The new() method looks like:
sub new {
my $class = shift;
my %opts = @_;# Line 102
$opts{visible} = 1  unless (exists $opts{visible});
$warn = $opts{warnings} if (exists $opts{warnings});
my $self = bless (\%opts, $class);
$self->_check_os_name();# line 106
if ( $opts{'ie'} or $opts{'find'} ){
return $self->_startCustomIE();
} else {
return $self->_startIE();
}
}

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 


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




SOLVED Re: Regex sending me mad

2012-07-27 Thread Gary Stainburn
On Friday 27 July 2012 15:58:07 Andy Bach wrote:

> Your RE is a bit odd - all that 'non-greedy *' -ness implies troubles.
>  The first "space star ?" can be greedy, right? You want all the
> spaces/white space in a row, or rather don't want - as you're anchored
> on the end, this doesn't do anything for the actual RE work. The next
> "word char *" means zero or more - you want at least one, right? Word
> char or non-white space?  The only requirement your RE looks for is
> the single blank between capture 1 and 2 - so
> Kia\tVenga
>
> won't work.  Actually anything w/o a blank will fail ... don't really
> know enough about your data but try maybe:
>  if ($model=~/(\S+)\s+(.*)\s*$/) {

Thanks Andy, Shawn and Jim.

The regex I'd supplied was built up over many attempts to get it working, 
hence the over the top spec.

The problem eventually turned out to be that the "space" between the make and 
model wasn't actually a space, i.e. wasn't ASCII 32. I have now got the 
people generating the data to generate it correctly and all is now fine, with 
a much simpler regex.

Gary


-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Regex sending me mad

2012-07-27 Thread Gary Stainburn
Hi folks.

I'm struggling to see what I'm doing wrong.  I have the following code in one 
of my programs but it isn't working as it should.


print STDERR "enqmake='$enqmake' model='$model'\n";
if (!$enqmake && $model) { # extract make
  print STDERR "About to split '$model'\n";
  if ($model=~/ *?(\w*) (.*?) *$/) {
$enqmake=lc($1);
$model=$2;
print STDERR "model split into '$enqmake' '$model'\n";
  }
} # extract make

This generates:

enqmake='' model='Kia Venga'
About to split 'Kia Venga'

I have a test script which works fine. Can anyone see what I'm doing wrong?

#!/usr/bin/perl -w

use warnings;
use strict;

my $t='Kia Venga';

if ($t=~/ *?(\w*) (.*?) *$/) {
  print "1='$1' 2='$2'\n";
}

[root@ollie exim]# ~/t
1='Kia' 2='Venga'
[root@ollie exim]# 



-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: & and subroutine

2012-04-17 Thread Gary Stainburn
On Tuesday 17 April 2012 15:13:40 Manfred Lotz wrote:
> You have
> sub mysub() {
>
> instead of
>
> sub mysub {
>
> which is the correct way.

Thank you. I can't believe how many years I've been getting that one wrong.

Gary

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




Re: & and subroutine

2012-04-17 Thread Gary Stainburn
On Tuesday 17 April 2012 13:30:59 Manfred Lotz wrote:
>
> One example is this:
>
> #! /usr/bin/perl
>
> use strict;
> use warnings;
>
> mysub;
>
> sub mysub {
>   print "Hi there\n";
> }
>
> If you run this you get an error:
> Bareword "mysub" not allowed while "strict subs" in use at ./testsub.pl
> line 6. Execution of ./testsub.pl aborted due to compilation errors.
>
>
> Perl tells you that it has no idea what you mean when you use the
> bareword mysub.
>
>
> Now you have two options to solve it.
>
> 1. &mysub;
>
> Using the sigil & you tell Perl that mysub is a subroutine.
>
> 2. mysub();
>
> Usind () after mysub you also tell Perl that mysub is a subroutine.
>
>
> 3. &mysub();
>
> Combining 1. and 2. works also but is not recommended. Hmm, at least I
> do no recommend it.
>
>
> Use 2. and you'll be happy.
>
>
> There are surely some other situations where using & might be
> appropriate. But this one came into my mind immediately.
>Hi Manfred,

Thank you for this, but below is what I am meaning.

Gary

[root@stan ~]# cat t.pl 
#!/usr/bin/perl -w

use strict;
use warnings;


mysub();


sub mysub() {
  print "hello world\n";
}
[root@stan ~]# ./t.pl 
main::mysub() called too early to check prototype at ./t.pl line 7.
hello world

}

>
> --
> Manfred



-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: & and subroutine

2012-04-17 Thread Gary Stainburn
On Monday 16 April 2012 15:20:35 Paul Johnson wrote:
> On Mon, Apr 16, 2012 at 06:53:53AM -0700, Paul.G wrote:
> > Hi All
> >
> > Have a question, is it good coding practice to use a & when calling a
> > subroutine, or it is not required, or it doesn't matter?
>
> It's good practice not to use it unless you understand exactly why you
> would need to use it.

Could someone please expand on this as I seem to always have to do this. If 
I 'use strict' and 'use warnings' I get errors if I don't.

-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Re: WWW::Selenium click not working - CPAN install problem

2012-04-05 Thread Gary Stainburn
't match '(?s-xim:^\s*Devel::REPL::Plugin::Selenium ok)'
# Looks like you failed 1 test of 4.
t/00-compile.t ... Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/4 subtests 
t/01_load.t .. ok   
t/interweb.t . skipped: not running live interweb tests
t/selenium-compat.t .. ok 
t/selenium-core.t  ok 
t/selenium-dwim.t  ok 
t/selenium-rc.t .. ok 
t/test-selenium.t  ok 
t/test_default_server.t .. # Test::WWW::Selenium running open 
(file:///root/.cpan/build/Test-WWW-Selenium-1.32-UsZLtW/t/files/test_click_page1.html)
t/test_default_server.t .. 1/7 # Test::WWW::Selenium running get_text (link 
(?-xism:Click here for next page) link contains expected text)
# Test::WWW::Selenium running get_location ((?-xism:test_click_page2\.html))
# Test::WWW::Selenium running get_location ((?-xism:test_click_page1\.html))
# Test::WWW::Selenium running open 
(file:///root/.cpan/build/Test-WWW-Selenium-1.32-UsZLtW/t/files/test_click_page1.html)
t/test_default_server.t .. ok   
t/test_google.t .. ok   
t/test_i18n.t  ok 
t/timeouts.t . ok   

Test Summary Report
---
t/00-compile.t (Wstat: 256 Tests: 4 Failed: 1)
  Failed test:  1
  Non-zero exit status: 1
Files=12, Tests=351, 37 wallclock secs ( 0.24 usr  0.05 sys +  2.89 cusr  0.31 
csys =  3.49 CPU)
Result: FAIL
Failed 1/12 test programs. 1/351 subtests failed.
make: *** [test_dynamic] Error 255
  LUKEC/Test-WWW-Selenium-1.32.tar.gz
  /usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
  reports LUKEC/Test-WWW-Selenium-1.32.tar.gz
Running make install
  make test had returned bad status, won't install without force
Failed during this command:
 LUKEC/Test-WWW-Selenium-1.32.tar.gz  : make_test NO

cpan[2]> 

On Thursday 05 April 2012 12:21:44 Gary Stainburn wrote:
> Hi folks.
>
> Returning to Perl on Win32 for the first time in ages. Installed Strawberry
> Perl and WWW::Selenium.  However, when I run the example in the CPAN help
> page, it hangs because the $sel->click doesn't work.
>
> If I manually click on the button the rest of the script works fine.
>
> Anyone got any ideas why and what I need to do to fix it?
> Alternatively, does anyone have experience of installing WWW::Selenium on a
> Linux box and using it to control a Windows machine?
>
> Example Script
>
> use WWW::Selenium;
>
> my $sel = WWW::Selenium->new( host => "localhost",
>   port => ,
>   browser => "*iexplore",
>   browser_url => "http://www.google.com";,
>     );
>
> $sel->start;
> $sel->open("http://www.google.com";);
> $sel->type("q", "hello world");
> $sel->click("btnG");
> $sel->wait_for_page_to_load(5000);
> print $sel->get_title;
> $sel->stop;



-- 
Gary Stainburn
Group I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




WWW::Selenium click not working

2012-04-05 Thread Gary Stainburn
Hi folks.

Returning to Perl on Win32 for the first time in ages. Installed Strawberry 
Perl and WWW::Selenium.  However, when I run the example in the CPAN help 
page, it hangs because the $sel->click doesn't work.

If I manually click on the button the rest of the script works fine.

Anyone got any ideas why and what I need to do to fix it?
Alternatively, does anyone have experience of installing WWW::Selenium on a 
Linux box and using it to control a Windows machine?

Example Script

use WWW::Selenium;

my $sel = WWW::Selenium->new( host => "localhost",
  port => ,
  browser => "*iexplore",
  browser_url => "http://www.google.com";,
);

$sel->start;
$sel->open("http://www.google.com";);
$sel->type("q", "hello world");
$sel->click("btnG");
$sel->wait_for_page_to_load(5000);
print $sel->get_title;
$sel->stop;

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




Re: SOLVED - Re: perl and pipes - reading from syslog-ng

2010-12-15 Thread Gary Stainburn
HI Shlomi,

On Wednesday 15 December 2010 11:57:25 Shlomi Fish wrote:
[snip]
> >
> > while  () {
> >   my $line=$_;
>
> Why are you doing this instead of:
>
> [code]
> while (my $line = )
> {
> }
> [/code]
>

For two reason, (1) I've not written Perl in ages and forgotten much of the 
style and syntax and (2) I copied the code straight from an example on a perl 
tutorial page.

> I should also note that normall  (shortened as <>) is preferable to
> . See:
>
> http://perl-begin.org/tutorials/bad-elements/
>

I've read the page, and changed my code accordingly.

Thank you.

> Regards,
 >
>   Shlomi Fish
>
> > and now it works perfectly.



-- 
Gary Stainburn
I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




SOLVED - Re: perl and pipes - reading from syslog-ng

2010-12-15 Thread Gary Stainburn
Isn't it typical.  Been working on this since yesterday, but as soon as I post 
the question I find the answer·

I've changed

foreach my $line () {

to

while  () {
  my $line=$_;

and now it works perfectly.

On Wednesday 15 December 2010 11:19:07 Gary Stainburn wrote:
> Hi folks.
>
> I've written a small perl script that reads from STDIN, parses the data and
> inserts into a database.  It takes the output from syslog-ng and captures
> output from my firewall.
>
> I've configured syslog-ng to send output to the pipe and if I run
>
> cat /var/log/firewall/pipe
>
> I see the output as it is being generated.
>
> The program works perfectly fine if I redirect STDIN from an old log file,
> but if I run it as either
>
> firewall_monitor 
> or
>
> cat /var/log/firewall/pipe | firewall_monitor
>
> it just sits there and does nothing.  Is there anything I need to do to the
> perl script to get it to work with the pipe?
>
> Here is the main part if the script. Even with everything else stripped,
> and justb this code it doesn't display anything.
>
> !/usr/bin/perl -w
>
> use warnings;
> use strict;
> use DBI;
>
> foreach my $line () {
>   my $wline=$line;
>   print "$line\n";
> } # while STDIN
>
>
>
>
>
> --
> Gary Stainburn
> I.T. Manager
> Ringways Garages
> http://www.ringways.co.uk



-- 
Gary Stainburn
I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




perl and pipes - reading from syslog-ng

2010-12-15 Thread Gary Stainburn
Hi folks.

I've written a small perl script that reads from STDIN, parses the data and 
inserts into a database.  It takes the output from syslog-ng and captures 
output from my firewall.

I've configured syslog-ng to send output to the pipe and if I run

cat /var/log/firewall/pipe

I see the output as it is being generated.

The program works perfectly fine if I redirect STDIN from an old log file, but 
if I run it as either

firewall_monitor ) {
  my $wline=$line;
  print "$line\n";
} # while STDIN





-- 
Gary Stainburn
I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Passing a REGEX as an argument to a sub

2010-11-22 Thread Gary Stainburn
Hi folks,

I've done some googling but haven't found anything that (a) does what i want 
or (b) I understand.

I've got the following code repeated thoughout a program I'm writing. I'm 
using www::Mechanize but because of extensive javascript usage on the web 
site I'm accessing I'm having to do a lot of manual HTML parsing.

The code is:

foreach (split(/\n/,$html)) {
  if (/HREF="(.*)".*SomeDisplayText/) {
  $URL=$1;
  last;
}

Is there a way I can change this to a sub and pass the HTML string and the 
regex as arguments?

Thanks
-- 
Gary Stainburn
I.T. Manager
Ringways Garages
http://www.ringways.co.uk 

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




Solved: First LWP::UserAgent and HTML::Form app.

2010-03-30 Thread Gary Stainburn
Sod's law folks.

Posted the question then reviewed what I'd done and found the problem.  Mixing 
three examples gave me the wrong code. Lifted the line straight from the 
HTML::Form perldoc and it worked.

$req=$ua->request($form->click);

Gary

On Tuesday 30 March 2010 09:41:54 Gary Stainburn wrote:
> Hi folks,
>
> I'm trying to write my first proper app using the above modules but
> following the perldocs/cookbooks I've come to a quick dead stop.
>
> According to the perldoc $form->click should generate an object I can pass
> straight to $ua->post, but when I try that I get the following:
>
> Code snippet:
>
> my $form=shift(@forms);
> my @inputs=$form->inputs;
>
> for (my $i=0; $i<$#inputs;$i++) {
>   my $inp=$inputs[$i];
>   my $type=$inp->type;
>   my $name=$inp->name;
>   my $value=$inp->value;
>   print "type='$type' name='$name' value='$value'\n";
> }
>
> $URL=$form->action;
> $form->value('userid','gary');
> $form->value('pw','secret');
> $form->value('submit','Continue');
>
> print "action=$URL\n";
> $req=$ua->post($URL,$form->click); # this is line 82
>
> Output:
>
> type='text' name='usersid' value=''
> type='password' name='pw' value=''
> type='submit' name='submit' value='Continue'
> type='hidden' name='fromHome' value='true'
> action=http://test.ringways.co.uk/formtest.html
> Not an ARRAY reference
> at /usr/lib/perl5/vendor_perl/5.10.0/HTTP/Request/Common.pm line 82.
>
> Any ideas what I'm doing wrong?
>
>
> --
> Gary Stainburn
>
> This email does not contain private or confidential material as it
> may be snooped on by interested government parties for unknown
> and undisclosed purposes - Regulation of Investigatory Powers Act, 2000



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

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




First LWP::UserAgent and HTML::Form app.

2010-03-30 Thread Gary Stainburn
Hi folks,

I'm trying to write my first proper app using the above modules but following 
the perldocs/cookbooks I've come to a quick dead stop.

According to the perldoc $form->click should generate an object I can pass 
straight to $ua->post, but when I try that I get the following:

Code snippet:

my $form=shift(@forms);
my @inputs=$form->inputs;

for (my $i=0; $i<$#inputs;$i++) {
  my $inp=$inputs[$i];
  my $type=$inp->type;
  my $name=$inp->name;
  my $value=$inp->value;
  print "type='$type' name='$name' value='$value'\n";
}

$URL=$form->action;
$form->value('userid','gary');
$form->value('pw','secret');
$form->value('submit','Continue');

print "action=$URL\n";
$req=$ua->post($URL,$form->click); # this is line 82

Output:

type='text' name='usersid' value=''
type='password' name='pw' value=''
type='submit' name='submit' value='Continue'
type='hidden' name='fromHome' value='true'
action=http://test.ringways.co.uk/formtest.html
Not an ARRAY reference 
at /usr/lib/perl5/vendor_perl/5.10.0/HTTP/Request/Common.pm line 82.

Any ideas what I'm doing wrong?


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

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




Re: How to read email from Inbox

2008-12-23 Thread Gary Stainburn
On Tuesday 23 December 2008 10:46:46 sanket vaidya wrote:
> Hi all,
>
> How can we read mail from inbox without using mail client like outlook?
> Using perl. i.e. Is it possible to read Inbox of your gmail account using
> perl?
>
> Thanks & Regards,
>
> Sanket Vaidya
>

This is not something I've done but I know there are lots of CPAN modules for 
doing this.  Go to

http://search.cpan.org/search?query=mail+web&mode=all

and the first suggestion I got was Mail::Webmail::GMail

For traditional mail server setups try searching for POP3 or IMAP
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

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




Re: grabbing text between two tokens

2008-04-14 Thread Gary Stainburn
On Monday 14 April 2008 16:35, Sharan Basappa wrote:
> Hi,
>
> I am trying to capture the text between two tokens. These tokens
> always exist in pairs but can occur N times.
> I somehow dont get what I want.
>
> $str =~ m/tokena(.*)tokenb/ms;
> print $1;
>
Try

$str =~ m/tokena(.*?)tokenb/ms;

The ? after the * stops it being greedy - i.e. it stops at the 1st tokenb and 
not the last

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: [OT] Warnings from code when using perl-dbi

2007-08-16 Thread Gary Stainburn
Hi 

Firstly, for an excelent general perl list, try [EMAIL PROTECTED] It's not 
just for beginners.

Secondly, it looks like you're trying to access a field that isn't defined, 
possibly by running off the end of the row.

I've re-written (but not tested) the routine slightly more perlified.

See what you think.

while (my @row = $sth->fetchrow_array )
  {
  foreach my $field (shift @row) {
if (! defined ($field) || (length($field) == 0))
  {
   # don't know why you do this cos
   # you're printing nothing here
print $field;
  } else {
print "\"$field\"";
  }
if (@row) # fields left, stick in a comma
  {
  print ",";
  }
  }
  print ("\n");
  }
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RT3 re-install, DBI login problem.

2007-08-09 Thread Gary Stainburn
I've had to build a new server and install RT3 on it. I rebuilt the database 
no problem, and can access it using psql, see listing 1.

I can also access it via DBI in a small perl script, see listing 2.

If I supply incorrect passwords to either of these I get the approriate error 
message.

However, when I try to use RT3 I get an error complaining about the password. 
The RT_Config.pm extract is listing 3, and the error is listing 4.

RT3 built and installed with no errors. Anyone got any ideas?

*** Listing 1

[EMAIL PROTECTED] ~]# export PGHOST=127.0.0.1
[EMAIL PROTECTED] ~]# export PGUSER=rt_user
[EMAIL PROTECTED] ~]# export PGDATABASE=rt3
[EMAIL PROTECTED] ~]# export PGPASSWORD=
[EMAIL PROTECTED] ~]# psql
Welcome to psql 8.1.9, the PostgreSQL interactive terminal.

Type:  \copyright for distribution terms
   \h for help with SQL commands
   \? for help with psql commands
   \g or terminate with semicolon to execute query
   \q to quit

rt3=>

*** listing 2

[EMAIL PROTECTED] ~]# more t
#!/usr/bin/perl -w

use DBI;

my $dbh=DBI->connect('dbi:Pg:dbname=rt3;host=127.0.0.1',
'rt_user','');
die $DBI::errstr unless ($dbh);

$dbh->disconnect;
[EMAIL PROTECTED] ~]#  


*** listing 3

Set($DatabaseType , 'Pg');
Set($DatabaseHost   , 'localhost'); # also tried 127.0.0.1
Set($DatabaseRTHost , 'localhost');
Set($DatabasePort , '');
Set($DatabaseUser , 'rt_user');
Set($DatabasePassword , '');
Set($DatabaseName , 'rt3');

*** listing 4

[Thu Aug 09 09:10:59 2007] [error] [client 10.2.1.3] Connect Failed FATAL:  
password authentication failed for user
"rt_user"\n\n at /opt/rt3/lib/RT.pm line 205\n
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Gary Stainburn
On Wednesday 18 July 2007 17:08, Joseph L. Casale wrote:
> Is that true?
> I use while loops and they cycle through each line without me keeping
> track? jlc

Yeah, it's true. Why would you want to keep track?
(you can BTW, look at perldoc perlvar for $.)

in my code, the 1st line is written into $prev. This code will fail if there's 
only one line in the input file as the look would never be entered.

The ($this=) reads from MYFILE putting the line into $this. The whole 
expression then returns the result. If it's worked it returns true and the 
loop is executed. If it fails it returns false and the loop exits.

Loosely speaking anyway

Gary

>
> -Original Message-
[snip]
> Hi Ayesha
>
> you need to only read once per line, but remember the last one.
>
> $prev=
> while ($this=) {
>   print "$prev and $this\n";
>   $prev=$this;
> }
>

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Extreme beginner question on reading lines from a file.

2007-07-18 Thread Gary Stainburn
On Wednesday 18 July 2007 06:16, Ayesha wrote:
> Hi all
>
> I got started on Perl only today!
> I have a text file in which I need to read a line and the line after
> that. Like
>
> line1 and line2
> line2 and line3
> line3 and line4
>
> when I use  while($line1 = ){
>$line = ;
>  }
>
> I get output
> line1 and line2
> line3 and line4 ..etc. I guess everytime I read a line, it increases
> the counter and reads the next line. I tried playing with the $.
> variable, but it did not help.
>
> Any suggestions here will be very helpful
>
> thanks
> Ayesha

Hi Ayesha

you need to only read once per line, but remember the last one.

$prev=
while ($this=) {
  print "$prev and $this\n";
  $prev=$this;
}

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Dynamically loading perl code

2007-07-12 Thread Gary Stainburn
On Thursday 12 July 2007 11:05, Gregory Machin wrote:
> Hi
> I have a rusty memory of perl have the ability, where by you can load
> perl code into an variable / array then execute it on demand, anyone
> got an example of how to do this ..
>
> Many Thanks
>

Hi Gregory

Are you thinking about the eval function.

perldoc -f eval

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: TWO loops and ONE

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 15:03, Amichai Teumim wrote:
> OK. So I removed $tmp. Now my code looks like this:
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @array = (5,3,2,1,4);
> my $n = @array;
>
> for my $i (0 .. $n-1) {
>for my $j (0 .. $n-1) {
>if ($array[$j+1] < $array[$j]) {  #compare the two neighbors
>@array[$j, $j+1] = @array[$j+1, $j];
>}
>}
> }
>
> for my $elem (@array) {
>print "$elem";
> }
>
> I get the following:
>
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in string at ./obj8-2.pl line 18.
>
> I was told that it just means my logic isn't in order, but it should work
> nevertheless right? Why isn't it working?
> *
> *

Have a look at line 11 again.
Work out what values $j and $j+1 will have as you go through the two loop2.

If you get an uninitialized value error on an array it usually means you've 
shot off the end of it.
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Fwd: TWO loops and ONE if statement

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 11:55, you wrote:
> OK. So I remove temp and I get this:
>
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in numeric lt (<) at ./obj8-2.pl line 11.
> Use of uninitialized value in string at ./obj8-2.pl line 19.
>
> Only thing I did is remove $temp.

Hi Amichai

The error about $tmp was a compile error. Because the program didn't compile 
it didn't run.

Now you've managed to get it to compile, perl has run your program.

These errors are run-time errors. In other words, they show errors in your 
logic rather than your syntax.

As a further clue, look at how you are indexing the array - specifically on 
line 11.  If necessary, walk through the program with pen and paper.

The mistake you've made is a common one

Gary

(BTW, please keep things on-list so others can share/help)
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Fwd: TWO loops and ONE if statement

2007-07-03 Thread Gary Stainburn
On Tuesday 03 July 2007 10:43, Amichai Teumim wrote:
> I forgot to add what I have done so far. I did:
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> my @array = (5,3,2,1,4);
> my $n = @array;
>
> for my $i (0 .. $n-1) {
>for my $j (0 .. $n-1) {
>if ($array[$j+1] < $array[$j]) {  #compare the two neighbors
>  $tmp = $array[$j];  # swap $array[j] and $array[j+1]
>@array[$j, $j+1] = @array[$j+1, $j];
>}
>}
> }
>
> for my $elem (@array) {
>print "$elem";
>
> Yet this wont work. I get:
>
> Global symbol "$tmp" requires explicit package name at ./obj8-2.pl line 12.
> Execution of ./obj8-2.pl aborted due to compilation errors.
>
>
> Any ideas?

The problem is that you're defining $tmp but not scoping it.  Then you don't 
use it, so you don't need it anyway.

(Hint, re-think about the array index ranges you're looking at)
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




SOLVED - Re: Tie::Handle::CSV

2007-06-28 Thread Gary Stainburn
Hi folks

The problem was that the files I'm reading are generated on M$ servers in DOS 
format.

This meant that at the end of the file is a line containing the DOS EOF char 
^Z.  Using grep to remove this before reading the file has fixed the problem.

The error's gone and my program continues as it should.

Thanks for your help.

Gary

On Wednesday 27 June 2007 19:49, Chas Owens wrote:
> On 6/27/07, Jay Savage <[EMAIL PROTECTED]> wrote:
> snip
>
> > Make sure that the last record in your file is correctly terminated
> > (i.e. there are no unclosed quotes), and that the last record is
> > followed immediately by the final newline, which is alos the last
> > character of the file.
>
> snip
>
> Try applying the following patch against
> $YOUR_PERL_DIR/Tie/Handle/CSV.pm.  It extends the error message on a
> bad parse to make it more readable.
>
> --- CSV.pm.bak  2007-06-27 14:39:54.0 -0400
> +++ CSV.pm  2007-06-27 14:46:10.0 -0400
> @@ -151,7 +151,7 @@
>if (defined $csv_line)
>   {
>   $opts->{'csv_parser'}->parse($csv_line)
> -|| croak $opts->{'csv_parser'}->error_input();
> +|| croak "could not parse: [" .
> $opts->{'csv_parser'}->error_input() . "]";
>   if ( $opts->{'header'} )
>  {
>  my $parsed_line = $opts->{'simple_reads'}

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Tie::Handle::CSV

2007-06-27 Thread Gary Stainburn
On Wednesday 27 June 2007 17:54, Tom Phoenix wrote:
>
> My best guess is that somewhere near end of file, Tie::Handle::CSV is
> using Carp to report an error, but it's not doing a very good job of
> telling you what the error actually is. See whether adding this to
> your program gives you the full stack backtrace:
>
> BEGIN { $Carp::Verbose = 1 }
>
> When you find the problem, I'm sure that the module's author would
> appreciate a patch that improves the error handling. Good luck with
> it!
>

Thanks Tom.

I added the line immediately after the #!/usr/bin/perl line and ran the 
script. It didn't give any output, but when I redirected the output to VIM it 
reported the error line as

^Z at ../bin/walon line 25

It looks like Tie::Handle::CSV just dies when there are no records left.

I've looked at the perldoc for the module and I can't see any reference to why 
it should do this, or how to stop it.

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Tie::Handle::CSV

2007-06-27 Thread Gary Stainburn
Hi folks.

I've got the following script which works until it reaches the end of the 
input file. It processes the last line and prints out the contents, but then 
the program terminates with the unhelpful error:

Manufacturers Ref.: L53522  Status: 5290(Work not pulled)
Comments:   ''


 at ../bin/walon4 line 25

Line 25 is the last print statement within the while loop. If I delete that 
line and re-run the script it then complains about line 24. Either way, the 
program terminates before printing 'Hello World'

Anyone got any ideas?

#!/usr/bin/perl -w

use strict;
use warnings;

use Tie::Handle::CSV;
my $csv_fh = Tie::Handle::CSV->new($ARGV[0], header => 1);

while (my $csv_line = <$csv_fh>) {
  print "Arrival Date:\t",$csv_line->{"Arrival Date"}, "\t";
  print "Chassis:\t",$csv_line->{"Chassis"}, "\t";
  print "Walon Ref.:\t",$csv_line->{"Walon Ref."}, "\t";
  print "Radio Code:\t",$csv_line->{"Radio Code"}, "\t";
  print "Key No.:\t",$csv_line->{"Key No."}, "\n";
  print "Inspection 1:\t",$csv_line->{"Inspection 1"}, "\t";
  print "Parts Ordered:\t",$csv_line->{"Parts Ordered"}, "\t";
  print "Parts Received:\t",$csv_line->{"Parts Received"}, "\n";
  print "Estimate Sent:\t",$csv_line->{"Estimate Sent"}, "\t";
  print "Authorised:\t",$csv_line->{"Authorised"}, "\t";
  print "Repaired:\t",$csv_line->{"Repaired"}, "\n";
  print "Manufacturers Ref.:\t",$csv_line->{"Manufacturers Ref."}, "\t";
  print "Status:\t",$csv_line->{"Status"}, "\t";
  print "(",$csv_line->{"."}, ")\n";
  print "Comments:\t'",$csv_line->{"Comments"}, "'\n";
  print "\n\n"; # *** this is line 25 
}

print "Hello World\n";
close $csv_fh;
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




CPAN problem - Test::WWW::Mechanize

2007-05-09 Thread Gary Stainburn
ed 2/5 tests, 60.00% okay
t/pod-coverage..skipped
all skipped: Test::Pod::Coverage 0.08 required for testing POD 
coverage
t/pod...skipped
all skipped: Test::Pod 1.00 required for testing POD
t/stuff_inputs..ok
Failed TestStat Wstat Total Fail  Failed  List of Failed
---
t/follow_link_ok.t61  16.67%  4
t/get_ok.t   112  18.18%  5 7
t/link_content.t  92  22.22%  5 9
t/link_status.t   83  37.50%  4 6 8
t/links_ok.t  84  50.00%  4-7
t/page_links_content.t92  22.22%  5 9
t/page_links_ok.t 52  40.00%  4-5
2 tests skipped.
Failed 7/17 test scripts, 58.82% okay. 16/104 subtests failed, 84.62% okay.
make: *** [test_dynamic] Error 255
  /usr/bin/make test -- NOT OK
Running make install
  make test had returned bad status, won't install without force

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

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: first Perl application

2006-09-11 Thread Gary Stainburn
On Monday 11 September 2006 15:34, Peter Grey wrote:
> I will receive an XML file onto a server I am setting up. I need to
> examine the file and detect text in a payload section. Based on what
> I find I examine a lookup table and send a SMS message  via a GSM
> modem attached to the server via a USB port. Any clues where I can
> find Perl script to help?
>
> Thanks
>
>
> Peter

Hi Peter

No real answers for you but a couple of questions.

1) how much perl do you want to learn and how dirty do you want to get your 
hands?
2) how complicated is the XML file you will be receiving.

If the answer's are not very dirty, and very complicated, look at 
http://search.cpan.org/search?query=xml&mode=all
There are plenty of XML modules, many of which have examples and 
documentation.

If the answer's very dirty, and not very complicated, have a go at reading the 
file directly, and parsing the contents.

I've got a basic script that I use to read .xml files written by MS Excel, as 
I find that's the easiest way to import multi-sheel Excel spreadsheets.

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: XML::Simple help request

2006-08-22 Thread Gary Stainburn
On Tuesday 22 August 2006 05:32, Owen Cook wrote:
> I am trying to get email addresses out of a Sylpheed address book. The
> output of Dumper is;
>
> $VAR1 = {
>   'attribute-list' => [
>   {}
> ],
>   'first-name' => '',
>   'uid' => '158149473',
>   'cn' => 'Julie Jumper',
>   'address-list' => [
> {
>   'address' => [
>{
>  'email' =>
> '[EMAIL PROTECTED]', 'uid' => '158149474', 'remarks' =[1]> '',
>  'alias' => ''
>}
>  ]
> }
>   ],
>   'last-name' => '',
>   'nick-name' => ''
> };
>
> I cannot get my head around extracting the 'email' it seems be be buried
> deep inside an array and a hash
>
> Here is an attempt;
>
> #!/usr/bin/perl
>
> use XML::Simple;
> use Data::Dumper;
> use strict;
>
> my $xml = new XML::Simple (KeyAttr=>[], ForceArray => 1);
>
> my $data = $xml->XMLin("ab6.xml");
>
> foreach my $d (@{$data->{person}}) {
>   print $d->{cn};#<- that works
> print "\t";
>   print $d->{"address-list"} # <-need to get down to address and email.
># most attempts failed but some gave a
># hash reference
> print "\n";
>
> }
>
> TIA for any assistance/clues
>
>
> --
> Owen

print "cn='".$VAR1->{'cn'}."'\n";
print "email='".$VAR1->{'address-list'}[0]->{'address'}[0]->{'email'}."'\n";

Work your way down the list counting curly and square brackets.

$VAR1-> pointer to whole hash
{'address-list'}hash element
[0]->   because address-list is an array => [
{'address'} hash element of array's first entry
[0]->   because address is an array
{'email'}   hash element in 'address's 1st entry
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




solved - Re: POD rendering - was Re: POD: force line break?

2006-08-08 Thread Gary Stainburn
On Tuesday 08 August 2006 12:16, Mumia W. wrote:
> On 08/08/2006 04:19 AM, Gary Stainburn wrote:
> > [ snipped ]
> > What's the best way to force the formatting similar to the original
> > layout?
>
> Did you read the perlpod document (perldoc perlpod)?

yes

> Did you read Ken Foskey's response in the thread?

yes

However, I've now re-read ken's response and got it working.  The problem was 
that I was trying combinations of both suggestions and either getting the 
output I posted before, or nothing at all.

I've now removed all the =begin/=end,  etc. from my output and simply
prefixed every line with a space.

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




POD rendering - was Re: POD: force line break?

2006-08-08 Thread Gary Stainburn
On a similar note. I have:

=head2 version history

2006-07-12  Went live with version 1.
2006-07-25  Updated now to now() in uploads update to fix problem with
  not marking as complete
2006-08-03  changed all references to now() to use $now and initialised
  at start of program. All updates now have the same timestamp
  to enable reporting.
2006-08-08  Removed 'Photos' column from import after WALON removed it from
  the spreadsheet
=cut

which renders as :

   version history

   2006-07-12  Went live with version 1.  2006-07-25  Updated now to now()
   in uploads update to fix problem with
   not marking as complete 2006-08-03  changed all references
   to now() to use $now and initialised
   at start of program. All updates now have the same times-
   tamp
   to enable reporting.  2006-08-08  Removed ’Photos’ column
   from import after WALON removed it fromthe
   spreadsheet =cut

perl v5.8.6   2006-08-08  WALON(1)

What's the best way to force the formatting similar to the original layout?
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




using MS Excel generated .xml files

2006-06-30 Thread Gary Stainburn
Hi folks

I'm just about to look into writing a perl prog to read in an excel 
spreadsheet and us that to populate a SQL database.

The idea is to save the spreadsheet as a .xml file (using Office XP), use a 
perl module to read in the file, and using the parsed data update the 
database.

Would anyone like to pass on any experiences / recommendations before I dive 
headlong in.

Ta

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

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: uninitialized value error

2006-06-21 Thread Gary Stainburn
On Wednesday 21 June 2006 16:23, Smith, Derek wrote:
> I am getting the following error yet the script is doing what I need it
> to do restart a process:
>
>
>
> Use of uninitialized value at /usr/local/admin/named_monit.pl line 71
> (#1)
>
>

What is the code at line 71?

Is it something like

$var1=$var2;

or

if ($var2 == 'fred')  {

If so, you're trying to read a value from $var2 before you've written a value 
to it, hence the warning message given. 
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: 15 Million RAW

2005-11-25 Thread Gary Stainburn
Here's my 2peneth.

Avoid regex.  While it's powerfull, it's also expensive.

Short but sweet

Gary

On Friday 25 November 2005 3:31 am, Chris Devers wrote:
> On Thu, 24 Nov 2005, Pierre Smolarek wrote:
> > Lorenzo Caggioni wrote:
> > > The program I written takes 25 sec for 10.000 line... too
> > > much
> >
> > How quickly do you need to it if 25 seconds is too long?
>
> If 10,000 lines take 25 seconds, you're doing 400 lines per second.
>
> At that rate, 15,000,000 lines will take 37,500 seconds, or 10h25m.
>
> While asking for a firmer definition for "faster" is a fair question,
> it's fair to assume that he wants to do better than 10.4 hours :-)
>
> That said, the canned answer applies here. If the problem is --
>
> 1 Read Line from an input file
> 2 Validate the raw (for example: is second char == 2?)
> 3 Split the line
> 4 Write the validated and splitted raw in an output file with a
>   different order (for example: last 2 digits I have to write as
>   first 2 digits)
>
> -- then, in order to give *any* constructive advice, we need:
>
> * to see the code in question
> * to know if the code has been benchmarked
>
> If we can't see the code, we can't possibly offer useful suggestions.
>
> If we don't have benchmark info to know what part of the code is
> taking so long, we can't even speculate as to where to start
> optimizing things.
>
> One of the suggestions in Damian Conway's _Perl Best Practices_ is a
> simple piece of advice: "Don't Optimize Code -- Benchmark It". For
> details, look over this excerpt from the book:
>
> http://www.perl.com/lpt/a/2005/07/14/bestpractices.html
>
> It's sound advice. The book's next suggestion -- which I can't seem
> to find a reference to online, so you're just going to have to find a
> copy of the book itself -- is "Don't optimize data structures --
> measure them." This is also sound advice. If you use a module like
> Devel::Size to determine how space is being allocated, you can get a
> better sense of where you might be choking on data and, in turn, have
> a sense of where you need to fix things.
>
> Once you've used such tools to map out how your program is consuming
> time and space, you can start making decisions about how to reduce
> that consumption, by speeding up critical sections, reducing memory
> use, or just throwing more RAM and CPU at the problem if you're
> starved there and software optimizations seem like they might not be
> enough. But until you've figured out where the time is being spent,
> or what system resource is being exhausted, you can't properly
> address the problem.
>
> Really, you could do a whole lot worse than by just getting a copy of
> _Perl Best Practices_ and using its advice to rewrite your program
> from scratch. Almost everyone could improve their code this way...
> :-)

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




call ext prog - best way

2005-11-24 Thread Gary Stainburn
Hi folks

I'm writing a script to be called from exim to allow multiple virus 
scanners to be used, and I'm wondering what the best way to do it is.

My script as it stands is below, and I'm using qx{}, to capture the 
output, but want to also capture the called program's exit code.

Suggestions welcome on good style and technique.

Gary

#!/bin/perl -w

# called from exim passing a directory name as argument
# calls Sophos Sweep and clamscan on the directory

die "Usage: $0 " unless $ARGV[0];

# cmd   - command to call
# viri  - result code if virus found
# regex - regex to extract virus lines
my %engines={'sweep'=>{'cmd'=>'/usr/local/bin/sweep -all -rec', 
   'viri'=>3,   
   'regex'=>'found'},   
 'clamscan'=>{'cmd'=>'/usr/bin/clamscan --quiet --stdout -r 
--no-summary -i', 
  'viri'=>1,
  'regex'=>'found'}
 };

chdir $ARGV[0] || die "$0: cannot chdir: $!\n";

foreach my $engine (%engines) {
  my @output=qx{$engine->{'cmd'} .};
 # check for result code to indicate success/failure/virus found etc
 # if virus, return lines reporting it from @output
 # use map/grep/whatever to extract lines.

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: regex search/replace syntax

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

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




regex search/replace syntax

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

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

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

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

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

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

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

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

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

which for some reason it displays twice.

Anyone got any ideas?


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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: regex search/replace syntax

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

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

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: What am I doing wrong?

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

Hi Jean

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

Gary

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



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: What am I doing wrong?

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

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: IP address and Browser version.

2004-11-20 Thread Gary Stainburn
On Friday 19 November 2004 7:18 pm, Chris Devers wrote:
> On Fri, 19 Nov 2004 [EMAIL PROTECTED] wrote:
> > I wanted to get the IP address and the OS of the system when some
> > one checks in the page...How will I get the IP address and OS of
> > the person who visits the page(with PERL CGI)
>
> As I was saying the last time you asked a version of this question --
> I think it was yesterday, or maybe the day before -- look in the %ENV
> hash. There are plenty of examples for this online if you can't
> figure out how to examine it on your own.

Bellow is a usefull CGI that I use for debugging occasionally, and 
included you will see the variables that you think may work for you, 
including remote IP, remote hostname etc.

However, they are not to be trusted a) because they can be spoofed as 
already been said. b) if there is a web cache/proxy inbetween, such as 
a transparrent proxy run by the viewer's ISP then that's what you'll 
get.

#!/usr/bin/perl
#
# CGI script to print out the relevant environment variables.
# It's just one big print statement, but note the use of the
# associative %ENV array to access the environment variables.
#

print <

 CGI Tutorial: Environment variables script





 Environment variables script




Here are the environment variables that this CGI script has been
called with.





  
Label
Value
  
EOF

while (($KEY,$VALUE) = each(%ENV)) {
  $VALUE='<empty>' if (!$VALUE);
  print "
  
$KEY
$VALUE
  
";
}
print "  ";

chomp(@SETS = qx!/bin/bash -c set!);

for(@SETS) {
  print "$_\n";
}
print "


";   # Print statement (and program) ends 
here

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Append on top

2004-11-15 Thread Gary Stainburn
On Monday 15 November 2004 1:43 pm, NYIMI Jose \(BMB\) wrote:
> > However, if you do have these restrictions it can be done using the
> > psudocode below
> >
> > calculate write_size
> > seek EOF-buffer_size
> > read buffer_size
> > seek EOF-buffer_size+write_size
> > repeat until at BOF
Don't forget

Seek BOF
write new data
>
> Why should I care with all these details when Tie::File is available
> from CPAN. And now comes as standard dist of recent Perl version ?
>
> José.
>
Hi José.

You man want to know this, because, as I said in my OP there may be 
reasons why you can't create a new file and have to do the update in 
place.  Tie::File, like the other methods creates a new file and then 
copies that over the original.

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Append on top

2004-11-15 Thread Gary Stainburn
On Monday 15 November 2004 1:25 pm, Gary Stainburn wrote:
[snip]
>
> calculate write_size
> seek EOF-buffer_size
> read buffer_size
> seek EOF-buffer_size+write_size
> repeat until at BOF
>

Oops, missed out the final lines of code, which are:

seek BOF
write new data

bit of a pointless excercise without that.

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Append on top

2004-11-15 Thread Gary Stainburn
On Friday 29 October 2004 10:35 am, Ing. Branislav Gerzo wrote:
> Rajesh Dorairajan [RD], on Thursday, October 28, 2004 at 18:11
> (-0700) thoughtfully wrote the following:
>
> RD> Does anyone know of a way to open a file in append mode and
> append on top of RD> the file?
>
> I don't think it is possible. You have to read source file, and after
> print your results to new file (open through >) and append old file
> through >>

It is possible, but very messy.  The above method is the most efficient, 
but does require free disk space equivelent to the the size of the new 
file.  Not usually a problem these days, withthe low cost of HDDs.  

However, if you do have these restrictions it can be done using the 
psudocode below

calculate write_size
seek EOF-buffer_size
read buffer_size
seek EOF-buffer_size+write_size
repeat until at BOF

Actually coding this into perl should be fairly easy, and could even be 
used to insert data mid-file if required.

However, if this is something that you're going to be doing regularly, 
I'd suggest re-evaluating the data format, such as using a database.

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



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Append on top (easy sollution)

2004-11-15 Thread Gary Stainburn
On Monday 15 November 2004 3:02 am, K-sPecial wrote:
> Rajesh Dorairajan wrote:
> > Does anyone know of a way to open a file in append mode and append
> > on top of the file?
> >
> > Thanks in Advance,
> >
> > --Rajesh
>
> I don't know why people are having a problem with this sollution,
> simply open in append mode so open doesn't clobber the file, then use
> seek() to move to the beginning of the file. Done :)
>

The problem is that if you do that, you're going to overwrite the 
existing data with every write you do. What is required when appending 
to the front (oxymoron as append means to stick on the end), is that 
the existing data is shuffled down when you write.

To clarify.

if you had 

a
b
c
d

and did as you suggested to write 'f' you would end up with

f
b
c
d

See?

> --K-sPecial
>
> [ http://xzziroz.freeshell.org
>irc://xzziroz.dtdns.net   ]

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



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Creating Microsoft Word Document with Perl

2004-11-02 Thread Gary Stainburn
On Tuesday 02 November 2004 12:28 pm, Rok Jaklic wrote:
> Hi.
>
> Is there any way to create Microsoft Word Document (.doc) with Perl;
> without installed Microsoft Word and Win32::OLE?
>
> Best regards,
>
> Rok

Hi Rok.

Not a direct answer to your question, but.

Does it need to be a .doc?

When I had to create documents I found it easier to create a .rtf file 
instead.  RTF supports most of the formatting features you're likely to 
require and and much more portable.

There are a number of modules on CPAN for creating RTF files, but I 
didn't even need those.  I simply created the blank letter in 
OpenOffice putting placeholders where I wanted to insert text and then 
simply used that as a template for my perl prog - I was using it to 
extract data from our company management system written in COBOL to 
create pre-mailmerged documents (having a mailmerge/datasource and 
using Word to do the mailmerge took too long!!!)

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: qx{} and ping problem.

2004-09-09 Thread Gary Stainburn
On Thursday 09 Sep 2004 12:20 pm, Flemming Greve Skovengaard wrote:
[snip]

>
> Don't you mean 'ping -n -c 50 10.1.1.31' instead of 'ping -n 50
> 10.1.1.31'. Else read the man page for ping.

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


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




qx{} and ping problem.

2004-09-09 Thread Gary Stainburn
Hi folks.

Got the simplest of small scripts that runs ping and shows the summary.  
However, although the ping command works at the shell, it doesn't work 
in the perl script.

any ideas?

#!/usr/bin/perl -w

while(1) {
  my @lines=qx{ping -n 50 10.1.1.31};
  my $times=pop @lines;
  my $counts=pop @lines;
  print "$times $counts";
  if ($times=~/^(\d+) .?, (\d+) .?, (\d+%)/) {
$sent=$1;
$rec=$2;
$perc=$3;
printf "%3d %3d %3d %s", $sent,$rec,$perc,$times;
  }
  sleep 60;
}

#--- lswitchh.ringways.co.uk ping statistics ---
#120 packets transmitted, 120 packets received, 0% packet loss
#round-trip min/avg/max/mdev = 0.243/0.391/0.834/0.079 ms
[EMAIL PROTECTED] gary]$ ping  lswitchh
#

[EMAIL PROTECTED] gary]$ ./pingcheck
connect: Invalid argument
Use of uninitialized value in concatenation (.) at ./pingcheck line 7.
Use of uninitialized value in concatenation (.) at ./pingcheck line 7.
Use of uninitialized value in pattern match (m//) at ./pingcheck line 8.
^C
[EMAIL PROTECTED] gary]$
-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




  1   2   3   4   >