[6952] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 577 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 5 18:12:26 1997

Date: Thu, 5 Jun 97 15:00:23 -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           Thu, 5 Jun 1997     Volume: 8 Number: 577

Today's topics:
     Re: -----> replacing & symbol! <------- <rootbeer@teleport.com>
     Re: -----> replacing & symbol! <------- (Chipmunk)
     Re: A problematic twist with =~ and regex <usenet-tag@qz.little-neck.ny.us>
     Beginning Books on Perl bill_leber@hotmail.com
     Re: call "c" from "perl"? <rootbeer@teleport.com>
     Re: Core dump (!?) from PERL <rootbeer@teleport.com>
     Re: data structure question (Chipmunk)
     Re: Decoding of the 'Zafir' language :) (John L. Allen)
     Error in openning a file ... <eermmb@engunx.unl.edu>
     Re: File for read and write problem. <rootbeer@teleport.com>
     Filtering a mail message. <ac212@cam.ac.uk>
     Re: Filtering a mail message. (Nathan V. Patwardhan)
     Re: Finding string length <rootbeer@teleport.com>
     Help : Error running a script from a script <eermmb@engunx.unl.edu>
     How do you print out only the <tags> in an sgml or html <jkalogri@thomtech.com>
     Re: Interupting a stream (Nathan V. Patwardhan)
     Is there a reccomended method for... (Hashes/Arrays/Com (Mark Bainter)
     looping question <webmaster@deltastar.nb.ca>
     Re: Newbie question - File does not print in order. (Tung-chiang Yang)
     Re: newbie question (Tung-chiang Yang)
     Re: NNTP <rootbeer@teleport.com>
     Re: pack template that packs like 'a' but unpacks like  <uwe@ptc.spbu.ru>
     perl script to install Type1 files on X11? (Brian Wheeler)
     Re: Perl5 garbage collection too lazy? <rootbeer@teleport.com>
     Re: Problem: Installing Perl 5.004 on irix 6.4 (Lamont Alan Lucas)
     Re: Replacing A single Text Character <rootbeer@teleport.com>
     Re: Synchronizing output from system command? <rra@stanford.edu>
     Re: Voting Script (Faust Gertz)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Thu, 5 Jun 1997 12:20:29 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Farshad Abasi <fabasi@unixg.ubc.ca>
Subject: Re: -----> replacing & symbol! <-------
Message-Id: <Pine.GSO.3.96.970605121927.14730F-100000@kelly.teleport.com>

On 2 Jun 1997, Farshad Abasi wrote:

> I am trying to search s string for the & symbol and replace it with \&

The trick is to use two backslashes whenever you want one.

    s/&/\\&/g;		# Backwhack the ampersand

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 5 Jun 1997 19:32:30 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: -----> replacing & symbol! <-------
Message-Id: <5n748e$t1l$2@dartvax.dartmouth.edu>

In article <5mv2c4$ibd$1@nntp.ucs.ubc.ca>
fabasi@unixg.ubc.ca (Farshad Abasi) writes:

> $title1 =~ s/&/\&/g;

$title1 =~ s/&/\\&/g;

If you want an actual backslash, you need to escape it.

Chipmunk


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

Date: 5 Jun 1997 19:17:01 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: A problematic twist with =~ and regex
Message-Id: <5n73bd$nrt$1@news.netusa.net>

Matt Murdock  <bmurdock@wat.hookup.net> wrote:
> push( @TERMS, $+ ) while $text =~ m{
>         ((?:.?)"[^\"\\]*(?:\\.[^\"\\]*)*)"\s?  # groups the phrase i$
>         | ([^\s]+)\s?                    # Ignore extended whitespac$
>         | \s
> }gx;

Your comments seem truncated.

> [the] first quote is NEVER removed!  How can I modify this such that the
> keyword modifier remains as the first character, and both quotes are
> removed from the term?

I think you want this for that second line:

         .?"([^\"\\]*(?:\\.[^\"\\]*)*)"\s?  # groups the phrase i$

If you really do want to capture the optional anychar before the
first quote, without catching the first quote, you probably should
use another statement to remove the quote.

Elijah
------
not sure that ".?" is a good idea


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

Date: Thu, 05 Jun 1997 16:12:31 -0600
From: bill_leber@hotmail.com
Subject: Beginning Books on Perl
Message-Id: <865544452.9548@dejanews.com>

Any suggestions for a starter book on perl.  I am
familiar with other programming languages.

-------------------==== Posted via Deja News ====-----------------------
      http://www.dejanews.com/     Search, Read, Post to Usenet


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

Date: Thu, 5 Jun 1997 12:36:48 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Jun Zhuang <jzhuang@ringer.cs.utsa.edu>
Subject: Re: call "c" from "perl"?
Message-Id: <Pine.GSO.3.96.970605123537.14730O-100000@kelly.teleport.com>

On 5 Jun 1997, Jun Zhuang wrote:

> Can I call a "c" executable program from perl script?

Yes, and it doesn't matter whether it's written in C or in Perl or some
other language. See system() and exec() in perlfunc(1), or check out
backticks (backquotes) in perlop(1). Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Thu, 5 Jun 1997 12:23:06 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: "Kent E. Holsinger" <kent@darwin.eeb.uconn.edu>
Subject: Re: Core dump (!?) from PERL
Message-Id: <Pine.GSO.3.96.970605122136.14730G-100000@kelly.teleport.com>

On 5 Jun 1997, Kent E. Holsinger wrote:

> the result was a segmentation fault and core dump. Any ideas
> about what might have caused it and about how to fix it?

Well, it's sure to be a bug (not necessarily in Perl) when your program
unexpectedly dumps core. 

> perl -v reports:
> 
>    This is perl, version 5.003 with EMBED
>            built under sunos at Jul 11 1996 08:01:49
>            + suidperl security patch
> 
> (Yes, I know it's not 5.004, but I haven't had time to upgrade yet.)

That would be a good next step. :-)  If you still have the problem,
though, please use perlbug to file a bug report. Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 5 Jun 1997 19:28:37 GMT
From: Ronald.J.Kimball@dartmouth.edu (Chipmunk)
Subject: Re: data structure question
Message-Id: <5n7415$t1l$1@dartvax.dartmouth.edu>

In article <3396BF6B.22972B15@absyss.fr>
Douglas Seay <seay@absyss.fr> writes:

> But the problem is that no normal line will be false without a chomp. 
> They all have "\n" at the end, which makes it a true value.

Compare:

% cat > temp
1
0^D
% wc temp
       1       2       3 temp
% perl -e 'open(IN, "temp"); while(<IN>) {print "$_\n";}'
1

0
% perl -e 'open(IN, "temp"); while($a = <IN>) {print "$a\n";}'
1

%

Chipmunk


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

Date: 5 Jun 1997 15:23:17 -0400
From: allen@gateway.grumman.com (John L. Allen)
Subject: Re: Decoding of the 'Zafir' language :)
Message-Id: <5n73n5$dj6@gateway.grumman.com>

In article <5n6our$37e@news-central.tiac.net>,
Mike Stok <mike@stok.co.uk> wrote:
>In article <33963973.24813610@news.seanet.com>,
>Tim Gim Yee <tgy@chocobo.org> wrote:
>
>>Is it because I'm still using 5.003?  In any case, explicitly adding
>>$_ did the trick:
>>
>>print map {ucfirst lc reverse $_} split;
>
>No, reverse doesn'h have a default argument (well, none is mentioned in
>the 2nd edition of programming perl or the online docs for 5.004 - the
>functions which do take $_ as a default usually have something like "If
>LIST is omitted [does somehting to] $_ ..." in the description.)

Actually, in scalar context it does.  From the Changes file, added as
of 5.003_96.  I believe Larry concurred.

  Title:  "Make C<scalar(reverse)> mean C<scalar(reverse $_)>"
   From:  Chip Salzenberg
  Files:  pp.c

I guess perlfunc.pod needs updating.

John.


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

Date: Thu, 5 Jun 1997 16:19:04 -0500
From: Daneshjoo <eermmb@engunx.unl.edu>
Subject: Error in openning a file ...
Message-Id: <Pine.OSF.3.95.970605160510.12513A-100000@engunx.unl.edu>

Hi :

	I have a script which reads a random line from a file.  It works
fine, except for one file.  Here is how the file looks like :


#************ File : quotes_friends   *****************************

Man is the only animal that can remain on friendly terms with the victims he intends to eat until he eats them.    -Samuel Butler 1835-1902
We do not inherit the land, we borrow it from our children.  -Native American saying
Man is a complex thing: he makes deserts bloom and lakes die.   -Gil Stern
If we keep doing what we are doing, we are going to keep getting what we are getting.   -Stephen Covey, First Things First
Everyone thinks of changing the world, but no one thinks of changing himself.   -Tolstoy

#*******************************************************************


(note : the file should look as if the end of each line is missing)

The reason I wrote it this way, was that I didn't know how to write a
script to choose random paragraphs, but random lines are easy.  The
problem accurs when I run the script :


\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
////////////////////////////////////////////////////////////////////

#!/usr/local/bin/perl  -w

open (Quotes, "quotes_friends") || die $!; 
@QUOTES = <Quotes>;
srand;
$QUOTE = rand @QUOTES;

system "cat /$QUOTES[$QUOTE]  >  /quote.txt";

/////////////////////////////////////////////////////////////////
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

It gives me the error message "can't open /[Here is prints one of the
lines of the file by random]".  Could it be because of the "wide lines" or
is it some thing else?  Could some one please help me? TIA


				Daneshjoo


			



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

Date: Thu, 5 Jun 1997 12:25:10 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Rob Dickens <dickenrp@boat.bt.com>
Subject: Re: File for read and write problem.
Message-Id: <Pine.GSO.3.96.970605122348.14730H-100000@kelly.teleport.com>

On Thu, 5 Jun 1997, Rob Dickens wrote:

> print TEMPFILE "greetings\n";                             
> while ($readLine=<TEMPFILE>){                             

On some (most?) systems, you must use seek() between reading and writing,
or vice versa. Also, you should use defined() in the conditional. I don't
know whether those are your problems, but they're worth fixing anyway.
Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Thu, 5 Jun 1997 22:02:42 +0100
From: Alistair Cunningham <ac212@cam.ac.uk>
Subject: Filtering a mail message.
Message-Id: <Pine.LNX.3.96.970605215914.186b-100000@ursa.sel.cam.ac.uk>


I'm going to be writing a program in Perl, which takes a mail message on
it's input stream, and outputs a cleaned up version on it's output stream,
which smail can then pipe to lp. Developement is on a Linux system, but
the final system is to run on HPUX. It has to do the following:

A. Remove all uninteresting headers.

B. Remove all mime attachments, leaving only the body text.

C. If possible, remove uuencoding from within the body text.

D. Maybe remove the .sig from the body?

E. Only print out the first, say, 4 pages.


I have a few questions:

1. Is there an existing package to do this?

2. Is there a Perl module to help parse mime, etc? If more than one, which
is the best for this purpose?

3. Any other advice?

Thank you in advance for your help.

Alistair Cunningham.

--------------------------------------------------------------------------
 Alistair Cunningham   Selwyn College, Cambridge   Email: ac212@cam.ac.uk
                         Ursa on IRC and Quake   



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

Date: 5 Jun 1997 21:09:20 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Filtering a mail message.
Message-Id: <5n79u0$492@fridge-nf0.shore.net>

Alistair Cunningham (ac212@cam.ac.uk) wrote:

: 1. Is there an existing package to do this?

Get the MIME* and MailTools packages from a CPAN near you!  Before
downloading read the READMEs to see if the module does what you want.

: 2. Is there a Perl module to help parse mime, etc? If more than one, which
: is the best for this purpose?

[see above]

: 3. Any other advice?

Don't step on Superman's cape.  Don't spit in the wind.  Don't pull
the mask off that old Lone Ranger.  And *don't* mess around with Jim.

:-)

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Thu, 5 Jun 1997 12:16:58 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Chipmunk <Ronald.J.Kimball@dartmouth.edu>
Subject: Re: Finding string length
Message-Id: <Pine.GSO.3.96.970605121229.14730D-100000@kelly.teleport.com>

On 5 Jun 1997, Chipmunk wrote:

> Kieran Tully <tullyk@tcd.ie> writes:
> 
> > How can I find the length of a string (or more particularly a line) in
> > Perl ?
> 
> $i = -1;
> $i++ while (defined substr($string, $i+1, 1));
> $length = $i;

Stop that! This person really wanted to know. If you're going to give a
joke answer, Usenet Rule #42 requires you to include a smiley "or
equivalent emoticon such as to show the tyro that the response is intended
as humorous and not intended to be used." 

(And your code doesn't give a reliable answer.) 

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Thu, 5 Jun 1997 16:03:32 -0500
From: Daneshjoo <eermmb@engunx.unl.edu>
Subject: Help : Error running a script from a script
Message-Id: <Pine.OSF.3.95.970604213231.4273A-100000@engunx.unl.edu>

Hi :

	I have written a script to work as an auto-reply for incoming
email messages.  It is supposed to send messages with random subjects,
messages, signatures, and quotes.  When I write the whole thing in one
script, it works fine, but the problem is the file has to be customized
for each person I want to reply.  But I thought if I put some parts in an
individual script, which will be common, then try to run it through the
main script, and getting the out put, I can minimize the script.  But
the problem is at the part where it is supposed to get the common values
from the common script.  It doesn't work.  The scripts are written at the
buttom of the message.  Could some one please look at them and tell me
what I have done wrong.  TIA


				Daneshjoo

			eermmb@engvms.unl.edu



(note : both the scripts are at the same directory.  I even tried to
define the path to each one, but still didn't work.)


//////////////////////////////////////////////////////////////////
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


#!/usr/local/bin/perl  -w

#*****************************************************
# This is the Common script  named  Friends_auto_reply
#*****************************************************

open (Subs, "h_friends_all") || die $!;
@SUBS = <Subs>;
srand;
$SUB = rand @SUBS;

@STAMPS = ("stamp4","stamp5","stamp6","stamp7");
@BODYS = ("body1","body2","body3","body4","body5","body6","body7","body8");

open (Quotes, "quotes_2_friends") || die $!; 
@QUOTES = <Quotes>;
srand;
$QUOTE = rand @QUOTES;

srand;
$STAMP = rand @STAMPS;
$BODY = rand @BODYS;


/////////////////////////////////////////////////////////////////////
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\


#!/usr/local/bin/perl  -w

#************************
# This is the Main script
#************************

@script = `Friends_auto_reply`;

open (MAIL, "|/usr/bin/mail -s '$SUBS[$SUB]'   eermmb\@engvms ");
print "$STAMPS[$STAMP]\n" ;
print MAIL ("Hi Daneshjoo : \n");
print MAIL ("$BODYS[$BODY]\n\n");
print MAIL ("			   Daneshjoo  \n\n");
print MAIL ("--- ");
print MAIL ("$QUOTES[$QUOTE]");
close (MAIL);




\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
//////////////////////////////////////////////////////////////////






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

Date: 5 Jun 1997 20:49:43 GMT
From: "John Kalogridis" <jkalogri@thomtech.com>
Subject: How do you print out only the <tags> in an sgml or html file.
Message-Id: <01bc71f2$13d85420$0527b7cc@nyc3323lap>

I'm new in programming perl...

I need to print out only the tags in an SGML file with each tag in a line
by itself.

A tag is anything enclosed between the angle brackets <>.

There are no nested tags.

In the following line of text:

	sample text <tag1>sample text</tag2> sample text

the output should be:

	<tag1>
	</tag2>

The phrase: 
	<tag1>sample text</tag2>

should not match even though it begins with a "<" and ends with a ">"

I wrote the following perl script but it doesn't work:

while (<>)
{
 print("$&\n") if m/(\<.+\>)/g;
}

I've searched the news groups and looked through perl books to find
something similar but was not able to find it.  Any help will be
appreciated.

Thanks in advance.


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

Date: 5 Jun 1997 21:10:45 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Interupting a stream
Message-Id: <5n7a0l$492@fridge-nf0.shore.net>

William Leizerowicz (leizero@ie.utoronto.ca) wrote:

: I am listening to a socket ... waiting for a connection ...
: but ... I need to run something once a minute within the program ...
: can I do this in perl?

sleep(60), perhaps?

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Thu, 05 Jun 1997 19:16:35 GMT
From: mark@michiana.net (Mark Bainter)
Subject: Is there a reccomended method for... (Hashes/Arrays/Complex Structures)
Message-Id: <33970c65.158541580@news.michiana.net>

removing items from a complex structure?  My specific application is
that I'm working on a perl script to manage my sendmail alias file.  I
have scored a major victory already in this script (I'm still new to
perl.) but now I'm a bit stumped.

The data file is a flat file that is of the form:
Alias: username[s]

mark: ted@othersite.com
company: mark, ted, john, pete

I have successfully created a script to read this file and create an
array of hashes of arrays. 

Array1
	0 : mark =>
		0: ted@othersite.com
	1 : company =>
		0: mark
		1: ted
		2: john
		3: pete

and so on.  Adding something to this list and writing it back out
would be fairly simple.  But removing an alias not quite so. I need to
make it search through, find the names that match and then list them
with a confirmation request.  This means it will have to search both
sides of the hash.  Again, I can make it do this.  The hard part (for
me anyway) is determining an efficient way to handle the search and
delete.  This file is fairly large and grows every month.  The only
way I know of to do this is to step through each item and if it
matches, put it in another array.  At the end, list the array for the
user to confirm.  If confirmed, step through the array again and this
time create a second complex structure matching the first, but don't
include the ones you want to delete.  Then write it all out to a file.
I tried searching CPAN to see if anyone had come up with a way to
handle complex data structures of this type, but I didn't see
anything.  If somebody has a better method, I would love to hear about
it.  If I can come up with an efficient script for handling this, I'll
post the completed version.

Please note that I'm not looking for a complete solution to this
problem.  I am happy working it out for myself.  But I will accept any
help I can get. :)

Just before I sent this I realized that it might not make sense to
you why I chose to go with the array of hashes of arrays instead of
just a hash of arrays so I included some of the script at the end of
this document for your consideration.


Thanks for your time,
Mark Bainter
Michiana Net Technical Services.

Note: In consideration of a post earlier which indicated that people
in this newsgroup dislike bogus reply-to headers, I removed the spam
protection from mine for this newsgroup.  So clicking your reply
button will work. 




#!/usr/local/bin/perl5 -Tw

use strict;
use diagnostics;
use vars qw( @iphost $rec $key $value @value $ALIASES $i $field $tmp);

&Fill_Records;
&Display_Records;

sub Fill_Records{
        $ALIASES = "/usr/acct/mark/rmu/aliases";
	open(ALIASES) or die "Cannot open data";
	while ( <ALIASES> ){
		chop;
		if ($_ =~ /^#/){next;}
			$rec = {};
			for $field ( split ){
				($key,$value) = split /:/, $field;
				@value = split /,/, $value;
				$rec->{$key} = [@value];
			}
			push @iphost, $rec;
	}
	close ALIASES;
}
	
sub Display_Records{
	for $i (0 .. $#iphost){
		for $field ( keys %{ $iphost[$i] } ){
		    print "element $i $field is \n";
		    foreach $tmp (@{$iphost[$i]{$field}}){
			print "\t${tmp}\n";
		    }
		}
	}
}



---
Mark A. Bainter          MCP, A+
Technical Engineer    mailto:mark@turnergroup.com
Turner Group          WWW: http://www.turnergroup.com
2707 Middlebury St.   Phone: 219-295-4290
Elkhart, IN 46516     Fax: 219-522-2964
--------------------------------------------------------------------------------------
 ex abusu non arguitur in usum                                      
 (the abuse of a thing is no argument against its use)  
--------------------------------------------------------------------------------------


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

Date: Thu, 05 Jun 1997 12:25:15 -0300
From: Brian Freeze <webmaster@deltastar.nb.ca>
Subject: looping question
Message-Id: <3396DA5B.5594@deltastar.nb.ca>

I have the following piece of code which I want to have loop if
conditions are not right. How do I end the statement in the sleep
portion so that after it sleeps it will go back to the first part of the
loop? ( I want it to call uptime again.)

Thanks in advance.

open (UPTIME,   "$process |") ||  die "I can't open this process: $!\n";
while (<UPTIME>) {
chop;

print "$_ is the result\n";  # this gives full stats now lets split this
to get last 15 min.
@load = split (/\s+/);
chop $load[10];
print "$load[10]\n";

if ($load[10] < 2.5)  {

print "The load is fine we can ftp\n";


# system $ftp $files[0]    # call ftp script to start a download.
}

else{
sleep 60       # at this point if it goes to the sleep portion I want it
to go through the full process again of calling up uptime.
}

}


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

Date: Thu, 5 Jun 1997 19:22:26 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Newbie question - File does not print in order.
Message-Id: <tcyangEBBHtE.5s8@netcom.com>

You should not 'sort' the key for %longday.  Note that the print out
you got are in dictionary order for "Fri", "Mon", ... "Wed".  A good
idea is using 0, 1, .... 6 to index the days.

===============================
John L. Stein (stein@seas.ucla.edu) wrote:

: #!/usr/local/bin/perl -w

: $longday;
: %longday = (
: 	  "Sun" , "Sunday",
: 		"Mon" , "Monday",
: 		"Tue" , "Tuesday",
: 		"Wed" , "Wednesday",
: 		"Thu" , "Thursday",
: 		"Fri" , "Friday",
: 		"Sat" , "Saturday",
: );

: foreach $blue (sort keys %longday)
:   {print "blue = $blue\n";}

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Thu, 5 Jun 1997 19:22:24 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: newbie question
Message-Id: <tcyangEBBHtC.5rK@netcom.com>

Well, I told some nice guy offering me the answer by E-mail that
I confused $" with $,    .........

===============================
Chipmunk (Ronald.J.Kimball@dartmouth.edu) wrote:

: Because the array is being interpolated in double quotes when it is
: printed:
: print "@mylist";

: From Camel 1:
: $"
: This is similar to $, except that it applies to array values
: interpolated into a double-quoted string (or similar interpreted
: string).  Default is a space.  (Mnemonic: obvious, I think.)

: So, "@mylist" is equivalent to join($", @mylist).

: Chipmunk 

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://www.iglou.com/tcyang/Taiwan_faq.shtml, China_faq.shtml


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

Date: Thu, 5 Jun 1997 12:38:49 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Daniel Schnaider <snaider@galcom.co.il>
Subject: Re: NNTP
Message-Id: <Pine.GSO.3.96.970605123733.14730P-100000@kelly.teleport.com>

On Wed, 4 Jun 1997, Daniel Schnaider wrote:

> I am looking for a source of informaiton!
> I am trying to make an NNTP client... Where can I find information about
> it!

I'd start with the Perl modules list. There's something in there about
NNTP. Hope this helps!

    http://www.perl.com/CPAN/modules/00modlist.long.html

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: Fri, 6 Jun 1997 00:37:57 +0400
From: "Valeriy E. Ushakov" <uwe@ptc.spbu.ru>
To: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: pack template that packs like 'a' but unpacks like 'A'
Message-Id: <%RVxlzcWZF@snark.ptc.spbu.ru>

On Thu, 5 Jun 1997, Tom Phoenix wrote:

> > a - any - This one is for binary data.  You can grab some bytes as is
> >   when you unpack.  You can put some bytes when you pack and null
> >   padding is just what you expect for binary data (least surprise).
> >   This one is symmetric for bynary.
> 
> I don't think so. If I have binary data, it may have null values as valid
> data. I'd pack it in a fixed-width field, either using substr or a
> different pack template character than 'a'. 

Hmm, just curious, which one?  Despite the fact that 'a' is documented
in perlfunc(1) as "as an ascii string", it handles arbitrary binary
data (is it a documentation bug?)  When you pack, it pads with nulls
-- just what you expect for binary data.

    $ perl -e 'print pack "a4", "\0\1";' | od -b
    0000000 000 001 000 000
    0000004

While substr might be more efficient, using 'a' as part of bigger
template is often usefull for clarity and brevity.

But this is a different story.


> > To reiterate: the problem I have been talking about is the *lack* of
> > format that is symmetric for C null delimited strings.
> 
> So, have you run perlbug yet? :-)

Yep.  I also posted the patch to clpm.  If someone wants to try it
out, just don't forget to add a patchid to local patches in
patchlevel.h.  I'm sorry I forgot to add it to the patch I posted.
The following will do.

--- patchlevel.h.orig	Thu Jun  5 19:14:35 1997
+++ patchlevel.h.new	Fri Jun  6 00:27:04 1997
@@ -41,3 +41,4 @@
+	,"PACKZ1 - new pack/unpack format letter Z for C null delimited strings"
 	,NULL
 };


SY, Uwe
-- 
uwe@ptc.spbu.ru                         |       Zu Grunde kommen
http://www.ptc.spbu.ru/~uwe/            |       Ist zu Grunde gehen



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

Date: 5 Jun 1997 20:40:08 GMT
From: bdwheele@indiana.edu (Brian Wheeler)
Subject: perl script to install Type1 files on X11?
Message-Id: <5n7878$6tq$4@dismay.ucs.indiana.edu>

I know I saw this somewhere, but I can't remember where.  Its a perl script
that'll take a .pfa file and create a fonts.scale from it.  Anyone know
this script, or have I really lost my mind?


-- 
Brian Wheeler
bdwheele@indiana.edu


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

Date: Thu, 5 Jun 1997 12:11:43 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Kjetil Skotheim <kjetil.skotheim@usit.uio.no>
Subject: Re: Perl5 garbage collection too lazy?
Message-Id: <Pine.GSO.3.96.970605120803.14730C-100000@kelly.teleport.com>

On 5 Jun 1997, Kjetil Skotheim wrote:

> I have tried  undef %hash, but when watching the memory usage while
> running, nothing happens. Even after more than 3 minutes. This %hash
> is a 14MB beast.

On most systems, when you undef a variable, the memory isn't given back to
the system. Instead, it's returned to a pool for Perl to use. (I don't
know under what conditions Perl can give memory back to the system, but
it's not customary for it to do so.) So, if you subsequently needed
another 14MB, Perl shouldn't have to allocate any additional memory, at
least.

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 5 Jun 1997 15:51:31 -0500
From: lamont@thrakkorzog.ece.utexas.edu (Lamont Alan Lucas)
Subject: Re: Problem: Installing Perl 5.004 on irix 6.4
Message-Id: <5n78sj$q2o@thrakkorzog.ece.utexas.edu>

In article <oeepvuiuz3y.fsf@alpha.hut.fi>,
Jarkko Hietaniemi  <jhi@alpha.hut.fi> wrote:
>
>:  ld: FATAL 112: cannot link old 32-bit object with -n32 link:
>:  /usr/local/lib/libdb.a(db.o).
>
>I suggest you recompile your libdb with cc -n32.  (The other way
>would be to reconfigure Perl not to use Berkeley DB but then you
>lose the possibility to use Berkeley DB within Perl)

A little more on this.  (I just spent a day getting perl to work on
6.4.1, so I figure'd I'd help)

Many people (ie oracle) ship their libraries for Irix in -o32 (aka -32)
rather than -n32.  As the warning says, you can't link the two.  So, if
you want to do anything like DBD-Oracle (like we did) your only choice
is to compile all of perl with -32.  Either set the cflags with a -32,
or create an environment variable SGI_ABI=-32.  

I should probably send out my config.sh to someone, none of the irix
defaults (6.1, 6.3, 6) worked.  (can't use nm to extract)

The only thing i've not been able to get to work is db, gdbm, ndbm, etc.
It compiles cleanly, but the tests say "skipping on this platform"

Actually, i lied, that's not the only thing, I also can't get DProf to
work, but that's a seperate post.




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

Date: Thu, 5 Jun 1997 12:19:07 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett Borger <bxb121@psu.edu>
Subject: Re: Replacing A single Text Character
Message-Id: <Pine.GSO.3.96.970605121731.14730E-100000@kelly.teleport.com>

On 5 Jun 1997, Brett Borger wrote:

> I'm using a severely bastardized version of Perl for Novell Netware on our 
> Web Page.  Among the problems it causes are:
> 1) No command line swithces
> 2) No documentation
> 3) A lot of Standard Perl functions just don't work.

Are you sure it's Perl? Maybe it's Visual Perl++ ? :-)

> 	splice($MYSTR,$ind,1,'\n');    #PROBLEM!!!!

> I know splice() is looking for an Array, but how can I "do what I mean"?  

Maybe you're looking for substr(), or maybe you can do what you want with
s///. Good luck!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 05 Jun 1997 12:51:28 -0700
From: Russ Allbery <rra@stanford.edu>
To: alweiner@presstar.com.net (I hate spam!)
Subject: Re: Synchronizing output from system command?
Message-Id: <m3hgfc96bj.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

I hate spam! <alweiner@presstar.com.net> writes:

> The following program:
>   print "This should print first\n";
>   system("echo \"this should print second\"");

> produces:
>   this should print second
>   this should print first

> How do you synchronize the output in perl so that the results of a
> system command appear in the same logical order as the calling code?

Unbuffer stdout.  You should always unbuffer stdout when you're worried
about ensuring output from external commands goes through in the right
order.  Otherwise, your print statements in your Perl program may be
buffered and the buffers not flushed until after you run your external
program.

To unbuffer stdout, just do:

        $| = 1;

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Thu, 05 Jun 1997 19:35:31 GMT
From: faust@wwa.com (Faust Gertz)
Subject: Re: Voting Script
Message-Id: <33990b87.3645591@news.wwa.com>

On Wed, 04 Jun 1997 21:43:08 -0500, Arthur Merar <amerar@unsu.com>
wrote:

>I am looking for a script that will perform some voting functions for
>me. Basically the user will select an area on a graphical image.  A
>number ranging from 1 to 10 will be passed to the script and it will
>tally and return a percentage.

I'll assume that you want to do this in perl since you have posted
this article to comp.lang.perl.misc.  

There probably does not exist a script to do exactly what you describe
in the major script archives, so your best bet is probably to look at
a general survey/poll perl script (such as the one found on pages
151-163 of Shishir Gundavaram's _CGI Programming on the World Wide
Web_ or found at ftp://ftp.ora.com/published/oreilly/nutshell/cgi/  in
either Examples.tar, Examples.tar.gz, or Examples.zip in subdivision
seven as part of the Ice Cream Survey) and figure out how you want to
modify it.

You might also want to look at Rob Lanphier's article from the Autumn
1996 issue of _The Perl Journal_ entitled "Perl, Politics, and
Pairwise Voting: Perl as the Activist's Friend".  It might give you
some ideas as to various strategies and methods for collecting and
tallying your poll data, which might make for a more interesting than
average poll, and would show you put some thought into what it is you
are really trying to measure with your poll.

Hope this helps.


Streben nach Wahrheit

Faust Gertz
Philosopher at Large

The Boston Review is a left-center-of-gravity magazine of ideas: a
magazine that aims to expand political debate, shift the cultural
assumptions that frame that debate, and create greater space for
political initiative guided by egalitarian, radically democratic, and
culturally pluralist values.  http://www-polisci.mit.edu/BostonReview/


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.  

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

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