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
Posted by fourfour2 on June 3, 2008, 2:59 am
Please log in for more thread options
Greetings,

I'm using Perl 4 and have problems getting syntax error when using a
grep BLOCK LIST.

What I am trying to do is see if a string is in a list of strings, but
using grep BLOCK LIST.
Note, I have parenthesis in the string.

This works in Perl 5 but not Perl 4:

...
$string1="thisisstring(one)";
@stringlist=("thisisstring(one)", "thisisafunnystring");


if (( !grep { $potatoe eq $_ ) @listofpotatoes {
print "Not found in list....\n"
}


>syntax error,next 2 tokens :grep {"

Is grep BLOCK LIST not supported in Perl 4 ?

In Perl 4 how can I use perl grep to grep for strings like the above.
Is it possible, supported?
I want to use perl grep, nothing else.

Thanks!

Posted by fourfour2 on June 3, 2008, 3:02 am
Please log in for more thread options
On Jun 2, 11:59=A0pm, fourfo...@gmail.com wrote:
> Greetings,
>
> I'm using Perl 4 and have problems getting syntax error when using a
> grep BLOCK LIST.
>
> What I am trying to do is see if a string is in a list of strings, but
> using grep BLOCK LIST.
> Note, I have parenthesis in the string.
>
> This works in Perl 5 but not Perl 4:
>
> ...
> $string1=3D"thisisstring(one)";
> @stringlist=3D("thisisstring(one)", "thisisafunnystring");

I mean
$potatoe=3D"thisisstring(one)";
@listofpotatoes=3D("thisisstring(one)", "thisisafunnystring");

if (( !grep { $potatoe eq $_ ) @listofpotatoes {
=A0 =A0print "Not found in list....\n"

}
>syntax error,next 2 tokens :grep {"

Is grep BLOCK LIST not supported in Perl 4 ?

In Perl 4 how can I use perl grep to grep for strings like the above.
Is it possible, supported?
I want to use perl grep, nothing else.

Thanks!


Posted by Gunnar Hjalmarsson on June 3, 2008, 3:39 am
Please log in for more thread options
fourfour2@gmail.com wrote:
>> This works in Perl 5 but not Perl 4:
>>
>> ...
>> $string1="thisisstring(one)";
>> @stringlist=("thisisstring(one)", "thisisafunnystring");
>
> I mean
> $potatoe="thisisstring(one)";
> @listofpotatoes=("thisisstring(one)", "thisisafunnystring");
>
> if (( !grep { $potatoe eq $_ ) @listofpotatoes {
> print "Not found in list....\n"
>
> }
>> syntax error,next 2 tokens :grep {"

I don't believe you when you say that the above code works in Perl 5.
Please copy and paste the code you post; don't type it with multiple typos.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Posted by fourfour2 on June 3, 2008, 3:52 am
Please log in for more thread options
> fourfo...@gmail.com wrote:
> >> This works in Perl 5 but not Perl 4:
>
> >> ...
> >> $string1=3D"thisisstring(one)";
> >> @stringlist=3D("thisisstring(one)", "thisisafunnystring");
>
> > I mean
> > $potatoe=3D"thisisstring(one)";
> > @listofpotatoes=3D("thisisstring(one)", "thisisafunnystring");
>
> > if (( !grep { $potatoe eq $_ ) @listofpotatoes {
> > =A0 =A0print "Not found in list....\n"
>
> > }
> >> syntax error,next 2 tokens :grep {"
>
> I don't believe you when you say that the above code works in Perl 5.
> Please copy and paste the code you post; don't type it with multiple typos=
.
>
> --
> Gunnar Hjalmarsson
> Email:http://www.gunnar.cc/cgi-bin/contact.pl- Hide quoted text -
>
> - Show quoted text -


#this works in perl 5, not perl 4
$potatoe=3D"thisisapotatoe(one)";
@listofpotatoes=3D("thisisapotatoe(one)", "thisisanoldpottit");

if ( !grep { $potatoe eq $_ } @listofpotatoes) {
print "Not found in list....\n";
}


Posted by Frank Seitz on June 3, 2008, 3:59 am
Please log in for more thread options
fourfour2@gmail.com wrote:
>>>
>>>>syntax error,next 2 tokens :grep {"
[...]
> #this works in perl 5, not perl 4
> $potatoe="thisisapotatoe(one)";
> @listofpotatoes=("thisisapotatoe(one)", "thisisanoldpottit");
>
> if ( !grep { $potatoe eq $_ } @listofpotatoes) {
> print "Not found in list....\n";
> }

The error message says that the block syntax is not
allowed in Perl 4. Use grep(EXPR,LIST) instead.

Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel

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
What does 'grep -M' do? April 14, 2007, 8:42 pm
Grep Help November 16, 2007, 12:56 am
Grep -v option November 4, 2004, 3:05 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap