[11774] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5374 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Apr 13 16:07:30 1999

Date: Tue, 13 Apr 99 13:00:17 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 13 Apr 1999     Volume: 8 Number: 5374

Today's topics:
    Re: Count Linenumber <cassell@mail.cor.epa.gov>
        Database structure for a search engine <howitgolook@my-dejanews.com>
    Re: Delete Line Feed/Carriage Return <aqumsieh@matrox.com>
    Re: Don't you have to work? <cassell@mail.cor.epa.gov>
    Re: Don't you have to work? (Larry Rosler)
    Re: Examples of slow regexes? (was: Re: Perl regexps co <cassell@mail.cor.epa.gov>
        HASH OF HASH OF LIST <hojo@i-tel.com>
    Re: Hash symbol '%' a stylized what? <cassell@mail.cor.epa.gov>
    Re: Hash symbol '%' a stylized what? (Robin Parmar)
    Re: Help: From Unix to NT <gregm@well.com>
    Re: How to get yesterday date <staffan@ngb.se>
    Re: How to get yesterday date <cassell@mail.cor.epa.gov>
    Re: Net::Telnet input out of order <jay@rgrs.com>
    Re: Problem with my & local declarations <emschwar@rmi.net>
    Re: Problem with my & local declarations (Mike Mckinney)
    Re: Problem with my & local declarations <emschwar@rmi.net>
    Re: What is the end of file character for Mac (Dan Wilga)
        whats up with PAUSE? sstarre@my-dejanews.com
    Re: whats up with PAUSE? <jimbox@lucent.com>
    Re: Where we can get perl code snippets? <cassell@mail.cor.epa.gov>
    Re: Where we can get perl code snippets? (Abigail)
        Writing to socket from Win95 and Perl 5 <beyoder@raleigh.ibm.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Tue, 13 Apr 1999 11:34:07 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Count Linenumber
Message-Id: <37138E1F.832DAFC4@mail.cor.epa.gov>

Philip Newton wrote:
> 
> Abigail wrote:
> >
> > This is the shortest code I can think of:
> >
> >        perl -wlpe '}{$_=$.' file
> 
> Clever. Took me a bit to figure out how it works.

Yeah, the first time I saw Abigail post this line, my cerebrum exploded.
I didn't have a Perl with debugging handy, so it took a bit to work it 
out.

My question: given the way this works, is it liable to become broken
with future changes in the way Perl implelements -p ?

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Tue, 13 Apr 1999 18:10:52 GMT
From: howitgolook <howitgolook@my-dejanews.com>
Subject: Database structure for a search engine
Message-Id: <7f01b5$ctg$1@nnrp1.dejanews.com>

Can anyone suggest a database structure I should use if I am writing a search
engine?

I wish to record URL, Date Modified, Title, Keywords, Description, and
possibly some or all of the text on the page.

Should I use text files to store the data? What database structure would
facilitate efficient (fast!) searching?

Thanks in advance...

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 13 Apr 1999 13:47:14 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Delete Line Feed/Carriage Return
Message-Id: <x3y90bwbefz.fsf@tigre.matrox.com>


markaw2091@my-dejanews.com writes:

> I have a Perl script (at foot of this message) which I am trying to use to
> remove all of the "complete comment line(s)" from a.n. other text file/perl
> script. That is to say that I want it to remove all lines which begin with a #
> and then go on to remove all blank lines (those which are made up of a line
> feed carriage return).

Well, the blank lines are east to remove. But the comment lines are a
bit more tricky. A '#' symbol does not always signify the beginning of
a comment. Consider for example the following:

	s#\w##g
or
	$line = '# this is not a comment';

I don't think there is any easy way to do that. But, why do you want
to do it in the first place?

> I was under the impression that I could do this by making use of the s/^#.*//g
> and s/^$//mg. However, this does not seem to work. At least, the second part

No. Both of these aren't general enough. Apart from what I mentioned
above, your first regexp will fail to match an authentic comment that
doesn't start at the beginning of the line:

	my $x = 1;	# useless comment

Moreover, your second regexp will fail to match a line with only white
space characters. I would consider such lines to be "blank", but it
all depends on your definition of "blank". So, I would change that to:

	s/^\s*$//;

But, again, this is not very useful.

> does not work. Any help would be greatly appreciated at
> mawilliams@walsh-international.com . FYI, here is the Perl script as it
> currently stands:
> 
> print "Please enter the name of the file you wish to modify:\n";
> $modify = <STDIN>;

$modify will have a trailing '\n' character at its tail. You need to
remove that.

	chomp $modify;

> $new =  "./test.txt";
> 
> open("fle", "$modify");
> open("new", "> $new");

You should test the results of the open() commands. Most probably, the
first open() failed (due to the '\n' at the end of $modify), and you
didn't know about it. Also, follow the convention that filehandles
should have CAPITALIZED names. And the quotes around $modify are
unnecessary.
	
	open FLE, $modify or die "Couldn't open $modify: $!\n";
	open NEW, ">$new" or die "Couldn't create $new : $!\n";

> while (<fle>) {
> 	s/^#.*//g;
> 	s/^$//mg;

The /m modifier here is useless; and so is the complete line!

> 	print new "$_";
> 	}
> 
> close "fle";
> close "new";

Your above script can be substituted by this one-liner:

	perl -ne 'print unless /^\s*$/ || /^#/' old_script > new_script

But, this will not do what you want, and I don't know of a way to
strip all comments. I still don't see why you want to do that though!

HTH,
Ala



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

Date: Tue, 13 Apr 1999 11:09:00 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Don't you have to work?
Message-Id: <3713883C.F170CC46@mail.cor.epa.gov>

Ronald J Kimball wrote:
> 
> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > > Some particularly helpful people in this newsgroup seem to get a word in on
> > > virtually every question posted.
> >
> > As the most frequent poster in the most recent period (60 between 29 Mar
> > and 05 Apr), perhaps I should respond.  DejaNews reports 58000 total
> > articles during that time, which seems way too high.  (Can anyone
> > explain that?  My guess is about 1000 messages on a weekday.)  But
> > whatever the real number is, 'virtually every question' seems like a
> > slight overstatement.
> 
> Actually, DejaNews _estimates_ 58000 articles during that time.
> DejaNews only searches for as many articles as it is going to display;
> it would be terribly inefficient if it had to find all 1600 messages
> every time just to list 25 of them.  Unfortunately, this means its
> estimates may be wildly inaccurate.
> 
> 1000 is too high as well.  There are generally 200-250 messages posted
> to this newsgroup each day.

And doesn't Greg Bacon (or his bot) post the actual count in this ng
once
each week?

1500 per week seems about right.. although some days it feels more like
1500 per *hour*.  :-)

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Tue, 13 Apr 1999 12:25:00 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Don't you have to work?
Message-Id: <MPG.117d39e6d882622f9898a6@nntp.hpl.hp.com>

In article <3713883C.F170CC46@mail.cor.epa.gov> on Tue, 13 Apr 1999 
11:09:00 -0700, David Cassell <cassell@mail.cor.epa.gov> says...
 ... 
> And doesn't Greg Bacon (or his bot) post the actual count in this ng
> once each week?
> 
> 1500 per week seems about right.. although some days it feels more like
> 1500 per *hour*.  :-)

Right.  1576 on most recent report. 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Tue, 13 Apr 1999 11:16:12 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Examples of slow regexes? (was: Re: Perl regexps compared to Python regexps)
Message-Id: <371389EC.A1B23BE6@mail.cor.epa.gov>

Bart Lateur wrote:
> 
> Abigail wrote:
> 
> >Can anybody please give an
> >^^ example of such a beast, point out the reason for it's slowness, and
> >^^ possibly even recipes on what to avoid?
> >
> >"aaaaaaaaaaaaaaaaaaaaaab"  =~  /a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a*a.c/;
> 
> That IS slow. While I'm writing this, I'm still waiting for the match to
> terminate.
> 
> BTW I was just reading in my copy of the april '99 issue of DDJ (bought
> it just yesterday), there's an article on a simple implementation of
> grep, and and I quote:
> 
>         "Pathological expressions can cause exponential behaviour, such
>          as "a*a*a*a*a*b" when given the input "aaaaaaaaac", but the
>          exponential behaviour exists in many applications, too."
> 
> So this is the same example. I guess it's the same (exponential?)
> behaviour.
> 
> But what strikes me is that it is /obvious/, to me anyway, that /a*a*b/
> is equivalent to /a*b/, since because of the greedy nature of the regex,
> IF it matches, the first subpattern will have grabbed everything, and
> the second subpattern will be empty. Always. The same goes for
> /[ab]*b*/, which is equivalent to /[ab]*/, and /[ab]*b+/ is equivalent
> to /[ab]*b/: the first subpattern will grab everything but the final
> "b".
> 
> What is a bit strange is that Perl's regex compiler doesn't even warn
> for the inefficiency, let alone optimize it. So: is it indeed *easy* for
> a regex compiler, to spot the possibility for simplification? How come
> this jumps into my face?
> 
> And are there examples of (very) inefficient regexes than CANNOT be
> simplified/optimized in this manner?
> 
> Slightly more complicated examples, such as /[ab]*[ac]*[ab]*[ac]*/ come
> to mind. /[ab]*[ac]*/ must be equivalent to /[ab]*(?:c[ac]*)?/, which
> *looks* like it should be more efficient, but it isn't. In fact, it's a
> bit slower.
> 
> BTW the test script still hasn't finished.
> 
>         Bart.

Look on the bright side.  Try this:
 perl -ne 'print if /(x*|a+)*/' /usr/dict/words

But only try it on a modern version of Perl, okay?

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Tue, 13 Apr 1999 18:11:07 GMT
From: hojo <hojo@i-tel.com>
Subject: HASH OF HASH OF LIST
Message-Id: <7f01bk$cto$1@nnrp1.dejanews.com>

I am using a rather weird data structure that is a hash of hash of a list.
However I could also use a hash of lists of lists.  At any rate, here is my
data definition:  I have call records to countries.  each record has a dest
number and a completion code ($ccc).  to count them I have a structure that
looks like this and it works beautifully $cccRecord{$countryName}{$ccc}++ 
Now I want to have a seperate structure that holds the call records.  This is
indexed the same way, just that instead of counting occurances, I add a list
and push on each record under its respective completion code: 
$destRecord{$countryName}{$ccc} = [$newlist]  ($newlist = [] above)

***Now, how do I push scalars into the new list that deep into this structure?

I tried push @{ $destRecord{$countryName}{$ccc} } [$callrecord]; but to no
avail.

Any Ideas?
--
=-=-=-=-=-=-=-=-=-=
David Hajoglou
Sys. Admin., Abbreviator
=-=-=-=-=-=-=-=-=-=

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 13 Apr 1999 11:01:44 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <37138688.88BDA6FB@mail.cor.epa.gov>

Damian Conway wrote:
> 
> "Matthew O. Persico" <mpersico@erols.com> writes:
> 
> >Ok, two questions:
> 
> snip on #1]
>
> >2) If Sir Larry were Brittish, what animal would have been the Perl
> >   Mascot? Certainly not a camel, yes?
> 
>         The hedgehog! But then Perl would be slow, prickly, and prone to
>         fatal accidents on the Information Superhighway :-(

Slow, prickly, prone to accidents... let me see...

Java and ActiveX?

:-)
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: Tue, 13 Apr 1999 19:46:31 GMT
From: robin@execulink.com (Robin Parmar)
Subject: Re: Hash symbol '%' a stylized what?
Message-Id: <37149417.13473981@news.execulink.com>

damian@cs.monash.edu.au (Damian Conway) wrote:

>>2) If Sir Larry were Brittish, what animal would have been the Perl
>>   Mascot? Certainly not a camel, yes?
>
>	The hedgehog! But then Perl would be slow, prickly, and prone to
>	fatal accidents on the Information Superhighway :-(

'Tis all three. Cute too.

<Is it the mirror which has lost its illusions, or is it
     the world which is disengaged from its opacity?> -- Eluard
robin
if media arts
robinz@zzzexeculink.com
(remove zeds to reply)


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

Date: Tue, 13 Apr 1999 11:33:46 -0700
From: Greg McCann <gregm@well.com>
Subject: Re: Help: From Unix to NT
Message-Id: <37138E0A.34BC2AC@well.com>

Eckbert Dollhofer wrote:
> 
> Could anybody help me? I know how to run perl scripts (as CGI) on UNIX
> but now I have to do the same on NT. I would like to know what changes
> have to be made.
> Is it correct to replace the line #!/usr/local/bin/perl by nameoffile.pl
> ?

The path seems to be ignored, so just leave it as /usr/bin/perl or whatever. 
However, it does use any flags placed on this line, such as -w.

> When I use a path do I have to writ wwwroot/myname/nameoffile od do type
> wwwroot\myname\nameoffile ?

In my experience so far, it seems best to use "/" instead of "\".  You may
possibly run in to some circumstance where "\" is needed - in a module or your
old code perhaps - but I haven't seen that happen yet.

Greg

-- 

======================
Gregory McCann
http://www.calypteanna.com

"Be kind, for everyone you meet is fighting a great battle."  Saint Philo of
Alexandria


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

Date: Tue, 13 Apr 1999 20:31:57 +0200
From: Staffan Liljas <staffan@ngb.se>
Subject: Re: How to get yesterday date
Message-Id: <37138D9D.AA1F1F8E@ngb.se>

Russ Allbery wrote:
> Philip Newton <Philip.Newton@datenrevision.de> writes:
> > Are there any weird places that add/subtract something other than
> > one hour in DST? Like 0.5 or 1.5 hours?
> 
> I'm fairly sure not.  I don't see any indication in Solaris that it's
> prepared to cope with such an event, at least.

There are some countries that have a time zone that's not a whole hour,
and I've heard of double daylight saving time. 

An internet resource (www.timeanddate.com) states:

Is DST always 1 hour ahead of normal time?

Today it is almost always 1 hour ahead of normal time, but during
history there has been several variants of this, such as half adjustment
(30 minutes) or double adjustment (2 hours), but adjustments of 20, 40
minutes have also been used. 2 hours adjustment was used in several
countries during some years in the 40's and has also been used elsewhere
a few times. Half adjustment was sometimes used in New Zealand in the
first half of this century. Sometimes DST is used for longer periods
than just one summer, like US during World War II: During 3 Feb 1942 to
30 Sep 1945 most of United States had DST all year, including the
winter.

Note the almost. Another page on the same site shows the time to be
14:23 in New York, but 03:53 in Adelaide and 07:08 on Chatham Island.
All of these due to timezone and not to DST, however.

Staffan


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

Date: Tue, 13 Apr 1999 11:36:14 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: How to get yesterday date
Message-Id: <37138E9E.A10F823@mail.cor.epa.gov>

Philip Newton wrote:
> 
> Russ Allbery wrote:
> >
> > # will subtract 0.  If $tdst is 1 and $ndst is 0, subtract an hour more
> > # from yesterday's time since we gained an extra hour while going off
> > # daylight savings time.  If $tdst is 0 and $ndst is 1, subtract a
> > # negative hour (add an hour) to yesterday's time since we lost an hour.
> 
> Are there any weird places that add/subtract something other than one
> hour in DST? Like 0.5 or 1.5 hours?
> 
> Cheers,
> Philip

Indiana.  The average time change is approximately .3 hours.
:-)

-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 13 Apr 1999 14:09:08 -0400
From: Jay Rogers <jay@rgrs.com>
Subject: Re: Net::Telnet input out of order
Message-Id: <82n20c2y0r.fsf@shell2.shore.net>

ellerp@my-dejanews.com writes:
> I am trying to write a telnet program using the Net::Telnet perl module that
> will login to our Unix systems and 'inventory' what hardware/software is
> installed there.  Once I login I set the prompt to some funky pattern that
> won't show up in the output of one of my commands.  One of the first things I
> do after setting the prompt is issue a 'uname -a', and parse the output for
> OS type etc.

Here's one way to login that doesn't require you to know the
user's prompt or shell.  It sets the shell to /bin/sh and the
prompt to 'MyPrompt> '.  It requires that /usr/bin/env and
/bin/sh exist.

    ## Connect and login.
    $t->open($host);
    
    $t->waitfor('/login: ?$/i');
    $t->print($username);
    
    $t->waitfor('/password: ?$/i');
    $t->print($passwd);
    
    ## Switch to a known shell, using a known prompt.
    $t->prompt('/MyPrompt> $/');
    $t->errmode("return");
    
    $t->cmd("exec /usr/bin/env 'PS1=MyPrompt> ' /bin/sh -i")
	or die "login failed to remote host $host";
    
    $t->errmode("die");
    
    ## Now you can do cmd().
    @output = $t->cmd("uname -a");

> Here is the code I am using:
> 
> $t->print("export PS1=$new_prompt");
> $success = $t->waitfor('/\s$/');
> if (!defined $success) {
>    error_routine();
> }
> 
> @array = $t->cmd(String => 'uname -a',
>                  Prompt => $new_prompt_reg);

The statement

    $success = $t->waitfor('/\s$/');

will match whitespace at the end of what was read (i.e. the $ is
used to anchor the pattern).  Perhaps you meant to match the $
prompt:

    $success = $t->waitfor('/\s\$/');

--
Jay Rogers
jay@rgrs.com


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

Date: 13 Apr 1999 12:12:14 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Problem with my & local declarations
Message-Id: <xkfvhf0jsox.fsf@valdemar.col.hp.com>

mike@mike.local.net (Mike Mckinney) writes:
> I've written the following, but I can't seem to use either my or local to
> delcare the variables, because it either breaks the code entirely, or reports
> typographical errors. I realize the error is occuring because I'm using a
> naked block for a redo, but I carefully read up on it in Learning Perl, and I
> don't see why it won't work. 
> Below is the code :

If you'd run this with -w and "use strict;", you'd have found this
already.  Use them in all your perl scripts; they'll make you write
better code, and usually more maintainable code.

> }
> sub CATALOG_ENTRY {
> 	START : { 
> 	print "Enter the book title : ";
> 	chomp( local $title = <STDIN> ); # can't use either my or local
> 		   ^^^^^^^^^^^^

Either "my" or "local" restricts the definition of the variable to the
current block.  Unless you're doing it on purpose, you nearly always will 
want to avoid "local" in favor of "my".

 .
 .
 .


> } 		

Here you've exited the block labeled "START".  Now the local definition
of $title has gone out of scope.  $title has its old definition, which is 
undef (I think; what *does* local do to the symbol table when you're
using it on a previously-undefined variable?).

> 	@book = join( ":", $title,$author,$fictionor,$classification,$rating );

Naturally, at this point, $title is undefined, so you'll get an error.
If you'd been using -w, you'd have seen something to the effect of: 'Use
of uninitialized value at <foo> line <bar>."  This should be a clue that
what you thought was an initialization didn't take.

All this applies equally to "my", which you should be using here.  Check
the perlsub manpage("Private Variables via my()" and "Temporary Values
via local()") to find out why.

-=Eric



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

Date: Tue, 13 Apr 1999 18:58:03 GMT
From: mike@mike.local.net (Mike Mckinney)
Subject: Re: Problem with my & local declarations
Message-Id: <slrn7h74r5.19a.mike@mike.local.net>

Eric The Read <emschwar@rmi.net> wrote:

>If you'd run this with -w and "use strict;", you'd have found this
>already.  Use them in all your perl scripts; they'll make you write
>better code, and usually more maintainable code.

That's only a small part of the code. I always use -w , and I was using 
using "use strict" until I got to that line, and couldn't use my or local.

>Either "my" or "local" restricts the definition of the variable to the
>current block.  Unless you're doing it on purpose, you nearly always will 
>want to avoid "local" in favor of "my".

I see. From reading Learning Perl, it looked like it only restricted it to
the function it was being used in for my, and the function it was used in and
any functions called from the current function for local.

>Here you've exited the block labeled "START".  Now the local definition
>of $title has gone out of scope.  $title has its old definition, which is 
>undef (I think; what *does* local do to the symbol table when you're
>using it on a previously-undefined variable?).
>
>> 	@book = join( ":", $title,$author,$fictionor,$classification,$rating );
>
>Naturally, at this point, $title is undefined, so you'll get an error.
>If you'd been using -w, you'd have seen something to the effect of: 'Use
>of uninitialized value at <foo> line <bar>."  This should be a clue that
>what you thought was an initialization didn't take.

Yes, I did get that error, and used various "print" statements to find
out that using either my or local was restricting it, with the result
being that $title was undef for my join. This is why I didn't use either,
and took out the "use strict". I just thought it was obvious that I had
probably seen that error, checked for what was happening, and stopped
using my or local as a temporary fix until I could find out why it
wasn't working the way I thought it should.  Maybe I should have said
"how can I use my or local in this section of code" and still get it to
work throughout.

>All this applies equally to "my", which you should be using here.  Check
>the perlsub manpage("Private Variables via my()" and "Temporary Values
>via local()") to find out why.

I read all the applicable docs I could find on both, just in case I wasn't
clearly understanding the material in Learning Perl, and the docs seem to 
agree.

-- 
mikemck@austin.rr.com



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

Date: 13 Apr 1999 13:32:02 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Problem with my & local declarations
Message-Id: <xkfsoa4jozx.fsf@valdemar.col.hp.com>

mike@mike.local.net (Mike Mckinney) writes:
> Yes, I did get that error, and used various "print" statements to find
> out that using either my or local was restricting it, with the result
> being that $title was undef for my join. This is why I didn't use either,
> and took out the "use strict".

If "use strict;" is complaining, the solution is to fix your code, not
disable the warnings.  For very specific cases, you can disable its
warnings, but you should only do that if you're very certain what you're
doing really is correct.

In case it wasn't clear before: you're defining a variable local to that
block.  When the block is exited, the variable is no more.  If you want
a variable to be visible throughout a block (subroutines are blocks),
then you should declare them (with "my", generally) at the beginning of
that block.

If you want to use globals, then check out "use vars;".

> I just thought it was obvious that I had probably seen that error,
> checked for what was happening, and stopped using my or local as a
> temporary fix until I could find out why it wasn't working the way I
> thought it should.

Unfortunately, it wasn't obvious from your code, and it seemed to me that 
if you had been using -w and "use strict;", then you'd have found it
already.

> Maybe I should have said "how can I use my or local in this section of
> code" and still get it to work throughout.

That would have been much clearer.

> I read all the applicable docs I could find on both, just in case I wasn't
> clearly understanding the material in Learning Perl, and the docs seem to 
> agree.

Agree on what?

-=Eric


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

Date: Tue, 13 Apr 1999 15:53:02 -0400
From: dwilgaREMOVE@mtholyoke.edu (Dan Wilga)
Subject: Re: What is the end of file character for Mac
Message-Id: <dwilgaREMOVE-1304991553020001@wilga.mtholyoke.edu>

In article <3712D0AA.621802BF@dynamite.com.au>, newman@dynamite.com.au wrote:

> I am progressing through the 'Learning Perl' book on my Apple. For the
> shorter exercises it is quickest to type data via the screen. I am now
> looking for a end of file character(s) to active the Perl script to
> accept the input. I understand that for Unix this is Ctrl D and often
> Ctrl Z elsewhere except Macintosh. Can someone please help

AFAIK, there isn't one. I think you would have to modify your code a
little to look for some special sequence, like this, for instance:

while( <STDIN> ) {
  last if /^\.end/;
  buffer .= $_;
}

This will keep reading from STDIN until it sees the string ".end".

Dan Wilga          dwilgaREMOVE@mtholyoke.edu
** Remove the REMOVE in my address address to reply reply  **


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

Date: Tue, 13 Apr 1999 18:38:50 GMT
From: sstarre@my-dejanews.com
Subject: whats up with PAUSE?
Message-Id: <7f02vo$efq$1@nnrp1.dejanews.com>

I excitedly read my new TPJ when it arrived a couple of weeks ago[1], and I
thought I'd try to upload some scripts to the PAUSE server discussed on page
14 & 15. Oddly, I sent a message according to the instructions (in "Get a
PAUSE ID"), and it neither bounced, nor was there any response. Not even an
autoresponse.

Has anyone any information on this system, or any way to contact them? I'd
like to participate but I'm not sure how since they don't reply to email.
They don't really give any timeframe in the article for a reply, so maybe
weeks is typical, but I often wonder why we need to beam messages to each
other at 3x10**8 m/s, then we wait 10**6 seconds to get a response.


HUG,
-S

[1] kudos to Uri for his prominent mention in the Perl News!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 13 Apr 1999 15:03:09 -0400
From: Jimi Mikusi <jimbox@lucent.com>
Subject: Re: whats up with PAUSE?
Message-Id: <371394ED.8655C6DD@lucent.com>

This is a multi-part message in MIME format.
--------------5261DDDEDD9F968F919F24FA
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

> I excitedly read my new TPJ when it arrived a couple of weeks ago[1], and I
> thought I'd try to upload some scripts to the PAUSE server discussed on page
> 14 & 15. Oddly, I sent a message according to the instructions (in "Get a
> PAUSE ID"), and it neither bounced, nor was there any response. Not even an
> autoresponse.

i'm cant say for sure- but i'm guessing every since the article in tpj that the
request for PAUSE ID's has been sky rocketing.  what used to be a niche thing
for "local's" has now been thrown into the public domain by the increasingly
popular magazine.  i'm sure everyone's itchin' to get their files on the CPAN
script site now...

give it some time and then try again.  ??

peace.jimbox.


--------------5261DDDEDD9F968F919F24FA
Content-Type: text/x-vcard; charset=us-ascii; name="vcard.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Jimi Mikusi
Content-Disposition: attachment; filename="vcard.vcf"

begin:          vcard
fn:             Jimi Mikusi
n:              Mikusi;Jimi
org:            Inferno Apps Team (VV0122000)
email;internet: jimbox@lucent.com
title:          Applications Developer
tel;work:       732-577-2740
tel;fax:        732-577-2727
x-mozilla-cpt:  ;0
x-mozilla-html: FALSE
version:        2.1
end:            vcard


--------------5261DDDEDD9F968F919F24FA--



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

Date: Tue, 13 Apr 1999 11:31:31 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Where we can get perl code snippets?
Message-Id: <37138D83.C60C123F@mail.cor.epa.gov>

9ZA>:9 (Park, Jong-Pork) wrote:
> 
> |
> | There's not much to see so far, but here's link anyway:
> |
> | www.perlnow.com.
> |
> | Server is slow, but process is set up and it's a matter of uploading
> | snippets now.
> |
> 
> Thank you! so good site. snippet no means a program. just example code. :)

As in 'snip it'.  So it's just a fragment of a program.  Usually.
Although 5 lines of Perl code can be quite a sophisticated program...

David
-- 
David Cassell, OAO                               
cassell@mail.cor.epa.gov
Senior Computing Specialist                          phone: (541)
754-4468
mathematical statistician                              fax: (541)
754-4716


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

Date: 13 Apr 1999 18:41:09 GMT
From: abigail@fnx.com (Abigail)
Subject: Re: Where we can get perl code snippets?
Message-Id: <7f0345$noa$1@client2.news.psi.net>

=?euc-kr?B?udrBvrq5IChQYXJrLCBKb25nLVBvcmsp?= (okclub@communitech.net)
wrote on MMLI September MCMXCIII in <URL:news:7eur74$ijo$1@news2.kornet.net>:
## Where is perl code snippets??


I've some snippets:


      if (@array) {


      split /:/ =>


      print <<EOF;


      /hello!/



Abigail
-- 
perl -wle 'print "Prime" if (0 x shift) !~ m 0^\0?$|^(\0\0+?)\1+$0'


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

Date: Tue, 13 Apr 1999 15:55:36 -0400
From: Brian Yoder <beyoder@raleigh.ibm.com>
Subject: Writing to socket from Win95 and Perl 5
Message-Id: <3713A137.C98677DB@raleigh.ibm.com>

Using the docs and examples from "Learning Perl on Win32
Systems", I created a socket-based client for our Unix gateway
server. The Perl script works perfectly.... on Unix. But not on
Win95.

I've tried setting $| to 1 to cause print's to be flushed. Still works
on Unix just fine but not on Win95. I tried fiddling with binmode
in case \n becomes CR-LF and even updated the Unix gateway
server to treat \r (CR) as whitespace.

Tracing in the Unix server indicates that the socket connection
was made successfully and the server process for that connection
is blocked waiting for the Perl client to send the initial text stream.
The server sees no data; when I Ctrl-C the client the server sees
the socket connection break as expected.

>From my experiences with MS-derived non-Unix platforms,
socket handles are not in the same domain as file handles.
Normal read/write/printf/scanf don't work with socket handles
on non-Unix platforms. I was quite surprised to find that the
socket examples given in the "Learning Perl on Win32 Systems"
simply called print to write text strings to the socket.

Any ideas? Is calling print using a socket obtained from
IO::Socket::INET->new(.....) function really supposed to
work under Win32 as the books say, or is this really
a Unix-only idiom and Win32 requires a different call
to write to a socket?

Brian Yoder



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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.  

To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.

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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5374
**************************************

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