[27902] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 9266 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 8 14:05:38 2006

Date: Thu, 8 Jun 2006 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 8 Jun 2006     Volume: 10 Number: 9266

Today's topics:
        [Fwd: Gtk and Glib::Timeout] <yg_blah_@this_domain.bla>
    Re: Active Perl Package Installation <bart.lateur@pandora.be>
    Re: Active Perl Package Installation razmaspaz@gmail.com
        array in hash <me@invalid.domain>
    Re: array in hash <David.Squire@no.spam.from.here.au>
    Re: array in hash <noreply@gunnar.cc>
        Converting XML to CSV <mark@gangwarily.ca>
    Re: Converting XML to CSV <glex_no-spam@qwest-spam-no.invalid>
    Re: Converting XML to CSV <DJStunks@gmail.com>
        Dealing with accented characters <mark@gangwarily.ca>
    Re: Dealing with accented characters <benmorrow@tiscali.co.uk>
    Re: default value <no@email.com>
    Re: filehandle to a member of a zip archive <fleming.scott@gmail.com>
    Re: filehandle to a member of a zip archive <fleming.scott@gmail.com>
        Finding all modular extensions to Perl on a system. dwmyers@my-deja.com
    Re: Finding all modular extensions to Perl on a system. <nobull67@gmail.com>
        hexadecimal addition <hara.acharya@gmail.com>
    Re: hexadecimal addition <mol10metal@hotmail.com>
    Re: hexadecimal addition <benmorrow@tiscali.co.uk>
        hi Mr.John Bokma <madan.narra@gmail.com>
        hi Mr.John Bokma <madan.narra@gmail.com>
    Re: hi Mr.John Bokma <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 08 Jun 2006 18:47:17 +0200
From: "Y.G." <yg_blah_@this_domain.bla>
Subject: [Fwd: Gtk and Glib::Timeout]
Message-Id: <e69kal$h98$1@info.science.uva.nl>

I am writing a program in perl which invokes a small window. This window
should time out after some time. For the window I use Gtk2. For the
timeout I use Glib::Timeout

The code looks something like this:

my $dialog  = new Gtk2::Dialog(  );

(creating some buttons and all)

my $timer = Glib::Timeout->add( $interval, \&some_func));

Gtk2->main;


This returns Not a CODE reference at /program_path line line_number

Should I use Glib (and how?) or is there any other function I should use.


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

Date: Thu, 08 Jun 2006 08:20:46 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Active Perl Package Installation
Message-Id: <38nf825d1uv5qq9mqefedkprqrnmaie8se@4ax.com>

razmaspaz@gmail.com wrote:

>I get the following error:
>Error: No valid repositories: Error: 500 Can't connect to
>ppm.ActiveState.com:80 (connect: Unknown error)
>
>I can ping theoryx5 and I can get the url to appear in the browser.  Am
>I missing something?

The fact that that repositiory probably isn't in your list of
repositories? Activestate and theoryx5 are different repositories.

Use "rep add" in the PPM shell to add it. Something like

	rep add theoryx5 http://theoryx5.uwinnipeg.ca/ppms/

-- 
	Bart.


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

Date: 8 Jun 2006 07:18:41 -0700
From: razmaspaz@gmail.com
Subject: Re: Active Perl Package Installation
Message-Id: <1149776321.704564.211630@h76g2000cwa.googlegroups.com>

Thank you all for the help to this point.  The problem was threefold.
First I did not have the theoryx5 in my repository list.  Second I did
not have the proxy configured for ppm.

Third, and this is still a problem, I get this error message:

Error: Failed to download URL http://theoryx5.uwinnipeg.ca/ppms/Crypt-
SSLeay.ppd: 501 Protocol scheme '' is not supported

I looked at the file that comes down, and I don't know what the scheme
is.  Any thoughts on what this might be?

Thanks,
Michael


Bart Lateur wrote:
> razmaspaz@gmail.com wrote:
>
> >I get the following error:
> >Error: No valid repositories: Error: 500 Can't connect to
> >ppm.ActiveState.com:80 (connect: Unknown error)
> >
> >I can ping theoryx5 and I can get the url to appear in the browser.  Am
> >I missing something?
>
> The fact that that repositiory probably isn't in your list of
> repositories? Activestate and theoryx5 are different repositories.
>
> Use "rep add" in the PPM shell to add it. Something like
>
> 	rep add theoryx5 http://theoryx5.uwinnipeg.ca/ppms/
> 
> -- 
> 	Bart.



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

Date: Thu, 08 Jun 2006 17:20:04 +0200
From: Me <me@invalid.domain>
Subject: array in hash
Message-Id: <4MydnWTwteyz3RXZnZ2dnUVZ_rWdnZ2d@is.co.za>


How do I add element to array which is a hash element?
So far I have:
====================
push ($data{"ny"}{list}, { dat=>2});
push ($data{"ny"}{list}, { dat=>5});
push ($data{"dc"}{list}, { dat=>9});

====================

which generatees the following:
====================
Type of arg 1 to push must be array (not hash element) at hash.pl line 
1, near "})"
Type of arg 1 to push must be array (not hash element) at hash.pl line 
2, near "})"
Type of arg 1 to push must be array (not hash element) at hash.pl line 
3, near "})"
=====================


I want to end up with something like:
data =>
{
     location => "ny"
     list = [
              {dat=>2},
              {dat=>5}
            ]
},
     location => "dc"
     list = [
              {dat=>9},
            ]
},



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

Date: Thu, 08 Jun 2006 16:34:04 +0100
From: David Squire <David.Squire@no.spam.from.here.au>
Subject: Re: array in hash
Message-Id: <e69g1c$sko$1@news.ox.ac.uk>

Me wrote:
> 
> How do I add element to array which is a hash element?

The important thing to remember here is that Perl lists and hashes are 
inherently one dimensional. The trick used to make seemingly 
multidimensional structures is to use references as the elements. See 
perldoc perldsc.

> So far I have:
> ====================
> push ($data{"ny"}{list}, { dat=>2});
> push ($data{"ny"}{list}, { dat=>5});
> push ($data{"dc"}{list}, { dat=>9});
> 
> ====================
> 
> which generatees the following:
> ====================
> Type of arg 1 to push must be array (not hash element) at hash.pl line 
> 1, near "})"
> Type of arg 1 to push must be array (not hash element) at hash.pl line 
> 2, near "})"
> Type of arg 1 to push must be array (not hash element) at hash.pl line 
> 3, near "})"
> =====================
> 

Yep. This is telling you exactly what the problem is. The first argument 
to push must be an array, so you need to dereference the array reference 
that is in the hash, viz:

----

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

use Data::Dumper;

my %data = (
	'ny' => {
		list => [],
	},
	'dc' => {
		list => [],
	},
);

push (@{$data{'ny'}{list}}, {dat => 2});
push (@{$data{'ny'}{list}}, {dat => 5});
push (@{$data{'dc'}{list}}, {dat => 9});

print Dumper(\%data);

----

Output:


$VAR1 = {
           'dc' => {
                     'list' => [
                                 {
                                   'dat' => 9
                                 }
                               ]
                   },
           'ny' => {
                     'list' => [
                                 {
                                   'dat' => 2
                                 },
                                 {
                                   'dat' => 5
                                 }
                               ]
                   }
         };


> I want to end up with something like:
> data =>
> {
>     location => "ny"
>     list = [
>              {dat=>2},
>              {dat=>5}
>            ]
> },
>     location => "dc"
>     list = [
>              {dat=>9},
>            ]
> },

This is not what your push statements said. Where was 'location' mentioned?


Regards,

DS


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

Date: Thu, 08 Jun 2006 17:46:04 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: array in hash
Message-Id: <4eqv1uF1fuucdU1@individual.net>

Me wrote:
> How do I add element to array which is a hash element?
> So far I have:
> ====================
> push ($data{"ny"}{list}, { dat=>2});
> push ($data{"ny"}{list}, { dat=>5});
> push ($data{"dc"}{list}, { dat=>9});

Maybe you mean:

     push @{ $data{"ny"}{list} }, { dat=>2 };

etc.

> I want to end up with something like:
> data =>
> {
>     location => "ny"
>     list = [
>              {dat=>2},
>              {dat=>5}
>            ]
> },
>     location => "dc"
>     list = [
>              {dat=>9},
>            ]
> },

Well, that's another thing. Keep on trying, and use Data::Dumper to 
study the resulting structure.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl


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

Date: Thu, 08 Jun 2006 10:48:47 -0400
From: Mark Drummond <mark@gangwarily.ca>
Subject: Converting XML to CSV
Message-Id: <pM2dneOsNbxNpRXZnZ2dneKdnZydnZ2d@magma.ca>

I have an application, Garmin Training Centre, which logs exercise data 
from my Garmin GPS/HRM. While the Training Centre provides all kinds of 
get data analysis, it does not do everything I like. I would like to be 
able to pull my exercise data into a spreadsheet or even a database 
where I can do more analysis.

The Training Center software allows me to export my data, but only in an 
XML format. I started writing a script to convert this to a CSV but I am 
wondering if using something like XML-Parser would make my life easier. 
I haven't done any work with XML files before.

Any suggestions?

Mark


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

Date: Thu, 08 Jun 2006 10:10:00 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Converting XML to CSV
Message-Id: <r9Xhg.7$V%2.227@news.uswest.net>

Mark Drummond wrote:
[...]
> to export my data, but only in an 
> XML format. I started writing a script to convert this to a CSV but I am 
> wondering if using something like XML-Parser would make my life easier. 
> I haven't done any work with XML files before.
> 
> Any suggestions?

Your first step would be to search CPAN (http://search.cpan.org/_
for possible modules.

Put in "XML CSV" and you'll find XML::CSV.

Could also look at XML::Simple, to parse the XML into a data
structure.


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

Date: 8 Jun 2006 09:11:31 -0700
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Converting XML to CSV
Message-Id: <1149783091.815217.80230@f6g2000cwb.googlegroups.com>


Mark Drummond wrote:
> I have an application, Garmin Training Centre, which logs exercise data
> from my Garmin GPS/HRM. While the Training Centre provides all kinds of
> get data analysis, it does not do everything I like. I would like to be
> able to pull my exercise data into a spreadsheet or even a database
> where I can do more analysis.
>
> The Training Center software allows me to export my data, but only in an
> XML format. I started writing a script to convert this to a CSV but I am
> wondering if using something like XML-Parser would make my life easier.
> I haven't done any work with XML files before.
>
> Any suggestions?

Someone else asked this exact question earlier this week and I'll tell
you what I told him - just open the .xml in Excel 2003 and save it as a
 .csv or .xls or whatever you like.

I love Perl, but if your spec is really this simple there's no need to
wield the big hammer...

-jp



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

Date: Thu, 08 Jun 2006 10:44:02 -0400
From: Mark Drummond <mark@gangwarily.ca>
Subject: Dealing with accented characters
Message-Id: <k_udnY3JYcQrqhXZnZ2dnUVZ_t-dnZ2d@magma.ca>

I don't do a lot of perl, but what I do usually always involves working
with data in LDAP directories. I have a script now that I run every
Monday to produce a CSV file containing a dump of some key user data
from my directory. I pass that CSV on to some other people and they pull
it in to Excel for viewing.

We recently started allowing accented characters in the directory and
I've noticed that the resulting CSV file ends up with some garbage in
the fields where accepted chars are being used. I'm trying to figure out
what I need to do to handle the accented characters properly.

My script runs from my WinXP laptop, using ActivePerl 5.8.x with the
latest perl-ldap module, connecting to a Sun directory server running on
a Solaris/SPARC box. It simply retrieves the attributes of interest for
all users in one branch of my DIT and outputs those attributes in CSV
format to a file on my laptop. I then email that file to the people who
need it.

Any help is greatly appreciated!

Mark


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

Date: Thu, 8 Jun 2006 16:49:38 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Dealing with accented characters
Message-Id: <ihtll3-36n.ln1@osiris.mauzo.dyndns.org>


Quoth Mark Drummond <mark@gangwarily.ca>:
> I don't do a lot of perl, but what I do usually always involves working
> with data in LDAP directories. I have a script now that I run every
> Monday to produce a CSV file containing a dump of some key user data
> from my directory. I pass that CSV on to some other people and they pull
> it in to Excel for viewing.
> 
> We recently started allowing accented characters in the directory and
> I've noticed that the resulting CSV file ends up with some garbage in
> the fields where accepted chars are being used. I'm trying to figure out
> what I need to do to handle the accented characters properly.
> 
> My script runs from my WinXP laptop, using ActivePerl 5.8.x with the
> latest perl-ldap module, connecting to a Sun directory server running on
> a Solaris/SPARC box. It simply retrieves the attributes of interest for
> all users in one branch of my DIT and outputs those attributes in CSV
> format to a file on my laptop. I then email that file to the people who
> need it.

That's all good, but we can't help without

1. A minimal script that reproduces the problem
2. An example of input that fails
3. What output that input should produce
4. What output it, in fact, does produce

I know nothing about how LDAP handles i18n, but, at a guess, your
accented characters are going into the CSV as UTF8 and Excel is reading
them as Windows-1251 (or whatever). The way forward is probably to write
your CSV file in UTF16, which Windows seems to like. Without knowing how
you write it, I can't tell you how to do that.

Ben

-- 
           All persons, living or dead, are entirely coincidental.
benmorrow@tiscali.co.uk                                           Kurt Vonnegut


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

Date: Sat, 03 Jun 2006 22:37:12 +0100
From: Brian Wakem <no@email.com>
Subject: Re: default value
Message-Id: <4eedo8F1d8dn0U1@individual.net>

Nospam wrote:

> 
> "Brian Wakem" <no@email.com> wrote in message
> news:4eeaflF1eg79bU1@individual.net...
>> Nospam wrote:
>>
>> >
>> > "Brian Wakem" <no@email.com> wrote in message
>> > news:4ee3feF1d8e9gU1@individual.net...
>> >> Nospam wrote:
>> >>
>> >> >
>> >> > "Bart Van der Donck" <bart@nijlen.com> wrote in message
>> >> > news:1149341535.307390.210370@f6g2000cwb.googlegroups.com...
>> >> >> Nospam wrote:
>> >> >>
>> >> >> > does anyone know a command to leave the default value for a field
> in
>> > a
>> >> >> > browser i.e something like field('value',); would something like
>> >> >> > this
>> >> > leave
>> >> >> > the default value in?
>> >> >>
>> >> >> This sounds (!) like an HTML question, please see alt.html. Maybe
> you
>> >> >> mean:
>> >> >>
>> >> >> <input type="text" size="5" value="apple">
>> >> >>
>> >> >> --
>> >> >>  Bart
>> >> >>
>> >> >
>> >> > I have something like
>> >> >
>> >> > <input type="hidden" name="field1" value="500" />
>> >> >
>> >> > this is the default value if I look at the source code in the
> browser,
>> >> > however I would like the field in mechanize to automatically use
>> >> > this default value, I have tried different connotations but none so
>> >> > far
> have
>> >> > worked:
>> >>
>> >>
>> >> You need do nothing, the preset values will be used my WWW::Mechanize
>> >> automatically.
>> >
>> > If this was a hidden field would I still need to do nothing?
>>
>>
>> Yes.
> 
> I have tried ignoring the hidden field with this program but it doesn't
> work
> :
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> use Data::Dumper;
> use WWW::Mechanize;
> 
> my $START='http://www.collegev2.com/?p=59';
> 
> my $mech = WWW::Mechanize->new();
> 
> $mech->get( $START );
> 
> $mech->form(2);
> 
> $mech->field('author','Eric Nuorven');
> $mech->field('email','ericn@example.com');
> $mech->field('url','');
> $mech->field('comment','Great idea');
> 
> #$mech->field('comment_post_ID','');
> 
> $mech->click("submit");


Well I copy and pasted that and ran it.  It worked fine and the comment is
now on the site.


-- 
Brian Wakem
Email: http://homepage.ntlworld.com/b.wakem/myemail.png


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

Date: 8 Jun 2006 09:40:18 -0700
From: "scottmf" <fleming.scott@gmail.com>
Subject: Re: filehandle to a member of a zip archive
Message-Id: <1149784818.057887.87550@c74g2000cwc.googlegroups.com>

>    s/open\(/mod_open(/;
>
> is a lot easier than
>
>    s/open\(/mod_open(\$/;
>
> (Seems like:
>    s/<FH>/<\$FH>/g;
>    s/(printf? )FH/$1\$FH/g;
>  would come pretty darn close though.

While I realize I could go through all of the scripts I need to update
and change every filehandle reference, it seems like there *should* be
a way to have my modified open function simply take a bareword
filehandle the same as open() does (and still "use strict;")  After
reading perdoc -q filehandle I have had some success passing the
type_glob by reference, but I cannot get this to work with IO::File or
IO::Zlib; see the code below for an example.  I can do exactly what I
want with the open() function, but I cannot get it to work with the
IO::File->new or IO::Zlib->new functions.

Thanks,
~Scott

#!/usr/local/bin/perl
#
use strict;
use warnings;
use IO::File;
use IO::Zlib;

new_open(\*FH_IN, "test.txt") || die "Can't open the file\n";  ## Pass
type glob by reference

while(<FH_IN>){  ## read the file without any modification to the
filehandle
    print "$_";
}
close(FH_IN);

sub new_open{
    my $FH = $_[0];
    my $file_name = $_[1];
    #$FH = IO::File->new($file_name, "r");  ## This also does not work
    #$FH = IO::Zlib->new($file_name, "rb") ; ## this does not work if I
have a .gz file
    open($FH, "$file_name") || die "Can't open $!\n";  ## This method
works
}



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

Date: 8 Jun 2006 10:46:01 -0700
From: "scottmf" <fleming.scott@gmail.com>
Subject: Re: filehandle to a member of a zip archive
Message-Id: <1149788761.566717.129890@y43g2000cwc.googlegroups.com>

Okay, I think I finally got things working the way I want (See code
below).  Thanks for all the help.  If anyone has any ideas on how to
improve this function it would still be greatly appreciated.

Thanks,
~Scott


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

new_open(\*FH_IN, "test.txt.gz") || die "Can't open the file\n"; ##
Pass typeglob by reference

while(<FH_IN>){  ## No change to bareword filehandle throughout code
    print "$_";
}
close(FH_IN);

sub new_open{
    my $FH = $_[0];
    my $file_name = $_[1];
    if($file_name =~ /\.gz$/){  ## check to see if it is a gzip file or
not
	tie *$FH, 'IO::Zlib', "$file_name", "rb";
    }
    else{
	tie *$FH, 'IO::File', "$file_name", "r";
    }
}



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

Date: 8 Jun 2006 09:20:53 -0700
From: dwmyers@my-deja.com
Subject: Finding all modular extensions to Perl on a system.
Message-Id: <1149783653.046333.145380@f6g2000cwb.googlegroups.com>

I have a box that needs to be replaced, and this is a web server on
which my predecessor (fired, and not on good terms) installed a
plethora of Perl, including some custom modules (I have these) and some
packages, the extent of which I'm not sure.

Is there any way to list all modules installed by CPAN that are not
part of the regular Perl distribution?

Are there tools that could scour a system for all perl and perl
modules, with particular emphasis on modules that extend the language?

Thanks in advance.

David.



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

Date: 8 Jun 2006 10:28:42 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: Finding all modular extensions to Perl on a system.
Message-Id: <1149787722.384485.33990@y43g2000cwc.googlegroups.com>


dwmyers@my-deja.com wrote:
> I have a box that needs to be replaced, and this is a web server on
> which my predecessor (fired, and not on good terms) installed a
> plethora of Perl, including some custom modules (I have these) and some
> packages, the extent of which I'm not sure.
>
> Is there any way to list all modules installed by CPAN that are not
> part of the regular Perl distribution?

The ones installed by CPAN will usually be in the 'site' directory.

> Are there tools that could scour a system for all perl and perl
> modules,

If you are talking only about modules installed in the standard places
(or know all the module search roots) then the first part of the answer
to the FAQ "How do I find which modules are installed on my system?"
will help.

If you don't know all the directories that could be in @INC at runtime
then simply finding all the .pm files on the system should hrelp you
guess them.



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

Date: 8 Jun 2006 06:11:28 -0700
From: "king" <hara.acharya@gmail.com>
Subject: hexadecimal addition
Message-Id: <1149772288.646019.10940@i39g2000cwa.googlegroups.com>

suppose i have got a variable say
$reserved=D0020078
I want to do a hexadecimal addition of $reserved with 08h.

so the output should come as $output=D0020080.
How can i do this.

I didn't find any syntax in "sprintf" for this.
Because this is a hexadecimal addition.
How can i do this?
thanx



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

Date: 8 Jun 2006 06:32:16 -0700
From: "Nick of course" <mol10metal@hotmail.com>
Subject: Re: hexadecimal addition
Message-Id: <1149773536.773639.44830@y43g2000cwc.googlegroups.com>


king wrote:
> suppose i have got a variable say
> $reserved=D0020078
> I want to do a hexadecimal addition of $reserved with 08h.
>
> so the output should come as $output=D0020080.
> How can i do this.
>
> I didn't find any syntax in "sprintf" for this.
> Because this is a hexadecimal addition.
> How can i do this?
> thanx
perl -e '$reserved="D0020078"; printf "%08x\n", oct("0x$reserved") +
oct("0x08")'

Note - you need to quote the D0020078.  If it had not started with an
alpha it would have barfed.  use strict would also have pointed this
out.



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

Date: Thu, 8 Jun 2006 14:42:49 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: hexadecimal addition
Message-Id: <p3mll3-mrl.ln1@osiris.mauzo.dyndns.org>


Quoth "king" <hara.acharya@gmail.com>:
> suppose i have got a variable say
> $reserved=D0020078

Nope, you haven't. That is, unless you aren't using 'strict', in which
case you don't have a number, you have an unquoted string. These are Bad.

You probably meant

my $reserved = 0xD0020078;

> I want to do a hexadecimal addition of $reserved with 08h.

There is no such thing as 'hexadecimal addition'. Addition is addition;
the question of base only applies to reading and writing numbers.

You tell Perl a number written in your source file is hex by preceding
it with '0x', as I showed you above. Please read perldoc perldata.

You tell Perl to interpret a string as a hex number with the hex
function. Please read perldoc -f hex. (While you're there, you'd do well
to read all of perldoc perlfunc.)

You tell Perl to convert a number to hex representation by using sprintf
with the %x or %X formats. You seem to have already read perldoc -f
sprintf: you may want to read it again with a proper understanding of
the difference between a number and the way it is written.

So the answer you are looking for is probably

    my $reserved = 0xD0020078;
    print sprintf "%X", $reserved + 0x08;

Please read at least some of the Perl documentation, or a good
introductory book, before trying random things on your own.

Ben

-- 
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks]  benmorrow@tiscali.co.uk


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

Date: 8 Jun 2006 02:18:00 -0700
From: "madan" <madan.narra@gmail.com>
Subject: hi Mr.John Bokma
Message-Id: <1149758280.229192.322450@j55g2000cwa.googlegroups.com>

hello Mr.John Bokma
thanks for ur replay..but i modified the source code as u specified but
still some error is coming...
the modified program is as below

#######################################################################

#! /usr/bin/perl

use lib '/cgi-bin/lib';
require("CGI.pm");
use strict;
use warnings;

use CGI::Carp 'fatalsToBrowser';
use CGI;
use Win32::ODBC;
my $cgi = CGI->new;
$dbh= new Win32::ODBC("dsn=madan; uid=madan; pwd=madan");
if(!$dbh)
 {
  &printFailure;
  exit();
 }
else
 {
  &printSucess;
 }
print $cgi->header( 'text/html' );
print $cgi->start_html;
print $cgi->startform("get","/cgi-bin/data.cgi");
sub printFailure {
   print "failure in connecting <br>".Win32::ODBC::Error();
}
sub printSucess {
   print "Connection Sucessful<br>";
}
print $cgi->endform;
print $cgi->end_html;
########################################################################

the following error is being displayed on the screen:

#######################################################################
Software error:
Undefined subroutine &Scalar::Util::blessed called at
W:/usr/lib/overload.pm line 89.
Compilation failed in require at W:/usr/lib/Config.pm line 70.
Compilation failed in require at W:/usr/site/lib/Win32/ODBC.pm line 27.
Compilation failed in require at W:/cgi-bin/dbtest.pl line 10.
BEGIN failed--compilation aborted at W:/cgi-bin/dbtest.pl line 10.
########################################################################



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

Date: 8 Jun 2006 02:19:42 -0700
From: "madan" <madan.narra@gmail.com>
Subject: hi Mr.John Bokma
Message-Id: <1149758382.000410.7610@g10g2000cwb.googlegroups.com>


hello Mr.John Bokma
thanks for ur replay..but i modified the source code as u specified but

still some error is coming...
the modified program is as below

#######################################################################



#! /usr/bin/perl


use lib '/cgi-bin/lib';
require("CGI.pm");
use strict;
use warnings;


use CGI::Carp 'fatalsToBrowser';
use CGI;
use Win32::ODBC;
my $cgi = CGI->new;
$dbh= new Win32::ODBC("dsn=madan; uid=madan; pwd=madan");
if(!$dbh)
 {
  &printFailure;
  exit();
 }
else
 {
  &printSucess;
 }
print $cgi->header( 'text/html' );
print $cgi->start_html;
print $cgi->startform("get","/cgi-bin/data.cgi");
sub printFailure {
   print "failure in connecting <br>".Win32::ODBC::Error();


}


sub printSucess {
   print "Connection Sucessful<br>";

}


print $cgi->endform;
print $cgi->end_html;
########################################################################


the following error is being displayed on the screen:


#######################################################################

Software error:
Undefined subroutine &Scalar::Util::blessed called at
W:/usr/lib/overload.pm line 89.
Compilation failed in require at W:/usr/lib/Config.pm line 70.
Compilation failed in require at W:/usr/site/lib/Win32/ODBC.pm line 27.

Compilation failed in require at W:/cgi-bin/dbtest.pl line 10.
BEGIN failed--compilation aborted at W:/cgi-bin/dbtest.pl line 10.
########################################################################



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

Date: Thu, 8 Jun 2006 08:06:31 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: hi Mr.John Bokma
Message-Id: <slrne8g86m.18s.tadmc@magna.augustmail.com>

madan <madan.narra@gmail.com> wrote:

> Subject: hi Mr.John Bokma


Please put the subject of your article in the Subject of your article.

Your article is not about saying hi, it appears to be about
some Perl error messages.


> i modified the source code 


DO NOT include code if you do not understand what the code does.

If you don't know what it is _supposed_ to do, then attempting to
"fix" it will be hopeless.


> require("CGI.pm");
> use strict;

> use CGI;


You should not include code if you do not understand what the code does.

Why do you (attempt to) pull the CGI module in *twice* like that?


> $dbh= new Win32::ODBC("dsn=madan; uid=madan; pwd=madan");


When you include "use strict" you are making a promise to perl, if
you break your promise, perl will refuse to run your program.

You are promising to declare all of your variables, so you need
to declare all of your variables:

   my $dbh= new Win32::ODBC("dsn=madan; uid=madan; pwd=madan");


> if(!$dbh)
>  {
>   &printFailure;
>   exit();
>  }
> else
>  {
>   &printSucess;
>  }
> print $cgi->header( 'text/html' );


Your code guarantees that you will make some output *before*
you output the headers.

They are called "headers" because they are supposed to come
before everything else.


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


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9266
***************************************


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