[15818] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3231 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 1 21:05:37 2000

Date: Thu, 1 Jun 2000 18:05:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <959907912-v9-i3231@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 1 Jun 2000     Volume: 9 Number: 3231

Today's topics:
    Re: C to perl? <juex@deja.com>
    Re: C to perl? <juex@deja.com>
        Case-Insensitive String Comparison <cdt9@cornell.edu>
    Re: Case-Insensitive String Comparison (Abigail)
    Re: Case-Insensitive String Comparison <lauren_smith13@hotmail.com>
        Disk requirements for installing PERL5 on UNIX? <rwilliamson@uno.gers.com>
    Re: file dates being reported incorrectly..... (Bart Lateur)
    Re: file dates being reported incorrectly..... (Tad McClellan)
    Re: generating WML (Andy Jones)
        Help: CGI.pm and constant.pm <mde@mde-net.de>
    Re: How can I do that? (Tad McClellan)
    Re: How do I make perl flush? (Tad McClellan)
    Re: How do I make perl flush? <philip@my-deja.com>
    Re: How do I make perl flush? (Craig Berry)
    Re: how do you create scalar vars from a hash? (Tad McClellan)
    Re: native file renaming function ? (Tad McClellan)
        Net::FTP question : Can I get control back on timeout? <tmvatcher@bigfoot.com>
    Re: Networking Perl for NT <carvdawg@patriot.net>
    Re: Newbie <flavell@mail.cern.ch>
    Re: Newbie: help with linking to another webpage <flavell@mail.cern.ch>
    Re: Non-reuse of memory for lexically-scoped variables? (Ilya Zakharevich)
    Re: patten matching (Tad McClellan)
        Peculiar? Re-entrant Subroutines? <odesseus@my-deja.com>
    Re: Perl unusable as a programming language (Ilya Zakharevich)
    Re: Perl unusable as a programming language <bet@rahul.net>
    Re: Trouble with Arrays of Hashes <rlanier@nc.rr.com>
    Re: Trouble with Arrays of Hashes (Sam Holden)
    Re: Trouble with Arrays of Hashes (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 1 Jun 2000 15:08:37 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: C to perl?
Message-Id: <3936dee5$1@news.microsoft.com>

"brian d foy" <brian@smithrenaud.com> wrote in message
news:brian-ya02408000R0106001613200001@news.panix.com...
> In article <39369278$1@news.microsoft.com>, "Jürgen Exner" <juex@deja.com>
posted:
>
> > That is what you usually use as a metric to compare two programs: The
same
> > input generates the same output.
>
> what about programs that take no input and give no output?

If a program doesn't generate any output, then what does it do? The output
is the only observable behaviour of a program (except for resource
consumption, but we are not talking real-time programming here anyway).

> do you contend that they are all equivalent?
> that seems like a limited view of computing.

Well, how do you want to distinguish them? All of them are doing exactly the
same thing, notably nothing. So their behaviour is identical and they are
all equivalent.
Maybe you have an example of two programs which don't produce any output but
which from your point of view are not equivalent?

> indeed, in that case, every program is a Perl program if
> you can use Perl as a wrapper that simply does nothing but
> pass on the input and output.

You mean via a 'system' call? Well, this point of view seems to be a bit
extreme.
Usually you are supposed to re-implement the functionality in the other
language, not to simply call the existing old program.

jue





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

Date: Thu, 1 Jun 2000 15:15:50 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: C to perl?
Message-Id: <3936e097$1@news.microsoft.com>

"brian d foy" <brian@smithrenaud.com> wrote in message
news:brian-ya02408000R0106001719120001@news.panix.com...
> In article <8h6gir$qhv$1@news.panix.com>, abigail@arena-i.com posted:
>
> > On Thu, 01 Jun 2000 16:13:20 -0400, brian d foy <brian@smithrenaud.com>
wrote:
> > ++ In article <39369278$1@news.microsoft.com>, "Jürgen Exner"
<juex@deja.com> posted:
> > ++
> > ++ > That is what you usually use as a metric to compare two programs:
The same
> > ++ > input generates the same output.
> > ++
> > ++ what about programs that take no input and give no output?  do you
contend
> > ++ that they are all equivalent?  that seems like a limited view of
> > ++ computing.
> >
> > Eh, yes, I certainly would say they are equivalent.
> >
> > If they were different, then how exactly would you notice the
difference?
>
> does that then mean that the only way anything is changed by output?
> what then qualifies as output?

Pretty simple: Any action of the program, which is observable by a user is
output(usually not including resource consumption unless you are talking
about real-time programming).

This might be some printout on the screen, changing the appearance of a
button in a dialog (from raised to pressed), or just establishing a
connection to some server on the other side of the planet.

jue




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

Date: Thu, 1 Jun 2000 20:18:16 -0400
From: "Courtney Tompos" <cdt9@cornell.edu>
Subject: Case-Insensitive String Comparison
Message-Id: <8h6ufm$o2p$1@news01.cit.cornell.edu>

Warning: Newbie =)

That said, I want to compare two strings to check whether one ($var2) is a
substring of the other ($var1). Thus the first thing I did was $var1 =~
$var2. Now here's my question! How can I alter the code so that its not
case-sensitive?

$var1 = "Thesaurus";
$var2 = "THE";

The check should return true, given these variables.

Thanks in advance.




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

Date: 2 Jun 2000 00:53:11 GMT
From: abigail@arena-i.com (Abigail)
Subject: Re: Case-Insensitive String Comparison
Message-Id: <8h70hn$498$1@news.panix.com>

On Thu, 1 Jun 2000 20:18:16 -0400, Courtney Tompos <cdt9@cornell.edu> wrote:
++ Warning: Newbie =)
++ 
++ That said, I want to compare two strings to check whether one ($var2) is a
++ substring of the other ($var1). Thus the first thing I did was $var1 =~
++ $var2. Now here's my question! How can I alter the code so that its not
++ case-sensitive?
++ 
++ $var1 = "Thesaurus";
++ $var2 = "THE";
++ 
++ The check should return true, given these variables.


If you want to see whether one string is a substring of the other,
use index. And to make it case insensitive, make it all the same
case.

    if (index (lc $var1, lc $var2) >= 0) { ... }


Abigail


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

Date: Thu, 1 Jun 2000 17:39:38 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: Case-Insensitive String Comparison
Message-Id: <8h6vqf$dcd$1@brokaw.wa.com>


Courtney Tompos <cdt9@cornell.edu> wrote in message
news:8h6ufm$o2p$1@news01.cit.cornell.edu...
>
> That said, I want to compare two strings to check whether one ($var2) is a
> substring of the other ($var1). Thus the first thing I did was $var1 =~
> $var2. Now here's my question! How can I alter the code so that its not
> case-sensitive?
>
> $var1 = "Thesaurus";
> $var2 = "THE";
>
> The check should return true, given these variables.

Look at the perlre documentation.

perldoc perlre

You should be able to learn the syntax to do what you want fairly quickly.

Lauren





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

Date: Thu, 01 Jun 2000 22:14:28 GMT
From: "Rusty Williamson" <rwilliamson@uno.gers.com>
Subject: Disk requirements for installing PERL5 on UNIX?
Message-Id: <8fBZ4.19858$Y4.104427@typhoon2.san.rr.com>

Hi!

I've looked and looked and can not find how much disk space is required to
install the latest stable version of PERL on UNIX.  Has anyone seen this
posted anywhere or know what I'll need?

Thanks!
Rusty




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

Date: Fri, 02 Jun 2000 00:13:26 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: file dates being reported incorrectly.....
Message-Id: <3936fad5.3202182@news.skynet.be>

scumjr wrote:

>For example the
>actual last modified time stamp would be 3/12/99......it would report
>11/31/69.   Actual last access time 8/27/00.....it would report 11/31/69.
>For ALL other files the time stamps are correct.

What's so special about 11/31/69... That is the last day of 1969, isn't
it? The day before Unix Epoch? Could it be that the "time" returned was
-1?

It looks to me like Your OS didn't find the file.

Now I wouldn't be surprised if the difference between character encoding
for accented characters, between DOS and Windows, has something
(actually, a lot) to do with it. Perhaps you need to convert the
character set from Windows to DOS or vice versa...

If so, and if you're using Activestate, I'd think it's a bug. You
shouldn't have to do that. From a DOS Perl, running under Windows, I can
understand it...

-- 
	Bart.


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

Date: Thu, 1 Jun 2000 19:18:55 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: file dates being reported incorrectly.....
Message-Id: <slrn8jdvbf.tv.tadmc@maxim.metronet.com>

On Thu, 01 Jun 2000 21:04:42 GMT, scumjr <scumjr@deja.com> wrote:
>
>> NT seems to report the file date in the 11-th field returned by stat().
>>
>> my $f_time = scalar localtime( (stat 'filename')[10] );
>
>Thanks for the tip, but I've been using indices 8 and 9 (last access/modify
>time) and it's been reporting the date as 11/31/69 (dates are offset by one
>so it is in fact reporting December (not Nov.)) for any files that have a
>"special" character in the name (ie the 1/2 character).
                                  ^^
                                  ^^ 
I assume you meant e.g. (for example) rather than i.e. (that is) there?

i.e. it happens with any special char, not just with 1/2 as
you have said.


I find it suspicious that 31 Dec 69 is the day before the
Unix epoch. Might that be a clue?


What do the -A and -M filetests do?


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


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

Date: Thu, 01 Jun 2000 22:07:09 GMT
From: Andrew_D_Jones@nospamhotmail.com (Andy Jones)
Subject: Re: generating WML
Message-Id: <3936ce2b.45149840@newnews.dircon.co.uk>

On Thu, 1 Jun 2000 15:43:02 +0200, "Alan J. Flavell"
<flavell@mail.cern.ch> wrote:

>
>On Thu, 1 Jun 2000, Andy Jones stood usenet on its head and out
>popped this:
>
>> I'm sorry but I must disagree.
>
>Yes, it's a constant of nature that there always has to be one like
>that.
>

Such is life on usenet ;-)

>> If someone wants to generate WML from
>> perl, then I would say that it has everything to so with this
>> newsgroup.
>

<rant about upside down posters snipped>

Apologies but your opinion is just that. In the perlfaq on Jeopardy
style posting at:-

	http://www.perlfaq.com/faqs/id/131

Joeseph Hall writes a note about Abigail's opinion on such posts. If
this is the unwritten rule in this newsgroup, then I'll try to stick
to this in future.

>
>> Comments such as the one below are at best unhelpful 
>
>On the contrary, they're only unhelpful to people who won't learn how
>to analyze their problems effectively, so that they can identify which
>part of the problem is relevant to what.  And, of course, unhelpful to
>those who post upside-down to usenet.
>

Sorry, but I thought this newsgroup was for general perl posts and
therefore a good place for this particular newbie to start looking for
info. Whether on or off topic, I've never particular liked the kind of
reply that simply says (as Kragen did) that this is the wrong place to
look and nothing else.

>> and at
>> worst very offputting for an obvious newbie.
>
>This is a programming language forum, ferchrissake, not a social
>encounter group.  Your reference to that URL seems to have been rather
>a complicated way of answering the question "how do I generate WML
>from Perl?" with the reply "using a print statement".  I would assume
>that the questioner already knows this.
>
>By the way, who appointed you net.cop of this group, and why does 
>your usenet posting history at deja consist of a grand total of two
>articles?

God forbid! I never have been, never claimed to be and never will be
net cop for this group. I'm sure there are more than enough people
capable of doing the job before me. I've only ever posted two articles
for the simple reason that that my 'enlightened' employer of the last
3 1/2 years will only allow the reading of news and not posting (which
is quite possibly the definition of frustration :-)

<rant about bad code snipped>

You're quite right it's not the best code in the world. However it's
the _only_ perl/WML tutorial I've seen on the web so far, and as the
guy's a newbie, then it will at least give him a starting point to get
some dynamic WML pages up.

I hope this clears things up,

Andy.


reply to Andrew_D_Jones@nospamhotmail.com

remove the nospam to reply.


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

Date: Fri, 2 Jun 2000 00:03:32 +0200
From: "Michael D. Eschner" <mde@mde-net.de>
Subject: Help: CGI.pm and constant.pm
Message-Id: <8h6ms1$b9s$13$1@news.t-online.com>

Hi,

I have implemented the library CGI.pm in a perl implementation in Windows
98. If I test this I get an error: can't find constant.pm in line 29. There
is an "use constant" statement, but I can't find constant.pm. I'm a perl
newbie :(

Any help?

MDE





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

Date: Thu, 1 Jun 2000 19:22:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How can I do that?
Message-Id: <slrn8jdvj2.tv.tadmc@maxim.metronet.com>

On Thu, 01 Jun 2000 10:35:27 -0400, Martin C Dore (LMC) 
  <lmcmcad@lmc.ericsson.se> wrote:

>     Suppose I have fetch FirstName, LastName, Date and I want to pass
>those 3 value to my C program so he can use an API function that need
>these 3 values.How can I do that ?


Write the Perl program to output them on STDOUT.

Write the C program to read them on stdin.

Then connect them with a pipe in the shell.


(I have answered the question that you asked, though I think you
 were probably trying to ask some other question...
)

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


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

Date: Thu, 1 Jun 2000 15:14:00 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How do I make perl flush?
Message-Id: <slrn8jdh08.qn.tadmc@maxim.metronet.com>

On Thu, 01 Jun 2000 02:01:36 GMT, Fearless <philip@my-deja.com> wrote:
>In article <8h2rro$pql$1@clematis.singnet.com.sg>,
>  "Swee Heng" <sweeheng@usa.net> wrote:
>> > So, how do I flush the output file (or do whatever) so diff sees a
>> > fully written file?
>>
>> perldoc -q flush
>
>We don't have perldoc, 


Then you don't have perl!

perldoc is *part of* perl. It comes with the perl distribution.

If your sysadmin took special action to have perldoc not be
installed, then *they* have volunteered to answer all of
their user's Perl questions.

Ask your sysadmin your Perl questions. Tell all of your
friends/coworkers to do so also. Ask the question again
if you do not get an answer in an hour or two.

It won't take long for the sysadmin to see the wisdom of
getting perl installed properly   :-)


>and none of websites I found would accept -q
>flush in their search field; some wouldn't even accept select(!).


This makes no sense whatsoever.

Perl is not websites. Websites are not Perl.

What are you trying to say there?


>The following attempts all failed:
>
>$|=1;


Then you have a serious problem (somewhere), 'cause that
code looks fine to me...


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


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

Date: Thu, 01 Jun 2000 23:22:15 GMT
From: Fearless <philip@my-deja.com>
Subject: Re: How do I make perl flush?
Message-Id: <8h6r6v$ks5$1@nnrp1.deja.com>

In article <5epcjs8dvjmp6hu34n2rihkjbb5psei6vs@4ax.com>,
  Abe Timmerman <abe@ztreet.demon.nl> wrote:
> so you probably should:
> 	close ARGVOUT;

Yep, that works too; yesterday afternoon (Sydney time) I worked out that
    close(ARGV);    #reset $.
    close;
would do the trick. I imagine that in the context of the close, ARGVOUT
is the default, and so our two approaches are identical. I'd never
heard of ARGVOUT until now.

Thanks, everyone

Philip

--
Fearless
(>|<)
  |


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Fri, 02 Jun 2000 00:00:55 GMT
From: cberry@cinenet.net (Craig Berry)
Subject: Re: How do I make perl flush?
Message-Id: <sjdu9naq5ri125@corp.supernews.com>

Fearless (philip@my-deja.com) wrote:
: I did say this was my first script. And I've considered several times
: already just shitcanning this perl thing and doing the job in C. But
: I'm a great believer in horses for courses, and I thought this job
: might be a good opportunity to learn perl (and give myself yet another
: horse from which to choose in future), so I'm persevering. If you or
: anyone else can suggest a better approach for my original problem
: (retaining the timestamp of unaltered files), I'm all ears.

Your code as written appears to do nothing if $MODIFY is false.  If it's
true, then all files are checked for the string 's1'; for each line
containing it, the result of substituting this with 's2' is sent to
stdout.  Then a diff is done with a .bak file which seemingly comes out of
nowhere...are you running with -i.bak and not telling us?  I'll assume so.

If I've understood the rest of what you're doing properly, this seems a
more direct path:

#!/usr/bin/perl -w

use File::Copy;

# ...

if ($MODIFY eq 'yes') {
  foreach my $file (@ARGV) {
    my $scratch = "$file.new";

    open FILE,    "< $file"    or die "$file : $!\n";
    open SCRATCH, "> $scratch" or die "$file.new : $!\n";

    my $dirty = 0;

    while (<FILE>) {
      $dirty ||= s/s1/s2/i;
      print SCRATCH;
    }

    close FILE;
    close SCRATCH;

    if ($dirty) {
      move $scratch, $file or die $!;
    }
    else {
      unlink $scratch or die $!;
    }
  }
}


-- 
   |   Craig Berry - cberry@cinenet.net
 --*--  http://www.cinenet.net/users/cberry/home.html
   |   "The road of Excess leads to the Palace
      of Wisdom" - William Blake


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

Date: Thu, 1 Jun 2000 15:22:02 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: how do you create scalar vars from a hash?
Message-Id: <slrn8jdhfa.qn.tadmc@maxim.metronet.com>

On Thu, 01 Jun 2000 02:28:00 GMT, Arne Hermann <arneh@NOSPAMistar.ca> wrote:
>On Mon, 29 May 2000 17:22:31 -0700, Larry Rosler <lr@hpl.hp.com>
>wrote:
>>In article <3932c114.62322141@news.direct.ca>, arneh@NOSPAMistar.ca 
>>says...
>>> this is not exactly a module question, but...
>>
>>You're right, so why mispost it?
>
>Cause I posted it several times elsewhere, without any luck!  


Perhaps you should have a look at Why Questions Go Unanswered:

    http://www.plover.com/~mjd/perl/Questions.html

so that you can increase your chances the next time.


>Sorry,
>but sometimes one has to bend the rules (flame shields UP!).  
                          ^^^^^^^^^^^^^^

You did not "bend" the rules.

You "broke" the rules (and you knew you were).



Flames should be only a minor concern, as they don't last long.

What _should_ concern you is hurting your chances of getting
_future_ Perl questions answered.

Knowingly making off-topic postings is a Very Good Way of
getting killfiled...


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


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

Date: Thu, 1 Jun 2000 15:27:14 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: native file renaming function ?
Message-Id: <slrn8jdhp2.qn.tadmc@maxim.metronet.com>

On Thu, 01 Jun 2000 00:03:10 GMT, Peter L. Berghold <peter@lberghold.net> wrote:
>In article <393598AF.9D15CCBF@shifted-bytes.de>, Michael Agbaglo <byteshifter@shifted-bytes.de> wrote:

>Secondly, I would actually advise you write a "safe" rename function that verifies that the file was renamed. 
>I got burned by using the rename function.


If you did not check the return value from rename() then you
got what you deserved!

There is no need for a module, simply check the return value:

   rename $old, $new or die "could not mv '$old' to '$new'  $!";


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


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

Date: Thu, 01 Jun 2000 15:09:18 -0700
From: Toni Vatcher <tmvatcher@bigfoot.com>
Subject: Net::FTP question : Can I get control back on timeout?
Message-Id: <3936DF0E.CBEB608E@bigfoot.com>

I am using Net::FTP to get a bunch of files from a server. 
Occasionally, I get a timeout on the $ftp->get but I want processing to
continue with the rest of the files.  In telnet, there is an option
"Errmode" that you can set to "return".  Is there anything like this for
FTP?

Right now, I get the error:
	timeout at D:/Perl/site/ib/Net/FTP.pm line 357
and the program execution terminates.

Does anybody have any ideas how I can get control back from FTP when it
gets the error?  Or any alternative ways to get the files that will
handle this situation?

Thanks for your help!

Toni Vatcher


P.S. Here's the code, if that helps...

	$ftp = Net::FTP-> new ("$modulename",%ftp_options);
	if ($ftp)
	{
	    $ftp->login("","");
	    $ftp->binary();

	    foreach $filename ( keys ( %{$dir {$modulename}} ))
	    {
		if (!$ftp->get("$filename"))
		{
		    print "Unable to get $filename from $modulename";
		}
		else
		{
                        .... file processing
		}
	    }

	    $ftp->quit();
	}


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

Date: Thu, 01 Jun 2000 20:50:05 -0400
From: H C <carvdawg@patriot.net>
Subject: Re: Networking Perl for NT
Message-Id: <393704BD.398AF25C@patriot.net>

check out Dave Roth's paper from the LISA-NT '99 conference...http://www.roth.net

In the paper, he talks about how he set up Perl on a networked share.

> I am having difficulty networking perl in an Windows environment.  I want perl
> to reside on the server and I want everyone to access it including any
> packages that I install. Its a centralization issue and I can't seem to get
> the clients to work properly. Once I map the drive to the server I do a simple
> "Perl -V" and it can't see the libaries. I don't want to have perl reside
> locally if I can help it..
>



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

Date: Fri, 2 Jun 2000 00:13:15 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Newbie
Message-Id: <Pine.GHP.4.21.0006020011450.20864-100000@hpplus03.cern.ch>

On Thu, 1 Jun 2000, !bull wrote:

[quoted some good advice]

>  Give us a break and
> just try to be helpfull and not insulting.

Listen to yourself.  I doubt if many other regulars will.



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

Date: Fri, 2 Jun 2000 00:24:58 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Newbie: help with linking to another webpage
Message-Id: <Pine.GHP.4.21.0006020018420.20864-100000@hpplus03.cern.ch>

On Thu, 1 Jun 2000, it was written:

> For each ../ the users browser will refer to one directory previous to its
> current... 

Oh no!  If that gets anywhere near a client agent, it will move one
level in the URL hierarchy.  What that new URL then corresponds to in
terms of server resources, only the server knows (it might not even be
in a "directory" at all).

> So for good measure you could try....
>
> print "Location: ../../../../search-main.html\n\n"; #load new

Have you the slightest idea what the CGI specification says?

There are two valid kinds of Location: reference.  They are required
to produce quite different results.  That is neither of them.
 
> *I am note sure if the second will function with all browsers. ;(

You've no right to expect it to even function with the server, let
alone send anything meaningful to a browser.  Sheesh. 


Oh, look, an upside-down poster.  I should've known.




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

Date: 1 Jun 2000 23:48:00 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Non-reuse of memory for lexically-scoped variables?
Message-Id: <8h6sng$dcp$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Denis Haskin 
<dwhaskin@earthlink.net>],
who wrote in article <3936D032.51FA5C51@earthlink.net>:

[You sent a stealth Cc.  Please don't do it, mark Cc's of postings as such]

> > Only one of these Ms is recoverable, one in $b, and only by explicit
> >
> >   undef $b;

> Shouldn't this be considered a bug? 

No, it is a feature.

>     {
>         my $b; # yes I know I can my and init at same time.
>         $b = 'x' x 1e6;
>     }
> even though $b is out of scope once I'm out of the block, that memory has
> been allocated and is not reused?

Allocated 2 or 3 times and then no reused.

> Is there a (good) reason that things work this way?

Space vs speed.  (Re)Allocation is slow.

Ilya


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

Date: Thu, 1 Jun 2000 13:48:13 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: patten matching
Message-Id: <slrn8jdbvd.qn.tadmc@maxim.metronet.com>

On Thu, 1 Jun 2000 01:53:42 +0200, Kumanan <Kumanan@uni.de> wrote:

>i want to get the email address from a file (url).
[ snip ]
>so on... (its a html file)
           ^^^^^^^^^^^^^^^

Then you should use one of the modules that can parse HTML,
such as HTML::Parser.


>who to write the patten match for this, 
>so that the emails are put in to a
>variable
>
>$mail = ~/ / /;


There are some regexes (that do a poor job) for doing that
in the Perl FAQ, part 9:

   "How do I check a valid mail address?"


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


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

Date: Thu, 01 Jun 2000 23:54:55 GMT
From: Paris <odesseus@my-deja.com>
Subject: Peculiar? Re-entrant Subroutines?
Message-Id: <8h6t4c$lvn$1@nnrp1.deja.com>

Hello All,

I was doing something peculiar with PERL the other day when I noticed
what might be an unreported *feature*....
I have a subroutine called 'search' which simply searches a text file
for lines containing a given word.
&search uses a *very* simple regular expression at it's core:

if ($search_in =~ /$search_for/oi){$slice_ok = 1}else{last}

The lines that match are copied into a temporary file...

Now the peculiar bit:
I decided that if I wanted to cross reference the results of this file,
against text taken from another file, I could do something like this...

sub one{
#modify the search parameters and call &search
}
sub search{
#do first search, determine whether or not to cross reference
#if yes, call &one
}

It didn't work....
The thing is, the re-entered &search subroutine works fine. PERL
doesn't complain that I can't re-enter the routine before I have
properly left it.
It's just that the regular expression I mentioned above absolutely
REFUSES to work.
I have done some debugging, and there is no way that the regular
expression shouldn't match.

So here are my questions...
Are subroutines in PERL re-entrant?
Why is the Regular Expression engine seemingly not re-entrant?

--
Paris. Not the City.
odesseus@my-deja.com


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 1 Jun 2000 20:56:09 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Perl unusable as a programming language
Message-Id: <8h6il9$a3e$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Russell Bornschlegel 
<kaleja@estarcion.com>],
who wrote in article <3936AA0B.9C36450@estarcion.com>:
> I understand that. I'm just lobbying for very careful use of the term 
> "non-deterministic".

Your run the same construct under different versions of Perl, and get
different results.  Now in which way is this "deterministic", as
programming languages go?

Scripting:	      "I tried it, and it works."

Programming:	      "If it does not work in next version of Perl, I will
		       report it as a bug."

Ilya


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

Date: Thu, 1 Jun 2000 17:07:28 -0400
From: Bennett Todd <bet@rahul.net>
Subject: Re: Perl unusable as a programming language
Message-Id: <20000601170728.Z2319@rahul.net>


--P2/AsD9qFFw+Iv3c
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

2000-05-25-16:41:56 brian d foy:
> there is a difference between sequencing events (scripting) and
> controlling hardware (programming in low level languages).

Not as an absolute, there isn't.

While the C programming language has grown and mutated significantly
in the last 25 years or so, between say the late '70s and today the
changes don't really effect the "level" of the language.

But computers have changed out from underneath it pretty
dramatically. On a PDP-11, using a late '70s C compiler, or on an
8088 using DeSmet C in the early '80s, there was such a
straightforward isomorphism between C source code and the assembler
it produced that C really was just a portable assembler.

But computer architectures have changed pretty dramatically. The
amount of analysis that's performed by a modern optimizing C
compiler when generating code for a modern RISCy CPU architecture is
so dramatic that the sense of "controlling hardware" is _definitely_
much fainter than it used to be, it'd fading fast, I expect it to be
largely gone before too much longer.

C continues to reflect a machine model that can be mapped with
pretty good efficiency --- using ever-more-powerful optimizing
compilers --- onto modern computer architectures, but the mapping is
certainly becoming more complex and subtle.

Whether you choose to do it in Perl or you choose to do it in C,
when you program a computer you control the hardware to sequence
events and manipulate data. There is no difference in kind between
scripting and programming.

-Bennett

--P2/AsD9qFFw+Iv3c
Content-Type: application/pgp-signature
Content-Disposition: inline


Version: GnuPG v1.0.0 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE5NtCQL6KAps40sTYRAr3QAJ9oIk6n0R9eb4WJga9cnlNcon34zwCdHrut
wbzaEhvn6CzHBYYHyx9DGTY=
=+zbU
-----END PGP SIGNATURE-----

--P2/AsD9qFFw+Iv3c--


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

Date: Fri, 02 Jun 2000 00:06:03 GMT
From: Tony Lanier <rlanier@nc.rr.com>
Subject: Re: Trouble with Arrays of Hashes
Message-Id: <3936FA4A.F83E7CC2@nc.rr.com>


Thanks Sam. I'll try this at work tomorrow. I still don't quite understand how
defining the array in the if statement will help, though. I've never had to do
this before when using hashes or arrays. I'm not saying your wrong, just that I
don't see how that will fix the problem. Also, you can see that the size of the
array is three, which is what I expect. What puzzles me is the extra loop the
inner loop does (or does it really loop once more?). Maybe Perl is getting
confused because the same word is used for the key in two different hashes (?).

Anyway, thanks for your help.

Tony


Sam Holden wrote:

> On Thu, 01 Jun 2000 14:01:22 -0700,
>         Tony Lanier <tlanierNOtlSPAM@atmel.com.invalid> wrote:
> >Hi,
> >
> >I have been having trouble using an Array of Hashes (AoH). The
> >file that I am parsing looks like this:
> >
> >Library: common SClib
> >Library: common Common
> >Library: at5600 StdLib
> >
> >I'm generating the AoH like this:
> >
> >if (/Library:/)
> >{
> >       $library{$line[1]} = $line[2];
> >       push @AoH, {%library};
> >}
>
> Notice that %library is a gobal hash.
>
> Notice that you don't ever clear it out.
>
> I'm assuming there's a loop around that if somewhere otherwise how does it all
> get inserted...
>
> So what you do is :
>
> %library = () at the start
> %library = (common => SClib)  after the first time you do that loop
> %library = (common => Common)  after the second time
> %library = (common => Common, at5600 => StdLib) after the third time...
>
> >
> >The trouble I'm having is when I implement this loop:
> >
> >for $i (0 .. $#AoH)
> >{
> >  print "$i\n";
> >  for $j (keys %{$AoH[$i]} )
> >  {
> >    print "$j\n";
> >    $sim_libraries .= "-y $cbic_kit\/$j\/$AoH[$i]{$j} ";
> >  }
> >}
> >
> >The output looks like this:
> >
> >0
> >common
> >1
> >common
> >2
> >at5600
> >common
> >
> >HUH?!?!?! This doesn't make any sense! It appears that the inner
> >loop has a mind of its own and wants to loop more than it should.
> >BTW, I got this routine from the O'Reilly book Programming Perl.
> >Any help someone can give would be much appreciated.
>
> Either do 'a %library = ();' after the push.
>
> Or a 'my %library;' at the start of the if block.
>
> --
> Sam
>
> Any computer scientist who praises orthogonality should be sentenced to
> use an Etch-a-Sketch.
>         -- Larry Wall



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

Date: 2 Jun 2000 00:23:20 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Trouble with Arrays of Hashes
Message-Id: <slrn8jdvjo.hv8.sholden@pgrad.cs.usyd.edu.au>

On Fri, 02 Jun 2000 00:06:03 GMT, Tony Lanier <rlanier@nc.rr.com> wrote:
>
>Thanks Sam. I'll try this at work tomorrow. I still don't quite understand how
>defining the array in the if statement will help, though. I've never had to do
>this before when using hashes or arrays. I'm not saying your wrong, just that I
>don't see how that will fix the problem. Also, you can see that the size of the
>array is three, which is what I expect. What puzzles me is the extra loop the
>inner loop does (or does it really loop once more?). Maybe Perl is getting
>confused because the same word is used for the key in two different hashes (?).

My assumption is that you are looping over that if statement
somewhere, and inserting a bunch of hash refs into the array. But you are not
clearing the old elements out of %library. That means that each element of
the array contains all the keys and values of the previous element plus
the one you added... 

Like this:

$hash{foo} = 1;
push @array, {%hash};
$hash{bar} = 2;
push @array, {%hash};
$hash{baz} = 3;
push @array, {%hash};

What you end up with after that is:

@array = ( { foo => 1 },
           { foo => 1, bar => 2},
           { foo => 1, bar => 2, baz => 3},
         );

I assume you really want foo in element 0, only bar in 1, and only baz in 2.

Of course if my assumptions are wrong, then my solution is wrong...

by using an if like:

if (/whatever it was/) {
	my %library;
	$library{$first} = $second;
	push @array, \%library; # or { %library }
}

a new empty library hash gets created for each element.

You could replace those three line with:

push @array {$first,$second};


-- 
Sam

i am not grouchy. i have a personality deficiency.
	-- Uri Guttman in <x7k8tshmn9.fsf@home.sysarch.com>


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

Date: Thu, 1 Jun 2000 19:34:55 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Trouble with Arrays of Hashes
Message-Id: <slrn8je09f.tv.tadmc@maxim.metronet.com>

On Thu, 01 Jun 2000 14:01:22 -0700, Tony Lanier 
   <tlanierNOtlSPAM@atmel.com.invalid> wrote:

>    $sim_libraries .= "-y $cbic_kit\/$j\/$AoH[$i]{$j} ";
                                    ^   ^
                                    ^   ^

You get paid by the character, it would appear  :-)

(those backslashes have no effect...)


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


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

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


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