[17742] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5162 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 20 18:05:39 2000

Date: Wed, 20 Dec 2000 15:05:20 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977353519-v9-i5162@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 20 Dec 2000     Volume: 9 Number: 5162

Today's topics:
        "Native" perl way to copy files (LMC)
    Re: (Beginner) Simple stuff not working <bart.lateur@skynet.be>
        [OT] Re: switch/case in Perl? <joe+usenet@sunstarsys.com>
    Re: assigning elements to ARGV from within a script (Tom Christiansen)
    Re: Boolean context in grep (Tad McClellan)
        Directory Recursion Kwestion... <kai_jang@my-deja.com>
        DSN/ODBC Client-Server Problem <sg@loralskynet.com>
    Re: DSN/ODBC Client-Server Problem nobull@mail.com
    Re: DSN/ODBC Client-Server Problem <jhelman@wsb.com>
    Re: FAQ 5.3:   How do I count the number of lines in a  (Jerome O'Neil)
    Re: getting output from net::telnet (Garry Williams)
        Getting the length from an array reference <matt.stoker@motorola.com>
    Re: Getting the length from an array reference <jhelman@wsb.com>
    Re: Getting the length from an array reference <matt.stoker@motorola.com>
    Re: Getting the length from an array reference <bart.lateur@skynet.be>
    Re: GNU Info-Zip & LWP (BUCK NAKED1)
    Re: Help with multipart form richardstands@my-deja.com
    Re: Help with REGEXP and templates! (Tad McClellan)
    Re: How to check if a class include a particular method <aphowe@netcom.ca>
    Re: How to check if a class include a particular method (Garry Williams)
    Re: how to invalidate a hash value during a foreach loo (Garry Williams)
    Re: HTTP::Request help (Getting past ASP Login pages) nobull@mail.com
        IDE for development in perl (Otto Wyss)
    Re: IDE for development in perl schnurmann@my-deja.com
    Re: is this bad perl programming habit? nobull@mail.com
    Re: Language evolution C->Perl->C++->Java->Python (Is P <kenny@kennypearce.net>
    Re: Language evolution C->Perl->C++->Java->Python (Is P <just_me@nowhere.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 20 Dec 2000 16:39:47 -0500
From: "Antoine Beaupre (LMC)" <lmcabea@lmc.ericsson.se>
Subject: "Native" perl way to copy files
Message-Id: <3A412723.D99788C2@lmc.ericsson.se>

Hello!

I guess that you can probably copy a file with:

	system "cp $file $newfile"

in perl. But this is platform dependent... Is there a "native" way to
copy files in perl (à la rename)? I searched all the doc I could find
and couldn't figure it out..

Thanks

A.


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

Date: Wed, 20 Dec 2000 19:17:28 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: (Beginner) Simple stuff not working
Message-Id: <nd124t4qim57hrf28u4i0ircmv58to2518@4ax.com>

Garry Heaton wrote:

>!#c:/perl/bin/perl.exe
>
>$phrase = "Its about time";
>print phrase;

3 lines. Your primary error is in the order of the "!" and the "#". Swap
those.

And second, your want

	print $phrase;

You forgot the dollar sign.

-- 
	Bart.


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

Date: 20 Dec 2000 16:37:14 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: [OT] Re: switch/case in Perl?
Message-Id: <m3elz2kc51.fsf_-_@mumonkan.sunstarsys.com>

Adam Levenstein <cleon42@my-deja.com> writes:

> Thanks Bart...Just trying to keep the code short.
> 
> And yeah - I never understood why Richie put the "break" in there.
> Seemed unnecessary to me.

So you can combine cases "easily":

switch (letter) {

  case 'a': case 'e': case 'i': case 'o': case 'u':
        #vowel
        break;

  default:
        #consonant
}

Of course, Perl has little use for such silliness :)

-- 
Joe Schaefer


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

Date: 20 Dec 2000 12:08:30 -0700
From: tchrist@perl.com (Tom Christiansen)
Subject: Re: assigning elements to ARGV from within a script
Message-Id: <3a4103ae@cs.colorado.edu>

In article <slrn941vmj.7r0.abigail@tsathoggua.rlyeh.net>,
Abigail <abigail@foad.org> wrote:
>Or this:
>
>    #!/opt/perl/bin/perl -pi
>    BEGIN {@ARGV = map {glob} @ARGV}
>    s/foo/bar/gs;
>    __END__
>
>and call the program as:
>
>    program '*/*.html'
>
>
>Having the application expand the wildcards instead of the shell might
>be useful if expanding by the shell leads to hitting command line length
>limits.

But now that doesn't work on files whose names contain wildcards!

    % perl 
    mkdir("*", 0755) 		    || die $!;
    open(GOTCHA, "> */*.html") 	    || die $!;
    print GOTCHA "foo on yoo\n";
    ^D

    % ls -l \*/*
    -rw-r--r--  1 tchrist  wheel  11 Dec 20 12:05 */*.html

I like mine better, as it doesn't have this problem.  

    % perl 
    local *ARGV;
    local @ARGV = glob("*/*.html");
    local $^I = "";
    while (<>) {
        s/foo/bar/gs;
        print;
    }
    ^D

    % cat \*/\*.html 
    bar on yoo

--tom


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

Date: Wed, 20 Dec 2000 15:55:36 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Boolean context in grep
Message-Id: <slrn942768.3cd.tadmc@magna.metronet.com>

Matt Venn <matt@cipherdesign.com> wrote:
>I think what I was trying to say was:
>
>How do I get something in list context when the operator is scalar?


You cannot. It is impossible. 

Perl FAQ, part 4:

   "there's no such thing as a list in scalar context."

and perlfunc.pod says:

   "You can't get a list like (1,2,3) into being in scalar context"


>For example:
>
>$a = "abc";
>$a .= ("abc"=~/(...)/);
>print $a;	#prints abc1


   $a .= $1 if "abc" =~ /(...)/;


>In my previous post, I wanted to get ($a=~/(pattern)/) in list context so
>that I would have access to the matched pattern.


You have access to the matched characters in scalar context too,
they are in $1.

   $temp = $1 if $text =~ /some(pattern)/;


>And doing this:
[snip list slice]
>Is the answer.

I get the feeling that it isn't "the" answer, but I can't figure
out the question...


>Sorry for any confusion caused.

I just went back and reread your first post, and I _still_
can't figure out what you were asking. <shrug>


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


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

Date: Wed, 20 Dec 2000 22:03:10 GMT
From: Kai Jang <kai_jang@my-deja.com>
Subject: Directory Recursion Kwestion...
Message-Id: <91raao$pkn$1@nnrp1.deja.com>

Hi guys.  I need a bit of help here.  I have a sub routine that changes
the name of all the directories under a specified directory into all
lowercase.  What I am trying to get it to do, is drill on down into the
lower sub directories and change them too.  I tried File::Find at
first, but as has been documented, you can't change directory names
using File::Find w/o it screwing up.  I know I need to use a chdir to
drill down, but I am seeking the proper format to do this.  Any
ideas???  Any help is GREATLY appreaciated.  My sub is below...

  -Kai

sub changed {
  opendir DIR, $dir1 or die "Cannot open $dir1\n";
  print "Opening $dir1\n";
  @dirlist = grep -d, readdir DIR;
  closedir DIR;
  print "$#dirlist\n";
  for ($a=$#dirlist;$a>=0;$a--) {
    $oldname = $dirlist[$a];
    $newname = lc $oldname;
    rename $oldname, $newname;
}
}


Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 20 Dec 2000 14:30:58 -0500
From: Stephan Gross <sg@loralskynet.com>
Subject: DSN/ODBC Client-Server Problem
Message-Id: <1q124tkumh6hntbf33qgucmtiscbmtgq6h@4ax.com>

I have a Microsoft Access database on Server A.  I have a perl program
that connects to the database via ODBC on Server B.  I have made the
database a System Data Source on Server B via the ODBC utility in the
Control Panel.

When I run the program while sitting at Server B, it works just fine.
However, when I run the program across the network  from a client PC,
I get an ODBC message that it cannot connect to the database. 

Any ideas?
================================================================
Stephan Gross          Loral Skynet           sg@loralskynet.com
Senior Software Engineer                      908-470-2388


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

Date: 20 Dec 2000 20:24:21 +0000
From: nobull@mail.com
Subject: Re: DSN/ODBC Client-Server Problem
Message-Id: <u9elz2zvre.fsf@wcl-l.bham.ac.uk>

Stephan Gross <sg@loralskynet.com> writes:

> Subject: Re: DSN/ODBC Client-Server Problem
> Newsgroups: comp.lang.perl.misc

What does any of this have to so with Perl?  Or to put it another way
why do you suspect it would be different in any other language?

> I have a Microsoft Access database on Server A.  I have a perl program
> that connects to the database via ODBC on Server B.  I have made the
> database a System Data Source on Server B via the ODBC utility in the
> Control Panel.

Would I be right in assuming that the DSN on B is accessing the
database on A as a file?

> When I run the program while sitting at Server B, it works just fine.
> However, when I run the program across the network  from a client PC,
> I get an ODBC message that it cannot connect to the database. 
> 
> Any ideas?

I'm guessing permissions.  I'm guessing that the ODBC driver tries to
access the file on A using the credentials of the process that is
calling it because you forgot to put any credentials in the DSN
itself.

If that's not the answer try asking in a newsgroup where this question
is on-topic.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 20 Dec 2000 20:52:03 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: DSN/ODBC Client-Server Problem
Message-Id: <3A411C47.A6D94C5F@wsb.com>

Stephan Gross wrote:
> 
> I have a Microsoft Access database on Server A.  I have a perl program
> that connects to the database via ODBC on Server B.  I have made the
> database a System Data Source on Server B via the ODBC utility in the
> Control Panel.

Note that this has nothing to do with Perl (even if your program is
written in Perl).

> When I run the program while sitting at Server B, it works just fine.
> However, when I run the program across the network  from a client PC,
> I get an ODBC message that it cannot connect to the database.

By "run the program across the network", does that mean you actually run
your program from the command line on another PC?  If so, then that's
the problem.  If you run the code on another computer, then that
computer must also have the DSN defined (and I'm guessing it doesn't).

Now, if you mean that you run it on the remote computer (using a CGI
script, for example), then it's probably a permission thing.  The
question to ask is which computer is actually processing the script and
does that machine have the DSN defined?

But again, this isn't a Perl question.  If the above doesn't work, ask
this question in an ODBC or Access group.

> Any ideas?
> ================================================================
> Stephan Gross          Loral Skynet           sg@loralskynet.com
> Senior Software Engineer                      908-470-2388

JH



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

Date: Wed, 20 Dec 2000 20:30:41 GMT
From: jerome@activeindexing.com (Jerome O'Neil)
Subject: Re: FAQ 5.3:   How do I count the number of lines in a file?
Message-Id: <RF806.1255$lz1.274493@news.uswest.net>

PerlFAQ Server <faq@denver.pm.org> elucidates:
> This message is one of several periodic postings to comp.lang.perl.misc
> intended to make it easier for perl programmers to find answers to
> common questions. The core of this message represents an excerpt
> from the documentation provided with every Standard Distribution of
> Perl.
> 
> +
>   How do I count the number of lines in a file?

I don't know who maintains this, but Abigail's line count JAPH aught
to be an answer to this as well, purely as an academic excercise.

-- 
If men could learn from history, what lessons it might teach us!  But
passion and party blind our eyes, and the light which experience gives
is a lantern on the stern, which shines only on the waves behind us.
				--Samuel Taylor Coleridge, "Recollections"


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

Date: Wed, 20 Dec 2000 21:02:23 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: getting output from net::telnet
Message-Id: <z7906.531$Kk5.27161@eagle.america.net>

On Wed, 20 Dec 2000 18:28:48 GMT, entropy <xuvetyn@my-deja.com> wrote:
>having a small problem w/ net::telnet.

That's Net::Telnet on my system.  

>my @lines = $t->cmd("/local/apache/bin/apachectl start");
>print @lines;
>
>returns nothing (yes, the command works and returns output when run
>manually from the command-line.
>
>any thoughts?

What does the dump_log or input_log contain?  That should make it
clear where you're going wrong.  I suspect that the prompt is arriving
before the output, but that's a guess.  Net::Telnet will tell you so
you don't have to guess.  

-- 
Garry Williams


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

Date: Wed, 20 Dec 2000 14:14:03 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Getting the length from an array reference
Message-Id: <3A41211B.47C919FB@motorola.com>

I have the following data structure:

$data_hash is a reference to a hash of arrays. So,

${$data_hash}{"key1"}->[i]

gives the ith value in the array referenced by the "key1" element of the
hash referenced by $data_hash.  Instead of getting at the values of this
array, I need to know the length of the array.  What is the proper
syntax to get this?

I tried @{$data_hash}{"key1"}, but this returns a reference (i.e.
ARRAY(0x93c7d74))
I also tried $#{$data_hash}{"key1"}, which is a syntax error.

Any help would be greatly appreciated.

-- 
/------------------------------------------------------------------\
| Matt Stoker                |     email: matt.stoker@motorola.com |
| Unit Process Modeling      | Mail Drop: M360                     |
| DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
| Motorola, SPS              |       Fax: (480)655-5013            |
| 2200 W Broadway Road       |     Pager: (888)699-8803            |
| Mesa, AZ 85202             |                                     |
\------------------------------------------------------------------/


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

Date: Wed, 20 Dec 2000 21:55:57 GMT
From: Jeff Helman <jhelman@wsb.com>
Subject: Re: Getting the length from an array reference
Message-Id: <3A412B40.9131B785@wsb.com>

Matthew Stoker wrote:
> 
> I have the following data structure:
> 
> $data_hash is a reference to a hash of arrays. So,
> 
> ${$data_hash}{"key1"}->[i]
> 
> gives the ith value in the array referenced by the "key1" element of the
> hash referenced by $data_hash.  Instead of getting at the values of this
> array, I need to know the length of the array.  What is the proper
> syntax to get this?
> 
> I tried @{$data_hash}{"key1"}, but this returns a reference (i.e.
> ARRAY(0x93c7d74))
> I also tried $#{$data_hash}{"key1"}, which is a syntax error.

Okay, so we are talking about a structure like:

$data_hash = {
    'key1' => [1,2,3,4,5,6,7,8],
    'key2' => [2,3,4,5,6,7]
};

The number of elements for the first key ("key1") can be determined by
one of the following:

scalar(@{$data_hash->{'key1'}})
scalar(@{$$data_hash{'key1'}})

(They do the same thing, it's just a question of how you address the
fact that $data_hash is a reference).  To get the index of the last
element of the array, use one of:

$#{$data_hash->{'key1'}}
$#{$$data_hash{'key1'}}

Same deal applies.  I generally like the arrow notation myself, as I
find it more readable.  Also, of course, you could lose the single
quotes around 'key1'.

> Any help would be greatly appreciated.

Hope this helps,
JH

> 
> --
> /------------------------------------------------------------------\
> | Matt Stoker                |     email: matt.stoker@motorola.com |
> | Unit Process Modeling      | Mail Drop: M360                     |
> | DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
> | Motorola, SPS              |       Fax: (480)655-5013            |
> | 2200 W Broadway Road       |     Pager: (888)699-8803            |
> | Mesa, AZ 85202             |                                     |
> \------------------------------------------------------------------/



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

Date: Wed, 20 Dec 2000 14:33:01 -0700
From: Matthew Stoker <matt.stoker@motorola.com>
Subject: Re: Getting the length from an array reference
Message-Id: <3A41258D.A25F3A21@motorola.com>

Matthew Stoker wrote:
> 
> I have the following data structure:
> 
> $data_hash is a reference to a hash of arrays. So,
> 
> ${$data_hash}{"key1"}->[i]
> 
> gives the ith value in the array referenced by the "key1" element of the
> hash referenced by $data_hash.  Instead of getting at the values of this
> array, I need to know the length of the array.  What is the proper
> syntax to get this?
> 
> I tried @{$data_hash}{"key1"}, but this returns a reference (i.e.
> ARRAY(0x93c7d74))
> I also tried $#{$data_hash}{"key1"}, which is a syntax error.
> 
> Any help would be greatly appreciated.
> 

After a little playing around I discovered the following:

my $lna = ${$data_hash}{"key1"};
print "$#$lna\n";

Prints the proper value (the last element index of the array). However,

my $lna = $#${$data_hash}{"key1"};
print "$lna\n";

gives a syntax error. What's going on?



-- 
/------------------------------------------------------------------\
| Matt Stoker                |     email: matt.stoker@motorola.com |
| Unit Process Modeling      | Mail Drop: M360                     |
| DigitalDNA(TM) Laboratories|     Phone: (480)655-3301            |
| Motorola, SPS              |       Fax: (480)655-5013            |
| 2200 W Broadway Road       |     Pager: (888)699-8803            |
| Mesa, AZ 85202             |                                     |
\------------------------------------------------------------------/


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

Date: Wed, 20 Dec 2000 22:11:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Getting the length from an array reference
Message-Id: <deb24t8gss94b3js5hr2uis5dgomk7hn4s@4ax.com>

Matthew Stoker wrote:

>Subject: Getting the length from an array reference

Another one that calls this "length"? Strange. Is this the Javascript
influence, or what? But, let's pass this by.

>I have the following data structure:
>
>$data_hash is a reference to a hash of arrays. So,
>
>${$data_hash}{"key1"}->[i]
>
>gives the ith value in the array referenced by the "key1" element of the
>hash referenced by $data_hash.

You can try

	$data_hash->{"key1"}[i]

as well. I think that's quite a bit simpler.

>Instead of getting at the values of this
>array, I need to know the length of the array.  What is the proper
>syntax to get this?
>
>I tried @{$data_hash}{"key1"}, but this returns a reference (i.e.
>ARRAY(0x93c7d74))

If you look closely, you'll see that this is too close for comfort, to
your syntax to get the array item. In fact, 

	@{$data_hash}{"key1"}

is the "slice" version (1 item) of

	${$data_hash}{"key1"}

so it cannot do what you want. How about

	@{$data_hash->{"key1"}}

>I also tried $#{$data_hash}{"key1"}, which is a syntax error.

	$#{$data_hash->{"key1"}}


p.s. you have a dereference precedence problem.

-- 
	Bart.


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

Date: Wed, 20 Dec 2000 13:42:31 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: GNU Info-Zip & LWP
Message-Id: <6596-3A410BA7-14@storefull-241.iap.bryant.webtv.net>

 
nobull@mail.com wrote:

> [snipped full-o-bull's non-responsive reply]
=A0
Next...

Kind Regards,
Dennis



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

Date: Wed, 20 Dec 2000 21:23:46 GMT
From: richardstands@my-deja.com
Subject: Re: Help with multipart form
Message-Id: <91r80o$ncm$1@nnrp1.deja.com>

In article <90bs42$r44$1@nnrp1.deja.com>,
  RUATurtle <jack.haberle@bigfoot.com> wrote:
> Hi,
>
> I'm trying to write a script to emulate a user entering data via web
> pages. (I'm told this will make it easier to do system testing ...)
>
> I'm having a problem POSTing a multipart form.  Snippets from the last
> way I've tried follow:
>
> .
> .
> $CF_pairs{'filename'}        = '/home/Bank.asf';
> $CF_pairs{'fileref'}        = ["/home/Bank.asf"];
> .
> .
>
> $next_url = url ("http://....ContentFormInsertResult");
>
> $req = POST $next_url,
>             Content_Type => 'form-data',
>             Content => \%CF_pairs;
> $content = $ua->request ($req)->as_string;
> print $content;
>
> I'm getting a "Corrupt form data: premature ending" error.
>
> If you haven't guessed already, I'm new at this.  Nobody else here
knows
> the terrain, either.
>
> The only documentation I've been able to find is that for
> lib::HTTP::Request::Common(3).
>
> Can anyone point to any other useful documentation?  Anyone have any
> idea where I've gone astray?
>
> TIA for any help!
> -Jack
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

Hi, I need to accomplish the same thing. I'm not getting any errors
myself but the server I am 'POST'ing to will not accept the file and
simply returns the form page as content. The HTTP::Request::Common
documentation looks straightforward but I wonder if it is something on
the backside that prevents this from working e.g. Apache or whatever
the web server is? I'm going to keep at this and I will let you know
what I find out if anything.

-Rich



Sent via Deja.com
http://www.deja.com/


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

Date: Wed, 20 Dec 2000 13:25:48 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Help with REGEXP and templates!
Message-Id: <slrn941udc.2o5.tadmc@magna.metronet.com>

k <none@none.ca> wrote:

>In the above, "REQUEST.form.FullName" is parsed out by a REGEXP and
>translated into $REQUEST->form->get('FullName')  by a subroutine a have
>written. I have created the following REGEXP to do this (Note: In previous
>scripts I have surrounded my variables in [delimiters] - I want to avoid
>doing this here)
>
>$template =~ s/(REQUEST)\.(\w*|\.*)(\W|$)/&parseVarCall($1,$2).$3/ges;


It seems strange to go to the trouble of remembering a constant:

   $template =~ s/REQUEST\.(\w*|\.*)(\W|$)/&parseVarCall('REQUEST',$1).$2/ges;


It seems even stranger to use an alternation instead of a character class:

   $template =~ s/REQUEST\.([\w.]*)(\W|$)/&parseVarCall('REQUEST',$1).$2/ges;


>I am trying to tell the REGEXP:
>
>  - Start matching at REQUEST.
>  - Match all letters (\w) or periods (\.) until you hit a non-word
>character (or the end of the string).


If you mean until a non-word, non-period character, then:

   $template =~ s/REQUEST\.([\w.]*)/&parseVarCall('REQUEST',$1)/ge;

and greed with take care of the rest.

Note also that I have removed your cargo-cultish s///s option. The 's'
option only affects the metadot character, but you do not have any
metadots in your pattern, only literal dots.


>This of course doesn't work because periods ARE non-word characters, so it
>stops at the first period. Is there any way to tell the REGEXP \W command to
>ignore the periods, or maybe another way of acheiving this effect?

   $template =~ s/REQUEST\.([\w.]*)([^\w.]|$)/&parseVarCall('REQUEST',$1).$2/ge;


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


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

Date: Wed, 20 Dec 2000 15:10:19 -0400
From: "Netcom" <aphowe@netcom.ca>
Subject: Re: How to check if a class include a particular method?
Message-Id: <su706.9910$t3.15018@tor-nn1.netcom.ca>

print "Method Exists!" if eval { &Class::A() };

"Ole Christian Eidheim" <eidheim@hivolda.no> wrote in message
news:3A3FB74B.FA16927@hivolda.no...
> Hi, I'm stuck again:)
>
> How do I figure out if a class include method A or not?
>
> I wish "defined($class->A)" worked, but it doesn't.
>
> Thanks again,
> Ole Christian Eidheim




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

Date: Wed, 20 Dec 2000 21:40:26 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: How to check if a class include a particular method?
Message-Id: <eH906.535$Kk5.27309@eagle.america.net>

On Wed, 20 Dec 2000 15:10:19 -0400, Netcom <aphowe@netcom.ca> wrote:
>"Ole Christian Eidheim" <eidheim@hivolda.no> wrote in message
>news:3A3FB74B.FA16927@hivolda.no...
>> Hi, I'm stuck again:)
>>
>> How do I figure out if a class include method A or not?
>>
>> I wish "defined($class->A)" worked, but it doesn't.
>
>print "Method Exists!" if eval { &Class::A() };

Maybe you should test the solutions you post: 

    $ cat x
    #!/usr/local/bin/perl -lw
    use strict;
    my $obj = Class->new;
    print $obj->A();
    print "Method Exists!" if eval { &Class::A() };
    package Class;
    sub new {
	my $class = shift;
	return bless { foo => 'value of foo' }, $class
    }
    sub A {
	my $self = shift;
	return $self->{foo};
    }
    $ perl x
    value of foo
    $ 

This question was answered by others with working solutions.  

-- 
Garry Williams


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

Date: Wed, 20 Dec 2000 19:43:50 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: how to invalidate a hash value during a foreach loop?
Message-Id: <WZ706.522$Kk5.26852@eagle.america.net>

On Wed, 20 Dec 2000 10:44:38 -0500, Tad McClellan <tadmc@metronet.com>
wrote:
>Garry Williams <garry@zweb.zvolve.net> wrote:
>>"values"
>>returns a list.  
> ^^^^^^^^^^^^^^
>
>Oops.
>
>Sometimes (when in list context) it returns a list, but this is 
>not one of those times  :-)
>
>>  if ( values(%form_results) ) {
>
>That is scalar context (ie. one of those "other times").
>
>No list here.

Luckily, since the values() function is defined to return the number
of elements in the hash, if evaluated in scalar context, the test
above will do as intended.  

Instead of relying on luck, I would have been better advised to check
the perlfunc manual page.  

    Returns a list consisting of all the values of the named hash. (In
    a scalar context, returns the number of values.)

DWIM rescued me.  :-)  

-- 
Garry Williams


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

Date: 20 Dec 2000 19:05:13 +0000
From: nobull@mail.com
Subject: Re: HTTP::Request help (Getting past ASP Login pages)
Message-Id: <u9lmtazzfa.fsf@wcl-l.bham.ac.uk>

"Steve Lok" <kaneda@intercom.com> writes:

> I'm trying to post some info to a form at /check/check.asp, but I get
> redirected to a /login.asp script whenever I send the request. I'm
> suspecting it's asking me to log in first, that's my problem.

You probably need to simulate submission the form that you find on the
/login.asp page, save the cookie returned and then send a request to
/check/check.asp with the same cookie.  You can automate cookie
handling in LWP::UserAgent simply by saying:

$ua->cookie_jar(HTTP::Cookies->new);

> $request1 = "ID=login&password=pass&txt1=you&txt2=me";
> my $rq1 = HTTP::Request->new (POST => $url1);
> $rq1->header('Content-Type' => 'text/xml');
> # Set the content of the request to the XML request text
> $rq1->content($request1);

XML?  XML?!  Do you have any idea what XML looks like?  That
$request1 variable is _not_ XML.  It doesn't look anything like XML.

The correct content type to describe it is
'application/x-www-form-urlencoded'.  (Dunno why there's still an 'x-'
in there after all these years).

Change the content-type and give the user agent a cookie jar and your
code may work.

You should consider using HTTP::Request::Common rather than building
application/x-www-form-urlencoded content by hand.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 20 Dec 2000 22:08:02 +0100
From: otto.wyss@bluewin.ch (Otto Wyss)
Subject: IDE for development in perl
Message-Id: <1elyjue.1lb4hw81qpiiz8N%otto.wyss@bluewin.ch>

Is there any useful IDE for development in perl (platform WindowsNT) or
does everyone just use a simple text editor?

If there is no IDE what's the best editor?

O. Wyss


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

Date: Wed, 20 Dec 2000 21:56:56 GMT
From: schnurmann@my-deja.com
Subject: Re: IDE for development in perl
Message-Id: <91r9v3$p6k$1@nnrp1.deja.com>

Take a look at this freebee....

www.html-kit.com

In article <1elyjue.1lb4hw81qpiiz8N%otto.wyss@bluewin.ch>,
  otto.wyss@bluewin.ch (Otto Wyss) wrote:
> Is there any useful IDE for development in perl (platform WindowsNT)
or
> does everyone just use a simple text editor?
>
> If there is no IDE what's the best editor?
>
> O. Wyss
>


Sent via Deja.com
http://www.deja.com/


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

Date: 20 Dec 2000 19:21:55 +0000
From: nobull@mail.com
Subject: Re: is this bad perl programming habit?
Message-Id: <u9k88uzyng.fsf@wcl-l.bham.ac.uk>

abigail@foad.org (Abigail) writes:

> nobull@mail.com (nobull@mail.com) wrote on MMDCLXVIII September MCMXCIII

> ()       ... I think I should point out that unthinkingly calling the
> () import() method of a module that's require()d  at runtime is probably
> () a bad habit.  I'm not saying you shouldn't call it, just that you
> () should think about what it means first.
> 
> By not calling import(), it wouldn't do the same as "use", which the
> OP attempted to do.

It is impossible for something at runtime to do exactly the same as
something at compile time.  I do not deny that you answered the
question.  I still stand by my statement.

> OP wanted to have a conditional, run-time use.

Actually that's what the OP _said_ they wanted.  This is not the same
thing.  The OP also explicitly stated that they wanted to be advised
of bad habits.

> Omitting import() would be a mistake.

Not necessarily.  Not thinking about the implication of calling
import() would be a mistake.  Having thought about the implications of
calling import() then you will probably decide to call it.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 20 Dec 2000 11:49:37 -0800
From: Kenny Pearce <kenny@kennypearce.net>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the    ULTIMATE oflanguages??)
Message-Id: <3A410D51.A24F4582@kennypearce.net>

Bart Lateur wrote:

> Kenny Pearce wrote:
>
> >I haven't used SmallTalk, but from this conversation it seems that the only difference
> >between "everything is an object" and having primitives is that the latter requires
> >less typing. Ex.
> >int x =1;
> >as opposed to
> >Integer x = new Integer(1);
> >
> >I can't c y there would be any other difference...
>
> Because now you can easily write functions (oops, "methods") that do
> unrelated things for integers and for floats?
>
> --
>         Bart.

well, in Java, you can apply Integer methods to a primitive type int, or you can just do
int primitive = 5;
Integer object = (Integer)primitive;

and force your primitive to become an object at any point in your code... not too
difficult..



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

Date: Wed, 20 Dec 2000 20:24:29 +0100
From: Just Me <just_me@nowhere.com>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the   ULTIMATE oflanguages??)
Message-Id: <3A41076D.23A764FC@nowhere.com>

First let me say that I don't want to start yet another religious war about
languages, but in Smalltalk this would be:

  |x|
  x=1.

Notice the same amount of keystrokes? ;-)

Now, let's see a case where Smalltalk is clearly better. Take this code
from Java for example:

  java.util.Enumeration enum=allEmployees.elements();
  while( enum.hasMoreElements() ) {
    Employee eachEmployee=(Employee)enum.nextElement();
    eachEmployee.firstMethod();
    eachEmployee.secondMethod();
  }

 ...into Smalltalk:

  allEmployees do: [:eachEmployee |
     eachEmployee
        firstMethod;
        secondMethod ].

In Smalltalk it's simple, elegant and easy to read whereas in Java one can get
headaches from all these braces. I mean what are braces for anyway if a
method has no arguments?

And as you can see, no types mean less typing!


Kenny Pearce wrote:

> I haven't used SmallTalk, but from this conversation it seems that the only difference
> between "everything is an object" and having primitives is that the latter requires
> less typing. Ex.
> int x =1;
> as opposed to
> Integer x = new Integer(1);
>
> I can't c y there would be any other difference...



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 5162
**************************************


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