<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dcterms="http://purl.org/rss/1.0/modules/dcterms/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <generator>Plagger/0.7.17</generator>
    <link>http://desert-island.me.uk:8888/~castaway/perl-signals/</link>
    <description>Everything Perl from the Web</description>
    <title>Perl Signals Aggregator</title>
    <pubDate>Sat, 23 Jul 2011 14:00:33 +0100</pubDate>
    <item>
      <author>nobody@example.com (mac)</author>
      <dc:creator>nobody@example.com (mac)</dc:creator>
      <category>string perl url</category>
      <link>http://stackoverflow.com/questions/6799991/how-can-i-get-a-unknown-length-string-from-a-webpage</link>
      <description>I need to get a string in perl whose length is varying each day. Look at
the URL content below

&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;title&gt;Index of /isos/preFCS5.3/LATESTGOODCVP&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;h1&gt;Index of /isos/preFCS5.3/LATESTGOODCVP&lt;/h1&gt;
&lt;table&gt;&lt;tr&gt;&lt;th&gt;&lt;img src="/icons/blank.gif" alt="[ICO]"&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="?C=N;O=D"&gt;Name&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="?C=M;O=A"&gt;Last      modified&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="?C=S;O=A"&gt;Size&lt;/a&gt;&lt;/th&gt;&lt;th&gt;&lt;a href="?C=D;O=A"&gt;Description&lt;/a&gt;&lt;/th&gt;&lt;/tr&gt;&lt;tr&gt;&lt;th colspan="5"&gt;&lt;hr&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top"&gt;&lt;img src="/icons/back.gif" alt="[DIR]"&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="/isos/preFCS5.3/"&gt;Parent   Directory&lt;/a&gt;&lt;/td&gt;&lt;td&gt;&amp;nbsp;&lt;/td&gt;&lt;td align="right"&gt;  - &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top"&gt;&lt;img src="/icons/unknown.gif" alt="[   ]"&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="CVP-LATEST-5.3.0.37.iso"&gt;CVP-LATEST-5.3.0.37.iso&lt;/a&gt;&lt;/td&gt;&lt;td align="right"&gt;19-Jul-2011 03:32  &lt;/td&gt;&lt;td align="right"&gt;816M&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top"&gt;&lt;img src="/icons/unknown.gif" alt="[   ]"&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="ChangeLog-LATEST.2011-07-19-03h.30m.01s"&gt;ChangeLog-LATEST.2011-07-19-03h.30m.01s&lt;/a&gt;&lt;/td&gt;&lt;td align="right"&gt;19-Jul-2011 03:32  &lt;/td&gt;&lt;td align="right"&gt; 16K&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top"&gt;&lt;img src="/icons/unknown.gif" alt="[   ]"&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="is.iso"&gt;is.iso&lt;/a&gt;&lt;/td&gt;&lt;td align="right"&gt;19-Jul-2011 03:32  &lt;/td&gt;&lt;td align="right"&gt;816M&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td valign="top"&gt;&lt;img src="/icons/unknown.gif" alt="[   ]"&gt;&lt;/td&gt;&lt;td&gt;&lt;a href="md5SUM"&gt;md5SUM&lt;/a&gt;&lt;/td&gt;&lt;td align="right"&gt;19-Jul-2011 03:32  &lt;/td&gt;&lt;td align="right"&gt;111 &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;th colspan="5"&gt;&lt;hr&gt;&lt;/th&gt;&lt;/tr&gt;
&lt;/table&gt;
&lt;address&gt;Apache/2.2.3 (Red Hat) Server at www.google.com Port 80&lt;/address&gt;
&lt;/body&gt;&lt;/html&gt;

You can see a string named "CVP-LATEST-5.3.0.37.iso". I need to get that
into $name. the string CVP-LATEST-5.3.0.37.iso will keep on changing
everyday say CVP-LATEST-5.3.0.39.iso or CVP-LATEST-5.3.39a.iso or to
CVP-LATEST-6.1.iso or CVP-LATEST-6.23.23.112.iso.

Is there any way I can get this ?

Here is the code

use strict;
use warnings;
use LWP::Simple;

my $oldVersion = CVP-LATEST-5.3.0.37.iso;
my $url        = 'http://www.google.com/isos/preFCS5.3/LATESTGOODCVP/';

my $newPage = get($url)
or die "Cannot retrieve contents from $url\n";

if ( $newPage =~ /href=\"CVP-LATEST-5\.3\.0\.(\d\d)/ ) {
my $version = $1;

if ( $version != $oldVersion ) {
    my $status = getstore($url . "CVP-LATEST-5.3.0.$version.iso",
                          "CVP-LATEST-5.3.0.$version.iso");
} else {
    print "Already at most recent version\n";
}

} else {
die "Cannot find version tag in contents from $url\n";
}

Here if you see the code its getting only the number(xx) after 5.3.0."XX"
and is of known length that is 2.

Is there anyway I can change it so that it will read the whole filename
ie. CVP-LATEST-XXXXXX*.iso and then compare it with the $oldversion ?

Please note the string "CVP-LATEST-" and ".iso" remains constant, but
later numbers change and can also contain alphabets. Also note that there
is one more file called is.iso in the URL content. I don't want to get
that.</description>
      <dc:date>2011-07-23T11:11:57Z</dc:date>
      <dc:subject>string perl url</dc:subject>
      <title>how can I get a unknown length string from a webpage</title>
      <pubDate>Sat, 23 Jul 2011 11:11:57 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I need to get a string in perl whose length is varying each day. Look at the URL content below&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"&amp;gt;
&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt;Index of /isos/preFCS5.3/LATESTGOODCVP&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Index of /isos/preFCS5.3/LATESTGOODCVP&amp;lt;/h1&amp;gt;
&amp;lt;table&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th&amp;gt;&amp;lt;img src="/icons/blank.gif" alt="[ICO]"&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;&amp;lt;a href="?C=N;O=D"&amp;gt;Name&amp;lt;/a&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;&amp;lt;a href="?C=M;O=A"&amp;gt;Last      modified&amp;lt;/a&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;&amp;lt;a href="?C=S;O=A"&amp;gt;Size&amp;lt;/a&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;th&amp;gt;&amp;lt;a href="?C=D;O=A"&amp;gt;Description&amp;lt;/a&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;&amp;lt;tr&amp;gt;&amp;lt;th colspan="5"&amp;gt;&amp;lt;hr&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign="top"&amp;gt;&amp;lt;img src="/icons/back.gif" alt="[DIR]"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;a href="/isos/preFCS5.3/"&amp;gt;Parent   Directory&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;amp;nbsp;&amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;  - &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign="top"&amp;gt;&amp;lt;img src="/icons/unknown.gif" alt="[   ]"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;a href="CVP-LATEST-5.3.0.37.iso"&amp;gt;CVP-LATEST-5.3.0.37.iso&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;19-Jul-2011 03:32  &amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;816M&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign="top"&amp;gt;&amp;lt;img src="/icons/unknown.gif" alt="[   ]"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;a href="ChangeLog-LATEST.2011-07-19-03h.30m.01s"&amp;gt;ChangeLog-LATEST.2011-07-19-03h.30m.01s&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;19-Jul-2011 03:32  &amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt; 16K&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign="top"&amp;gt;&amp;lt;img src="/icons/unknown.gif" alt="[   ]"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;a href="is.iso"&amp;gt;is.iso&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;19-Jul-2011 03:32  &amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;816M&amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;td valign="top"&amp;gt;&amp;lt;img src="/icons/unknown.gif" alt="[   ]"&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&amp;lt;a href="md5SUM"&amp;gt;md5SUM&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;19-Jul-2011 03:32  &amp;lt;/td&amp;gt;&amp;lt;td align="right"&amp;gt;111 &amp;lt;/td&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;tr&amp;gt;&amp;lt;th colspan="5"&amp;gt;&amp;lt;hr&amp;gt;&amp;lt;/th&amp;gt;&amp;lt;/tr&amp;gt;
&amp;lt;/table&amp;gt;
&amp;lt;address&amp;gt;Apache/2.2.3 (Red Hat) Server at www.google.com Port 80&amp;lt;/address&amp;gt;
&amp;lt;/body&amp;gt;&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;You can see a string named "CVP-LATEST-5.3.0.37.iso".
I need to get that into $name.
the string CVP-LATEST-5.3.0.37.iso will keep on changing everyday
say CVP-LATEST-5.3.0.39.iso or CVP-LATEST-5.3.39a.iso or to CVP-LATEST-6.1.iso or CVP-LATEST-6.23.23.112.iso. &lt;/p&gt;

&lt;p&gt;Is there any way I can get this ? &lt;/p&gt;

&lt;p&gt;Here is the code&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use strict;
use warnings;
use LWP::Simple;

my $oldVersion = CVP-LATEST-5.3.0.37.iso;
my $url        = 'http://www.google.com/isos/preFCS5.3/LATESTGOODCVP/';

my $newPage = get($url)
or die "Cannot retrieve contents from $url\n";

if ( $newPage =~ /href=\"CVP-LATEST-5\.3\.0\.(\d\d)/ ) {
my $version = $1;

if ( $version != $oldVersion ) {
    my $status = getstore($url . "CVP-LATEST-5.3.0.$version.iso",
                          "CVP-LATEST-5.3.0.$version.iso");
} else {
    print "Already at most recent version\n";
}

} else {
die "Cannot find version tag in contents from $url\n";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Here if you see the code its getting only the number(xx) after 5.3.0."XX" and is of known length that is 2. &lt;/p&gt;

&lt;p&gt;Is there anyway I can change it so that it will read the whole filename ie. CVP-LATEST-XXXXXX*.iso  and then compare it with the  $oldversion  ? &lt;/p&gt;

&lt;p&gt;Please note the string "CVP-LATEST-" and ".iso" remains constant, but later numbers change and can also contain alphabets.
Also note that there is one more file called is.iso in the URL content. I don't want to get that.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T11:11:57Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6799991/how-can-i-get-a-unknown-length-string-from-a-webpage</guid>
    </item>
    <item>
      <author>nobody@example.com (Aditya Kumar)</author>
      <dc:creator>nobody@example.com (Aditya Kumar)</dc:creator>
      <category>c++ perl g++</category>
      <link>http://stackoverflow.com/questions/6799750/how-to-detect-when-compiler-emits-an-error</link>
      <description>To compile a C++ project, I want to write a perl script to compile my
program and see if the compilation went wrong or not. If the compiler
gives any compilation error, I'll need to perform some other task.

The perl script will be something like this:

   @l1 =  `find . -name '*.c'`;
   @l2 =  `find . -name '*.cpp'`;
   @l3 =  `find . -name '*.cc'`;
   my $err;
   my $FLAGS = "-DNDEBUG"   
   push(@l , @l1, @l2, @l3);
   chomp(@l);
   foreach (@l) {
     print "processing file $_ ...";
     $err = `g++ $_ $FLAGS`;
     if($err == something) {
       #do the needful
     }
   }

so what should be something?</description>
      <dc:date>2011-07-23T10:22:14Z</dc:date>
      <dc:subject>c++ perl g++</dc:subject>
      <title>how to detect when compiler emits an error</title>
      <pubDate>Sat, 23 Jul 2011 10:22:14 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;To compile a &lt;code&gt;C++&lt;/code&gt; project, I want to write a &lt;code&gt;perl&lt;/code&gt; script to compile my program and see if the compilation went wrong or not. If the compiler gives any compilation error, I'll need to perform some other task.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;perl&lt;/code&gt; script will be something like this:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;   @l1 =  `find . -name '*.c'`;
   @l2 =  `find . -name '*.cpp'`;
   @l3 =  `find . -name '*.cc'`;
   my $err;
   my $FLAGS = "-DNDEBUG"   
   push(@l , @l1, @l2, @l3);
   chomp(@l);
   foreach (@l) {
     print "processing file $_ ...";
     $err = `g++ $_ $FLAGS`;
     if($err == something) {
       #do the needful
     }
   }
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;so what should be &lt;strong&gt;something&lt;/strong&gt;?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T10:22:14Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6799750/how-to-detect-when-compiler-emits-an-error</guid>
    </item>
    <item>
      <author>nobody@example.com (mac)</author>
      <dc:creator>nobody@example.com (mac)</dc:creator>
      <category>perl file mac</category>
      <link>http://stackoverflow.com/questions/6799508/unable-to-read-rtf-file-using-perl-on-mac</link>
      <description>I'm trying Perl on Mac. I have to read an RTF text file. the content of
the file is "36" (without double quotes). thats it, just two characters.

Here is the code I have to read it.

#!/usr/bin/perl
use strict;
use warnings;

my $file = "verInfo.rtf";

unless(open FILE, $file) {
    # Die with error message
    # if we can't open it.
    die "\nUnable to open $file\n";
}

my $oldversion = &lt;FILE&gt;;

print "conent is $oldversion";

close FILE;

Remember all I want is to read the value 36 from file and store it as a
integer in $oldversion

But when I read the file and print it, it prints following

conent is {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360

Im not able to read 36.</description>
      <dc:date>2011-07-23T09:28:34Z</dc:date>
      <dc:subject>perl file mac</dc:subject>
      <title>Unable to read RTF file using Perl on Mac</title>
      <pubDate>Sat, 23 Jul 2011 09:28:34 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I'm trying Perl on Mac. 
I have to read an RTF text file. the content of the file is "36" (without double quotes). thats it, just two characters.&lt;/p&gt;

&lt;p&gt;Here is the code I have to read it.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl
use strict;
use warnings;

my $file = "verInfo.rtf";

unless(open FILE, $file) {
    # Die with error message
    # if we can't open it.
    die "\nUnable to open $file\n";
}

my $oldversion = &amp;lt;FILE&amp;gt;;

print "conent is $oldversion";

close FILE;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Remember all I want is to read the value 36 from file and store it as a integer in $oldversion&lt;/p&gt;

&lt;p&gt;But when I read the file and print it, it prints following&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;conent is {\rtf1\ansi\ansicpg1252\cocoartf1038\cocoasubrtf360
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Im not able to read 36.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T09:28:34Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6799508/unable-to-read-rtf-file-using-perl-on-mac</guid>
    </item>
    <item>
      <author>nobody@example.com (Nickolay Stavrogin)</author>
      <dc:creator>nobody@example.com (Nickolay Stavrogin)</dc:creator>
      <category>perl dbus</category>
      <link>http://stackoverflow.com/questions/6799472/start-the-session-bus-of-dbus-with-perl-netdbus</link>
      <description>I am using Perl and the Net::DBus module. I wrote a simple test program:

#!/usr/bin/perl
use strict;
use warnings;

package MyObj;
use Net::DBus::Exporter qw(org.example.Tao);
use base qw(Net::DBus::Object);

sub new {
    my $class = shift;
    my $service = shift;
    my $self = $class-&gt;SUPER::new($service, '/MyObj');
    bless $self, $class;
    return $self;
}

dbus_method("Hello", ["string"]);

sub Hello {
    return 'Hello';
}

package main;
use Net::DBus;
use Net::DBus::Reactor;

my $bus = Net::DBus-&gt;session;
my $service = $bus-&gt;export_service("org.example.Tao");
my $object = MyObj-&gt;new($service);
my $reactor = Net::DBus::Reactor-&gt;main();
$reactor-&gt;run();

return 0;

I am connecting by ssh and using:

Perl, v5.8.8 built for x86_64-linux-thread-multi
Linux example.com 2.6.32.19-0.2.99.17.22250fd-xen #1 SMP 2010-09-13 10:16:50 +0200 x86_64 x86_64 x86_64 GNU/Linux
CentOS release 5.4 (Final)

When I try to start my test.pl, I get the error:

org.freedesktop.DBus.Error.Spawn.ExecFailed:
Failed to execute dbus-launch to autolaunch D-Bus session

This error is raised by this line:

my $bus = Net::DBus-&gt;session;

Google hinted to me about dbus-launch. I executed yum install dbus-x11.

I try start my test code again and get error in the same line:

org.freedesktop.DBus.Error.Spawn.ExecFailed: 
dbus-launch failed to autolaunch D-Bus session: 
Autolaunch error: X11 initialization failed.

After read manuals, I detect that DBUS session daemon isn't started and
my ENV var DBUS_SESSION_BUS_ADDRESS is empty:

[root@zion perl]# ps ax|grep dbus|grep -v grep
1019 ?        Ss     0:00 dbus-daemon --system

Then I exec:

[root@zion perl]# dbus-launch --sh-syntax
DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-smHadq6yxV,guid=101ccd74fb75ae501485ed004e2a9043';
export DBUS_SESSION_BUS_ADDRESS;
DBUS_SESSION_BUS_PID=5037;
[root@zion perl]# ps ax|grep dbus|grep -v grep
1019 ?        Ss     0:00 dbus-daemon --system
5037 ?        Ss     0:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session

But DBUS_SESSION_BUS_ADDRESS is same empty.

Question: I need simple two Perl apps. The first app registers the dbus
session service. Another app using my registered service. What is the
best and correct way to do it in my environment?</description>
      <dc:date>2011-07-23T09:20:46Z</dc:date>
      <dc:subject>perl dbus</dc:subject>
      <title>Start the session bus of DBus with Perl Net::DBus</title>
      <pubDate>Sat, 23 Jul 2011 09:20:46 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I am using Perl and the &lt;a href="http://p3rl.org/Net%3a%3aDBus" rel="nofollow"&gt;Net::DBus&lt;/a&gt; module. I wrote a simple test program:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl
use strict;
use warnings;

package MyObj;
use Net::DBus::Exporter qw(org.example.Tao);
use base qw(Net::DBus::Object);

sub new {
    my $class = shift;
    my $service = shift;
    my $self = $class-&amp;gt;SUPER::new($service, '/MyObj');
    bless $self, $class;
    return $self;
}

dbus_method("Hello", ["string"]);

sub Hello {
    return 'Hello';
}

package main;
use Net::DBus;
use Net::DBus::Reactor;

my $bus = Net::DBus-&amp;gt;session;
my $service = $bus-&amp;gt;export_service("org.example.Tao");
my $object = MyObj-&amp;gt;new($service);
my $reactor = Net::DBus::Reactor-&amp;gt;main();
$reactor-&amp;gt;run();

return 0;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I am connecting by ssh and using:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Perl, v5.8.8 built for x86_64-linux-thread-multi
Linux example.com 2.6.32.19-0.2.99.17.22250fd-xen #1 SMP 2010-09-13 10:16:50 +0200 x86_64 x86_64 x86_64 GNU/Linux
CentOS release 5.4 (Final)
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;When I try to start my &lt;code&gt;test.pl&lt;/code&gt;, I get the error:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;org.freedesktop.DBus.Error.Spawn.ExecFailed:
Failed to execute dbus-launch to autolaunch D-Bus session
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This error is raised by this line:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $bus = Net::DBus-&amp;gt;session;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Google hinted to me about &lt;code&gt;dbus-launch&lt;/code&gt;. I executed &lt;code&gt;yum install dbus-x11&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I try start my test code again and get error in the same line:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;org.freedesktop.DBus.Error.Spawn.ExecFailed: 
dbus-launch failed to autolaunch D-Bus session: 
Autolaunch error: X11 initialization failed.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After read manuals, I detect that DBUS session daemon isn't started and my ENV var DBUS_SESSION_BUS_ADDRESS is empty:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[root@zion perl]# ps ax|grep dbus|grep -v grep
1019 ?        Ss     0:00 dbus-daemon --system
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Then I exec:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;[root@zion perl]# dbus-launch --sh-syntax
DBUS_SESSION_BUS_ADDRESS='unix:abstract=/tmp/dbus-smHadq6yxV,guid=101ccd74fb75ae501485ed004e2a9043';
export DBUS_SESSION_BUS_ADDRESS;
DBUS_SESSION_BUS_PID=5037;
[root@zion perl]# ps ax|grep dbus|grep -v grep
1019 ?        Ss     0:00 dbus-daemon --system
5037 ?        Ss     0:00 /bin/dbus-daemon --fork --print-pid 4 --print-address 6 --session
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But DBUS_SESSION_BUS_ADDRESS is same empty.&lt;/p&gt;

&lt;p&gt;Question:
I need simple two Perl apps. The first app registers the dbus session service. Another app using my registered service. What is the best and correct way to do it in my environment? &lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T09:20:46Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6799472/start-the-session-bus-of-dbus-with-perl-netdbus</guid>
    </item>
    <item>
      <author>nobody@example.com (capser)</author>
      <dc:creator>nobody@example.com (capser)</dc:creator>
      <category>perl hash dereference multi-level</category>
      <link>http://stackoverflow.com/questions/6798308/derefencing-a-multi-level-hash-a-practical-example</link>
      <description>I have a data that I pump into this multi-level hash:

$newcomm_stat_hash{$stat_message_class}{$stat_process} = $stat_host;

I can print out the $stat_message_class, and the $stat_process with the
keys-values structure:

foreach my $stat_message_class (keys %newcomm_stat_hash) {

   my $stat_message_type = $stat_message_class;

   foreach my $stat_process (keys %{$newcomm_stat_hash{$stat_message_class}} ) {

      print $stat_host;
   }
}

But when I follow the same format to print out $stat_host values (see
code below), I get this error message:

  Can't use string ("dc109") as a HASH ref while "strict refs" in use
  at multilevel_hash line 24.

I get the same message for the keys or values function.

#!/usr/bin/perl
use warnings; 
use strict;

my %newcomm_stat_hash; 
my $control_server = "dc100";
my $control_stat_message = "OCCD2o";

$newcomm_stat_hash{'OCCD2o'} =  { 'filesrvr' =&gt; 'dc100',
                                  'dhcpsrv'  =&gt; 'dc100',
                                  'dnssrv'   =&gt; 'dc109',
                                  'mailpfd'  =&gt; 'dc100',
                                };

$newcomm_stat_hash{'PIDmon2'} = { 'pingstat' =&gt; 'fg100',
                                  'udpmon'   =&gt; 'fg100',
                                  'ftp'      =&gt; 'dc100',
                                  'casper'   =&gt; 'dc440',
                                };

foreach my $stat_message_class ( keys %newcomm_stat_hash ) {

 my $stat_message_type = $stat_message_class;

 foreach my $stat_process ( keys %{$newcomm_stat_hash{$stat_message_class}} ) {

         foreach my $stat_host (keys %{$newcomm_stat_hash{$stat_message_class}{$stat_process}} ) {

             print $stat_host;
         } 
     }
}

After dereferencing the multilevel hash to $stat_host I want to plug this
in at the end:

use TERM::ANSIColor;

if ($stat_host ne $control_server) {

    print "$stat_host, $stat_process , $stat_message_class";   
}   

elsif (  ($stat_host ne $control_server)
      &amp;&amp; ($stat_message_class eq $control_stat_message)
      ) {   

    print color 'red';   
    print "$stat_host, $stat_process , $stat_message_class";
    print color 'reset';   
}</description>
      <dc:date>2011-07-23T04:51:25Z</dc:date>
      <dc:subject>perl hash dereference multi-level</dc:subject>
      <title>Derefencing a multi-level hash: A practical example</title>
      <pubDate>Sat, 23 Jul 2011 04:51:25 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have a data that I pump into this multi-level hash:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;$newcomm_stat_hash{$stat_message_class}{$stat_process} = $stat_host;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I can print out the &lt;code&gt;$stat_message_class&lt;/code&gt;, and the &lt;code&gt;$stat_process&lt;/code&gt; with the 
keys-values structure:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;foreach my $stat_message_class (keys %newcomm_stat_hash) {

   my $stat_message_type = $stat_message_class;

   foreach my $stat_process (keys %{$newcomm_stat_hash{$stat_message_class}} ) {

      print $stat_host;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But when I follow the same format to print out &lt;code&gt;$stat_host values&lt;/code&gt; (see code below), I get this error message:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Can't use string ("dc109") as a HASH ref while "strict refs" in use at multilevel_hash line 24.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I get the same message for the keys or values function.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl
use warnings; 
use strict;

my %newcomm_stat_hash; 
my $control_server = "dc100";
my $control_stat_message = "OCCD2o";

$newcomm_stat_hash{'OCCD2o'} =  { 'filesrvr' =&amp;gt; 'dc100',
                                  'dhcpsrv'  =&amp;gt; 'dc100',
                                  'dnssrv'   =&amp;gt; 'dc109',
                                  'mailpfd'  =&amp;gt; 'dc100',
                                };

$newcomm_stat_hash{'PIDmon2'} = { 'pingstat' =&amp;gt; 'fg100',
                                  'udpmon'   =&amp;gt; 'fg100',
                                  'ftp'      =&amp;gt; 'dc100',
                                  'casper'   =&amp;gt; 'dc440',
                                };

foreach my $stat_message_class ( keys %newcomm_stat_hash ) {

 my $stat_message_type = $stat_message_class;

 foreach my $stat_process ( keys %{$newcomm_stat_hash{$stat_message_class}} ) {

         foreach my $stat_host (keys %{$newcomm_stat_hash{$stat_message_class}{$stat_process}} ) {

             print $stat_host;
         } 
     }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;After dereferencing the multilevel hash to &lt;code&gt;$stat_host&lt;/code&gt; I want to plug this in at the end: &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use TERM::ANSIColor;

if ($stat_host ne $control_server) {

    print "$stat_host, $stat_process , $stat_message_class";   
}   

elsif (  ($stat_host ne $control_server)
      &amp;amp;&amp;amp; ($stat_message_class eq $control_stat_message)
      ) {   

    print color 'red';   
    print "$stat_host, $stat_process , $stat_message_class";
    print color 'reset';   
}
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T04:51:25Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6798308/derefencing-a-multi-level-hash-a-practical-example</guid>
    </item>
    <item>
      <author>nobody@example.com (cwhelms)</author>
      <dc:creator>nobody@example.com (cwhelms)</dc:creator>
      <category>python perl file-upload node.js</category>
      <link>http://stackoverflow.com/questions/6798305/upload-file-to-nodejs-server-every-30-minutes</link>
      <description>I'm trying to figure out the best way to upload a file to a NodeJS(any
server I guess, but just being specific) every 30 mins.

I was thinking about using perl or python to acheive this, or even NodeJS
or a CGI script?

Would it be best to just create a multi-part form?

Trying to figure out the best practice.

Thanks.</description>
      <dc:date>2011-07-23T04:50:53Z</dc:date>
      <dc:subject>python perl file-upload node.js</dc:subject>
      <title>Upload file to NodeJS server every 30 minutes</title>
      <pubDate>Sat, 23 Jul 2011 04:50:53 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I'm trying to figure out the best way to upload a file to a NodeJS(any server I guess, but just being specific) every 30 mins.&lt;/p&gt;

&lt;p&gt;I was thinking about using perl or python to acheive this, or even NodeJS or a CGI script?&lt;/p&gt;

&lt;p&gt;Would it be best to just create a multi-part form?&lt;/p&gt;

&lt;p&gt;Trying to figure out the best practice.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T04:50:53Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6798305/upload-file-to-nodejs-server-every-30-minutes</guid>
    </item>
    <item>
      <author>nobody@example.com (Jay )</author>
      <dc:creator>nobody@example.com (Jay )</dc:creator>
      <category>perl</category>
      <link>http://stackoverflow.com/questions/6798299/how-can-i-use-perl-to-sum-up-individual-columns-in-a-text-file</link>
      <description>I have large text files in this format and would like to do statistical
analysis on these numbers, starting by adding the columns (ignoring the
first line). I've tried looking at other examples and modifying them but
my programming is poor! So I am wondering if someone could point me in
the right direction, thanks!

AF3     F7      F3      FC5     T7      P7      O1      O2      P8      T8      FC6 
4464.62 4285.13 4503.59 4505.64 4455.9  4341.03 4257.95 4306.67 4299.49 4180    4461.54 
4473.85 4288.72 4510.26 4508.72 4455.38 4347.18 4265.64 4318.97 4310.26 4184.1  4468.21 
4474.87 4289.74 4516.92 4510.77 4450.26 4345.13 4272.82 4332.82 4312.82 4188.72 4464.62</description>
      <dc:date>2011-07-23T04:49:51Z</dc:date>
      <dc:subject>perl</dc:subject>
      <title>How can I use Perl to sum up individual columns in a text file?</title>
      <pubDate>Sat, 23 Jul 2011 04:49:51 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have large text files in this format and would like to do statistical analysis on these numbers, starting by adding the columns (ignoring the first line). I've tried looking at other examples and modifying them but my programming is poor! So I am wondering if someone could point me in the right direction, thanks!&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;AF3     F7      F3      FC5     T7      P7      O1      O2      P8      T8      FC6 
4464.62 4285.13 4503.59 4505.64 4455.9  4341.03 4257.95 4306.67 4299.49 4180    4461.54 
4473.85 4288.72 4510.26 4508.72 4455.38 4347.18 4265.64 4318.97 4310.26 4184.1  4468.21 
4474.87 4289.74 4516.92 4510.77 4450.26 4345.13 4272.82 4332.82 4312.82 4188.72 4464.62
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-23T04:49:51Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6798299/how-can-i-use-perl-to-sum-up-individual-columns-in-a-text-file</guid>
    </item>
    <item>
      <author>nobody@example.com (phileas fogg)</author>
      <dc:creator>nobody@example.com (phileas fogg)</dc:creator>
      <category>regex perl</category>
      <link>http://stackoverflow.com/questions/6797113/how-do-i-match-a-word-followed-by-new-line-then-grab-the-next-line-up-to-its-new</link>
      <description>I'm editing a bunch of SQL files and I need to remove date references in
the queries. However the way the files are written is that logical
operators like, OR and AND are on lines by themselves and the rest of the
associated argument are on another line. Like so:

OR
   field.lastupdate &gt; DATE_SUB(CURDATE(), INTERVAL 31 DAY))
AND
  *some more code*

I want to remove the OR (and it can be an AND too) up to the newline
character, in this example, after the second parenthesis. However I want
to leave the rest of the code intact.

I think the regex should be straightforward except how do I ignore the
newline after the OR but stop at the following newline?

I should note that some of the date lines I want to remove end with a ";"
which I do not want to remove.

Here's a more complete example that I hope clears things up:

OR
        x.is_deleted = 0
OR
        x.lastupd &gt; DATE_SUB(CURDATE(), INTERVAL 31 DAY))
AND
        (j.active = 1
OR
        j.is_deleted = 0
OR
        j.lastupd &gt; DATE_SUB(CURDATE(), INTERVAL 31 DAY));

So you see I want to keep the first "OR" and it's following line,

delete the second "OR" and the line that follows it.

Keep the "AND" and the line that follows it as well as the following "OR"
and it's corresponding line.

And then delete the final "OR" and it's line while leaving the final ";".</description>
      <dc:date>2011-07-22T23:21:31Z</dc:date>
      <dc:subject>regex perl</dc:subject>
      <title>How do I match a word followed by new line then grab the next line up to its new line?</title>
      <pubDate>Fri, 22 Jul 2011 23:21:31 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I'm editing a bunch of SQL files and I need to remove date references in the queries.  However the way the files are written is that logical operators like, OR and AND are on lines by themselves and the rest of the associated argument are on another line.  Like so:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;OR
   field.lastupdate &amp;gt; DATE_SUB(CURDATE(), INTERVAL 31 DAY))
AND
  *some more code*
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I want to remove the OR (and it can be an AND too) up to the newline character, in this example, after the second parenthesis.  However I want to leave the rest of the code intact.&lt;/p&gt;

&lt;p&gt;I think the regex should be straightforward except how do I ignore the newline after the OR but stop at the following newline? &lt;/p&gt;

&lt;p&gt;I should note that some of the date lines I want to remove end with a &lt;code&gt;";"&lt;/code&gt; which I do not want to remove.&lt;/p&gt;

&lt;p&gt;Here's a more complete example that I hope clears things up:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;OR
        x.is_deleted = 0
OR
        x.lastupd &amp;gt; DATE_SUB(CURDATE(), INTERVAL 31 DAY))
AND
        (j.active = 1
OR
        j.is_deleted = 0
OR
        j.lastupd &amp;gt; DATE_SUB(CURDATE(), INTERVAL 31 DAY));
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;So you see I want to keep the first "OR" and it's following line, &lt;/p&gt;

&lt;p&gt;delete the second "OR" and the line that follows it.  &lt;/p&gt;

&lt;p&gt;Keep the "AND" and the line that follows it as well as the following "OR" and it's corresponding line.  &lt;/p&gt;

&lt;p&gt;And then delete the final "OR" and it's line while leaving the final ";".&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T23:21:31Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6797113/how-do-i-match-a-word-followed-by-new-line-then-grab-the-next-line-up-to-its-new</guid>
    </item>
    <item>
      <author>nobody@example.com (user811165)</author>
      <dc:creator>nobody@example.com (user811165)</dc:creator>
      <category>java perl soap jax-ws soaplite</category>
      <link>http://stackoverflow.com/questions/6797030/perl-client-to-jax-ws-java-server-issue</link>
      <description>I have a JAX-WS java server which publishes a web-service

@WebService(endpointInterface="calculator.operation.Calculator")
public class CalculatorWs implements Calculator{

public String[] add(String a) {

    System.out.println(a);

    String[] test = {"this", "that"};
    System.out.println(test);
    return test;
}

}

and

@WebService
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
public interface Calculator {
    String[] add(String a);
}

and have a perl client

use SOAP::Lite +trace =&gt; 'all';
$SOAP::Constants::PREFIX_ENV = 'soapenv';
$SOAP::Constants::PREFIX_ENC = "SOAP-ENC";
my $soap = SOAP::Lite
-&gt;service('http://localhost:8080/tomcat/calculator?wsdl')
-&gt;soapversion('1.1');
my $var = {'a' =&gt; "test"};
my $result = $soap -&gt; add($var);

The problem I'm having is that the Java server does not receive the
arguments passed by the Perl client, although the value returned by the
Java server is received and recognized by the client.

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;soapenv:Envelope xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsam="http://www.w3.org/2
007/05/addressing/metadata" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/
policy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="ht
tp://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://operation.calculator/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;&lt;soapenv:Body&gt;&lt;tns:add&gt;&lt;c-gensym3
&gt;&lt;a xsi:type="xsd:string"&gt;test&lt;/a&gt;&lt;/c-gensym3&gt;&lt;/tns:add&gt;&lt;/soapenv:Body&gt;&lt;/soapenv
:Envelope&gt;

this is the SOAP request sent by the Perl client. Im assuming the way its
building the SOAP request is to blame . But if anyone could help me
figure it out, would be greatly appreciated. Thanks.</description>
      <dc:date>2011-07-22T23:06:29Z</dc:date>
      <dc:subject>java perl soap jax-ws soaplite</dc:subject>
      <title>Perl client to JAX-WS java server issue</title>
      <pubDate>Fri, 22 Jul 2011 23:06:29 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have a JAX-WS java server which publishes a web-service &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@WebService(endpointInterface="calculator.operation.Calculator")
public class CalculatorWs implements Calculator{

public String[] add(String a) {

    System.out.println(a);

    String[] test = {"this", "that"};
    System.out.println(test);
    return test;
}

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;@WebService
@SOAPBinding(style=SOAPBinding.Style.DOCUMENT)
public interface Calculator {
    String[] add(String a);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and have a perl client &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use SOAP::Lite +trace =&amp;gt; 'all';
$SOAP::Constants::PREFIX_ENV = 'soapenv';
$SOAP::Constants::PREFIX_ENC = "SOAP-ENC";
my $soap = SOAP::Lite
-&amp;gt;service('http://localhost:8080/tomcat/calculator?wsdl')
-&amp;gt;soapversion('1.1');
my $var = {'a' =&amp;gt; "test"};
my $result = $soap -&amp;gt; add($var);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The problem I'm having is that the Java server does not receive the arguments passed by the Perl client, although the value returned by the Java server is received and recognized by the client.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;soapenv:Envelope xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsam="http://www.w3.org/2
007/05/addressing/metadata" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/
policy" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="ht
tp://schemas.xmlsoap.org/soap/encoding/" xmlns:tns="http://operation.calculator/
" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&amp;gt;&amp;lt;soapenv:Body&amp;gt;&amp;lt;tns:add&amp;gt;&amp;lt;c-gensym3
&amp;gt;&amp;lt;a xsi:type="xsd:string"&amp;gt;test&amp;lt;/a&amp;gt;&amp;lt;/c-gensym3&amp;gt;&amp;lt;/tns:add&amp;gt;&amp;lt;/soapenv:Body&amp;gt;&amp;lt;/soapenv
:Envelope&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;this is the SOAP request sent by the Perl client. Im assuming the way its building the SOAP request is to blame . But if anyone could help me figure it out, would be greatly appreciated. Thanks.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T23:06:29Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6797030/perl-client-to-jax-ws-java-server-issue</guid>
    </item>
    <item>
      <author>nobody@example.com (user811250)</author>
      <dc:creator>nobody@example.com (user811250)</dc:creator>
      <category>perl gd</category>
      <link>http://stackoverflow.com/questions/6796540/is-there-an-equivalent-to-imagecolorset-for-gd-from-php-in-perl</link>
      <description>I have a transparent image and I would like to change it's color. In PHP
this was done by using imagecolorset but I have read through CPAN's doc
on GD and I am unable to comprehend how to do it in Perl. (Using fill
does not preserve the transparency)

Thank you. :)</description>
      <dc:date>2011-07-22T21:57:00Z</dc:date>
      <dc:subject>perl gd</dc:subject>
      <title>Is there an equivalent to imagecolorset for GD from PHP in Perl?</title>
      <pubDate>Fri, 22 Jul 2011 21:57:00 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have a transparent image and I would like to change it's color. In PHP this was done by using imagecolorset but I have read through CPAN's doc on GD and I am unable to comprehend how to do it in Perl. (Using fill does not preserve the transparency)&lt;/p&gt;

&lt;p&gt;Thank you. :)&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T21:57:00Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6796540/is-there-an-equivalent-to-imagecolorset-for-gd-from-php-in-perl</guid>
    </item>
    <item>
      <author>nobody@example.com (mrburns)</author>
      <dc:creator>nobody@example.com (mrburns)</dc:creator>
      <category>perl cpan</category>
      <link>http://stackoverflow.com/questions/6795713/make-adds-an-exec-line-to-my-scripts</link>
      <description>I'm trying to build a perl package (module + scripts).

My Makefile.PL has the following to include my script

EXE_FILES =&gt; [
               'bin/somescript1',
             ],

But after installing the script, it adds the following to the beginning
of the installed script.

eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell

Why does it do this and can I make it not include that?</description>
      <dc:date>2011-07-22T20:25:05Z</dc:date>
      <dc:subject>perl cpan</dc:subject>
      <title>make adds an 'exec' line to my scripts</title>
      <pubDate>Fri, 22 Jul 2011 20:25:05 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I'm trying to build a perl package (module + scripts).&lt;/p&gt;

&lt;p&gt;My Makefile.PL has the following to include my script&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;EXE_FILES =&amp;gt; [
               'bin/somescript1',
             ],
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;But after installing the script, it adds the following to the beginning of the installed script.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;eval 'exec /usr/bin/perl  -S $0 ${1+"$@"}'
    if 0; # not running under some shell
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Why does it do this and can I make it not include that?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T20:25:05Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6795713/make-adds-an-exec-line-to-my-scripts</guid>
    </item>
    <item>
      <author>nobody@example.com (Shahab)</author>
      <dc:creator>nobody@example.com (Shahab)</dc:creator>
      <category>perl http-post</category>
      <link>http://stackoverflow.com/questions/6795338/connecting-keeps-closing</link>
      <description>so i'm having a problem trying to automatically login to a internal
website. I'm able to send a post request but in the response I always get
the Header Connection: close. I've tried to pass is through the post
request but it still seems to respond with Connection: close. I want to
be able to navigate through the website so I need the Connection:
keep-alive so that i can send more request. Could anyone tell me what I'm
doing wrong? here's the code:

#usr/bin/perl
#NetTelnet.pl

use strict; use warnings;

#Sign into cfxint Unix something...
use Net::Telnet;

# Create a new instance of Net::Telnet, 
my $telnetCon = new Net::Telnet (Timeout =&gt; 10,
                             Prompt =&gt; '/bash\$ $/') or die "Could not make connection.";

my $hostname = 'cfxint';

# Connect to the host of the users choice                                
$telnetCon-&gt;open(Host =&gt; $hostname,
             Port =&gt; 23) or die "Could not connect to $hostname.";

use WWW::Mechanize;

my $mech = WWW::Mechanize-&gt;new(cookie_jar =&gt; {});
&amp;login_alfresco;


sub login_cxfint {
#get username and password from user
my $CXusername = '';
my $CXpassword = '';

# Recreate the login
# Wait for the login: message and then enter the username
$telnetCon-&gt;waitfor(match =&gt; '/login:/i');

# this method adds a \n to the end of the username, it mimics hitting the enter key after entering your username
$telnetCon-&gt;print($CXusername);

# does the same as the previous command but for the password
$telnetCon-&gt;print($CXpassword);

#Wait for the login successful message
$telnetCon-&gt;waitfor();
}

sub login_alfresco{

my $ALusername = '';
my $ALpassword = '';
$mech-&gt;get('http://documents.ifds.group:8080/alfresco/faces/jsp/login.jsp');

my $res = $mech-&gt;res;
my $idfaces = '';

if($res-&gt;is_success){
    my $ff = $res-&gt;content;
    if($ff =~ /id="javax.faces.ViewState" value="(.*?)"/){
         $idfaces = $1;
    }
    else {
        print "javax.faces /Regex error?\n";
        die;
    }
}

print $idfaces, "\n";

#Send the get request for Alfresco
$mech-&gt;post('http://documents.ifds.group:8080/alfresco/faces/jsp/login.jsp',[
'loginForm:rediretURL' =&gt;,
'loginForm:user-name' =&gt; $ALusername,
'loginForm:user-password' =&gt; $ALpassword,
'loginForm:submit' =&gt; 'Login',
'loginForm_SUBMIT' =&gt; '1',
'loginForm:_idcl' =&gt; ,
'loginForm:_link_hidden_' =&gt; ,
'javax.faces.ViewState' =&gt; $idfaces], **'Connection' =&gt;'keep-alive'**);

$res = $mech-&gt;res;

open ALF, "&gt;Alfresco.html";
print ALF $mech-&gt;response-&gt;as_string;

if($res-&gt;is_success){
    my $ff = $res-&gt;content;
    if($ff =~ /id="javax.faces.ViewState" value="(.*?)"/){
         $idfaces = $1;
    }
    else {
        print "javax.faces /Regex error?\n";
        die;
    }
}
print $idfaces, "\n";

#Logout
$mech-&gt;post('http://documents.ifds.group:8080/alfresco/faces/jsp/extension/browse/browse.jsp', [
'browse:serach:_option' =&gt; '0',
'browse:search' =&gt; ,
'browse:spaces-pages' =&gt; '20',
'browse:content-pages' =&gt; '50',
'browse_SUBMIT' =&gt; '1',
'id' =&gt; ,
'browse:modelist' =&gt; '',
'ref'=&gt;'',
'browse:spacesList:sort' =&gt; ,
'browse:_idJsp7' =&gt; ,
'browse:sidebar-body:navigator' =&gt; ,
'browse:contentRichList:sort' =&gt; ,
'browse:act' =&gt; 'browse:logout',
'outcome' =&gt; 'logout',
'browse:panel' =&gt; ,
'javax.faces.ViewState' =&gt; $idfaces,])
}</description>
      <dc:date>2011-07-22T19:52:30Z</dc:date>
      <dc:subject>perl http-post</dc:subject>
      <title>Connecting keeps closing?</title>
      <pubDate>Fri, 22 Jul 2011 19:52:30 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;so i'm having a problem trying to automatically login to a internal website. I'm able to send a post request but in the response I always get the Header Connection: close. I've tried to pass is through the post request but it still seems to respond with Connection: close. I want to be able to navigate through the website so I need the Connection: keep-alive so that i can send more request. Could anyone tell me what I'm doing wrong? here's the code:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#usr/bin/perl
#NetTelnet.pl

use strict; use warnings;

#Sign into cfxint Unix something...
use Net::Telnet;

# Create a new instance of Net::Telnet, 
my $telnetCon = new Net::Telnet (Timeout =&amp;gt; 10,
                             Prompt =&amp;gt; '/bash\$ $/') or die "Could not make connection.";

my $hostname = 'cfxint';

# Connect to the host of the users choice                                
$telnetCon-&amp;gt;open(Host =&amp;gt; $hostname,
             Port =&amp;gt; 23) or die "Could not connect to $hostname.";

use WWW::Mechanize;

my $mech = WWW::Mechanize-&amp;gt;new(cookie_jar =&amp;gt; {});
&amp;amp;login_alfresco;


sub login_cxfint {
#get username and password from user
my $CXusername = '';
my $CXpassword = '';

# Recreate the login
# Wait for the login: message and then enter the username
$telnetCon-&amp;gt;waitfor(match =&amp;gt; '/login:/i');

# this method adds a \n to the end of the username, it mimics hitting the enter key after entering your username
$telnetCon-&amp;gt;print($CXusername);

# does the same as the previous command but for the password
$telnetCon-&amp;gt;print($CXpassword);

#Wait for the login successful message
$telnetCon-&amp;gt;waitfor();
}

sub login_alfresco{

my $ALusername = '';
my $ALpassword = '';
$mech-&amp;gt;get('http://documents.ifds.group:8080/alfresco/faces/jsp/login.jsp');

my $res = $mech-&amp;gt;res;
my $idfaces = '';

if($res-&amp;gt;is_success){
    my $ff = $res-&amp;gt;content;
    if($ff =~ /id="javax.faces.ViewState" value="(.*?)"/){
         $idfaces = $1;
    }
    else {
        print "javax.faces /Regex error?\n";
        die;
    }
}

print $idfaces, "\n";

#Send the get request for Alfresco
$mech-&amp;gt;post('http://documents.ifds.group:8080/alfresco/faces/jsp/login.jsp',[
'loginForm:rediretURL' =&amp;gt;,
'loginForm:user-name' =&amp;gt; $ALusername,
'loginForm:user-password' =&amp;gt; $ALpassword,
'loginForm:submit' =&amp;gt; 'Login',
'loginForm_SUBMIT' =&amp;gt; '1',
'loginForm:_idcl' =&amp;gt; ,
'loginForm:_link_hidden_' =&amp;gt; ,
'javax.faces.ViewState' =&amp;gt; $idfaces], **'Connection' =&amp;gt;'keep-alive'**);

$res = $mech-&amp;gt;res;

open ALF, "&amp;gt;Alfresco.html";
print ALF $mech-&amp;gt;response-&amp;gt;as_string;

if($res-&amp;gt;is_success){
    my $ff = $res-&amp;gt;content;
    if($ff =~ /id="javax.faces.ViewState" value="(.*?)"/){
         $idfaces = $1;
    }
    else {
        print "javax.faces /Regex error?\n";
        die;
    }
}
print $idfaces, "\n";

#Logout
$mech-&amp;gt;post('http://documents.ifds.group:8080/alfresco/faces/jsp/extension/browse/browse.jsp', [
'browse:serach:_option' =&amp;gt; '0',
'browse:search' =&amp;gt; ,
'browse:spaces-pages' =&amp;gt; '20',
'browse:content-pages' =&amp;gt; '50',
'browse_SUBMIT' =&amp;gt; '1',
'id' =&amp;gt; ,
'browse:modelist' =&amp;gt; '',
'ref'=&amp;gt;'',
'browse:spacesList:sort' =&amp;gt; ,
'browse:_idJsp7' =&amp;gt; ,
'browse:sidebar-body:navigator' =&amp;gt; ,
'browse:contentRichList:sort' =&amp;gt; ,
'browse:act' =&amp;gt; 'browse:logout',
'outcome' =&amp;gt; 'logout',
'browse:panel' =&amp;gt; ,
'javax.faces.ViewState' =&amp;gt; $idfaces,])
}
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T19:52:30Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6795338/connecting-keeps-closing</guid>
    </item>
    <item>
      <author>nobody@example.com (Shahab)</author>
      <dc:creator>nobody@example.com (Shahab)</dc:creator>
      <category>perl https ssl-certificate</category>
      <link>http://stackoverflow.com/questions/6795030/how-to-ignore-certificate-verify-failed-error-in-perl</link>
      <description>I want to access a website where the certificate cannot be verified. I'm
using WWW::Mechanize get request. So how would go about ignoring this and
continues to connect to the website?

Thanks

use strict;use warnings;

use WWW::Mechanize;

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $url = '';
my $mech = new WWW::Mechanize;



my $response = $mech-&gt;get($url);

print $response-&gt;as_string;</description>
      <dc:date>2011-07-22T19:25:47Z</dc:date>
      <dc:subject>perl https ssl-certificate</dc:subject>
      <title>How to ignore 'Certificate Verify Failed' error in perl?</title>
      <pubDate>Fri, 22 Jul 2011 19:25:47 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I want to access a website where the certificate cannot be verified. I'm using WWW::Mechanize get request. So how would go about ignoring this and continues to connect to the website?&lt;/p&gt;

&lt;p&gt;Thanks&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use strict;use warnings;

use WWW::Mechanize;

$ENV{PERL_LWP_SSL_VERIFY_HOSTNAME} = 0;
my $url = '';
my $mech = new WWW::Mechanize;



my $response = $mech-&amp;gt;get($url);

print $response-&amp;gt;as_string;
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T19:25:47Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6795030/how-to-ignore-certificate-verify-failed-error-in-perl</guid>
    </item>
    <item>
      <author>nobody@example.com (Charles)</author>
      <dc:creator>nobody@example.com (Charles)</dc:creator>
      <category>perl hash dereference</category>
      <link>http://stackoverflow.com/questions/6794344/dereferencing-perl-hashes</link>
      <description>Using Text::Ngram I have

my $c = ngram_counts($text, 3);
my %ct = %($c);

which doesn't work (Scalar found where operator expected). I think this
is a combination of not knowing what I'm doing (still not very good with
Perl) and being confused about what exactly I'm getting as output from
Text::Ngram. Help? I just want to look at the generated n-grams:

my @keys = sort {$ct{$a} cmp $ct{$b} } keys %ct;
foreach my $k (@keys) {
    print "$k: $ct{$k}\n"
}

Edit: Stupid error on my part, thanks everyone.</description>
      <dc:date>2011-07-22T18:17:31Z</dc:date>
      <dc:subject>perl hash dereference</dc:subject>
      <title>Dereferencing perl hashes</title>
      <pubDate>Fri, 22 Jul 2011 18:17:31 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;Using &lt;a href="http://search.cpan.org/~ambs/Text-Ngram-0.13/lib/Text/Ngram.pm" rel="nofollow"&gt;Text::Ngram&lt;/a&gt; I have&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $c = ngram_counts($text, 3);
my %ct = %($c);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;which doesn't work (&lt;code&gt;Scalar found where operator expected&lt;/code&gt;).  I think this is a combination of not knowing what I'm doing (still not very good with Perl) and being confused about what exactly I'm getting as output from Text::Ngram.  Help?  I just want to look at the generated n-grams:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my @keys = sort {$ct{$a} cmp $ct{$b} } keys %ct;
foreach my $k (@keys) {
    print "$k: $ct{$k}\n"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Edit: Stupid error on my part, thanks everyone.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T18:17:31Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6794344/dereferencing-perl-hashes</guid>
    </item>
    <item>
      <author>nobody@example.com (John Smith)</author>
      <dc:creator>nobody@example.com (John Smith)</dc:creator>
      <category>perl endianness</category>
      <link>http://stackoverflow.com/questions/6794307/how-do-i-convert-little-endian-to-big-endian-using-a-perl-script</link>
      <description>I just want to take a file in linux which is in binary form and convert
the data to big endian. I tried using the unpack("H*", $StringIn") but it
didn't work.</description>
      <dc:date>2011-07-22T18:14:00Z</dc:date>
      <dc:subject>perl endianness</dc:subject>
      <title>How do I convert little Endian to Big Endian using a Perl Script?</title>
      <pubDate>Fri, 22 Jul 2011 18:14:00 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I just want to take a file in linux which is in binary form and convert the data to big endian. I tried using the unpack("H*", $StringIn") but it didn't work.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T18:14:00Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6794307/how-do-i-convert-little-endian-to-big-endian-using-a-perl-script</guid>
    </item>
    <item>
      <author>nobody@example.com (Nemo)</author>
      <dc:creator>nobody@example.com (Nemo)</dc:creator>
      <category>perl templates</category>
      <link>http://stackoverflow.com/questions/6794142/perl-safe-templating-language</link>
      <description>Here are already several questions in SO about the safe template
languages, like:

  * Safe ERB Language?

  * templating system that is safe for end users to edit

  * Is there a “safe” subset of Python for use as an embedded scripting
    language?

  * Is Django's templating markup for views safe for end user editing
    like rails liquid templating

but the above questions are for asp, ruby, python.

My question is: What templating language can allow to be edited by users
in perl based web-app?

I want allow for users edit pages, (like in an wiki) with some
programming possibilities, so full featured mean with cycles,
conditionals, variable substitutions, includes and so on.

Is TT "enough safe"? Is here another solution as TT?</description>
      <dc:date>2011-07-22T17:59:32Z</dc:date>
      <dc:subject>perl templates</dc:subject>
      <title>Perl: Safe templating language</title>
      <pubDate>Fri, 22 Jul 2011 17:59:32 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;Here are already several questions in SO about the &lt;strong&gt;safe template languages&lt;/strong&gt;, like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/q/1716214/771480"&gt;Safe ERB Language&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/q/5567221/771480"&gt;templating system that is safe for end users to edit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/q/861864/771480"&gt;Is there a “safe” subset of Python for use as an embedded scripting language&lt;/a&gt;?&lt;/li&gt;
&lt;li&gt;&lt;a href="http://stackoverflow.com/q/4219735/771480"&gt;Is Django's templating markup for views safe for end user editing like rails liquid templating&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;but the above questions are for asp, ruby, python.&lt;/p&gt;

&lt;p&gt;My question is: What templating language &lt;strong&gt;can allow to be edited by users&lt;/strong&gt; in perl based web-app?&lt;/p&gt;

&lt;p&gt;I want allow for users edit pages, (like in an wiki) with some programming possibilities, so full featured mean with cycles, conditionals, variable substitutions, includes and so on.&lt;/p&gt;

&lt;p&gt;Is TT "enough safe"? Is here another solution as TT?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T17:59:32Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6794142/perl-safe-templating-language</guid>
    </item>
    <item>
      <author>nobody@example.com (lwijono)</author>
      <dc:creator>nobody@example.com (lwijono)</dc:creator>
      <category>perl</category>
      <link>http://stackoverflow.com/questions/6793787/perl-problem-require-the-same-file</link>
      <description>I have a shared module in perl. The main program needs two files, first,
a shared file (let's call it 'X'), and, second, a 'package' file. File
'X' is also included in the 'package' file using 'require'. When I
compile this program it gives me the following error:

Undefined subroutine &amp;main::trim called at testing.pl line 8.

My understanding is that perl couldn't find the trim() module. If I don't
include the package file, then this will run without any problem.

Can anyone shed light on this problem?

These are my codes:

Main program: testing.pl

#!/usr/bin/perl -w

use strict;
use postgres;

require "shared.pl";

trim("als");

Package File: postgres.pm

#!/usr/bin/perl

package postgres;

use strict;
use DBI;

require "shared.pl";

1;

shared file: shared.pl

#!/usr/bin/perl

# =============
# shared module 
# =============

use strict;

sub trim($)
{
}

1;</description>
      <dc:date>2011-07-22T17:28:15Z</dc:date>
      <dc:subject>perl</dc:subject>
      <title>Perl problem 'require' the same file</title>
      <pubDate>Fri, 22 Jul 2011 17:28:15 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have a shared module in perl. The main program needs two files, first, a shared file (let's call it 'X'), and, second, a 'package' file. File 'X' is also included in the 'package' file using 'require'. When I compile this program it gives me the following error:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Undefined subroutine &amp;amp;main::trim called at testing.pl line 8.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;My understanding is that perl couldn't find the trim() module. If I don't include the package file, then this will run without any problem.&lt;/p&gt;

&lt;p&gt;Can anyone shed light on this problem?&lt;/p&gt;

&lt;p&gt;These are my codes:&lt;/p&gt;

&lt;p&gt;Main program: testing.pl&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl -w

use strict;
use postgres;

require "shared.pl";

trim("als");
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Package File: postgres.pm&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl

package postgres;

use strict;
use DBI;

require "shared.pl";

1;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;shared file: shared.pl&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl

# =============
# shared module 
# =============

use strict;

sub trim($)
{
}

1;
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T17:28:15Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6793787/perl-problem-require-the-same-file</guid>
    </item>
    <item>
      <author>nobody@example.com (Craig)</author>
      <dc:creator>nobody@example.com (Craig)</dc:creator>
      <category>eclipse perl ide build path</category>
      <link>http://stackoverflow.com/questions/6793732/how-do-i-set-the-build-path-for-e-p-i-c-in-eclipse-galileo</link>
      <description>I have E-P-I-C installed on Eclipse Galileo. When I go to run a Perl
script nothing happens because I don't believe is any connection from
Eclipse to the Perl SDK (is that the right term? I don't know if it is
different because it's Perl).

I'm pretty sure it has something to do with C:\Perl\bin

If I click on Perl E-P-I-C project and click on properties I can then see
Perl include Path. I have added the above but it didn't change anything.

What this comes down to is: How do I set up the build path for Perl in
Eclipse Galileo?</description>
      <dc:date>2011-07-22T17:24:44Z</dc:date>
      <dc:subject>eclipse perl ide build path</dc:subject>
      <title>How do I set the build path for E-P-I-C in Eclipse Galileo?</title>
      <pubDate>Fri, 22 Jul 2011 17:24:44 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have E-P-I-C installed on Eclipse Galileo. When I go to run a Perl script nothing happens because I don't believe is any connection from Eclipse to the Perl SDK (is that the right term? I don't know if it is different because it's Perl).&lt;/p&gt;

&lt;p&gt;I'm pretty sure it has something to do with &lt;code&gt;C:\Perl\bin&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;If I click on Perl E-P-I-C project and click on properties I can then see 
Perl include Path. I have added the above but it didn't change anything.&lt;/p&gt;

&lt;p&gt;What this comes down to is: How do I set up the build path for Perl in Eclipse Galileo? &lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T17:24:44Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6793732/how-do-i-set-the-build-path-for-e-p-i-c-in-eclipse-galileo</guid>
    </item>
    <item>
      <author>nobody@example.com (Johannes Ernst)</author>
      <dc:creator>nobody@example.com (Johannes Ernst)</dc:creator>
      <category>perl osx cpan osx-10.7</category>
      <link>http://stackoverflow.com/questions/6793499/perl-config-h-needed-by-makefile-problem-after-osx-lion-upgrade</link>
      <description>SOLVED. See at bottom.

Just upgraded to OSX Lion and trying to get my Perl install running
again:

sudo /usr/bin/perl -MCPAN -e 'install "MODULENAME"'

with any value of MODULENAME that I tried (e.g. JSON) produces:

...
Checking if your kit is complete...
Looks good
Writing Makefile for JSON
make: *** No rule to make target `/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/config.h', needed by `Makefile'.  Stop.
  MAKAMAKA/JSON-2.53.tar.gz
  /Developer/usr/bin/make -- NOT OK

I can't find anything resembling config.h anywhere, the directory exists
though ...

Not even this works:

/usr/bin/cpan CPAN

SOLVED: Download and install latest version of XCode from AppStore. Note
that just downloading XCode from AppStore does not install it (why,
Apple, oh why?) but only dumps an installer into /Applications. Run the
installer, which will fix this issue.</description>
      <dc:date>2011-07-22T17:03:02Z</dc:date>
      <dc:subject>perl osx cpan osx-10.7</dc:subject>
      <title>perl ".../config.h, needed by `Makefile'" problem after OSX Lion upgrade</title>
      <pubDate>Fri, 22 Jul 2011 17:03:02 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;SOLVED. See at bottom.&lt;/p&gt;

&lt;p&gt;Just upgraded to OSX Lion and trying to get my Perl install running again:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;sudo /usr/bin/perl -MCPAN -e 'install "MODULENAME"'&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;with any value of &lt;code&gt;MODULENAME&lt;/code&gt; that I tried (e.g. &lt;code&gt;JSON&lt;/code&gt;) produces:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;...
Checking if your kit is complete...
Looks good
Writing Makefile for JSON
make: *** No rule to make target `/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE/config.h', needed by `Makefile'.  Stop.
  MAKAMAKA/JSON-2.53.tar.gz
  /Developer/usr/bin/make -- NOT OK
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I can't find anything resembling &lt;code&gt;config.h&lt;/code&gt; anywhere, the directory exists though ...&lt;/p&gt;

&lt;p&gt;Not even this works:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;/usr/bin/cpan CPAN
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;SOLVED: Download and install latest version of XCode from AppStore. Note that just downloading XCode from AppStore does not install it (why, Apple, oh why?) but only dumps an installer into /Applications. Run the installer, which will fix this issue.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T17:03:02Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6793499/perl-config-h-needed-by-makefile-problem-after-osx-lion-upgrade</guid>
    </item>
    <item>
      <author>nobody@example.com (thebourneid)</author>
      <dc:creator>nobody@example.com (thebourneid)</dc:creator>
      <category>perl</category>
      <link>http://stackoverflow.com/questions/6793384/how-to-use-htmltokeparser-to-extract-data</link>
      <description>I want to write a code to extract specific information from the imdb.com
Awards Section. With the below snippet I can print the text as a whole

use strict; 
use warnings;
use autodie;
use utf8;
use WWW::Mechanize;
use HTML::TokeParser;

#Example
my $url = 'http://www.imdb.com/title/tt1375666/awards';

my $mech = WWW::Mechanize-&gt;new;
$mech-&gt;agent_alias( 'Windows Mozilla' );
$mech-&gt;get( $url );

if ($mech-&gt;find_link(text_regex =&gt; qr/(?:Academy Awards|Golden Globes)/i)) {

    my $tp = HTML::TokeParser-&gt;new(\$mech-&gt;content);

    while (my $token = $tp-&gt;get_tag('big')) {
        $token = $tp-&gt;get_trimmed_text('big');
        if ( $token =~ /(?:Academy Awards|Golden Globes)/ ) {

            print "$token\n";

        }
    }

}

but I don't know how to separate the different tokens because most of
them have the same tags and also how to define the loop for each
'category/recipient' and print on new line if present.

my $year = $tp-&gt;get_trimmed_text();
my $result = $tp-&gt;get_trimmed_text();
my $award = $tp-&gt;get_trimmed_text();
my $category = $tp-&gt;get_trimmed_text();
my $recipient = $tp-&gt;get_trimmed_text();

print "$year $result $award $category $recipient\n"

  1. $year Won Oscar $category $recipient1..n

  2. etc.

  3. $year Nominated Oscar $category $recipient1..n

  4. etc.

  5. $year Won Golden Globe $category $recipient1..n

  6. etc

  7. $year Nominated Golden Globe $category $recipient1..n

  8. etc.

I'm not sure if this is the most efficient approach but I also tried
HTML::TableExtract with much less success.

Thanks.</description>
      <dc:date>2011-07-22T16:52:41Z</dc:date>
      <dc:subject>perl</dc:subject>
      <title>How to use HTML::TokeParser to extract data</title>
      <pubDate>Fri, 22 Jul 2011 16:52:41 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I want to write a code to extract specific information from the imdb.com Awards Section. With the below snippet I can print the text as a whole&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use strict; 
use warnings;
use autodie;
use utf8;
use WWW::Mechanize;
use HTML::TokeParser;

#Example
my $url = 'http://www.imdb.com/title/tt1375666/awards';

my $mech = WWW::Mechanize-&amp;gt;new;
$mech-&amp;gt;agent_alias( 'Windows Mozilla' );
$mech-&amp;gt;get( $url );

if ($mech-&amp;gt;find_link(text_regex =&amp;gt; qr/(?:Academy Awards|Golden Globes)/i)) {

    my $tp = HTML::TokeParser-&amp;gt;new(\$mech-&amp;gt;content);

    while (my $token = $tp-&amp;gt;get_tag('big')) {
        $token = $tp-&amp;gt;get_trimmed_text('big');
        if ( $token =~ /(?:Academy Awards|Golden Globes)/ ) {

            print "$token\n";

        }
    }

}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;but I don't know how to separate the different tokens because most of them have the same tags and also how to define the loop for each 'category/recipient' and print on new line if present.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $year = $tp-&amp;gt;get_trimmed_text();
my $result = $tp-&amp;gt;get_trimmed_text();
my $award = $tp-&amp;gt;get_trimmed_text();
my $category = $tp-&amp;gt;get_trimmed_text();
my $recipient = $tp-&amp;gt;get_trimmed_text();
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;print "$year $result $award $category $recipient\n"&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;$year Won Oscar $category $recipient1..n&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;li&gt;$year Nominated Oscar $category $recipient1..n&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;li&gt;$year Won Golden Globe $category $recipient1..n&lt;/li&gt;
&lt;li&gt;etc&lt;/li&gt;
&lt;li&gt;$year Nominated Golden Globe $category $recipient1..n&lt;/li&gt;
&lt;li&gt;etc.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I'm not sure if this is the most efficient approach but I also tried HTML::TableExtract with much less success.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T16:52:41Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6793384/how-to-use-htmltokeparser-to-extract-data</guid>
    </item>
    <item>
      <author>nobody@example.com (gangabass)</author>
      <dc:creator>nobody@example.com (gangabass)</dc:creator>
      <category>perl email gmail tls</category>
      <link>http://stackoverflow.com/questions/6793291/sending-email-via-gmail</link>
      <description>I have email sending code which doesn't work without any error messages
(by "doesn't work" i mean all seams OK but i have no message in my mail
box):

use strict;
use warnings;
use Email::Send;
use Email::Simple::Creator;

report_update();

sub report_update {

    my $mailer = Email::Send-&gt;new(
        {
            mailer      =&gt; 'SMTP::TLS',
            mailer_args =&gt; [
                Host     =&gt; 'smtp.gmail.com',
                Port     =&gt; 587,
                User     =&gt; $CONFIG{EMAIL_USER},
                Password =&gt; $CONFIG{EMAIL_PASS},
                Hello    =&gt; 'localhost',
            ]
        }
    );

    my $email = Email::Simple-&gt;create(
        header =&gt; [
            From    =&gt; $CONFIG{EMAIL_USER},
            To      =&gt; $CONFIG{TARGET_EMAIL},
            Subject =&gt; 'Updated info finded!',
        ],
        body =&gt; 'Updated info finded!',
    );

    eval { $mailer-&gt;send($email) };
    die "Error sending email: $@" if $@;

    print "Finished!\n";
}

Could you give me a hint what's wrong with it?</description>
      <dc:date>2011-07-22T16:45:17Z</dc:date>
      <dc:subject>perl email gmail tls</dc:subject>
      <title>Sending email via Gmail</title>
      <pubDate>Fri, 22 Jul 2011 16:45:17 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I have email sending code which doesn't work without any error messages (by "doesn't work" i mean all seams OK but i have &lt;strong&gt;no message in my mail box&lt;/strong&gt;): &lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use strict;
use warnings;
use Email::Send;
use Email::Simple::Creator;

report_update();

sub report_update {

    my $mailer = Email::Send-&amp;gt;new(
        {
            mailer      =&amp;gt; 'SMTP::TLS',
            mailer_args =&amp;gt; [
                Host     =&amp;gt; 'smtp.gmail.com',
                Port     =&amp;gt; 587,
                User     =&amp;gt; $CONFIG{EMAIL_USER},
                Password =&amp;gt; $CONFIG{EMAIL_PASS},
                Hello    =&amp;gt; 'localhost',
            ]
        }
    );

    my $email = Email::Simple-&amp;gt;create(
        header =&amp;gt; [
            From    =&amp;gt; $CONFIG{EMAIL_USER},
            To      =&amp;gt; $CONFIG{TARGET_EMAIL},
            Subject =&amp;gt; 'Updated info finded!',
        ],
        body =&amp;gt; 'Updated info finded!',
    );

    eval { $mailer-&amp;gt;send($email) };
    die "Error sending email: $@" if $@;

    print "Finished!\n";
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Could you give me a hint what's wrong with it?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T16:45:17Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6793291/sending-email-via-gmail</guid>
    </item>
    <item>
      <author>nobody@example.com (Shahab)</author>
      <dc:creator>nobody@example.com (Shahab)</dc:creator>
      <category>perl https</category>
      <link>http://stackoverflow.com/questions/6791608/problems-with-cryptssleay-and-using-https-request</link>
      <description>I'm trying to connect to a website via HTTPS, by sending a WWW::Mechanize
get request and whenever I try and run my script I get this error:

  This Application has faile to start because libeay32_.dll was not
  found. Re-installing the application may fix this problem

And inside the command prompt I get:

  Error GETing http...: can't load
  'C:/strawberry/perl/vendor/lib/auto/Crypt/SSLeay/SSLeay.dll for
  module Crypt::SSLeay: load_file: The specified module could not be
  found (Crypt::SSLeay or IO::Socket::SSL no installed) at ...

I don't understand the problem because I'm very new to programming with
Perl. Crypt::SSLeay is installed, the .dll is in the proper location and
IO::Socket::SSL is also installed, or whenever I try to install it via
cpan i get the libeay error again. The libeay32_.dll is located in the
C:\straberry\c\bin. I don't have full access right to the computer
because I am doing this from work. If someone could explain to me the
reason for the problem it would be appreciated.</description>
      <dc:date>2011-07-22T14:36:33Z</dc:date>
      <dc:subject>perl https</dc:subject>
      <title>problems with Crypt::SSLeay and using HTTPS request?</title>
      <pubDate>Fri, 22 Jul 2011 14:36:33 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I'm trying to connect to a website via HTTPS, by sending a WWW::Mechanize get request and whenever I try and run my script I get this error:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;This Application has faile to start because libeay32_.dll was not found. Re-installing the application may fix this problem &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And inside the command prompt I get:&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Error GETing http...: can't load 'C:/strawberry/perl/vendor/lib/auto/Crypt/SSLeay/SSLeay.dll for module Crypt::SSLeay: load_file: The specified module could not be found (Crypt::SSLeay or IO::Socket::SSL no installed) at ...&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;I don't understand the problem because I'm very new to programming with Perl. Crypt::SSLeay is installed, the .dll is in the proper location and IO::Socket::SSL is also installed, or whenever I try to install it via cpan i get the libeay error again. The libeay32_.dll is located in the C:\straberry\c\bin. I don't have full access right to the computer because I am doing this from work. If someone could explain to me the reason for the problem it would be appreciated.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T14:36:33Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6791608/problems-with-cryptssleay-and-using-https-request</guid>
    </item>
    <item>
      <author>nobody@example.com (Weiyan)</author>
      <dc:creator>nobody@example.com (Weiyan)</dc:creator>
      <category>perl mongodb</category>
      <link>http://stackoverflow.com/questions/6788896/mongodb-add-drop-elements-in-a-field-of-array-of-hash-how-to</link>
      <description>I am using perl MongoDBx::Class, following the tutorial I inserted the
document below. The tags field is an array of hash. Tried to remove tag
and add tag using mongodb's $pull and $addToSet function without success.

How to add/drop elements to/from tags field? If you are not a perl
programmer, answer in mongodb shell command also wlcome.

Thanks.

my $novel = $novels_coll-&gt;insert({
   _class =&gt; 'Novel',
   title =&gt; 'The Valley of Fear',
   year =&gt; 1914,
   author =&gt; {
      first_name =&gt; 'Arthur',
      middle_name =&gt; 'Conan',
      last_name =&gt; 'Doyle',
   },
   added =&gt; DateTime-&gt;now(time_zone =&gt; 'Asia/Jerusalem'),
   tags =&gt; [
      { category =&gt; 'mystery', subcategory =&gt; 'thriller' },
      { category =&gt; 'mystery', subcategory =&gt; 'detective' },
      { category =&gt; 'crime', subcategory =&gt; 'fiction' },
   ],
});

This is the document inserted:

{
    "_id": {
        "$oid": "4e27eae3008a6ee40f000000"
    },
    "_class": "Novel",
    "added": "2011-07-21T12:01:23+03:00",
    "author": {
        "middle_name": "Conan",
        "last_name": "Doyle",
        "first_name": "Arthur"
    },
    "tags": [
        {
            "subcategory": "thriller",
            "category": "mystery"
        },
        {
            "subcategory": "detective",
            "category": "mystery"
        },
        {
            "subcategory": "fiction",
            "category": "crime"
        }
    ],
    "title": "The Valley of Fear",
    "year": 1914
}

Edit:

After deeper exploration of MongoDBX, the update method overrided offical
MongoDB driver, so the $pull, $addToSet may not work. I will use this
stupid method:

my $novel = $novel_coll-&gt;find_one({ some criteria });
my @tags = $novel-&gt;tags;
my @updated_tags = grep(unless($tag{category=&gt;CATEGORY}, @tags);  #to pull out unwanted tag. Or use push to add new tag.
$novel-&gt;update({tags=&gt;\@updated_tags});

I hope MongoDBx has method to updated arrayRef field.</description>
      <dc:date>2011-07-22T10:47:50Z</dc:date>
      <dc:subject>perl mongodb</dc:subject>
      <title>MongoDB--add/drop elements in a field of array of hash how to</title>
      <pubDate>Fri, 22 Jul 2011 10:47:50 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I am using perl MongoDBx::Class, following the tutorial I inserted the document below. 
The tags field is an array of hash. Tried to remove tag and add tag using mongodb's $pull and $addToSet function without success. &lt;/p&gt;

&lt;p&gt;How to add/drop elements to/from tags field? If you are not a perl programmer, answer in mongodb shell command also wlcome.&lt;/p&gt;

&lt;p&gt;Thanks.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $novel = $novels_coll-&amp;gt;insert({
   _class =&amp;gt; 'Novel',
   title =&amp;gt; 'The Valley of Fear',
   year =&amp;gt; 1914,
   author =&amp;gt; {
      first_name =&amp;gt; 'Arthur',
      middle_name =&amp;gt; 'Conan',
      last_name =&amp;gt; 'Doyle',
   },
   added =&amp;gt; DateTime-&amp;gt;now(time_zone =&amp;gt; 'Asia/Jerusalem'),
   tags =&amp;gt; [
      { category =&amp;gt; 'mystery', subcategory =&amp;gt; 'thriller' },
      { category =&amp;gt; 'mystery', subcategory =&amp;gt; 'detective' },
      { category =&amp;gt; 'crime', subcategory =&amp;gt; 'fiction' },
   ],
});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This is the document inserted:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;{
    "_id": {
        "$oid": "4e27eae3008a6ee40f000000"
    },
    "_class": "Novel",
    "added": "2011-07-21T12:01:23+03:00",
    "author": {
        "middle_name": "Conan",
        "last_name": "Doyle",
        "first_name": "Arthur"
    },
    "tags": [
        {
            "subcategory": "thriller",
            "category": "mystery"
        },
        {
            "subcategory": "detective",
            "category": "mystery"
        },
        {
            "subcategory": "fiction",
            "category": "crime"
        }
    ],
    "title": "The Valley of Fear",
    "year": 1914
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Edit: &lt;/p&gt;

&lt;p&gt;After deeper exploration of MongoDBX, the update method overrided offical MongoDB driver, so the $pull, $addToSet may not work. I will use this stupid method:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;my $novel = $novel_coll-&amp;gt;find_one({ some criteria });
my @tags = $novel-&amp;gt;tags;
my @updated_tags = grep(unless($tag{category=&amp;gt;CATEGORY}, @tags);  #to pull out unwanted tag. Or use push to add new tag.
$novel-&amp;gt;update({tags=&amp;gt;\@updated_tags});
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I hope MongoDBx has method to updated arrayRef field.&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T10:47:50Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6788896/mongodb-add-drop-elements-in-a-field-of-array-of-hash-how-to</guid>
    </item>
    <item>
      <author>nobody@example.com (asker)</author>
      <dc:creator>nobody@example.com (asker)</dc:creator>
      <category>perl</category>
      <link>http://stackoverflow.com/questions/6787766/is-this-guaranteed-to-overwrite-hash1-with-hash2-when-conflict-arises</link>
      <description>%args = (%hash1,%hash2);

Is this guaranteed to overwrite %hash1 with %hash2 when conflict arises
in Perl?</description>
      <dc:date>2011-07-22T08:59:55Z</dc:date>
      <dc:subject>perl</dc:subject>
      <title>Is this guaranteed to overwrite %hash1 with %hash2 when conflict arises?</title>
      <pubDate>Fri, 22 Jul 2011 08:59:55 -0000</pubDate>
      <content:encoded>
            &lt;pre&gt;&lt;code&gt;%args = (%hash1,%hash2);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Is this guaranteed to overwrite &lt;code&gt;%hash1&lt;/code&gt; with &lt;code&gt;%hash2&lt;/code&gt; when conflict arises in Perl?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T08:59:55Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6787766/is-this-guaranteed-to-overwrite-hash1-with-hash2-when-conflict-arises</guid>
    </item>
    <item>
      <author>nobody@example.com (asker)</author>
      <dc:creator>nobody@example.com (asker)</dc:creator>
      <category>perl</category>
      <link>http://stackoverflow.com/questions/6787225/how-can-my-perl-code-catch-ctrld</link>
      <description>chomp($input = &lt;&gt;);

How do I know whether $input is Ctrl+D?</description>
      <dc:date>2011-07-22T08:09:13Z</dc:date>
      <dc:subject>perl</dc:subject>
      <title>How can my Perl code catch Ctrl+D?</title>
      <pubDate>Fri, 22 Jul 2011 08:09:13 -0000</pubDate>
      <content:encoded>
            &lt;pre&gt;&lt;code&gt;chomp($input = &amp;lt;&amp;gt;);
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;How do I know whether &lt;code&gt;$input&lt;/code&gt; is &lt;kbd&gt;Ctrl&lt;/kbd&gt;+&lt;kbd&gt;D&lt;/kbd&gt;?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T08:09:13Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6787225/how-can-my-perl-code-catch-ctrld</guid>
    </item>
    <item>
      <author>nobody@example.com (user857223)</author>
      <dc:creator>nobody@example.com (user857223)</dc:creator>
      <category>regex perl</category>
      <link>http://stackoverflow.com/questions/6785572/perl-replace-nth-substring-in-a-string</link>
      <description>i have a scenario, i need to replace the nth sub-string in a string.

s/sub-string/new-string/g; will replace all the sub strings. but i need
to do for a particular occurrence say (3rd Occurrence).

please help me with this

Thanks</description>
      <dc:date>2011-07-22T04:10:10Z</dc:date>
      <dc:subject>regex perl</dc:subject>
      <title>Perl replace nth substring in a string</title>
      <pubDate>Fri, 22 Jul 2011 04:10:10 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;i have a scenario, i need to replace the nth sub-string in a string. &lt;/p&gt;

&lt;p&gt;s/sub-string/new-string/g; will replace all the sub strings. but i need to do for a particular occurrence say (3rd Occurrence).&lt;/p&gt;

&lt;p&gt;please help me with this&lt;/p&gt;

&lt;p&gt;Thanks &lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T04:10:10Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6785572/perl-replace-nth-substring-in-a-string</guid>
    </item>
    <item>
      <author>nobody@example.com (xenoterracide)</author>
      <dc:creator>nobody@example.com (xenoterracide)</dc:creator>
      <category>perl</category>
      <link>http://stackoverflow.com/questions/6785462/why-do-some-functions-in-perl-have-to-be-called-with-parens-and-others-dont</link>
      <description>An example to illustrate is the Synopsis of my own Test::Version.

use Test::More;
use Test::Version 0.04;

# test blib or lib by default
version_all_ok();

done_testing;

I don't have to include parenthesis on done_testing(); I can simply call
it. However when I've tried to call version_all_ok; ( note: First attempt
at Dist::Zilla::Plugin::Test::Version failed this way) I get an error.
Why is this?

Update Perhaps my example is not quite as good as I've thought. The
actual error I've gotten is

Bareword "version_all_ok" not allowed while "strict subs" in use at t/release-test-version.t line 19.

and here's the full code

#!/usr/bin/perl

BEGIN {
  unless ($ENV{RELEASE_TESTING}) {
    require Test::More;
    Test::More::plan(skip_all =&gt; 'these tests are for release candidate testing');
  }
}

use 5.006;
use strict;
use warnings;
use Test::More;

eval "use Test::Version";
plan skip_all =&gt; "Test::Version required for testing versions"
    if $@;

version_all_ok; # of course line 19, and version_all_ok() works here.
done_testing;

The following should be relevant snippets pulled from Test::Version 1.0.0
for exportation.

use parent 'Exporter';
our @EXPORT = qw( version_all_ok ); ## no critic (Modules::ProhibitAutomaticExportation)
our @EXPORT_OK = qw( version_ok );</description>
      <dc:date>2011-07-22T03:51:29Z</dc:date>
      <dc:subject>perl</dc:subject>
      <title>Why do some functions in Perl have to be called with parens and others don't?</title>
      <pubDate>Fri, 22 Jul 2011 03:51:29 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;An example to illustrate is the Synopsis of my own &lt;a href="http://search.cpan.org/dist/Test-Version/lib/Test/Version.pm" rel="nofollow"&gt;&lt;code&gt;Test::Version&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use Test::More;
use Test::Version 0.04;

# test blib or lib by default
version_all_ok();

done_testing;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;I don't have to include parenthesis on &lt;code&gt;done_testing();&lt;/code&gt; I can simply call it. However when I've tried to call &lt;code&gt;version_all_ok;&lt;/code&gt; &lt;em&gt;( note: First attempt at Dist::Zilla::Plugin::Test::Version failed this way)&lt;/em&gt; I get an error. Why is this?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Update&lt;/strong&gt; Perhaps my example is not quite as good as I've thought. The actual error I've gotten is&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;Bareword "version_all_ok" not allowed while "strict subs" in use at t/release-test-version.t line 19.
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;and here's the full code&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;#!/usr/bin/perl

BEGIN {
  unless ($ENV{RELEASE_TESTING}) {
    require Test::More;
    Test::More::plan(skip_all =&amp;gt; 'these tests are for release candidate testing');
  }
}

use 5.006;
use strict;
use warnings;
use Test::More;

eval "use Test::Version";
plan skip_all =&amp;gt; "Test::Version required for testing versions"
    if $@;

version_all_ok; # of course line 19, and version_all_ok() works here.
done_testing;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;The following should be relevant snippets pulled from &lt;code&gt;Test::Version 1.0.0&lt;/code&gt; for exportation.&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use parent 'Exporter';
our @EXPORT = qw( version_all_ok ); ## no critic (Modules::ProhibitAutomaticExportation)
our @EXPORT_OK = qw( version_ok );
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-22T03:51:29Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6785462/why-do-some-functions-in-perl-have-to-be-called-with-parens-and-others-dont</guid>
    </item>
    <item>
      <author>nobody@example.com (Rubin)</author>
      <dc:creator>nobody@example.com (Rubin)</dc:creator>
      <category>perl cpan</category>
      <link>http://stackoverflow.com/questions/6783629/why-dont-i-see-race-conditions-when-my-processes-are-writing-to-file</link>
      <description>I use the Parallel::ForkManager module for fetching some pages. Below is
the relevant code snippet:

use Parallel::ForkManager;

open FILE,"&gt;myfile" or die "cann't open file$!";
$pm = new Parallel::ForkManager(5);

foreach $data (@all_data) {

    my $pid = $pm-&gt;start and next;
    #doing the fetching here and get the result on parsed_string

    print FILE $parsed_string;
    $pm-&gt;finish; # Terminates the child process
}

Could someone expain why the results are OK and don't overlap one with
the other even there is more than one process writing to the same File ?</description>
      <dc:date>2011-07-21T22:35:19Z</dc:date>
      <dc:subject>perl cpan</dc:subject>
      <title>Why don't I see race conditions when my processes are writing to file?</title>
      <pubDate>Thu, 21 Jul 2011 22:35:19 -0000</pubDate>
      <content:encoded>
            &lt;p&gt;I use the &lt;a href="http://search.cpan.org/perldoc?Parallel%3a%3aForkManager" rel="nofollow"&gt;&lt;code&gt;Parallel::ForkManager&lt;/code&gt;&lt;/a&gt; module for fetching some pages. Below is the relevant code snippet:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;use Parallel::ForkManager;

open FILE,"&amp;gt;myfile" or die "cann't open file$!";
$pm = new Parallel::ForkManager(5);

foreach $data (@all_data) {

    my $pid = $pm-&amp;gt;start and next;
    #doing the fetching here and get the result on parsed_string

    print FILE $parsed_string;
    $pm-&amp;gt;finish; # Terminates the child process
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Could someone expain why the results are OK and don't overlap one with the other even there is more than one process writing to the same File ?&lt;/p&gt;

        </content:encoded>
      <dcterms:modified>2011-07-21T22:35:19Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6783629/why-dont-i-see-race-conditions-when-my-processes-are-writing-to-file</guid>
    </item>
    <item>
      <author>nobody@example.com (Will Fix)</author>
      <dc:creator>nobody@example.com (Will Fix)</dc:creator>
      <category>windows perl vbscript</category>
      <link>http://stackoverflow.com/questions/6783203/perl-vb-script-migrate-to-new-printer-server-match-delete-printer-locally</link>
      <description>  This script will effectively migrate to new print server and delete,
  for example, these printers (short share name):

  printer name=\\p1\(share)Laserjet 1000 -- share name/UNC
  path=\\p1\share

  printer name=\\p1\(share1)Laser 1000 -- share name/UNC
  path=\\p1\share1

  If I have a printer with a long share name/UNC Path, it won't remove
  that printer:

  printer name=\\p1\(share)Laserjet 1000 -- share name/UNC
  path=\\p1\(share)Laserjet1000

  printer name=\\p1\(share1)Laser 1000 -- share name/UNC
  path=\\p1\(share1)UniversalHP

  Rules:

    1. I cannot use WMI, as not everyone has WMI running..

    2. I need to stick to languages that do not require any framework
      to be installed..this is why i chose PERL and VBScript.

    3. The parentheses always exists, and always has the correct share
      name in it.

  Idea: I imagine I have to use "net view" to match the printer name
  with the actual share name..I want to implement something like this,
  to remove printers with long share names:

sub RemovePrinterLong
{
print "Long printer names:";
my @list = `net view $OldServer`;
foreach my $line (@list)
{
if($line =~ /sharename/i)
{
my($shr,$rest) = split(/Print/,$line);
$shr =~ s/\s+$//;
if($shr =~ /sharename\)/i)
{
print "\\\\$OldServer\\$shr\n"; 
}
#$line =~ /^\s*(.)\s+Print\s+/; $newLine = $1;
#print "=$newLine=";
}
}
}

Basically, I want it to catch if it's a long share name by catching the
parentheses and then run a net view on the old server to create a vbs
script to remove those printers with long share names...

  Here is the PERL script:

#this script will not migrate novaPDF pritter
my @printers;
my %PQ2;
my %PQ;
my @NewPQ;
my $NewServer = "P3";
my $OldServer = "P1";

#Retrive print queues info from the new network print server
print "Generating a printer list on $NewServer..\n";
@NewPQ = `net view $NewServer`;


#Create a required TEMP folder on C:
system("md C:\\TEMP") if(not (-e "C:\\TEMP"));

#Create a VBScripts to enumerate network printer connections
open(OUTFILE,"&gt;C:\\TEMP\\EnumPQ.vbs") or die "Unable to create TEMP file";

print OUTFILE  "Option Explicit\n";
print OUTFILE  "Dim objNetwork, objPrinter, intDrive, intNetLetter\n";
print OUTFILE  "Set objNetwork = CreateObject(\"WScript\.Network\")\n";
print OUTFILE  "Set objPrinter = objNetwork.EnumPrinterConnections\n";
print OUTFILE  "For intDrive = 0 To (objPrinter.Count -1) Step 2\n";
print OUTFILE  "  intNetLetter = IntNetLetter +1\n";
print OUTFILE  "  Wscript.Echo objPrinter.Item(intDrive +1)\n";
print OUTFILE  "Next\n";
print OUTFILE  "Wscript\.Quit(1)\n";

close OUTFILE;

#Run VBScript EnumPQ.vbs to generate a list of connected network printers
print "Enumerating local printers...\n";
my @results = `cscript c:\\TEMP\\EnumPQ.vbs`;
print "Local printer enumeration complete\n";

my $FOUND = 0;
#Search for printer(s) on PQ1
foreach my $rec (@results)
{
    chomp $rec;

    next if($rec =~ /nova/i); #bypass nova PDF printer
    #Searching for old server in the form of \\ServerName
    if($rec =~ /\\\\$OldServer/i)
    {
        #Exp rec=\\P1\(05-103) HP Color LaserJet 4650 PS 6=
        push @printers, $rec;
        $FOUND = 1;
    }
}

if($FOUND)
{
    &amp;RemovePrinter();
    &amp;AddPrinter();
}
else
{
    print "No network printer on $OldServer found..\n"
}

exit 0; #exit main
#===============================================================================
#Creat a VB script to remove network printer(s)
#===============================================================================
sub RemovePrinter
{

   open(OUTFILE,"&gt;C:\\TEMP\\rmprint.vbs") or die "Error open outfile..";
   print OUTFILE 'Set WshNetwork = WScript.CreateObject("WScript.Network")'."\n\n";

   foreach my $printer (@printers)
   {
     $printer =~ m/^\\\\$OldServer\\\((.+)\)/i;
     $PQ2{$1} = "old printer";
   }

   foreach my $shrname (@NewPQ)
   {
     chomp $shrname;
     $shrname =~ m/^.+\((.+)\).+/i;
     $PQ{$1} = "New printer";
   }

   my @PQ2Printers = keys %PQ2;

   foreach my $prt (@PQ2Printers)
   {
      if(exists $PQ{$prt})
      {
         #Create VB Script to remove the found printers
         print OUTFILE "PrinterPath = \"\\\\$OldServer\\$prt\"\n";
         print OUTFILE "WshNetwork.RemovePrinterConnection PrinterPath, true, true\n\n";
      }
   }


   print OUTFILE  "Wscript\.Quit(1)\n";
   close OUTFILE;

   print "Deleting $OldServer printer(s)..\n";
   sleep 2;
   my $rm_results = `cscript c:\\TEMP\\rmprint.vbs`;
   #print "remove result:\n";
   #print $rm_results."\n";


}#end sub RemovePrinter
#===============================================================================
#Create a VB script to add network printers
#===============================================================================
sub AddPrinter
{
   open(OUTFILE,"&gt;C:\\TEMP\\addprint.vbs") or die "Error open outfile..";
   print OUTFILE 'Set WshNetwork = WScript.CreateObject("WScript.Network")'."\n\n";


   my @PQ2Printers = keys %PQ2;

   #if old printer exists on new server, map it.
   foreach my $prt (@PQ2Printers)
   {
      if(exists $PQ{$prt})
      {
         #Create VB Script to map the found printers to new server
         print OUTFILE "PrinterPath = \"\\\\$NewServer\\$prt\"\n";
         print OUTFILE "WshNetwork.AddWindowsPrinterConnection PrinterPath, true, true\n\n";
         print "Remapping $OldServer printer to: \\\\$NewServer\\$prt\n";
      }
   }

   print OUTFILE  "Wscript\.Quit(1)\n";
   close OUTFILE;

   sleep 2;
   my $add_results = `cscript c:\\TEMP\\addprint.vbs`;
   #print "Add result:\n";
   #print $add_results."\n";

}#end sub AddPrinter
#===============================================================================</description>
      <dc:date>2011-07-21T21:43:38Z</dc:date>
      <dc:subject>windows perl vbscript</dc:subject>
      <title>PERL -- VB Script migrate to new printer server, match &amp; delete printer locally -- HELP with printer that have long share names..</title>
      <pubDate>Thu, 21 Jul 2011 21:43:38 -0000</pubDate>
      <content:encoded>
            &lt;blockquote&gt;
  &lt;p&gt;This script will effectively migrate to new print server and delete, for example, these printers (short share name):&lt;/p&gt;
  
  &lt;p&gt;printer name=\\p1\(share)Laserjet 1000  -- share name/UNC path=\\p1\share&lt;/p&gt;
  
  &lt;p&gt;printer name=\\p1\(share1)Laser 1000  -- share name/UNC path=\\p1\share1&lt;/p&gt;
  
  &lt;p&gt;If I have a printer with a long share name/UNC Path, it won't remove that printer:&lt;/p&gt;
  
  &lt;p&gt;printer name=\\p1\(share)Laserjet 1000  -- share name/UNC path=\\p1\(share)Laserjet1000&lt;/p&gt;
  
  &lt;p&gt;printer name=\\p1\(share1)Laser 1000  -- share name/UNC path=\\p1\(share1)UniversalHP&lt;/p&gt;
  
  &lt;p&gt;Rules:&lt;/p&gt;
  
  &lt;ol&gt;
  &lt;li&gt;I cannot use WMI, as not everyone has WMI running..&lt;/li&gt;
  &lt;li&gt;I need to stick to languages that do not require any framework to be installed..this is why i chose PERL and VBScript.&lt;/li&gt;
  &lt;li&gt;The parentheses always exists, and always has the correct share name in it.&lt;/li&gt;
  &lt;/ol&gt;
  
  &lt;p&gt;Idea: I imagine I have to use "net view" to match the printer name with the actual share name..I want to implement something like this, to remove printers with long share names:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre&gt;&lt;code&gt;sub RemovePrinterLong
{
print "Long printer names:";
my @list = `net view $OldServer`;
foreach my $line (@list)
{
if($line =~ /sharename/i)
{
my($shr,$rest) = split(/Print/,$line);
$shr =~ s/\s+$//;
if($shr =~ /sharename\)/i)
{
print "\\\\$OldServer\\$shr\n"; 
}
#$line =~ /^\s*(.)\s+Print\s+/; $newLine = $1;
#print "=$newLine=";
}
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;Basically, I want it to catch if it's a long share name by catching the parentheses and then run a net view on the old server to create a vbs script to remove those printers with long share names...&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;Here is the PERL script:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;pre&gt;&lt;code&gt;#this script will not migrate novaPDF pritter
my @printers;
my %PQ2;
my %PQ;
my @NewPQ;
my $NewServer = "P3";
my $OldServer = "P1";

#Retrive print queues info from the new network print server
print "Generating a printer list on $NewServer..\n";
@NewPQ = `net view $NewServer`;


#Create a required TEMP folder on C:
system("md C:\\TEMP") if(not (-e "C:\\TEMP"));

#Create a VBScripts to enumerate network printer connections
open(OUTFILE,"&amp;gt;C:\\TEMP\\EnumPQ.vbs") or die "Unable to create TEMP file";

print OUTFILE  "Option Explicit\n";
print OUTFILE  "Dim objNetwork, objPrinter, intDrive, intNetLetter\n";
print OUTFILE  "Set objNetwork = CreateObject(\"WScript\.Network\")\n";
print OUTFILE  "Set objPrinter = objNetwork.EnumPrinterConnections\n";
print OUTFILE  "For intDrive = 0 To (objPrinter.Count -1) Step 2\n";
print OUTFILE  "  intNetLetter = IntNetLetter +1\n";
print OUTFILE  "  Wscript.Echo objPrinter.Item(intDrive +1)\n";
print OUTFILE  "Next\n";
print OUTFILE  "Wscript\.Quit(1)\n";

close OUTFILE;

#Run VBScript EnumPQ.vbs to generate a list of connected network printers
print "Enumerating local printers...\n";
my @results = `cscript c:\\TEMP\\EnumPQ.vbs`;
print "Local printer enumeration complete\n";

my $FOUND = 0;
#Search for printer(s) on PQ1
foreach my $rec (@results)
{
    chomp $rec;

    next if($rec =~ /nova/i); #bypass nova PDF printer
    #Searching for old server in the form of \\ServerName
    if($rec =~ /\\\\$OldServer/i)
    {
        #Exp rec=\\P1\(05-103) HP Color LaserJet 4650 PS 6=
        push @printers, $rec;
        $FOUND = 1;
    }
}

if($FOUND)
{
    &amp;amp;RemovePrinter();
    &amp;amp;AddPrinter();
}
else
{
    print "No network printer on $OldServer found..\n"
}

exit 0; #exit main
#===============================================================================
#Creat a VB script to remove network printer(s)
#===============================================================================
sub RemovePrinter
{

   open(OUTFILE,"&amp;gt;C:\\TEMP\\rmprint.vbs") or die "Error open outfile..";
   print OUTFILE 'Set WshNetwork = WScript.CreateObject("WScript.Network")'."\n\n";

   foreach my $printer (@printers)
   {
     $printer =~ m/^\\\\$OldServer\\\((.+)\)/i;
     $PQ2{$1} = "old printer";
   }

   foreach my $shrname (@NewPQ)
   {
     chomp $shrname;
     $shrname =~ m/^.+\((.+)\).+/i;
     $PQ{$1} = "New printer";
   }

   my @PQ2Printers = keys %PQ2;

   foreach my $prt (@PQ2Printers)
   {
      if(exists $PQ{$prt})
      {
         #Create VB Script to remove the found printers
         print OUTFILE "PrinterPath = \"\\\\$OldServer\\$prt\"\n";
         print OUTFILE "WshNetwork.RemovePrinterConnection PrinterPath, true, true\n\n";
      }
   }


   print OUTFILE  "Wscript\.Quit(1)\n";
   close OUTFILE;

   print "Deleting $OldServer printer(s)..\n";
   sleep 2;
   my $rm_results = `cscript c:\\TEMP\\rmprint.vbs`;
   #print "remove result:\n";
   #print $rm_results."\n";


}#end sub RemovePrinter
#===============================================================================
#Create a VB script to add network printers
#===============================================================================
sub AddPrinter
{
   open(OUTFILE,"&amp;gt;C:\\TEMP\\addprint.vbs") or die "Error open outfile..";
   print OUTFILE 'Set WshNetwork = WScript.CreateObject("WScript.Network")'."\n\n";


   my @PQ2Printers = keys %PQ2;

   #if old printer exists on new server, map it.
   foreach my $prt (@PQ2Printers)
   {
      if(exists $PQ{$prt})
      {
         #Create VB Script to map the found printers to new server
         print OUTFILE "PrinterPath = \"\\\\$NewServer\\$prt\"\n";
         print OUTFILE "WshNetwork.AddWindowsPrinterConnection PrinterPath, true, true\n\n";
         print "Remapping $OldServer printer to: \\\\$NewServer\\$prt\n";
      }
   }

   print OUTFILE  "Wscript\.Quit(1)\n";
   close OUTFILE;

   sleep 2;
   my $add_results = `cscript c:\\TEMP\\addprint.vbs`;
   #print "Add result:\n";
   #print $add_results."\n";

}#end sub AddPrinter
#===============================================================================
&lt;/code&gt;&lt;/pre&gt;

        </content:encoded>
      <dcterms:modified>2011-07-21T21:43:38Z</dcterms:modified>
      <guid isPermaLink="false">tag:insel,2006:http://stackoverflow.com/questions/6783203/perl-vb-script-migrate-to-new-printer-server-match-delete-printer-locally</guid>
    </item>
  </channel>
</rss>

