[24516] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6696 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 16 03:05:43 2004

Date: Wed, 16 Jun 2004 00:05:06 -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           Wed, 16 Jun 2004     Volume: 10 Number: 6696

Today's topics:
    Re: [PERL] internal server error <jurgenex@hotmail.com>
    Re: Class method call fails - "unblessed reference" (Anno Siegel)
    Re: Class method call fails - "unblessed reference" <MyFirstnameHere.News1@gustra.org>
        filehandles <darius_fatakia@yahoo.com>
    Re: filehandles <noreply@gunnar.cc>
    Re: filehandles <bmb@ginger.libs.uga.edu>
    Re: filehandles <darius_fatakia@yahoo.com>
    Re: filehandles <wcitoan@NOSPAM-yahoo.com>
    Re: filehandles <usenet@morrow.me.uk>
    Re: filehandles <bmb@ginger.libs.uga.edu>
    Re: filehandles <wcitoan@NOSPAM-yahoo.com>
    Re: filehandles (Sam Holden)
    Re: How to launch VFP from perl <wherrera@lynxview.com>
        I need help with an 'if statement' in perl (Sam)
    Re: I need help with an 'if statement' in perl <usenet@morrow.me.uk>
        method call works with non-existent invocant (Unknown Poster)
    Re: method call works with non-existent invocant <tassilo.parseval@rwth-aachen.de>
        RE: parsing a text file <gsuresh@rogers.com>
    Re: parsing a text file <noreply@gunnar.cc>
    Re: parsing file name assigning extension to a variable (Alexander Heimann)
        Perl and Oracle, deferred constraints stopped working i <kjetilskotheim@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 16 Jun 2004 00:43:15 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: [PERL] internal server error
Message-Id: <DIMzc.29483$tA6.3238@nwrddc03.gnilink.net>

Nicolas D wrote:
> I tried my perl scrip on my localhost and it' s OK.
> When i upload it on a web server with perl interprer, i have "INTERNAL
> SERVOR ERROR", i used chomp 755 for the files.cgi and its directory ,
> i have the good path in the program begining . So what's the problem ?

This Question is Asked Frequently, please see 'perldoc -q 500';

jue




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

Date: 15 Jun 2004 22:21:52 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Class method call fails - "unblessed reference"
Message-Id: <cansq0$2do$1@mamenchi.zrz.TU-Berlin.DE>

Gunnar Strand  <MyFirstnameHere.News1@gustra.org> wrote in comp.lang.perl.misc:
> Hi,
> 
> I am trying to write test cases using Test::Unit, and one of the
> test object starts like this:
> 
>        1 package Test::TestProfileSettings;
>        2
>        3 use Cmpm::Profile::Settings;
>        4 use Test::Unit::TestCase;
>        5 use base qw( Test::Unit::TestCase );
>        6
>        7 sub new {
>        8   my $class = shift;
>        9   my $self = $class -> SUPER::new( @_ );
>       10   return $self;
>       11 }
>       12
>       13 sub test_settings1 {
>       14   my $self = shift;
>       15   my $s = Cmpm::Profile::Settings -> new;
>       16   print STDERR "\$s = $s\n";
>       ...more code below, but this is the only method...
> 
> I use a TestSuite to run several test objects. If I run one certain
> test case before the one above, then perl complains:
> 
>   Test/TestProfileSettings.pm:15 - test_settings1(Test::TestProfileSettings)
>   Can't call method "new" on unblessed reference
> 
> It seems odd to me that perl would consider the class name to be
> an unblessed reference. If the test cases run in a different order,
> then all passes without any errors. Has anyone seen this before,
> and has any idea on what could be wrong?

This looks as if there was a sub named Settings in package Cmpm::Profile.
If that sub returned an unblessed reference, you would get the behavior
you describe.  Is that a possibility?

Anno


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

Date: Wed, 16 Jun 2004 08:26:34 +0200
From: Gunnar Strand <MyFirstnameHere.News1@gustra.org>
Subject: Re: Class method call fails - "unblessed reference"
Message-Id: <caop70$m2b$1@hudsucker.umdac.umu.se>

Anno Siegel wrote:
> Gunnar Strand  <MyFirstnameHere.News1@gustra.org> wrote in comp.lang.perl.misc:
> 
>>Hi,
>>
>>I am trying to write test cases using Test::Unit, and one of the
>>test object starts like this:
>>
>>       1 package Test::TestProfileSettings;
>>       2
>>       3 use Cmpm::Profile::Settings;
>>       4 use Test::Unit::TestCase;
>>       5 use base qw( Test::Unit::TestCase );
>>       6
>>       7 sub new {
>>       8   my $class = shift;
>>       9   my $self = $class -> SUPER::new( @_ );
>>      10   return $self;
>>      11 }
>>      12
>>      13 sub test_settings1 {
>>      14   my $self = shift;
>>      15   my $s = Cmpm::Profile::Settings -> new;
>>      16   print STDERR "\$s = $s\n";
>>      ...more code below, but this is the only method...
>>
>>I use a TestSuite to run several test objects. If I run one certain
>>test case before the one above, then perl complains:
>>
>>  Test/TestProfileSettings.pm:15 - test_settings1(Test::TestProfileSettings)
>>  Can't call method "new" on unblessed reference
>>
>>It seems odd to me that perl would consider the class name to be
>>an unblessed reference. If the test cases run in a different order,
>>then all passes without any errors. Has anyone seen this before,
>>and has any idea on what could be wrong?
> 
> 
> This looks as if there was a sub named Settings in package Cmpm::Profile.
> If that sub returned an unblessed reference, you would get the behavior
> you describe.  Is that a possibility?
> 
> Anno

Yes, you are correct. A thousands thanks, Anno! I have been struggling
with this problem for some time.

Cheers,

/Gunnar


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

Date: Tue, 15 Jun 2004 16:51:08 -0700
From: "superfly2" <darius_fatakia@yahoo.com>
Subject: filehandles
Message-Id: <cao21d$g2i$1@news.Stanford.EDU>

Hi,

I'm getting the following error, but I don't know why this would happen
given my script.

readline() on unopened filehandle at /bin/apache/cgi-bin/termCompare.pl line
96., referer: http://[host]/biotools/termCompare.shtml
(and one more just like it)

My script is:

use LWP::UserAgent;
use HTTP::Cookies;
use CGI;

use strict;


open(DEBUG, ">/bin/apache/cgi-bin/compareDebug.txt");

# Read in POST data and put in variables

#$CGI::POST_MAX = 512 * 1024; #limit to 512kb upload
my $cgi = new CGI;
my $area1 = $cgi->param('areax');
my $area2 = $cgi->param('areay');
my $file1 = $cgi->param('filex');
my $file2 = $cgi->param('filey');
my $submit_method = $cgi->param('submit');

print DEBUG $file1;            #prints filenames correctly
print DEBUG $file2;

my(@list1, @list2);
if($submit_method eq 'Submit Text')
{
    $area1 =~ s/\r/\n/g;
    $area1 =~ s/;/\n/g;
    $area1 =~ s/\t/\n/g;
    $area1 =~ s/(\n+)/\n/g;
    $area2 =~ s/\r/\n/g;
    $area2 =~ s/;/\n/g;
    $area2 =~ s/\t/\n/g;
    $area2 =~ s/(\n+)/\n/g;

    # Now put into arrays the data stuff
    @list1 = split(/\n/, $area1);
    @list2 = split(/\n/, $area2);
}
else
{
    my $term;
    while($term = <$file1>)                # error refers to this line
    {
         chomp $term;
         print DEBUG "* $term\n";
         push @list1, $term;
    }
    while($term = <$file2>)               # error refers to this line
    {
         chomp $term;
         print DEBUG "+ $term\n";
         push @list2, $term;
    }
}

# if i print list1 or list2, there is nothing in them.




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

Date: Wed, 16 Jun 2004 02:36:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: filehandles
Message-Id: <2j9j02Fvfe48U1@uni-berlin.de>

superfly2 wrote:
> I'm getting the following error, but I don't know why this would
> happen given my script.
> 
> readline() on unopened filehandle at
> /bin/apache/cgi-bin/termCompare.pl line 96., referer:
> http://[host]/biotools/termCompare.shtml
> (and one more just like it)

Do you have

     enctype="multipart/form-data"

in the form element?

Have you tried upload() instead of param() for getting the filehandles?

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



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

Date: Tue, 15 Jun 2004 20:37:52 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: filehandles
Message-Id: <Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu>

On Tue, 15 Jun 2004, superfly2 wrote:

> Hi,
>
> I'm getting the following error, but I don't know why this would happen
> given my script.
>
> readline() on unopened filehandle at /bin/apache/cgi-bin/termCompare.pl line
> 96., referer: http://[host]/biotools/termCompare.shtml
> (and one more just like it)

Perhaps because your script never opens them the files?  :-)

>
> My script is:
>
> use LWP::UserAgent;
> use HTTP::Cookies;
> use CGI;
>
> use strict;
>
>
> open(DEBUG, ">/bin/apache/cgi-bin/compareDebug.txt");

You should always, yes ALWAYS, check the return value from open.
Hi, Tad.  :-)

(But that's not your problem here ...)


> # Read in POST data and put in variables
>
> #$CGI::POST_MAX = 512 * 1024; #limit to 512kb upload
> my $cgi = new CGI;
> my $area1 = $cgi->param('areax');
> my $area2 = $cgi->param('areay');
> my $file1 = $cgi->param('filex');
> my $file2 = $cgi->param('filey');
> my $submit_method = $cgi->param('submit');
>
> print DEBUG $file1;            #prints filenames correctly
> print DEBUG $file2;
>
> my(@list1, @list2);
> if($submit_method eq 'Submit Text')
> {
>     $area1 =~ s/\r/\n/g;
>     $area1 =~ s/;/\n/g;
>     $area1 =~ s/\t/\n/g;
>     $area1 =~ s/(\n+)/\n/g;
>     $area2 =~ s/\r/\n/g;
>     $area2 =~ s/;/\n/g;
>     $area2 =~ s/\t/\n/g;
>     $area2 =~ s/(\n+)/\n/g;
>
>     # Now put into arrays the data stuff
>     @list1 = split(/\n/, $area1);
>     @list2 = split(/\n/, $area2);
> }
> else
> {
>     my $term;
>     while($term = <$file1>)                # error refers to this line

Whoa, you can't read a file this way.  First, you open it, then you read
it.  See perldoc -f open

[snippage]

Regards,

Brad


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

Date: Tue, 15 Jun 2004 18:06:25 -0700
From: "superfly2" <darius_fatakia@yahoo.com>
Subject: Re: filehandles
Message-Id: <cao6el$kg6$1@news.Stanford.EDU>

"Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
news:Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu...
> On Tue, 15 Jun 2004, superfly2 wrote:
>
> > Hi,
> >
> > I'm getting the following error, but I don't know why this would happen
> > given my script.
> >
> > readline() on unopened filehandle at /bin/apache/cgi-bin/termCompare.pl
line
> > 96., referer: http://[host]/biotools/termCompare.shtml
> > (and one more just like it)
>
> Perhaps because your script never opens them the files?  :-)
>

That is not true. $file1 and $file2 should be open filehandles.


> >
> > My script is:
> >
> > use LWP::UserAgent;
> > use HTTP::Cookies;
> > use CGI;
> >
> > use strict;
> >
> >
> > open(DEBUG, ">/bin/apache/cgi-bin/compareDebug.txt");
>
> You should always, yes ALWAYS, check the return value from open.
> Hi, Tad.  :-)
>
> (But that's not your problem here ...)
>
>
> > # Read in POST data and put in variables
> >
> > #$CGI::POST_MAX = 512 * 1024; #limit to 512kb upload
> > my $cgi = new CGI;
> > my $area1 = $cgi->param('areax');
> > my $area2 = $cgi->param('areay');
> > my $file1 = $cgi->param('filex');
> > my $file2 = $cgi->param('filey');
> > my $submit_method = $cgi->param('submit');
> >
> > print DEBUG $file1;            #prints filenames correctly
> > print DEBUG $file2;
> >
> > my(@list1, @list2);
> > if($submit_method eq 'Submit Text')
> > {
> >     $area1 =~ s/\r/\n/g;
> >     $area1 =~ s/;/\n/g;
> >     $area1 =~ s/\t/\n/g;
> >     $area1 =~ s/(\n+)/\n/g;
> >     $area2 =~ s/\r/\n/g;
> >     $area2 =~ s/;/\n/g;
> >     $area2 =~ s/\t/\n/g;
> >     $area2 =~ s/(\n+)/\n/g;
> >
> >     # Now put into arrays the data stuff
> >     @list1 = split(/\n/, $area1);
> >     @list2 = split(/\n/, $area2);
> > }
> > else
> > {
> >     my $term;
> >     while($term = <$file1>)                # error refers to this line
>
> Whoa, you can't read a file this way.  First, you open it, then you read
> it.  See perldoc -f open
>
> [snippage]
>
> Regards,
>
> Brad




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

Date: Wed, 16 Jun 2004 01:38:25 -0000
From: "W. Citoan" <wcitoan@NOSPAM-yahoo.com>
Subject: Re: filehandles
Message-Id: <slrnccv947.2pc.wcitoan@wcitoan-via.supernews.com>

On Tue, 15 Jun 2004 18:06:25 -0700, superfly2 wrote:
>  "Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
>  news:Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu...
> >
> > Perhaps because your script never opens them the files?  :-)
>  
>  That is not true. $file1 and $file2 should be open filehandles.

That statement doesn't match the comment in your code:

> > > print DEBUG $file1;            #prints filenames correctly
> > > print DEBUG $file2;

- W. Citoan
-- 
What signature?


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

Date: Wed, 16 Jun 2004 01:46:50 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: filehandles
Message-Id: <cao8qa$ra2$1@wisteria.csv.warwick.ac.uk>


Quoth "W. Citoan" <wcitoan@NOSPAM-yahoo.com>:
> On Tue, 15 Jun 2004 18:06:25 -0700, superfly2 wrote:
> >  "Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
> >  news:Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu...
> > >
> > > Perhaps because your script never opens them the files?  :-)
> >  
> >  That is not true. $file1 and $file2 should be open filehandles.
> 
> That statement doesn't match the comment in your code:
> 
> > > > print DEBUG $file1;            #prints filenames correctly
> > > > print DEBUG $file2;

Read the docs for CGI.pm.

Ben

-- 
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
  ben@morrow.me.uk                                                 (Kate Rusby)


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

Date: Tue, 15 Jun 2004 22:10:22 -0400
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: filehandles
Message-Id: <Pine.A41.4.58.0406152206170.11938@ginger.libs.uga.edu>

On Tue, 15 Jun 2004, superfly2 wrote:

> "Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
> news:Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu...
> >
> > Perhaps because your script never opens them the files?  :-)

s/them //;

> >
>
> That is not true. $file1 and $file2 should be open filehandles.
 ...
> > > my $file1 = $cgi->param('filex');
> > > my $file2 = $cgi->param('filey');

Sorry, but param() doesn't return open filehandles.  I guess you just need
to open them yourself.

Regards,

Brad


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

Date: Wed, 16 Jun 2004 02:24:59 -0000
From: "W. Citoan" <wcitoan@NOSPAM-yahoo.com>
Subject: Re: filehandles
Message-Id: <slrnccvbrj.2pc.wcitoan@wcitoan-via.supernews.com>

On Wed, 16 Jun 2004 01:46:50 +0000 (UTC), Ben Morrow wrote:
>  
>  Quoth "W. Citoan" <wcitoan@NOSPAM-yahoo.com>:
> > On Tue, 15 Jun 2004 18:06:25 -0700, superfly2 wrote:
> > >  "Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
> > >  news:Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu...
> > > >
> > > > Perhaps because your script never opens them the files?  :-)
> > >  
> > >  That is not true. $file1 and $file2 should be open filehandles.
> > 
> > That statement doesn't match the comment in your code:
> > 
> > > > > print DEBUG $file1;            #prints filenames correctly
> > > > > print DEBUG $file2;
>  
>  Read the docs for CGI.pm.

Okay, I just learned something new.  Thanks for the tip.

- W. Citoan
-- 
What signature?


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

Date: 16 Jun 2004 02:47:30 GMT
From: sholden@flexal.cs.usyd.edu.au (Sam Holden)
Subject: Re: filehandles
Message-Id: <slrnccvd62.3tb.sholden@flexal.cs.usyd.edu.au>

On Tue, 15 Jun 2004 22:10:22 -0400, Brad Baxter <bmb@ginger.libs.uga.edu> wrote:
> On Tue, 15 Jun 2004, superfly2 wrote:
> 
>> "Brad Baxter" <bmb@ginger.libs.uga.edu> wrote in message
>> news:Pine.A41.4.58.0406152031000.11938@ginger.libs.uga.edu...
>> >
>> > Perhaps because your script never opens them the files?  :-)
> 
> s/them //;
> 
>> >
>>
>> That is not true. $file1 and $file2 should be open filehandles.
> ...
>> > > my $file1 = $cgi->param('filex');
>> > > my $file2 = $cgi->param('filey');
> 
> Sorry, but param() doesn't return open filehandles.  I guess you just need
> to open them yourself.

Yes it does. I guess you need to read the documentation.

Of course using upload() instead of param() is a far wiser choice.

-- 
Sam Holden


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

Date: Tue, 15 Jun 2004 22:05:43 -0600
From: Bill <wherrera@lynxview.com>
Subject: Re: How to launch VFP from perl
Message-Id: <HaidnTSsMY-HWlLdRVn-sA@adelphia.com>

zeke wrote:
> I have a VisualFoxPro program (.fxp extension) that I wish my perl
> script to launch.  In addition I need to pass an argument from perl to
> the VFP program, and lastly receive back from the VFP program an
> argument (successful vs error condition at end of VFP program).  I can
> do this in Mac environment, but am now required to do same in
> Windows2000PRO 

If you would post the part of the script that is Mac-specific in its 
call of VFP, we could probably help you port it.



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

Date: 15 Jun 2004 18:40:18 -0700
From: samuelvange@cox.net (Sam)
Subject: I need help with an 'if statement' in perl
Message-Id: <dae5ebbf.0406151740.16124d04@posting.google.com>

I have a .cgi script on my website and (I think) it's written in perl.
 I know some c++ and as far as I can tell this is the drop down menu
on my store.cgi page:
	</ul> 
<!--  VF begin client add search params form -->
	<form action="$script_url" method="post">
	List by Collection<br>
	<select name="collection"><option>Select</option>|;

	@collections=&get_collections;
	foreach $collection (@collections) {print
"<option>$collection</option>";}

	print qq | </select>
	<input type="submit" value="Search">

I have a list of items categorized by collection.  One of these is
simply called 'collection' (where as the others have names like
'ceramic collection', 'glassware collection', etc.).

*What I need to do is have the drop down menu list all of these
categories, and for the group that is simply called 'collection', I'd
like it to display 'Ken Edwards collection'. For example:

change
____________________________     that's the
Ceramic collection       |\/| <-down arrow on the drop down menu
Figurine collection         |
Collection                  |  *This line needs to change
Glassware collection________|

to
____________________________
Ceramic collection       |\/| 
Figurine collection         |
Ken edwards collection      |  *This line needs to change
Glassware collection________|

I assume this can be done with an if statement, but I can't do it.

Thanks in advance

PS:I sell Mexican crafts, and I'm looking for reciprocal links, if
your interested please email me.  I wont plug myself here, but I'll
email you my website if youd like.

Thanks again

Sam


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

Date: Wed, 16 Jun 2004 01:53:15 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: I need help with an 'if statement' in perl
Message-Id: <cao96b$ra2$2@wisteria.csv.warwick.ac.uk>


Quoth samuelvange@cox.net (Sam):
>
> I have a list of items categorized by collection.  One of these is
> simply called 'collection' (where as the others have names like
> 'ceramic collection', 'glassware collection', etc.).
> 
> *What I need to do is have the drop down menu list all of these
> categories, and for the group that is simply called 'collection', I'd
> like it to display 'Ken Edwards collection'.
> 
> 	@collections=&get_collections;

You don't need the '&' on that sub call; in fact, it may do things
you're not expecting.

> 	foreach $collection (@collections) {print
> "<option>$collection</option>";}

print '<option>', 
    (/^collection$/i ? 'Ken Edwards collection' : $_), 
    '</option>'
        for @collections;

Note that this is a Very Bad Idea: the right answer is to fix whatever
is causing this collection to have the wrong name in the first place.
        
Ben

-- 
Musica Dei donum optimi, trahit homines, trahit deos.    |
Musica truces molit animos, tristesque mentes erigit.    |   ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras.        |


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

Date: 15 Jun 2004 19:44:22 -0700
From: use63net@yahoo.com (Unknown Poster)
Subject: method call works with non-existent invocant
Message-Id: <c62e93ec.0406151844.60111554@posting.google.com>

I don't see how this not only compiles under Perl 5.6.1, but the call to 
init() in the Parent class works, with a scalar or bareword that refers 
to nothing.  (It fails if there is no invocant at all.)  Why is the call 
seen below considered OK by the compiler?

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

package Child;

use base("Parent");
use strict;
use warnings;

sub new
{
   my $i = shift;  
   my $hr = x->SUPER::init();  #or even $x   
   my $s = {%$hr, count => 0, label => 'none'};
   return bless $s, ref($i) || $i;
}

 .
 .
 .


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

Date: Wed, 16 Jun 2004 07:23:51 +0200
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: method call works with non-existent invocant
Message-Id: <2ja3r9FurhtlU1@uni-berlin.de>

Also sprach Unknown Poster:

> I don't see how this not only compiles under Perl 5.6.1, but the call to 
> init() in the Parent class works, with a scalar or bareword that refers 
> to nothing.  (It fails if there is no invocant at all.)  Why is the call 
> seen below considered OK by the compiler?
> 
> -------------------
> 
> package Child;
> 
> use base("Parent");
> use strict;
> use warnings;
> 
> sub new
> {
>    my $i = shift;  
>    my $hr = x->SUPER::init();  #or even $x   
>    my $s = {%$hr, count => 0, label => 'none'};
>    return bless $s, ref($i) || $i;
> }

First of all, this is not so much an issue of the compiler. Perl's
compiler just creates an op-tree which wont fail as long as your script
is syntactically correct. If the above was an error, it would be
detected by the interpreter at runtime.

However, the above is totally ok. Using SUPER:: will change Perl's
notion of method dispatch. Which class' method is invoked now no longer
depends on the invocant but rather on the first value in @Child::ISA:

    package A; 
    sub init { print "@_\n" }
    package B;
    @B::ISA = qw/A/;
    x->SUPER::init(1, 2, 3);
    __END__
    x 1 2 3

This makes sense as you explicitely asked to call the init() method of
the superclass. In this case perl wont look at the invocant at all.
Instead it will eventually translate the above to:

    A::init("x", 1, 2, 3);

The following example shows more clearly that perl ignores the type of
invocant when SUPER:: was given:

    package A;
    sub init { print "A::init: @_\n" }
    
    package B;
    @B::ISA = qw/A/;
    sub init { print "B::init: @_\n" }
    
    $x = bless { } => __PACKAGE__;
    $x->init(1, 2, 3);
    $x->SUPER::init(1, 2, 3);
    __END__
    B::init: B=HASH(0x8139c84) 1 2 3
    A::init: B=HASH(0x8139c84) 1 2 3
    
Tassilo
-- 
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval


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

Date: Wed, 16 Jun 2004 03:20:33 GMT
From: "Suresh" <gsuresh@rogers.com>
Subject: RE: parsing a text file
Message-Id: <50Pzc.256$8BU1.74@news04.bloor.is.net.cable.rogers.com>

Hi,

I have a file in the following format.


Title 223
Version 2324
protocol src: 172.30.39.3
data

0000  94 93 32 43 f3 h3
1223  23 k3 j3 3k k3 2k
9232 92 k3 92 k2 92 l2

Title 3434
Version 233
 ........ keeps on gooing in the same format.

I want to write a script that grep/parse Title,src, and the data part(all
the data).
The format is same all the time.  The data always start with 0000 and two
spaces.  After that
the data follow the same pattern.

What I want is that i have to go to a specific(user input) src and parse the
data for that specific src.

I was able to go the src but don't know how to iterate one line at a time,
from 0000 to the end of the data.

while(<>) {
if(src=$user input)
print .....

if(/^0000\s\s .. /end../
 ....

I wanna way to iterate each line once it entered into a loop.

thanks,
Sean




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

Date: Wed, 16 Jun 2004 08:39:18 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: parsing a text file
Message-Id: <2ja88cFv2djrU1@uni-berlin.de>

Suresh wrote:
> I have a file in the following format.
> 
> Title 223
> Version 2324
> protocol src: 172.30.39.3
> data
> 
> 0000  94 93 32 43 f3 h3
> 1223  23 k3 j3 3k k3 2k
> 9232 92 k3 92 k2 92 l2
> 
> Title 3434
> Version 233
> ........ keeps on gooing in the same format.
> 
> I want to write a script that grep/parse Title,src, and the data
> part(all the data).
> The format is same all the time.  The data always start with 0000
> and two spaces.  After that the data follow the same pattern.

One idea:

     my %items;
     my $all = do { local $/; <> };
     while ( $all =~ /(Title.*?)(?:(?=Title)|$)/gs ) {
         if ( $1 =~ /^Title\s+(\d+).+?src:\s([\d.]+).+?(0000  .+)/s ) {
             $items{$1} = {
                 src  => $2,
                 data => [ split /\s+/, $3 ],
             };
         }
     }

     for (keys %items) {
         print "Title: $_\n",
               "protocol src: $items{$_}{src}\n",
               "data: [ @{$items{$_}{data}} ]\n\n";
     }

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



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

Date: 15 Jun 2004 18:46:08 -0700
From: AlexanderHeimann@yahoo.com (Alexander Heimann)
Subject: Re: parsing file name assigning extension to a variable
Message-Id: <1c63154d.0406151746.6e66c726@posting.google.com>

If anyone is interested. I am pasting the code that worked for the
above problem. The main problem i was having was that when I was
reading the directory i forgot to add
next if $file =~/^\.\.?$/; after the while (defined($file =
readdir(DIR))) to skip over the .

after i stopped getting crazy errors

thanks for all your help guys. i will try to contribute as much as I
can i have only been playing with perl for a week now

# modules used 
use DBI;
use File::Basename;
use File::Slurp;


  
 
 


#create connection to database 
$dbh = DBI->connect('dbi:mysql:$dbname:localhost:3306',
			'$username','$password8',
			{ RaiseError => 1, AutoCommit => 1});
fileparse_set_fstype("MSDOS");


#open directory loop while there is still a file
$mydir = "D:/desc";
opendir (DIR, $mydir) || die "couldn't opendir $mydir: $!\n";   
while (defined($file = readdir(DIR))) {
  next if $file =~/^\.\.?$/; 
  

 #open file and assign content of file to variable $content
 my $content = read_file("$mydir/$file");
 
 
 #parse file and assing extension to $ext variable
 ($name, $dir, $ext) = fileparse($file, '\..*');
 $ext =~s/^\.//;
 
 
 

 #SQL insert statement to insert $ext and $content into DB
 #prepare then excecute
  
 $sth= $dbh->prepare("INSERT INTO `desc`VALUES (?,?)"); 
 $sth->execute ( $ext, $content );
  

}
#close directory
closedir(DIR);
#disconnect from database
$dbh->disconnect();


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

Date: Wed, 16 Jun 2004 02:50:43 +0200
From: "Kjetil Skotheim" <kjetilskotheim@yahoo.com>
Subject: Perl and Oracle, deferred constraints stopped working in new version
Message-Id: <opr9nwmttttm9jxl@edelweiss.upc.no>


A question on Perl and Oracle:

We're having trouble with   alter session set constraints=deferred
through perl after some major upgrades on OS and perl on our server.
It used to work, but not anymore. That is: it still works perfecly
well through sqlplus. Using precicely the same update's in the same
order.

Deferred constraints is a mechanism in oracle that makes is possible
to postpone the foreign and unique keys control until commit instead
of immediately after each update/insert/delete.

I'm using DBI.pm indirectly via   sub ora_do   in Oraperl.pm due to
a local legacy library.

Oraperl version is 1.43
DBI version is 1.39
DBD::Oracle is 1.14
perl -v   says 5.8.0
Oracle client (for both DBD::Oracle and sqlplus) I think is 8.1.7
Oracle server is 8.1.7.4.0

Good answers would be greatly appreciated.

--
Kjetil Skotheim


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

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 6696
***************************************


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