[6878] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 503 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 20 18:17:27 1997

Date: Tue, 20 May 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           Tue, 20 May 1997     Volume: 8 Number: 503

Today's topics:
     Re: $number = hex("ffff1c20") no work <jay@rgrs.com>
     Re: [Q] Non-intermeshing output streams when capturing  (Charles DeRykus)
     Re: array of arrays <heidi.ruijling@tip.nl>
     AWKer needs Perl help (Elton Hughes)
     Re: Hide Perl Code? Perl for NT (A. Deckers)
     Re: How to output special characters with PERL (Bek Oberin)
     How would you optimize this ugly script? (Craig Schenk)
     Re: Installation of Perl for NT 3.51 , IIS 1.0 <shane@iol.ie>
     Re: Memory Clearing mpeppler@mbay.net
     Mirror 2.8 on Solaris 2.5.1 trouble! (Rob Torok)
     Re: Multiple ENDs in one file. (M.J.T. Guy)
     Re: Multiple open in perl <mishra.aditya@emeryworld.com>
     Newsreader in Perl <kk@minimalist.com>
     Re: Newsreader in Perl (Nathan V. Patwardhan)
     open and redirect <hong@taligent.com>
     Output from Perl program to CERN-Server. <informatik.webmaster@fernuni-hagen.de>
     Re: pack bug? (M.J.T. Guy)
     passing argument to system command (Chim Kin Sang)
     Re: passing argument to system command (M.J.T. Guy)
     Re: Pattern matching question (Andrew M. Langmead)
     Re: Pattern matching question (Andrew M. Langmead)
     Perl Textbooks <s003mto@discover.wright.edu>
     Re: perl4.036 to 5.003 code breaks (brian d foy)
     Re: print variable $abc which consist of '$' in it (Honza Pazdziora)
     Q: Closing open files in child process. How? (Amit Bhati)
     Re: Q: the rand() function seems strange... (Mike Stok)
     Re: Syslog.pm problems in Linux <psrc@corp.airmedia.com>
     Re: Year 2000 compliance (Tung-chiang Yang)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 20 May 1997 15:24:41 -0400
From: Jay Rogers <jay@rgrs.com>
To: whyte@sector.kodak.com
Subject: Re: $number = hex("ffff1c20") no work
Message-Id: <82n2pqc5fq.fsf@shell2.shore.net>

whyte@sector.kodak.com (Tony Whyte) writes:
> My sparc 10 insists that this is negative number and Ill 
> be damned if I can sprintf my way out of it. I want it to 
> interpret it as big unsigned number not negative. 

Here's a general purpose routine that's only limited by the size of a
double float on your system:

    print "decimal value is ", &unsigned_hex("ffff1c20"), "\n";
    exit;
    
    sub unsigned_hex {
        my($hex_string) = @_;
        my $i;
        my $value = 0;
    
        ## Ensure even number of digits.
        if (length($hex_string) % 2) {
            $hex_string = "0" . $hex_string;
        }
    
        ## Build value one byte at a time.
        for ($i = 0; $i < length($hex_string); $i += 2) {
            $value *= 256;
            $value += hex substr($hex_string, $i, 2);
        }
    
        $value;
    }

--
Jay Rogers
jay@rgrs.com


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

Date: Tue, 20 May 1997 18:36:26 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: [Q] Non-intermeshing output streams when capturing STDOUT in a pipe
Message-Id: <EAHt0q.D2E@bcstec.ca.boeing.com>

In article <337C912B.1CFB@boeing.com>,
David S. Patterson <david.s.patterson@boeing.com> wrote:
>Howdy,
>However, if I do try to pipe the output to another
>process (perlprog | tee foo.out  -for example)
>the output of the program(s) invoked by my main perl
>program go to STDOUT first, and the prints from the
>main perl program are supressed until that program
>terminates.   Upon termination, all the stored up
>prints from the main perl program print out.

>  Here is an example:
>
>
>Listing of perl program "run1":
>
>  #!/bin/perl
>  print "line 1 from run1\n";
>  system ("kscript1 2");
>  print "line 3 from run1\n";
>  system ("kscript1 4");
>  print "line 5 from run1\n";
>
>
>  [ omitted ]

>What is going on here?
>


Hi David,

Buffering is the problem. Add this line at the top before the prints 
and system calls: 

$|++;   

The problem is that from the command line the print's are line 
buffered, i.e., wait for "\n" before outputing. So, you see 'em as
they occur in the program.  When piped to tee though, that same 
output'll be block buffered and won't be flushed until run1 exits. 
Meanwhile the system call output will sneak in ahead because system 
calls fork an additional process and then wait for the process to 
finish before continuing. So, system calls appear to occur synchronously
with program execution. 


Regards,

--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: Tue, 20 May 1997 20:52:39 +0200
From: "Harro / Heidi" <heidi.ruijling@tip.nl>
Subject: Re: array of arrays
Message-Id: <5lsrsq$stt$1@news.Kijfhoek.NL.net>

>>Hi ,
>> is it possible to build an array of arrays like:
>>
>> @Array1= ('a','b','c');
>> @Array1= ('x','y','z');
>> push (@BIGARRAY,@Array1);
>> push (@BIGARRAY,@Array2);
>>
>> now, how do I print $BIGARRAY[0] data (which ofcourse must be:
>> 'x' 'y' and 'z') ???
>>
>> Thanks, Allon
>
>   Your code won't work, as you probably already know, but what you are
>trying to do is possible with Perl 5.  Read up on references, and if you
>have access to the man pages, check out perlref and perllol.
>
> Bill
>--
Now this is all very true, but you don't help Aloon with this. What's wrong
with just answering the question ?
To answer the original question:
@arr = ('a', 'b', 'c');
push (@arr2, [@arr]);

Greetings,
Harro




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

Date: Tue, 20 May 1997 18:31:13 GMT
From: ehughes@netcom.com (Elton Hughes)
Subject: AWKer needs Perl help
Message-Id: <ehughesEAHss1.HFs@netcom.com>


Hello All,

I have a problem that I hope someone can help me with. I have a
text file, that is approximately 200 lines long. Each line represents
a single recond, fields are seperated by commas. here is a snippet of
what the text file and records look like:

001Z220A,64,59,0,0,0,27,32,0,32,0,,0,0,0,0,56,,0
001Z220B,1,1,0,0,0,0,1,0,1,0,,0,0,0,0,1,,0
001Z220E,17,11,9,8,0,0,0,0,0,2,15.0556,2,0,9,0,12,8.35,0
001Z220J,4,2,2,2,0,0,0,0,0,0,11.215,0,0,2,0,3,6,0
011E220E,45,21,16,11,0,0,0,0,0,5,13.2494,0,0,16,0,35,7,0 

In awk $1 would be a contract number, $2 the number of enrollments
and so on. There are 19 fields overall, sometimes fields are left
blank. In Perl they would be undef. This is acceptable, given the
nature of the contracts.

I need to be able to extract the data from a single line. Using awk,
that is very simple. I have finished 86 pages of the llama book, but
have not yet found that magic bit of code that puts it all together
in a neat little package that I can use, modify, and learn from. 

BTW, after extract the data, I need to format it for display. I am
assuming that printf should handle most of my needs in that respect.

If you have a solution, please let me know. I am finding Perl to be
almost overwhelming in its capabilities. But it is a fun sort of
overwhelming!

Thank you for your time,

Elton Hughes
IT Specialist
NOVA Private Industry Council

ehughes@novapic.org


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

Date: 20 May 1997 15:07:21 GMT
From: I-hate-cyber-promo@man.ac.uk (A. Deckers)
Subject: Re: Hide Perl Code? Perl for NT
Message-Id: <slrn5o3fgu.1sa.I-hate-cyber-promo@nessie.mcc.ac.uk>

In <spectranEAHIL5.BqM@netcom.com>,
	Tracy Bednar <spectran@netcom.com> wrote:
>Is there a way to "tokenize" perl code to hide the actual source?  I
>saw a program, but it doesn't seem to be around anymore.

Maybe somebody hid it? :-)

>Also where can you download the perl executable for NT 4.0.

See the FAQ (URL below).

-- 
Perl information: <URL:http://www.perl.com/perl/>
        Perl FAQ: <URL:http://www.perl.com/perl/faq/>
    Perl archive: <URL:http://www.perl.com/CPAN/>
>>>>>>>> comp.lang.perl.misc is NOT a CGI group <<<<<<<<<<


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

Date: 20 May 1997 06:23:38 GMT
From: gossamer@glasswings.com.au (Bek Oberin)
Subject: Re: How to output special characters with PERL
Message-Id: <slrn5o2goo.1cu.gossamer@amarok.glasswings.com.au>

In article <Pine.GSO.3.96.970519193144.12414S-100000@kelly.teleport.com>, Tom Phoenix wrote:
>On Tue, 20 May 1997, Dico Reyers wrote:
>> I am writing a script in PERL that outputs special characters like  "
>> and   '  to the HTML page.  For example...
>> print "<a href="./blabla.html">\n";
[...]
>Or you can represent the quote mark in other ways.
>    $doublequote = '"';
>    print "<a href=$quote./blabla.html$quote>\n";

Or, even better:

    $quote = '"';
    print "<a href=$quote./blabla.html$quote>\n";


;)

gossamer

PS
Reading this newsgroup, I get the general impression that
I'm the only person left in the galaxy who uses Perl for
stuff that isn't CGI scripting ...  (Or, more likely, that
those who use it for more stuff are just smart enough to
RTFM and so post 95% less :))




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

Date: 20 May 1997 21:12:48 GMT
From: murple@ares.bsg.erols.net (Craig Schenk)
Subject: How would you optimize this ugly script?
Message-Id: <5lt44g$lpi@winter.erols.com>


I have been tasked with working on an internal system at the ISP where I work.
This system is a suite of perl scripts (with a CGI front end) that is supposed
to automate domain name registration and setup of the domains on our web
servers and other places. The problem is that the back-end script which
pulls new sales into the system doesnt always work.

This is a particularly ugly script. In theory, this is what it is supposed to do:

   - Reads in a comma-delimited file from the Novell-based sales system (MAGIC)

   - Splits each line into fields, and assigns variables

   - Grabs the domain choices (up to 3) and parses whois queries to find the
     first choice which is not taken

   - Reads in a blank InterNIC registration template that has placeholders
     and substitutes in the variable values

   - If there are no acceptible domain name choices, it should generate a
     error ticket based on the sales ticket number.

I would GREATLY appreciate any advice anyone could give for improvements.

Here is a sample of the sales system's flat file output. The file (domproc.txt)
consists of many of these lines. I have broken it up here to fit on the screen.
Note that there is an extra space following the comma between the state and
zip code.

"ZZ182266609A","SUGARLOAF MOUNTAIN WORKS ","WLADKOWSKI, BEVERLY      ",
"200 ORCHARD RIDGE DRIVE     ","#215 ","GAITHERSBURG    ","MD", "20878",
"301","990","1400","  0","  0","0000","05/19/97","ERO-DOMAIN  ","$   0.00",
"00/00/00","smworks  ","PO#97-310             sugarloafcrafts.com
                         "," "

And here is the script itself:

#!/usr/bin/perl -U

$ENV{PATH} = "/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin";

require "/www/dns/config.pl";

# Open up the output of a B.B. report from MAGIC
open (DOMPROC,"/f-drive/data/domain/domproc.txt");

while (<DOMPROC>)
{
	if ($_ !~ /^[\012\015]/)
	{
		# These variables will be local
		my($street_in, $suite, $hph1, $hph2, $hph3, $wph1, $wph2, $wph3, $bullshit1, $domraw);

		# Split Magic's fields into various variables
		my($in1, $in2) = split(/\", \"/, $_);
		($ticket,$orgname,$contact,$street_in,$suite,$city,$state) = split(/\",\"/, $in1);
		($zipcode,$hph1,$hph2,$hph3,$wph1,$wph2,$wph3,$selldate,$bullshit1,$price,$expiration,$username,$domraw) = split(/\",\"/, $in2);

		$ticket =~ s/\"//;

		# Strip tailing whitespace
		$orgname =~ s/\s+$//;
		$contact =~ s/\s+$//;
		$street_in =~ s/\s+$//;
		$username =~ s/\s+$//;

		# If theres only one name given use it as both
		if ($contact eq "") { $contact = $orgname; }
		if ($orgname eq "") { $orgname = $contact; }

		# Assemble broken strings
		$street = "$street_in" . " $suite";
		$homephone = "($hph1)" . " $hph2" . "-$hph3";
		$workphone = "($wph1)" . " $wph2" . "-$wph3";

		chomp($domraw);

		# Strip notes off domain field
		$domainnotes = substr($domraw,0,22);

		# Convert the rest of domain field to lowercase
		my($domains_lowered) = lc($domraw);

		# Split domain field into choices
		$domainchoice1 = substr($domains_lowered,22,26);
		$domainchoice2 = substr($domains_lowered,48,26);
		$domainchoice3 = substr($domains_lowered,74);

		# Strip tailing whitespaces
		$domainchoice1 =~ s/\s+$//;
		$domainchoice2 =~ s/\s+$//;
		$domainchoice3 =~ s/\s+$//;

		&open_log;

		# Go through (what appear to be) domain choices and parse them against
		# whois to see if it is taken
		if ($domainchoice1 =~ /[a-z]+\.\w\w\w/)
		{
			if (&whois_check("$domainchoice1") eq "OK")
			{
				&submit("$domainchoice1");
				goto NEXT;
			}
		}
		if ($domainchoice2 =~ /[a-z]+\.\w\w\w/)
		{
			if (&whois_check("$domainchoice2") eq "OK")
			{
				&submit("$domainchoice2");
				goto NEXT;
			}
		}
		if ($domainchoice3 =~ /[a-z]+\.\w\w\w/)
 		{
			if (&whois_check("$domainchoice3") eq "OK")
			{
				&submit("$domainchoice3");
				goto NEXT;
			}
		}
		else
		{
			print "No domains found!!! Creating error ticket!\n";
			&submit_error;
			goto NEXT;
		}
	}
	NEXT:
}

# Check domain with whois
sub whois_check
{
	my(@whois_result);
	my($testdomain) = @_;

	if ($testdomain =~ /^www\./)
	{
		$testdomain = substr($testdomain,4);
	}

	print "\nCHECKING: $testdomain\n";

	open(WHOIS, "/usr/bin/whois $testdomain |");
	while(<WHOIS>)
	{
		push(@whois_result, $_);
	}

	if ($whois_result[1] =~ /^No match/) 
	{
		$domainname = $testdomain;
		return "OK";
	}
	else
	{
		print "Taken, bummer...\n";
		return "Taken";
	}
}

# Open a ticket in the domain factory system
sub submit
{
	my($FILENAME) = "$NEWDIR/$domainname";

	print "Opening ticket $FILENAME\n";

	# Make sure there's not a request already pending
	# by checking for the existence of a domain ticket
	unless (( -e $FILENAME ) || (-e "$PENDINGDIR/$domainname") || (-e "$REGGEDDIR/$domainname") || (-e "$FAILEDDIR/$domainname") || (-e "$SUBMITTEDDIR/$domainname") || (-e "$DONEDIR/$domainname") || (-e "$NOTDONEDIR/$domainname"))
	{
		# What is the top level domain?
		my($top) = substr($domainname, -3);
		print "OK! Submitting $domainname under $top\n";

		open(NEWTICKET,"> $FILENAME");
		open (TEMPLATE, $DNSTEMPLATE);
		print NEWTICKET "\n\n";
		while (<TEMPLATE>)
		{
		        if (/\{ACTION\}/) { s/\{ACTION\}/N/; }
		        if (/\{PURPOSE\}/)
			{
				if ($top eq "com")
				{
					s/\{PURPOSE\}/Request domain name $domainname to provide information about the services provided by $orgname/;
				}
				elsif ($top eq "net")
				{
					s/\{PURPOSE\}/Request domain name $domainname to provide network services for $orgname/;
				}
				elsif ($top eq "org")
				{
					s/\{PURPOSE\}/Request domain name $domainname to provide information about the non-profit services of $orgname/;
				}
				elsif ($top eq "edu")
				{
					s/\{PURPOSE\}/Request domain name $domainname to provide information about the educational services of $orgname/;
				}
				elsif ($top eq "gov")
				{
					s/\{PURPOSE\}/Request domain name $domainname to provide information about the government services of $orgname/;
				}
	        	}
		        if (/\{COMPLETE\}/) { s/\{COMPLETE\}/$domainname/; }
	        	if (/\{ORG\}/) { s/\{ORG\}/$orgname/; }
		        if (/\{ADDRESS\}/) { s/\{ADDRESS\}/$street/; }
		        if (/\{CITY\}/) { s/\{CITY\}/$city/; }
		        if (/\{STATE\}/) { s/\{STATE\}/$state/; }
		        if (/\{ZIP\}/) { s/\{ZIP\}/$zipcode/; }
		        if (/\{COUNTRY\}/) { s/\{COUNTRY\}/US/; }
	        	if (/\{ADMIN_HANDLE\}/) { s/\{ADMIN_HANDLE\}//; }
	        	if (/\{ADMIN_NAME\}/) { s/\{ADMIN_NAME\}/$contact/; }
		        if (/\{ADMIN_ORG\}/) { s/\{ADMIN_ORG\}/$orgname/; }
		        if (/\{ADMIN_ADDRESS\}/) { s/\{ADMIN_ADDRESS\}/$street/; }
		        if (/\{ADMIN_CITY\}/) { s/\{ADMIN_CITY\}/$city/; }
       			if (/\{ADMIN_STATE\}/) { s/\{ADMIN_STATE\}/$state/; }
	        	if (/\{ADMIN_ZIP\}/) { s/\{ADMIN_ZIP\}/$zipcode/; }
		        if (/\{ADMIN_COUNTRY\}/) { s/\{ADMIN_COUNTRY\}/US/; }
		        if (/\{ADMIN_PHONE\}/) { s/\{ADMIN_PHONE\}/$homephone/; }
			if (/\{ADMIN_EMAIL\}/) { s/\{ADMIN_EMAIL\}/$username\@erols\.com/; }
		        if (/\{BILLING_HANDLE\}/) { s/\{BILLING_HANDLE\}//; }
		        if (/\{BILLING_NAME\}/) { s/\{BILLING_NAME\}/$contact/; }
		        if (/\{BILLING_ORG\}/) { s/\{BILLING_ORG\}/$orgname/; }
		        if (/\{BILLING_ADDRESS\}/) { s/\{BILLING_ADDRESS\}/$street/; }
	        	if (/\{BILLING_CITY\}/) { s/\{BILLING_CITY\}/$city/; }
	        	if (/\{BILLING_STATE\}/) { s/\{BILLING_STATE\}/$state/; }
	        	if (/\{BILLING_ZIP\}/) { s/\{BILLING_ZIP\}/$zipcode/; }
	        	if (/\{BILLING_COUNTRY\}/) { s/\{BILLING_COUNTRY\}/US/; }
		        if (/\{BILLING_PHONE\}/) { s/\{BILLING_PHONE\}/$homephone/; }
 			if (/\{BILLING_EMAIL\}/) { s/\{BILLING_EMAIL\}/$username\@erols\.com/; }
		        if (/\{INVOICE_TYPE\}/) { s/\{INVOICE_TYPE\}/P/; }
		        print NEWTICKET;
		}
		close (NEWTICKET);
		system("chown $WEB_UID $FILENAME");
		system("chmod 664 $FILENAME");

		# Set up the logdir
		system("mv $LOGDIR/$ticket $LOGDIR/$domainname");
		open(LOG, ">> $LOGDIR/$domainname");
		print LOG `date`;
		print LOG "Using Domain Name: $domainname\n";
		print LOG "--------------------------------------------------------------------------------\n";
		close(LOG);
	}
	else
	{
		print "Already in process!\n";
	}
}

sub open_log
{
	# my(@domerr);
	# @domerr =~ s/\"//;
	open(LOG, "> $LOGDIR/$ticket");
	print LOG "\n--------------------------------------------------------------------------------\n";
	$open_date = `date`;
	print LOG "Ticket Opened: $open_date";
	print LOG "Sell Date: $selldate\n";
	print LOG "Organization Name: $orgname\n";
	print LOG "Contact Name: $contact\n";
	print LOG "Address: $street\n";
	print LOG "City: $city\n";
	print LOG "State: $state\n";
	print LOG "Zip: $zip\n";
	print LOG "Phone: $homephone\n";
	print LOG "Secondary Phone from MAGIC: $workphone\n";
	print LOG "Username: $username\n";
	print LOG "Notes: $domainnotes\n";
	print LOG "Domain Choices from MAGIC: $domainchoice1\n";
	print LOG "                           $domainchoice2\n";
	print LOG "                           $domainchoice3\n";
	print LOG "--------------------------------------------------------------------------------\n";
	close(LOG);
}

sub submit_error
{
	system("mv $LOGDIR/$ticket $ERRDIR");
	open(LOG, ">> $ERRDIR/$ticket");
	print LOG `date`;
	print LOG "No acceptible domain choices - Creating error ticket!\n";
	print LOG "--------------------------------------------------------------------------------\n";
	close(LOG);
}




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

Date: 20 May 1997 07:35:05 GMT
From: "Shane Wilson" <shane@iol.ie>
Subject: Re: Installation of Perl for NT 3.51 , IIS 1.0
Message-Id: <01bc64f0$28b35020$d2297dc2@shanecrh>


I installed Perl recently on a NT4 machine and the instructions I
had (which worked out fine) .. said to change some settng with RegEdit.
As far as I understand it, IIS has to run .Pl extensions not the Internet
Explorer, so the System registry would make more sense.

Hope this helps... I you cannot find the RegEdit settings to change
Email me and I will look them up.


Shane Wilson,
Dublin, Ireland.


Prasannas <prasannas@aol.com> wrote in article
<19970520012100.VAA21031@ladder02.news.aol.com>...
> I downloaded perl5 from the web. I seem to have some problems in
> installating it. I'm not sure whether its installed properly. when i
tried
> to run a test.pl script the Internet explorer recognised it as a text
file
> and opens it as a text file instead of running the script. I did map the
> .pl file extension under Internet Explorer options.
> 
> What else should i do to install and configure perl properly. ?
> 
> THe following is the configuration I have.
> MS-windows NT 3.51 server, service pack 4
> Internet Information Server 1.0
> Perl 5. for WIndows NT.
> 
> thanks
> prasanna
> email : prasannavs@aol.com
> 


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

Date: Tue, 20 May 1997 10:21:08 -0600
From: mpeppler@mbay.net
To: abigail@fnx.com
Subject: Re: Memory Clearing
Message-Id: <864141381.15758@dejanews.com>

In article <EA3FrI.2r6@nonexistent.com>,
  abigail@fnx.com wrote:
>
>
> I have a couple of programs that use Sybase::DBlib to access a
> database. The entire database contains less than 20 Mb data.
> But if the program does many queries to the database, it will
> run out of memory. In about 100.000 queries it will use over
> 150 Mb of memory. I've no idea what is leaking the memory.
> All my variables are my()ed (running with -wT & use strict;),
> and the few global variables are assigned to only once.
>
> Is this a known bug in Sybase::DBlib?
> Are there methods to find out which module uses so such memory?

Could you tell me which version of Sybase::DBlib you are using?
I have run programs that handled massive amounts of data (like 500MB and
more) over 12-14 hour runs and that were stable in their memory usage.

Michael

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


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

Date: Tue, 20 May 1997 06:28:30 GMT
From: rob@trump.net.au (Rob Torok)
Subject: Mirror 2.8 on Solaris 2.5.1 trouble!
Message-Id: <3381413d.25818466@newsroom.trump.net.au>

Please pardon my ignorance, but does anyone have any ideas why mirror
2.8 would be giving my the following error:

ossa % mirror
Undefined subroutine &Socket::PF_INET called at lchat.pl line 42.

In response to perl -v and uname -a:

ossa % perl -v
 
This is perl, version 5.003 with EMBED
        built under solaris at Sep 14 1996 22:39:00
        + suidperl security patch
 
Copyright 1987-1996, Larry Wall
 
Perl may be copied only under the terms of either the Artistic License
or the GNU General Public License, which may be found in the Perl 5.0
source kit.
 
ossa % uname -a
SunOS ossa 5.5.1 Generic sun4u sparc SUNW,Ultra-2

I believe I have made use of the Solaris based socket.ph as
instructed.  That is, I have replaced the one created by h2ph with the
one included in the package.

Thanks in advance for any suggestions of things to try or places to
look for more information.

Please reply by email as well as following up here.

Regards,
Rob Torok




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

Date: 20 May 1997 07:47:55 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Multiple ENDs in one file.
Message-Id: <5lrkvb$c5e@lyra.csx.cam.ac.uk>

In article <EAGoDF.91s@nonexistent.com>, Abigail <abigail@fnx.com> wrote:
>
>Subroutine END redefined at /nfs1/home/abigail/xx.pl line 7.
>
>Is this a bug in perl 5.003, is the Camel II wrong or incomplete,
>or am I doing something which I shouldn't do?

It's a bug in 5.003.   Mended in 5.004.


Mike Guy


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

Date: Tue, 20 May 1997 10:51:47 -0700
From: "A. Mishra" <mishra.aditya@emeryworld.com>
To: nasir@xs.net.pk
Subject: Re: Multiple open in perl
Message-Id: <3381E4B3.3284@emeryworld.com>

A.R. Nasir Qureshi wrote:
> I have tried using just open and close commands and it does not works.
> 
> Please some body tell me what the problem is.

Read the perl book(Camel),perl FAQ,try out all possibilities 
then post to this newsgroup also when you post to this group 
include the problematic code.

Adi


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

Date: Tue, 20 May 1997 11:06:40 -0400
From: Kurt Koller <kk@minimalist.com>
Subject: Newsreader in Perl
Message-Id: <3381BE00.A7B7EB5E@minimalist.com>

Anyone have a code fragment or more of a basic NNTP newsreader in perl? 
Nothing fancy.  Anyone know?

Thanks


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

Date: 20 May 1997 15:42:27 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: Newsreader in Perl
Message-Id: <5lsgp3$2vk@fridge-nf0.shore.net>

Kurt Koller (kk@minimalist.com) wrote:
: Anyone have a code fragment or more of a basic NNTP newsreader in perl? 
: Nothing fancy.  Anyone know?

You can roll-yer-own using News::NNTPClient.

Hope this helps!

--
Nathan V. Patwardhan
nvp@shore.net



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

Date: Tue, 20 May 1997 11:51:45 -0700
From: Deyoung Hong <hong@taligent.com>
Subject: open and redirect
Message-Id: <3381F2C1.1C21@taligent.com>

How do I use open to pipe STDOUT to one file and STDERR to another?

For example, I can pipe a command output as open(FH, "/bin/ls |"),
how about its error output?

Thanks,
hong@taligent.com


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

Date: Tue, 20 May 1997 09:46:48 +0200
From: "Informatik.Webmaster" <informatik.webmaster@fernuni-hagen.de>
Subject: Output from Perl program to CERN-Server.
Message-Id: <338156E8.796C@fernuni-hagen.de>

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

How can I write the output the www-server would understand and excecute?

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

Here the description to my problem:

#!/usr/bin/perl

# ReadRequest decodes the information from the environment variable QUERY_STRING

@parameters=&ReadRequest;

# ReadFile brings two parameters I need from the user's answer 
# Result is an integer that gives me information about the parameters. 
# Are they correct, do I have the answer, etc.

$result=&ReadFile($parameters[1], $parameters[3]);

# I used the command print tried with Content-Type:".." a short antwort. 
print "Content-Type: ....and so on"
# This works always

# I decided to give different answers to the users depending on the value 
# of $result. 

print "Content-Type: ... and so on"
if($result eq 1){
print "This is an interesting case;
}
else {
print "This case is rather trivial;
}

# This would work always at the command line. It doesn't work When I 
# request for an answer from a # browser. In this case the server would 
# always execute the if-command. But why?


# I decided to output an URL and waited for the server to give back the 
# browser a new page

print "Location: /path/answer.html";

# This attempt didn't work either.

# How can I get a proper output for this perl script?

Thanks,

Mariana Wuerz



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

Date: 20 May 1997 07:43:52 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: pack bug?
Message-Id: <5lrkno$brp@lyra.csx.cam.ac.uk>

Kevin Luster <kluster@goth.engr.sgi.com> wrote:
>I'm seeing this problem on a variety of OS/Chips from Perl 4.036
>up to Perl 5.003 (wasn't able to test it on 5.004)
> 
>Under Irix/MIPS, for example,
> 
>        perl -e "printf( pack("f", 1201.177383))" | od -x
>        0000000 4496 ad00
>        0000003
> 
> 
>Which is wrong. The correct answer is "4496 25ad".  Aside from changes
>in byte ordering, the same result happens with NetBSD/Intel, and 
>SunOS/Sparc.

On my platform (SunOS/Sparc), this is OK with 5.004 and broken with 5.003.
So I suggest you upgrade.


Mike Guy


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

Date: 20 May 1997 05:49:17 GMT
From: mecks@uxmail.ust.hk (Chim Kin Sang)
Subject: passing argument to system command
Message-Id: <5lre0t$ruv@ustsu10.ust.hk>

Hi,    
	I am new to Perl. I want to write a perl script to backup my data 
in exabyte tape. But I feel not easy to pass the argument into the mt command.
Can anyone give me an hand. The command I used is as follow

system('mt -f /dev/nrtape fsf $i')

The problem is that the $i isnot the one that I set before the system call.


Thanks

	Jim


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

Date: 20 May 1997 07:55:47 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: passing argument to system command
Message-Id: <5lrle3$ch4@lyra.csx.cam.ac.uk>

Chim Kin Sang <mecks@uxmail.ust.hk> wrote:
>
>system('mt -f /dev/nrtape fsf $i')
>
>The problem is that the $i isnot the one that I set before the system call.

Variables are not substituted in '' strings; you want to use "":

 system("mt -f /dev/nrtape fsf $i");

should do what you want.    Incidentally, it's a good idea (and more
efficient) to use the multiple argument form of system, to avoid the shell
getting its sticky fingers on things.   (Suppose a malefactor set $i to
'1;rm -rf /').    So you could write

 system qw(mt -f /dev/nrtape fsf), $i;


Mike Guy


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

Date: Tue, 20 May 1997 21:32:34 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Pattern matching question
Message-Id: <EAI16B.82F@world.std.com>

ddougal@concentric.net (David Dougal) writes:

>                        if ($array[$count] =~ /^w\d*/) {
>                                print ("found a win\n");
>                       # match the l character followed by any digits
>                        } elsif ($array[count] =~ /^l\d*/) {
                                         ^^^^^ $count maybe?
>                                print ("found a lost\n");
>                        # match the t character followed by any digits
>                        } elsif ($array[count] =~ /^t\d*/) {
                                         ^^^^^ $count again?
>                                print ("found a tie\n");
>                        } else {
>                                print ("no match found\n");
>                         print ("element $count is $array[$count]\n");
>                        }

The characters "count", since there is no operator, function or
subroutine of that name, is treated as a bareword. Since you haven't
use the "use strict" pragma to prohibit barewords (nor the "-w" switch
to warn you against them) it is treated as the string 'count', just
like it had quotes. See the perldata man page for details.

The string 'count' when evaluated in a numeric context, will result in
the number 0. (run "perl -e 'print 5 + count'" at a shell prompt and
see what you get. The string/numeric conversion rules are written down
somewhere in the camel and in the man pages. I have it clear in my
head that its done with atof() and sprintf("%.{something}g"), but then
I knew what atof() and sprintf("%.{something}g") did before I learned
perl.)

So, in those places where you forgot the dollar signs, you are always
looking at "$array[0]"

The moral of the story is, "always use the -w switch, and always use
the 'use strict' pragma for any new, serious work which you are
starting."

-- 
Andrew Langmead


-- 
Andrew Langmead


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

Date: Tue, 20 May 1997 21:31:05 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Pattern matching question
Message-Id: <EAI13t.70G@world.std.com>

ddougal@concentric.net (David Dougal) writes:

>                        if ($array[$count] =~ /^w\d*/) {
>                                print ("found a win\n");
>                       # match the l character followed by any digits
>                        } elsif ($array[count] =~ /^l\d*/) {
                                         ^^^^^ $count maybe?
>                                print ("found a lost\n");
>                        # match the t character followed by any digits
>                        } elsif ($array[count] =~ /^t\d*/) {
                                         ^^^^^ $count again?
>                                print ("found a tie\n");
>                        } else {
>                                print ("no match found\n");
>                         print ("element $count is $array[$count]\n");
>                        }

The characters "count", since there is no operator, function or
subroutine of that name, is treated as a bareword. Since you haven't
use the "use strict" pragma to prohibit barewords (nor the "-w" switch
to warn you against them) it is treated as the string 'count', just
like it had quotes. See the perldata man page for details.

The string 'count' when evaluated in a numeric context, will result in
the number 0. (run "perl -e 'print count + 5'" at a shell prompt and
see what you get. The string/numeric conversion rules are written down
somewhere in the camel and in the man pages. I have it clear in my
head that its done with atof() and sprintf("%.{something}g"), but then
I knew what atof() and sprintf("%.{something}g") did before I learned
perl.)

So, in those places where you forgot the dollar signs, you are always
looking at "$array[0]"

The moral of the story is, "always use the -w switch, and always use
the 'use strict' pragma for any new, serious work which you are
starting."

-- 
Andrew Langmead


-- 
Andrew Langmead


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

Date: Tue, 20 May 1997 01:48:18 -0500
From: "Overman, Bradshaw Hunter" <s003mto@discover.wright.edu>
Subject: Perl Textbooks
Message-Id: <33814932.13CD@discover.wright.edu>

I was wondering if anyone knew of any textbooks written for Perl.  Not
the ones where authors list scripts for you to copy, but a textbook like
Turbo Pascal, where the language is defined, syntax, etc.  The only
programming experience is one wuarter of TP 7.0.

Thanks,

Mike Overman
s003mto@discover.wright.edu
Overmt1@aol.com


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

Date: Tue, 20 May 1997 03:57:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: perl4.036 to 5.003 code breaks
Message-Id: <comdog-2005970357200001@nntp.netcruiser>

In article <33810027.41C67EA6@ugcs.caltech.edu>, Wart
<wart@ugcs.caltech.edu> wrote:

> The following is a perl program that worked with 4.036 and
> then broke in 5.003 with the message:
> "Modification of a read-only value attempted at adjlw.pl line 5, <STDIN>
> chunk 1"

> #!/usr/local/bin/perl
> 
> while(<STDIN>) {
>     if  (m/([0-9])+\s+setlinewidth/) {
>         $1 && ($width = --$1);
>         s/[0-9]\s+setlinewidth/$width setlinewidth/;
>     }
>     print;
> }

well, in line 5 you try to modify $1, a read-only value, just like the
error message says :)  try:

#!/usr/local/bin/perl

while(<STDIN>) {
    if  (m/([0-9])+\s+setlinewidth/) {
        $width = $1;
        $width && (--$width);
        s/[0-9]\s+setlinewidth/$width setlinewidth/;
    }
    print;
}

-- 
brian d foy                              <URL:http://computerdog.com>                       
unsolicited commercial email is not appreciated


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

Date: Tue, 20 May 1997 14:26:39 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: print variable $abc which consist of '$' in it
Message-Id: <adelton.864138399@aisa.fi.muni.cz>

Query???? writes:

> Hi,
> 
>      How do I print a variable($abc) which consist of '$' in it.
>      The variable is read from the lines of a file.
> 
>      while ( $abc = <inputfile> )
>      {
>         print "$abc";
>      }

Where do you see a problem?

$ perl
     while ( $abc = <> )
     {
        print "$abc";
     }
__END__
jezek$jezek
jezek$jezek
^D

Since Perl doesn't do a double expansion, it will print out the
content of $abc, no matter if there is $ in it. Also 

	print $abc;

would work as well and is better.

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 20 May 1997 15:23:07 GMT
From: amit@visi.com (Amit Bhati)
Subject: Q: Closing open files in child process. How?
Message-Id: <5lsfkr$r3$1@darla.visi.com>


When fork() -ing a child process I should close all open file
descriptors inherited from the parent process. In C I can do,

for(fd = 0; fd < NOFILE; fd++) close(fd);

What is the appropriate Perl equivalent? I could not find any
references to any Perl entity or construct equivalent to NOFILE (as
shown above). Or is it that I need only worry about closing STDIN,
STDOUT and STDERR? If yes, why?

Thanks,

--
amit


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

Date: 20 May 1997 15:31:16 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: Q: the rand() function seems strange...
Message-Id: <5lsg44$ri7@news-central.tiac.net>

In article <e9127005-2005971627250001@sozgr.htu.tuwien.ac.at>,
Sascha Kerschhofer <e9127005@stud1.tuwien.ac.at> wrote:
>In every tutorial you find that the rand(x) function returns a random
>number between 0 and x.
>the following code should return 30 random numbers between 0 and 6!
>
>srand;
>for ($i=1; $i<=30; $i++) { 
>print int(rand(6));
>print "\n";
>}

Looks like the randbits setting was wrong when perl was configured or
built.  On my Digital Unix and Linux boxes (randbits 15 and 31
respectively) the code works fine.  What OS, and perl version are you
using, and what does

perl -MConfig -e 'print $Config{randbits}, "\n"'

report?

Hope this helps,

Mike

-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@psa.pencom.com                |      Pencom Systems Administration (work)


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

Date: Tue, 20 May 1997 12:16:03 -0400
From: Paul S R Chisholm <psrc@corp.airmedia.com>
To: cwg-spambegone@pobox.com
Subject: Re: Syslog.pm problems in Linux
Message-Id: <3381CE43.2A1@corp.airmedia.com>

chris wrote:
> Hey.. I'm having a great deal of difficulty in getting the
> Syslog.pm module to work.  No matter what I try, (and I have both
> copied the sample code from the man page and the blue camel book),
> Syslog.pm will not write to the system log.

Try something like the logger(1) command to make sure that syslog is
working at all (and that you understand how it works on your system).
The biggest problem is often just finding a facility/severity
combination that really gets written somewhere, and finding where it's
written. (Triple check your syslog.conf file.)

If logger(1) logs stuff but a Perl script (using the same facility and
severity) doesn't, then worry about Perl. Until then, don't.  --PSRC


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

Date: Tue, 20 May 1997 05:25:36 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: Year 2000 compliance
Message-Id: <tcyangEAGsEo.6nD@netcom.com>

Guys, take it easy.  At that time IBM will have a giant software called
"Deep Brew" with artificial intelligence, and it can search through
all softwares in C, C++, Java, Perl, Cobol, Pascal, Basic,
8086 Assembly .....  and correct the 2038 problem by rewriting the codes
when scanning, just like today we use antivirus programs to disinfect
our programs :)

(But maybe Deep Brew still has no clues about Microsoft "Window 38"
with code name "Las Vegas")

================================
Craig Berry (cberry@cinenet.net) wrote:

: : Forgive me for asking (since it's not in the FAQ) but how then do you deal
: : with the year 2038 problem? (Assuming you're not on a 64-bit machine by
: : then).

: Hey, we have to leave our children and grandchildren *some* interesting 
: problems to work on! :)

--
Tung-chiang Yang                       tcyang@netcom.com

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


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

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

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