[18127] in Perl-Users-Digest
Perl-Users Digest, Issue: 287 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 14 09:05:35 2001
Date: Wed, 14 Feb 2001 06:05:10 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <982159509-v10-i287@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 14 Feb 2001 Volume: 10 Number: 287
Today's topics:
Array - reading two files. <cindyann@mbox3.singnet.com.sg>
Re: CRC-32 in Perl (was: Strings and pointers in Perl?) <jonni@ifm.liu.se>
Re: CRC-32 in Perl (was: Strings and pointers in Perl?) (Lack Mr G M)
Re: die hard <wyzelli@yahoo.com>
Re: die hard hefe@in-time.se
Re: die hard <joe+usenet@sunstarsys.com>
Re: FAQ 4.24: How do I reformat a paragraph? (Peter J. Acklam)
Re: Fastest way to parse a XML-document? <thunderbear@bigfoot.com>
Re: How to measure the duration of a Perl-subfunction i (Anno Siegel)
How to scan spaces from a string of characters? <cindyann@mbox3.singnet.com.sg>
Re: How to scan spaces from a string of characters? <tore@extend.no>
Re: How to scan spaces from a string of characters? (Anno Siegel)
Re: How to scan spaces from a string of characters? <cindyann@mbox3.singnet.com.sg>
Re: links in cgi? <raspe@uni-trier.de>
print << END; hefe@in-time.se
Re: print << END; (LK)
Re: print << END; (Bernard El-Hagin)
Re: print << END; <nandukc@synopsys.com>
Re: rand function does not work <camerond@mail.uca.edu>
Re: Replacing single-letter words doesn't work (Anno Siegel)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 14 Feb 2001 13:36:19 GMT
From: "cindy" <cindyann@mbox3.singnet.com.sg>
Subject: Array - reading two files.
Message-Id: <01c0968c$963f69e0$2cb115a5@default>
hi,
File1 contains
1010, John, 12/05/65
1020, Peter, 21/10/69
1030, May, 27/02/70
File2 contains
1010, swimming, jogging, tennis
1020, jogging, badminton
1030, swimming, tennis
I read File1 and 2 into an array
@File1 = File1;
@File2 = File2;
I did a for loop
foreach $file1 (@File1)
{
($student_no1, $name, $birth_date) = split( /, /, $file1);
foreach $file2 (@File2)
{
($student_no2, $activity_1, $activity_2, $activity_3) = split( /, /,
$file2);
if $student_no1 = $student_no2
{
print $student_no1, $name, $birth_date, $activity_1,
$activity_2, $activity_3
( How do I ask Perl to exit from here after printing and read
the
next record from File1)
}
else
{ ( I am stuck here too. How do I ask Perl to exit from the 2nd
loop and read
the next record from File1)
}
} # exit from File2
} # exit from File1
I believed there are simple way to do the above. Can anyone advice me?
Thank you.
Regards,
Cindy
--
'Courage is standing up for what you believe in without worrying about
the opinions of others. It's following your own heart, living your own
life, and settling for nothing less than the best for yourself.'
~ Caroline Kent ~
------------------------------
Date: Wed, 14 Feb 2001 12:36:46 +0100
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: CRC-32 in Perl (was: Strings and pointers in Perl?)
Message-Id: <96dqi5$btj$1@newsy.ifm.liu.se>
I don't know the CRC-32 algorithms but as posted before there are a lot of
ways to do calculation on each character in a string. Some examples:
$string="Hello World!";
foreach (split('',string)) {
# $_ contains chars from first to last
}
or
$s=~s/(.)/(#CODE#),$1/ge;
Where #CODE# is executed for each char in string, the char being $1.
Just pick one. There are allways a lot of different ways to solve a problem
in perl. :)
/jN
--
_____________________ _____________________
| Jonas Nilsson | | |
|Linkoping University | | Telephone |
| IFM | | --------- |
| Dept. of Chemistry | | work: +46-13-285690 |
| 581 83 Linkoping | | fax: +46-13-281399 |
| Sweden | | home: +46-13-130294 |
|_____________________| |_____________________|
"Frank van Wensveen" <fw@lanvision.nl> wrote in message
news:5gkk8tgb8soi660smvsgucjhk7ch8usb9r@4ax.com...
> On Tue, 13 Feb 2001 21:44:45 GMT, tjla@guvfybir.qlaqaf.bet (Gwyn Judd)
> wrote:
>
> [In answer to my question on strings and chars]
> > There is a few ways but you don't really say what it is you are doing to
> > the string so that influences things.
>
> Well, basically I'm trying to calculate the 32-bit CRC for a string. I
> haven't found *any* perl code at all to do this, just modules that
> call C code. The String::crc32 module on Cpan is an extension, the
> Compression::* modules call code in the Zlib compression library.
>
> I want to write a piece of Perl code without external dependencies
> (i.e. that will run without having to install things like Zlib or
> exensions). The algorithm itself is fairly simple. Coding it is simple
> in C but not so in Perl. (That's probably the reason that everyone's
> doing this in C.)
>
> So what I'm looking for (call me stubborn) is a Perl-only method of
> calculating CRC32. I'll be CRC-ing strings (not huge blocks of data)
> so performance shouldn't be too much of an issue. I hope.
>
> Suggestions anyone?
>
>
>
> FVW
------------------------------
Date: Wed, 14 Feb 2001 12:10:03 GMT
From: gml4410@ggr.co.uk (Lack Mr G M)
Subject: Re: CRC-32 in Perl (was: Strings and pointers in Perl?)
Message-Id: <2001Feb14.121003@ukwit01>
In article <5gkk8tgb8soi660smvsgucjhk7ch8usb9r@4ax.com>, Frank van Wensveen <fw@lanvision.nl> writes:
|>
|> Well, basically I'm trying to calculate the 32-bit CRC for a string. I
|> haven't found *any* perl code at all to do this, just modules that
|> call C code.
Is the code for checksums in "perldoc unpack" any use?
--
--------- Gordon Lack --------------- gml4410@ggr.co.uk ------------
This message *may* reflect my personal opinion. It is *not* intended
to reflect those of my employer, or anyone else.
------------------------------
Date: Wed, 14 Feb 2001 20:43:42 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: die hard
Message-Id: <ELti6.6$v8.1821@vic.nntp.telstra.net>
<hefe@in-time.se> wrote in message news:96dk5b$6q2$1@news.netmar.com...
> How do you kill a cgi script and print out ONLY your own error message to
the
> browser?
>
> I noticed that if you do a regular die, the message doesn't show up in the
> browser, so I used
> use CGI::Carp qw(fatalsToBrowser);
>
> This prints out:
>
> "Content-type: text/html
> Software error:
> Error message! at cgi.cgi line 22, <FILE> chunk 1.
> For help, please send mail to the webmaster (webmaster@server.net), giving
> this error message and the time and date of the error."
>
> Don't want that!
>
> I just want the Error message!
>
> Can I do this with die or something similar?
>
3.7 seconds into scanning the documentation for CGI::Carp I cam across the
following:_
SYNOPSIS
use CGI::Carp;
croak "We're outta here!";
confess "It was my fault: $!";
carp "It was your fault!";
warn "I'm confused";
die "I'm dying.\n";
use CGI::Carp qw(cluck);
cluck "I wouldn't do that if I were you";
use CGI::Carp qw(fatalsToBrowser);
die "Fatal error messages are now sent to browser";
I guess that should be ALMOST self explanatory....
Wyzelli
--
#Modified from the original by Jim Menard
for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
wall,\n";
print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
wall\n\n";}print'*burp*';
------------------------------
Date: 14 Feb 2001 12:52:07 GMT
From: hefe@in-time.se
Subject: Re: die hard
Message-Id: <96dv1n$39m$1@news.netmar.com>
>3.7 seconds into scanning the documentation for CGI::Carp I cam across the
>following:_
Wow, I'm impressed you actually made the effort to clock your search time with
such accuracy... or are you maybe trying to insinuate something..? :)
>I guess that should be ALMOST self explanatory....
Well, if that's so, I do apologize for being such a moron. But no, this
doesn't do what I asked for (see bottom of email), and I HAVE read through
this already.
> use CGI::Carp;
> croak "We're outta here!";
> confess "It was my fault: $!";
> carp "It was your fault!";
> warn "I'm confused";
> die "I'm dying.\n";
(none of these print out anything to the browser, naturally)
> use CGI::Carp qw(fatalsToBrowser);
> die "Fatal error messages are now sent to browser";
This prints out the whole yadayada that I didn't want. So does this combined
with any of the above alternatives.
Or am I missing something here?? If it's just me being a moron, please explain
this to me so I can understand, otherwise, other suggestions??
In article <ELti6.6$v8.1821@vic.nntp.telstra.net>, Wyzelli <wyzelli@yahoo.com>
writes:
><hefe@in-time.se> wrote in message news:96dk5b$6q2$1@news.netmar.com...
>> How do you kill a cgi script and print out ONLY your own error message to
>the
>> browser?
>>
>> I noticed that if you do a regular die, the message doesn't show up in the
>> browser, so I used
>> use CGI::Carp qw(fatalsToBrowser);
>>
>> This prints out:
>>
>> "Content-type: text/html
>> Software error:
>> Error message! at cgi.cgi line 22, <FILE> chunk 1.
>> For help, please send mail to the webmaster (webmaster@server.net), giving
>> this error message and the time and date of the error."
>>
>> Don't want that!
>>
>> I just want the Error message!
>>
>> Can I do this with die or something similar?
>>
>
>3.7 seconds into scanning the documentation for CGI::Carp I cam across the
>following:_
>
>SYNOPSIS
>
> use CGI::Carp;
>
>
>
> croak "We're outta here!";
> confess "It was my fault: $!";
> carp "It was your fault!";
> warn "I'm confused";
> die "I'm dying.\n";
>
>
>
> use CGI::Carp qw(cluck);
> cluck "I wouldn't do that if I were you";
>
>
>
> use CGI::Carp qw(fatalsToBrowser);
> die "Fatal error messages are now sent to browser";
>
>I guess that should be ALMOST self explanatory....
>
>Wyzelli
>--
>#Modified from the original by Jim Menard
>for(reverse(1..100)){$s=($_==1)? '':'s';print"$_ bottle$s of beer on the
>wall,\n";
>print"$_ bottle$s of beer,\nTake one down, pass it around,\n";
>$_--;$s=($_==1)?'':'s';print"$_ bottle$s of beer on the
>wall\n\n";}print'*burp*';
>
>
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: 14 Feb 2001 09:00:03 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: die hard
Message-Id: <m3puglicv0.fsf@mumonkan.sunstarsys.com>
hefe@in-time.se writes:
> How do you kill a cgi script and print out ONLY your own error message
> to the browser?
>
> I noticed that if you do a regular die, the message doesn't show up
> in the browser, so I used
> use CGI::Carp qw(fatalsToBrowser);
>
> This prints out:
>
> "Content-type: text/html
> Software error:
> Error message! at cgi.cgi line 22, <FILE> chunk 1.
> For help, please send mail to the webmaster (webmaster@server.net),
> giving this error message and the time and date of the error."
>
> Don't want that!
>
> I just want the Error message!
If you're in a CGI environment, you certainly need the HTTP
headers. If you want a custom error message, you could look
for help in the docs for CGI::Carp:
% man CGI::Carp
...
Changing the default message
...
You may also pass in a code reference in order to create a
custom error message. At run time, your code will be
called with the text of the error message that caused the
script to die. Example:
use CGI::Carp qw(fatalsToBrowser set_message);
BEGIN {
sub handle_errors {
my $msg = shift;
print "<h1>Oh gosh</h1>";
print "Got an error: $msg";
}
set_message(\&handle_errors);
}
You could try something like this:
% cat try.pl
#!/usr/bin/perl -w
use CGI::Carp qw(fatalsToBrowser set_message);
BEGIN{ set_message(sub{print shift}); }
croak "can't foo";
__END__
% ./try.pl 2>&-
Content-type: text/html
can't foo at ./try.pl line 5
%
HTH
Joe Schaefer
--
print in_str(shift, shift); #prints number of times $ARGV[1] occurs in $ARGV[0]
use Inline C => q{ int in_str(SV *x, SV *y){int cnt=0; char *hay=SvPV(x,PL_na);
char *ndl=SvPV(y,PL_na);if(!SvPOK(x)||!SvPOK(y)){return 0;}hay=strstr(hay,ndl);
while( hay != NULL ){ ++cnt; hay = strstr( hay + 1, ndl ); } return( cnt ); } }
------------------------------
Date: 14 Feb 2001 14:05:08 +0100
From: jacklam@math.uio.no (Peter J. Acklam)
Subject: Re: FAQ 4.24: How do I reformat a paragraph?
Message-Id: <cxcg0hhs9dn.fsf@masterblaster.uio.no>
From the FAQ:
> The paragraphs you give to Text::Wrap should not contain embedded
> newlines. Text::Wrap doesn't justify the lines (flush-right).
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Umm...but did we agree that the text in the FAQ ought to be
changed? :-)
Peter
--
sub int2roman{@x=split//,sprintf'%04d',shift;@r=('','I','V','X','L','C','D'
,'M');@p=([],[1],[1,1],[1,1,1],[1,2],[2],[2,1],[2,1,1],[2,1,1,1],[1,3],[3])
;join'',@r[map($_+6,@{$p[$x[0]]}),map($_+4,@{$p[$x[1]]}),map($_+2,@{$p[$x[2
]]}),map($_+0,@{$p[$x[3]]})];}print "@{[map{int2roman($_)}@ARGV]}\n";#JAPH!
------------------------------
Date: Wed, 14 Feb 2001 10:37:00 +0100
From: =?iso-8859-1?Q?Thorbj=F8rn?= Ravn Andersen <thunderbear@bigfoot.com>
Subject: Re: Fastest way to parse a XML-document?
Message-Id: <3A8A51BC.2F686645@bigfoot.com>
Matt Sergeant wrote:
> One thing you could consider, if you're not too bad at C, but don't want to
> be worrying about things like memory allocation, is to have a go at using
> Ken MacLeod's Orchard framework. This provides an OO alternative to C called
> MoC (mostly C) that does things like garbage collection for you
> automatically. Its built with XML capabilities specifically in mind, and
> should be almost as fast as a raw expat based C parser (i.e. faster than
> Java). There are interfaces from MoC to Perl in case you need to do that
> (modulo the slowdown of doing so).
C as such is not a problem, except I do not like the C approach to doing
things. I will have your suggestion in mind when deciding what to do
now.
Would it be reasonable in the long term to create a Perl-oriented expat
which works with Perl object templates instead? This should avoid a lot
of the conversions which degrades speed.
Thank you for your reply.
--
Thorbjørn Ravn Andersen "...sound of...Tubular Bells!"
http://bigfoot.com/~thunderbear
------------------------------
Date: 14 Feb 2001 11:30:14 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to measure the duration of a Perl-subfunction in fractions of a second?
Message-Id: <96dq86$qul$1@mamenchi.zrz.TU-Berlin.DE>
Marcus Spang <Marcus.Spang@germany.ncr.com> wrote in comp.lang.perl.misc:
>
>
>Hello,
>
>I'm a Perl newbie.
>I need to measure the duration of a Perl-subfunction in fractions of a
>second.
>
>I've tried 'localtime' but that doesn't return fractions of a second.
That's a faq. perldoc -q 'time under a second' takes you there. Also
take a look at the Benchmark module, which is part of the standard
distribution.
Anno
------------------------------
Date: 14 Feb 2001 13:09:13 GMT
From: "cindy" <cindyann@mbox3.singnet.com.sg>
Subject: How to scan spaces from a string of characters?
Message-Id: <01c09688$ccd677e0$2cb115a5@default>
hi,
How do I break a string into two lines using Perl and my line will.
not appear like the following.
Line1 = "How are you today? Have you ta"
Line2 = "ken lunch?"
One line can only contain 30 characters.
How do I scan spaces from a string of characters using Perl and
get the length?
e.g.
$string = "How are you today? Have you ta";
I want Perl to scan the $string for spaces, once it reaches the
space before 'ta', give me the length of the string from "How are
you today? Have you". Then I will be able to break the whole
line using substr into:
Line1 = "How are you today? Have you"
Line2 = "taken lunch?"
I tried using $text_2 = length ($string =~ /(\s+)/ );
When I print $text_2, it keep giving me 1.
Or is there anyway that I can do a backward scan of the $string and
get the first space that it hits?
Can anyone please help? Thank You.
Regards,
Cindy
--
'Courage is standing up for what you believe in without worrying about
the opinions of others. It's following your own heart, living your own
life, and settling for nothing less than the best for yourself.'
~ Caroline Kent ~
------------------------------
Date: Wed, 14 Feb 2001 14:22:09 +0100
From: Tore Aursand <tore@extend.no>
Subject: Re: How to scan spaces from a string of characters?
Message-Id: <MPG.14f4a4e9f0ac317c9898ae@news.online.no>
In article <01c09688$ccd677e0$2cb115a5@default>,
cindyann@mbox3.singnet.com.sg says...
> How do I break a string into two lines
> [...]
You might want to search for 'wrap' at CPAN;
<URL:http://search.cpan.org/>
--
Tore Aursand - tore@extend.no - http://www.extend.no/~tore/
------------------------------
Date: 14 Feb 2001 13:30:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to scan spaces from a string of characters?
Message-Id: <96e190$8f5$1@mamenchi.zrz.TU-Berlin.DE>
cindy <cindyann@mbox3.singnet.com.sg> wrote in comp.lang.perl.misc:
>hi,
>
>How do I break a string into two lines using Perl and my line will.
>not appear like the following.
>
>Line1 = "How are you today? Have you ta"
>Line2 = "ken lunch?"
We frequently see problem descriptions (here, and without doubt in
other technical newsgroups as well) that try to get away with giving
an example of the input and the output. This usually leaves a lot
of guesswork to the unfortunate reader. Here we have a problem
description that gives no input and an example of what the output
should not look like. Well, lets start guessing...
The Text::Wrap module is probably what you're looking for.
Anno
------------------------------
Date: 14 Feb 2001 13:51:34 GMT
From: "cindy" <cindyann@mbox3.singnet.com.sg>
Subject: Re: How to scan spaces from a string of characters?
Message-Id: <01c0968e$b7d536a0$2cb115a5@default>
I have tried wrap but it break it in the following way.
Output:
Line1 = "How are you today? Have you ta"
Line2 = "ken lunch?"
Input:
How are you today? Have you taken lunch?
Therefore, I need something to tell me that it break in a
full words and not "ta" in the 1st line and "ken" in the 2nd line.
Anno Siegel <anno4000@lublin.zrz.tu-berlin.de> wrote in article
<96e190$8f5$1@mamenchi.zrz.TU-Berlin.DE>...
> cindy <cindyann@mbox3.singnet.com.sg> wrote in comp.lang.perl.misc:
> >hi,
> >
> >How do I break a string into two lines using Perl and my line will.
> >not appear like the following.
> >
> >Line1 = "How are you today? Have you ta"
> >Line2 = "ken lunch?"
>
> We frequently see problem descriptions (here, and without doubt in
> other technical newsgroups as well) that try to get away with giving
> an example of the input and the output. This usually leaves a lot
> of guesswork to the unfortunate reader. Here we have a problem
> description that gives no input and an example of what the output
> should not look like. Well, lets start guessing...
>
> The Text::Wrap module is probably what you're looking for.
>
> Anno
>
------------------------------
Date: Wed, 14 Feb 2001 14:54:47 +0100
From: Martin Raspe <raspe@uni-trier.de>
Subject: Re: links in cgi?
Message-Id: <3A8A8E27.8627C6C3@uni-trier.de>
hefe@in-time.se schrieb:
> I have a cgi script which prints out links for other webpages. Currently, I'm
> doing this as
> print '<a href.......</a>';
> Is there an alternate way of doing this using cgi?
use CGI ':standard';
print a( {href => 'http://www.xyz.com/';}, 'Destination');
> And, more importantly, is there a way to print out your own error message if
> the page can not be accessed, instead of getting a "404" from the
> server
> where the file used to be?
Instead of the original URL, put in a link to a CGI script that tests
for broken URLs, e. g. a link looking like
<a href = "cgi-bin/test_url.pl?http://www.xyz.com">Destination</a>.
If the script "test_url.pl" succeeds (gets a "200" from the
destination), redirect the user to the destination, otherwise give him
your customized error message.
Martin
------------------------------
Date: 14 Feb 2001 13:02:44 GMT
From: hefe@in-time.se
Subject: print << END;
Message-Id: <96dvlk$4l0$1@news.netmar.com>
I have a cgi with LOTS of html code and just a few lines of perl/cgi stuff.
I tried to do a
print << END;
..lots of html code....
END
but I keep getting an error message saying something like "terminator was not
found before EOF"... why is that, what am I doing wrong? I'm sure this is the
way I saw it done somewhere else in somebody's example code.
I tried another thing that works, but seems a bit weird.
print '
..lots of html code....
';
For some reason I'm having second thoughts about this method, it doesn't
appear to me as the most correct way to do it... or is that how it's supposed
to be done? There is lots of code, so it just seems weird to have all of that
between ''.
----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
NewsOne.Net prohibits users from posting spam. If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
------------------------------
Date: Wed, 14 Feb 2001 13:23:17 GMT
From: lkenny@fisheries.org (LK)
Subject: Re: print << END;
Message-Id: <3a8a86b4.3231971@wingate>
On 14 Feb 2001 13:02:44 GMT, hefe@in-time.se wrote:
>I have a cgi with LOTS of html code and just a few lines of perl/cgi stuff.
>
>I tried to do a
>
>print << END;
>
>..lots of html code....
>
>END
>
>but I keep getting an error message saying something like "terminator was not
>found before EOF"... why is that, what am I doing wrong? I'm sure this is the
>way I saw it done somewhere else in somebody's example code.
>
>I tried another thing that works, but seems a bit weird.
>
>print '
>
>..lots of html code....
>
>';
>
>For some reason I'm having second thoughts about this method, it doesn't
>appear to me as the most correct way to do it... or is that how it's supposed
>to be done? There is lots of code, so it just seems weird to have all of that
>between ''.
>
>
> ----- Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web -----
> http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
> NewsOne.Net prohibits users from posting spam. If this or other posts
>made through NewsOne.Net violate posting guidelines, email abuse@newsone.net
Post the code that wasn't working so we can have a look.
LK
------------------------------
Date: Wed, 14 Feb 2001 13:32:10 +0000 (UTC)
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: print << END;
Message-Id: <slrn98l26p.7s.bernard.el-hagin@gdndev25.lido-tech>
On 14 Feb 2001 13:02:44 GMT, hefe@in-time.se <hefe@in-time.se> wrote:
>I have a cgi with LOTS of html code and just a few lines of perl/cgi stuff.
>
>I tried to do a
>
>print << END;
>
>..lots of html code....
>
>END
>
>but I keep getting an error message saying something like "terminator was not
>found before EOF"... why is that, what am I doing wrong? I'm sure this is the
>way I saw it done somewhere else in somebody's example code.
Remove the space in:
print <<END
and try again.
Cheers,
Bernard
--
#requires 5.6.0
perl -le'* = =[[`JAPH`]=>[q[Just another Perl hacker,]]];print @ { @ = [$ ?] }'
------------------------------
Date: Wed, 14 Feb 2001 19:06:24 +0530
From: Nandu Kumar chowdhury <nandukc@synopsys.com>
Subject: Re: print << END;
Message-Id: <3A8A89D8.ED8BC7C9@synopsys.com>
Hi,
Try this :
print << "END";
# anything...
END
And remember to put the last END starting from first column itself in whatever
editor u r using.
No spaces, no tabs please before END.
This works for me !!!
Regards,
-Nandu.
------------------------------
Date: Wed, 14 Feb 2001 07:44:18 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
Subject: Re: rand function does not work
Message-Id: <3A8A8BB2.413D179A@mail.uca.edu>
Homer Simpson wrote:
>
> This sample should help explain what's happening:
Operative word here is "should," see after the code.
> #!/usr/bin/perl -w
> srand ; # init. the qseudo-random # generator
> @All_Quotes=<DATA> ; # everything after the __END__ token
> # ----------------------------------------------------------------------------
> $temp=join("",@All_Quotes) ; # string all quotes together
> @All_Quotes=split(/%%/,$temp) ; # make a new array with quotes as elements
> $All_Quotes=@All_Quotes ; # get number of elements in the array
> $rand_num=rand($All_Quotes) ; # get a random number for the quote
> # and display it.
> print $All_Quotes[$rand_num];
> print "Random number was $rand_num \n";
> __END__
> %%
> Quote ONE
> %%
> Quote TWO
> %%
> Quote THREE
> %%
>
It might be a nice example, except that exactly half the time your "
print $All_Quotes[$rand_num];" statement prints only a newline, because
that's all the specified array element contains. IMHO, not a very good
teaching tool.
Cameron
--
Cameron Dorey
Associate Professor of Chemistry
University of Central Arkansas
Phone: 501-450-5938
camerond@mail.uca.edu
------------------------------
Date: 14 Feb 2001 11:41:07 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Replacing single-letter words doesn't work
Message-Id: <96dqsj$qul$2@mamenchi.zrz.TU-Berlin.DE>
Uri Guttman <uri@sysarch.com> wrote in comp.lang.perl.misc:
[...]
>assuming :alpha: works with your locale. there is an active german perl
>community which would be of help to you here. i think they even have
>their own newsgroup and probably some perl monger groups too.
Indeed. There are
de.comp.lang.perl.misc
de.comp.lang.perl.cgi
Anno
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 287
**************************************