Click here to get back home

Perl grep and Perl 4

 HomeNewsGroups | Search | About
 comp.lang.perl.misc    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Perl grep and Perl 4 fourfour2 06-03-2008
Get Chitika Premium
Posted by szr on June 5, 2008, 12:54 pm
Please log in for more thread options
Charlton Wilbur wrote:
>
>
> f> Yep - this works when using Perl 5. Unfortunately not in Perl
> f> 4.035 though.
>
> Charlton> Why are you using Perl 4? Why are you using a version of
> Charlton> Perl 4 that isn't the latest version?
>
>> The difference between 4.035 and 4.036 was a very trivial
>> patch, although I think it was a security patch. I'm not good
>> at recalling things from a decade ago, though. :)
>
> Oh, right, but there's something pathological here - using Perl 4
> instead of Perl 5, and then, in this day and age, where you have to go
> through extra effort to get Perl 4 in the first place, not using the
> latest version, trivial patch or no.

That's assuming that he wasn't stuck with a server that had only Perl 4
on it (and insufficient privileges to install a newer one.)

--
szr



Posted by Jürgen Exner on June 3, 2008, 4:55 pm
Please log in for more thread options
fourfour2@gmail.com wrote:
>Yep - this works when using Perl 5.
>Unfortunately not in Perl 4.035 though.

I think you correctly pinpointed the root cause of your problems.

jue

Posted by Hans Mulder on June 3, 2008, 6:17 pm
Please log in for more thread options
Glenn Jackman wrote:
> At 2008-06-03 12:50PM, "fourfour2@gmail.com" wrote:
>> I'm using Perl 4 and .....
[....]
>> print "Not found in list....\n"
>> }

That's not valid perl 4. In perl 4 you must write a ';' at the end
of each statement. In perl 5 it's optional for the last statement
in the block; not so in perl 4.

> see: perldoc -f quotemeta

Perl 4 did not have quotemeta (nor perldoc, for that matter).

> print "in list" if grep(/^\Q$potatoe\E$/, @listofpotatoes);

Nor did it have \Q.

> or, since you're just testing for equality:
>
> print "in list" if grep($_ eq $potatoe, @listofpotatoes)
>
> (tested in perl 5.8.8)

Try:

$potatoe="thisisstring(one)";
@listofpotatoes=("thisisstring(one)", "thisisafunnystring");

$quayle = $potatoe;
$quayle =~ s/(\W)/\$1/g;

if ( !grep(/$quayle/, @listofpotatoes)) {
print "Not found in list....\n";
}


(tested in perl 4.036)

The OP should try to find a 15 year old copy of the FAQ.
This s/(\W)/\$1/g thing was discussed in the FAQ back then.

Hope this helps,

-- HansM

Posted by Tad J McClellan on June 3, 2008, 7:55 am
Please log in for more thread options


> I'm using Perl 4


Why?


--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"

Posted by Randal L. Schwartz on June 3, 2008, 10:04 am
Please log in for more thread options

fourfour2> I'm using Perl 4 and have problems

I think you can stop right there. Anything after that is redundant. :)

Are you still playing DOOM too? And using Netscape 1.0?

Perl5 was released FOURTEEN YEARS AGO. Heck, it's almost old enough
to drive. :)

Your first order of business is to climb into the new millenium, new century,
new decade.

print "Just another Perl hacker,"; # the original!

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion

Similar ThreadsPosted
using grep in Perl November 10, 2006, 3:50 am
(Perl) FILE/IO and grep causes 100% CPU November 25, 2004, 4:27 am
perl grep problem May 25, 2005, 8:01 am
Want to use equivalent of grep function in perl November 9, 2005, 5:31 pm
system calls (mv + grep) within Perl script January 6, 2006, 3:19 pm
Linux find and grep to pure Perl August 3, 2006, 7:58 pm
problem running grep within system command in perl March 19, 2006, 12:53 pm
Noob trying to understand simple Perl grep statement December 2, 2008, 12:16 pm
What does 'grep -M' do? April 14, 2007, 8:42 pm
Grep Help November 16, 2007, 12:56 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap