[19251] in Perl-Users-Digest
Perl-Users Digest, Issue: 1446 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 5 11:06:03 2001
Date: Sun, 5 Aug 2001 08:05:21 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <997023920-v10-i1446@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 5 Aug 2001 Volume: 10 Number: 1446
Today's topics:
Re: ActiveState Perl <-> Cygwin perl and newlines... <bcaligari@fireforged.com>
Re: ActiveState Perl <-> Cygwin perl and newlines... (nobody)
Re: Additional questions <sh@planetquake.com>
Re: automatic array elements <bcaligari@fireforged.com>
Re: CGI -> Apache Problem (noident)
Re: CGI.pm file upload problem - Please Help! <gnarinn@hotmail.com>
Re: CGI.pm file upload problem - Please Help! <dan@nospam_dtbakerprojects.com>
Re: COmments appreciated <markku@huilustudio.fi>
FAQ: How can I know how many entries are in a hash? <faq@denver.pm.org>
FAQ: How do I look up a hash element by value? <faq@denver.pm.org>
filename expansion <sh@planetquake.com>
Re: filename expansion (Eric Bohlman)
Re: filename expansion (noident)
Re: How do I select a random element from an array? (Logan Shaw)
Re: How to use IO::Handle to open a pipe (noident)
Re: Save memory and measure used memory??? (Eric Bohlman)
Re: serial ports/modems and chat2.pl (Randal L. Schwartz)
Re: string extraction (shaz)
Tuesday 7 August 2001 LXNY Meeting: Jesse Erlbaum, CTO secretary@lxny.org
Re: using eval (Logan Shaw)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 5 Aug 2001 14:32:59 -0000
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: ActiveState Perl <-> Cygwin perl and newlines...
Message-Id: <9kje4a02to4@enews4.newsguy.com>
"nobody" <nobody@nobody.com> wrote in message
news:OgOa7.263742$E4.6547889@amsnews02.chello.com...
>
>
> print "hello\nHow are you?\n";
>
> will print correct newlines.
>
> Running the same line of code in cygwin perl, it won't print
> the newlines, because cygwin only outputs a \n.
>
> Is there a simple setting that makes cygwin behave like
> activeperl, without doing many changes in the code?
>
are you running perl under cygwin from a cygwin shell or straight from a
console window?
B.
------------------------------
Date: Sun, 05 Aug 2001 14:48:31 GMT
From: nobody@nobody.com (nobody)
Subject: Re: ActiveState Perl <-> Cygwin perl and newlines...
Message-Id: <31db7.12265$Xf2.325959@amsnews03.chello.com>
In article <9kje4a02to4@enews4.newsguy.com>
"B. Caligari" <bcaligari@fireforged.com> wrote:
> "nobody" <nobody@nobody.com> wrote in message
> news:OgOa7.263742$E4.6547889@amsnews02.chello.com...
>>
>>
>> print "hello\nHow are you?\n";
>>
>> will print correct newlines.
>>
>> Running the same line of code in cygwin perl, it won't print
>> the newlines, because cygwin only outputs a \n.
>>
>> Is there a simple setting that makes cygwin behave like
>> activeperl, without doing many changes in the code?
>>
>
> are you running perl under cygwin from a cygwin shell or straight from a
> console window?
>
> B.
>
>
>
Straigt from a console window.
------------------------------
Date: Sun, 05 Aug 2001 07:12:36 GMT
From: "Sean Hamilton" <sh@planetquake.com>
Subject: Re: Additional questions
Message-Id: <El6b7.22383$uM6.3100933@news1.telusplanet.net>
Sorry if unclear...
I'd like to be able to do both of the following:
myfunc foreach (@array);
and
myfunc ($string);
"if (@_)" seems to be the right way to go, I'll see if I can take care of it
myself.
sh
"Alan Barclay" <gorilla@elaine.furryape.com> wrote in message
news:996973139.375261@elaine.furryape.com...
> In article <Ku_a7.28121$b_3.2282979@news0.telusplanet.net>,
> Sean Hamilton <sh@planetquake.com> wrote:
> >Two additional questions.
> >
> >1. How does "print" work, in that it allows an argument to be specified,
and
> >if one is not, it defaults to $_? How would myprint be written to do
this?
> >Must I declare two primts, one of which calls the other with $_?
>
> Something like this does the trick.
>
> sub myprint {
> my $x;
> if(@_){
> $x=shift;
> } else {
> $x=$_
> }
> print "$x\n";
> }
>
> Or, somewhat more concisly:
>
> sub doit {
> my $x=$_;
> $x=shift if(@_);
> print "$x\n";
> }
>
------------------------------
Date: Sun, 5 Aug 2001 14:39:16 -0000
From: "B. Caligari" <bcaligari@fireforged.com>
Subject: Re: automatic array elements
Message-Id: <9kjeg202u89@enews4.newsguy.com>
"Les Ander" <citykid@nospam.edu> wrote in message
news:Pine.LNX.4.33.0108041734560.16822-100000@schewanella.stanford.edu...
> Hi,
> i would like to build an array automatically.
> i know that @arr=(1..10) fills the @arr with elements 1 to 10.
>
> But i want to fill @arr with elements from 10..100 with every 10th
> elements. For example in matlab i can say a=[10:10:100]
> which will make a=(10, 20, 30, ..,100)
>
> Can i do some thing similar with perl (i.e. can i give an arbitrary
> increment to fill up the array?)
@a = map {$_ * 10} (1..10);
should do the trick
B
------------------------------
Date: 5 Aug 2001 06:14:38 -0700
From: noident@my-deja.com (noident)
Subject: Re: CGI -> Apache Problem
Message-Id: <66fba11b.0108050514.94998cf@posting.google.com>
> system ($command) or print "Fuck the system command:$!";
I'm not a Windows person, but on a good old Unix this command would
return 0 for success. I'd write this:
system ($command) && print "Fuck the system command:$!";
Or am I missing something?
cheers
------------------------------
Date: Sun, 5 Aug 2001 10:31:00 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: CGI.pm file upload problem - Please Help!
Message-Id: <997007460.633499381132424.gnarinn@hotmail.com>
In article <ze1b7.31269$Kd7.19120199@news1.rdc1.sfba.home.com>,
Gala <Gala@nonono.com> wrote:
(snipped upload problem)
>17 my $q = new CGI;
>18
>19 print "Content-type: text/plain\n\n";
>20
>21 my $file = $q->param("file") || print "No file specified.";
>22 my $fh = $q->upload($file) || print "error";
>23
you probably mean:
my $fh = $q->upload('file') || print "error";
gnari
------------------------------
Date: Sun, 05 Aug 2001 14:48:24 GMT
From: Dan Baker <dan@nospam_dtbakerprojects.com>
Subject: Re: CGI.pm file upload problem - Please Help!
Message-Id: <3B6D5D07.B890E884@nospam_dtbakerprojects.com>
Gala wrote:
>
> Hi, I've been working on a upload script but have not been able to get this to work. I'm been working weeks trying to get
> this to work.
-----------------------------------
feel free to use this snippet and modify as you need to.....
A webpage with source like this:
<form ENCTYPE="multipart/form-data" ACTION="UploadImage.pl"
METHOD="POST">
<P>Type the full path of file to upload, or use the browse
button:
<input TYPE="file" ACCEPT="image/jpeg,image/gif"
NAME="UploadFile" SIZE="32" VALUE="C:\">
<i><font color="#CC0000">When browsing, you will need to
set file type to *.* every time in the dialog box
to list .gif and .jpg image files! The default file type is
.htm, and that
is NOT what you are looking for...</font>
<BR>When browsing for the first time, note that you may need to
change
the current folder displayed to your local image directory to
see the
available images.</i>
<div align=right><input TYPE=submit VALUE="Upload to Server Now"
></div>
</form>
will send a multipart request to the server. Note that the
param('UploadFile') will be BOTH a filename and an open FILEHANDLE.
example perl script to handle it might look like this:
#! /usr/bin/perl -w
use CGI qw( param uploadInfo );
$CGI::POST_MAX=1024 * 100 ; # set maximum
size of post to 100k
$TempFile::TMPDIRECTORY = './tmp_images' ; # force temp
file location
#
------------------------------------------------------------------------------
# check input
unless ( $OverwriteFlag ) { $OverwriteFlag = 'no-overwrite' }
unless ( $UploadedImage ) {
&ExitToBrowser( 'warn' , "You did not enter a path for a
file to ".
"upload. Use your browser \"Back\" button and enter a
filepath." )
}
# check to make sure it is the right type
# -----
$tempString = ${uploadInfo($UploadedImage)}{'Content-Type'} ; #
deref the hash of info
#
unless ( $tempString ) {
print "Content-type: text/plain\n\n";
print "WARNING - \n".
"Path entered for file was invalid...\n".
"Try using the browse button to select a
file.\n".
"\nUse the Browser \"Back\" button to return to
the ".
"upload management page.\n" ;
exit ;
}
#
if (( $temp ne 'image/jpeg' )and( $temp ne 'image/gif' )) {
print "Content-type: text/plain\n\n";
print "WARNING - \n".
"Cannot upload file with Content-Type = $temp, ".
"it MUST be either .jpg or .gif file!".
"\nPlease use the browser \"Back\" button, and
select an image
file.\n";
exit ;
}
# save the original local file name/handle to use later
my $UploadFH = $UploadedImage ;
# figure out filename to save it as, and make sure it is "legal"
# -----
$UploadedImage =~ s/.*[\\|\/](.+)$/$1/ ; # grab end of path
passed in
$UploadedImage =~ s/\s/_/g ; # convert spaces to _
# build relative path to new image target
# -----
my $ImagePath = $cAdminCgi2Gallery ;
if ( $TargetFolder ) { $ImagePath = "$ImagePath\/$TargetFolder"
}
$ImagePath = "$ImagePath\/$UploadedImage" ;
# check to see if we will overwrite an existing file on the
server
# -----
if ( -f $ImagePath and ( $OverwriteFlag eq 'no-overwrite' ))
{
# build warning page
print "Content-type: text/plain\n\n";
print "WARNING - \n".
"File $ImagePath already exists on server, ".
"you currently have set preferences not to overwrite
existing
files. \n".
"\nUse the browser \"Back\" button to return to the
upload
page.\n";
exit ;
}
#
------------------------------------------------------------------------------
#
# write the file from open filehandle
&WriteUploadFile( $UploadFH , "$ImagePath" ) ;
1;
#
##############################################################################
# local subs
#
##############################################################################
sub WriteUploadFile { my ( $FromFH , $ToPath ) = @_ ;
# we are using this sub because we dont trust CGI:: to check
size
# local vars
my $bytesread ;
my $buffer = "";
my $flen = 0 ;
open ( TARGETFILE , ">$ToPath" ) ;
binmode( TARGETFILE );
binmode( $FromFH );
$flen = 0 ;
while ( $bytesread = read( $FromFH , $buffer , 1024 ) ) {
print TARGETFILE $buffer ;
$flen += 1024 ;
if ( $flen > $CGI::POST_MAX ) { # check size here since
# we cant count on CGI
to do it
print "Content-type: text/plain \n\n".
"FATAL ERROR - \n\n".
"The file $FromFH \nthat you attempted to upload
".
"is too big. \nOnly $CGI::POST_MAX kbytes are ".
"allowed. \n\n".
"Please use your browser \"Back\" button and ".
"resample, crop, or select a smaller file...\n";
close $FromFH ;
close TARGETFILE ;
unlink $ToPath or die "could not delete working
file because $!" ;
exit;
}
}
close $FromFH ;
close TARGETFILE ;
chmod 0666, "$ToPath" ;
unless (-f $ToPath ) { # something might have gone wrong during
the
save
die "FATAL ERROR - could not upload >$FromFH< to
>$ToPath< because $!
\n";
}
1;}
#
##############################################################################
------------------------------
Date: Sun, 05 Aug 2001 14:42:38 +0300
From: Markku Hirvonen <markku@huilustudio.fi>
Subject: Re: COmments appreciated
Message-Id: <t5cqmtkrr8sd3empl3b6j00f06pj1kccbb@4ax.com>
Yves.
Although it's "nicer" (and i agree 100% with that), your \e version
gave me some new insight on my other problem. Thx for sharing it with
me!!
Markku Hirvonen
Finland
On 3 Aug 2001 19:47:45 GMT, 194.203.212.8 [demerphq] wrote:
>> Markku Hirvonen <markku@huilustudio.fi> wrote:
>> >
>> >I have a messageboard and i wanted to shorten all the words longer
>> >than 20 characters and put 3 dots after them.
>>
>>
>> $orig_message =~ s/(\w{20})\w+/$1.../g;
>
>Erk. And there I was doing the /e version.
>
>This is much nicer.
>
>Yves
>
>
>==================================
>Poster's IP address: 194.203.212.8
>Posted via http://nodevice.com
>Linux Programmer's Site
------------------------------
Date: Sun, 05 Aug 2001 12:17:01 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I know how many entries are in a hash?
Message-Id: <1Pab7.39$T3.171432960@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How can I know how many entries are in a hash?
If you mean how many keys, then all you have to do is take the scalar
sense of the keys() function:
$num_keys = scalar keys %hash;
The keys() function also resets the iterator, which in void context is
faster for tied hashes than would be iterating through the whole hash,
one key-value pair at a time.
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.56
--
This space intentionally left blank
------------------------------
Date: Sun, 05 Aug 2001 06:17:00 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How do I look up a hash element by value?
Message-Id: <wx5b7.37$T3.177179136@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How do I look up a hash element by value?
Create a reverse hash:
%by_value = reverse %by_key;
$key = $by_value{$value};
That's not particularly efficient. It would be more space-efficient to
use:
while (($key, $value) = each %by_key) {
$by_value{$value} = $key;
}
If your hash could have repeated values, the methods above will only
find one of the associated keys. This may or may not worry you. If it
does worry you, you can always reverse the hash into a hash of arrays
instead:
while (($key, $value) = each %by_key) {
push @{$key_list_by_value{$value}}, $key;
}
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
04.55
--
This space intentionally left blank
------------------------------
Date: Sun, 05 Aug 2001 06:56:54 GMT
From: "Sean Hamilton" <sh@planetquake.com>
Subject: filename expansion
Message-Id: <W66b7.28381$b_3.2357462@news0.telusplanet.net>
What would be the best way to expand a filename, ie
~user/dir/../file
to
/home/user/file
etc, etc?
Must this be done manually?
sh
------------------------------
Date: 5 Aug 2001 07:29:52 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: filename expansion
Message-Id: <9kislg$s0m$2@bob.news.rcn.net>
Sean Hamilton <sh@planetquake.com> wrote:
> What would be the best way to expand a filename, ie
> ~user/dir/../file
> to
> /home/user/file
> etc, etc?
> Must this be done manually?
See "How can I translate tildes (~) in a filename?" in perlfaq5. The
entry includes some code that you could probably copy and paste.
------------------------------
Date: 5 Aug 2001 05:16:48 -0700
From: noident@my-deja.com (noident)
Subject: Re: filename expansion
Message-Id: <66fba11b.0108050416.2686af0f@posting.google.com>
"Sean Hamilton" <sh@planetquake.com> wrote in message news:<W66b7.28381$b_3.2357462@news0.telusplanet.net>...
> What would be the best way to expand a filename, ie
>
> ~user/dir/../file
>
> to
>
> /home/user/file
>
$file = '~test/dir/file';
$file =~ /~([^\/]+)(.*)/g;
$expanded = (getpwnam $1)[7] . $2;
print "$expanded\n";
/home/test/dir/file
cheers
------------------------------
Date: 5 Aug 2001 01:51:21 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: How do I select a random element from an array?
Message-Id: <9kiqd9$59d$1@charity.cs.utexas.edu>
In article <9ki5eg$mc5$0@216.155.32.133>, ~greg <gm@magpage.com> wrote:
>And it occurred to me that one way to random-sort
>an array is like this:
>
>print join (',', sort { int(rand(3))-1 } (1,2,3,4,5,6,7,8,9));
>
>- which works, but it's scary,
>because the comparison function isn't consistent.
>
>So I wondered if that could be trusted
>to never cause a problem?
No, because there are no guarantees which algorithm sort uses.
Some sorting algorithms (and associated implementations) would have
a problem with this, and some would not. Since you don't know
which is being used, you can't really assume that it'll work.
And anyway, what you probably *really* want when shuffle an array,
is for the original array sequence to have no effect on the
resulting sequence. This is actually harder than you might
think. I once wrote a Perl program to generate an approximate
value of e using a law of probability that relies on shuffling an
array randomly. I used the fisher-yates shuffle from the FAQ, but
I made a very slight change (can't remember what) that seemed
completely insignificant. Lo and behold, I was getting numbers
that were nowhere near 2.71828. I changed it to work exactly like
what's listed in the FAQ, and suddenly my numbers came out right.
The moral? Shuffling an array randomly isn't actually an
easy problem, and if you don't understand it, copying the
code from "perldoc -q shuffle" is the best way to go.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 5 Aug 2001 05:58:31 -0700
From: noident@my-deja.com (noident)
Subject: Re: How to use IO::Handle to open a pipe
Message-Id: <66fba11b.0108050458.41e59f8@posting.google.com>
I don't really know what your code does or is supposed to do, but...
> sub recMsg {
> #my $ent = shift;
> if ($ent) {
> my $v =$ent->get;
> my $vorig = $v . ".au";
> #record message thru sound card
> # print "start recording; type ctrl-c when finished";
> my $pid = open2(\*READR, \*RCONTROL, "rec -d /dev/audio $vorig"); #open
we have just forked, therefore we should use:
if($pid){blah blah}
else{something else}
> (RCONTROL, "| rec -d /dev/audio $vorig");
> # test to see when RCONTROL disappears
> waitpid ($pid,"");
> my $vnu = $v . ".au";
> `autopvf $vorig | pvftormd US_Robotics 4 > $vnu`;
> }
^^ this whole block is in both child's and parent's execution threads
> else {
> $NOPLAYFILE->Show eq 'OK';
> }
> }
> sub stopRec {
> print RCONTROL \cC;
> close RCONTROL;
> }
>
> Thanks for all the help.
>
> Paul Schwartz
cheers
------------------------------
Date: 5 Aug 2001 07:17:10 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Save memory and measure used memory???
Message-Id: <9kirtm$s0m$1@bob.news.rcn.net>
In comp.lang.perl.misc Markus <markus.cl@gmx.de> wrote:
> Is this better:
> $rules{'A'}{'MPN'}{'NP'} = 1;
> $rules{'A'}{'MPN'}{'NP'}{'$.'} = 1;
> $rules{'A'}{'MPN'}{'NP'}{'CARD'}{'$.'} = 1;
That style is actually broken, creating unintended symbolic references;
e.g. your second assignment is actually setting $1{'$.'}. You could fix
it by picking a "sentinel" value that can't occur in your actual input and
using it as the last key in a rule that's a prefix of other rules, e.g.
$rules{'A'}{'MPN'}{'NP'}{0} = 1;
> or this:
> $rules{'A MPN NP'} = 1;
> $rules{'A MPN NP $.'} = 1;
> $rules{'A MPN NP CARD $.'} = 1;
That's going to be rather awkward to work with; if you need something like
it, you might as well use an array rather than a hash.
What you're probably looking for is a "trie" structure; there are a couple
modules on CPAN dealing with tries.
------------------------------
Date: 05 Aug 2001 07:26:42 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: serial ports/modems and chat2.pl
Message-Id: <m1d76a1t25.fsf@halfdome.holdit.com>
>>>>> "Alan" == Alan Barclay <gorilla@elaine.furryape.com> writes:
Alan> chat2.pl is very outdated, and should be considered obsolete. As
Alan> the comments say
Alan> # This library is no longer being maintained, and is included
Alan> # for backward compatibility with Perl 4 programs which may
Alan> # require it.
Alan> #
Alan> # In particular, this should not be used as an example of modern Perl
Alan> # programming techniques.
It should not have even been used as an example of *ancient* Perl
programming techniques. :)
print "Just another Perl hacker," # waiting for internic.pl to give me chat2!
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 5 Aug 2001 04:53:37 -0700
From: ssa1701@yahoo.co.uk (shaz)
Subject: Re: string extraction
Message-Id: <23e71812.0108050353.46b061e@posting.google.com>
The program should count the occurance of each word and also find the
word which occurs most often (keyword).
> #!/usr/bin/perl -w
> use strict;
There is a problem with the tags as I have found out that they will
not be of the form <NN> and <VBZ>. They should be like /NN and /VBZ. I
have tried to make the change but the program stops reading the file.
> my @tags = ('<NN>', '<VBZ>', '<DET>');
> my $search = join('|',@tags);
> my %taglist;
>
> while (<DATA>) {
> while (/(\w+)\s($search)/og) {
The program does not reach this point (due to the $search variable)
> # print "$1 -> $2\n";
> $taglist{$2}{$1}++;
> }
> }
> foreach my $tag (sort keys %taglist) {
> print "Tag $tag\n";
> foreach my $word (sort keys %{$taglist{$tag}}) {
> print "\t$word ($taglist{$tag}{$word})\n";
> }
> }
>
The data is now
This is part of Sol05a.txt and also the final exam/NN. This is used
for eegggtgg the book/NN.
hello/VBZ
bye
computer/NN
printer
table/VBZ
monitor/NN
explorer/NN
a/NN
a/NN
a/NN
The keyword should be "a"
------------------------------
Date: 5 Aug 2001 04:32:40 -0400
From: secretary@lxny.org
Subject: Tuesday 7 August 2001 LXNY Meeting: Jesse Erlbaum, CTO Vanguard Media, on Web Development Strategies for People Who Don't Like to Work Weekends
Message-Id: <9kj0b8$kn$1@panix6.panix.com>
Keywords: available, hackable, freely redistributable source; GPL, BSDL, ArtisticL, XSL
LXNY will have a general meeting Tuesday 7 August 2001.
This meeting is free and open to the public.
The meeting runs from 6:30 pm to 9:00 pm. After the meeting full and
precise instructions on how to get to our traditional place of refreshment
will be given in clear.
Thanks to support of the IBM Corporation, the meeting is at their building
at 590 Madison Avenue at East 57th Street on the Island of Manhattan.
Enter the building at the corner of Madison and 57th and ask at the desk
for the floor and room number.
Jesse Erlbaum, Chief Technical Officer of Vanguard Media, will speak on
"Web Development Strategies for People Who Don't Like to Work Weekends".
<blockquote
edit-level="light">
what="Jesse's own biographical blurb">
Jesse Erlbaum is the Chief Technology Officer for the Vanguard Media
Corporation (http://www.vm.com/), located in New York City, where he has
worked since 1994. Vanguard Media, founded in 1989, builds custom software
for its clients on a contract basis. The firm has developed custom software
for a variety of clients including the WPP Group, Time Inc., and the Asia
Society. Vanguard Media's work ranges from developing internal business
intranets and applications to public consumer websites.
Jesse has been a fervent supporter of all things open-source for many
years. In addition to his work at Vanguard Media, Jesse is a programmer
and registered author on CPAN (the Comprehensive Perl Archive Network). His
Perl module, CGI::Application, was recently featured in an article on
Perl.com:
http://www.perl.com/pub/2001/06/05/cgi.html
</blockquote>
Jesse was a panelist on the Free Software Panel at the NYSIA "Software
Summit" in January 1999 - alongside Richard M. Stallman and others.
<blockquote
edit-level="light"
what="Jesse's blurb for the talk">
Jesse will discuss and answer questions about basic techniques, both
technical and managerial, which can be employed to make interactive web
application development less risky and more fun. He will discuss how
Vanguard Media uses a combination of technology (Linux, Apache, Perl,
MySQL), management techniques (two-phase funding, specifications) and
management enabling technology (CVS, advanced development environments,
HTML::Template, CGI::Application) to successfully build custom software on
time and on budget. Questions are encouraged, from specific technical
details to account management strategies.
</blockquote>
<blockquote
edit-level="light"
about="CGI::Application"
from="a post from Jesse to the WWWhackoes list, http://www.wwwac.org">
At VM we have used this module, or its closed-source predecessor for over
three years. We've used it on some pretty beefy projects (no offense to
the vegetarians in the crowd!), in terms of complexity, performance
requirements and criticality of the application to our client's
organizations.
The thing which many people find quite useful about the module is that it
greatly assists in separating the HTML GUI from the application code. When
used in conjunction with HTML::Template, CGI::Application allows the best
Perl programmer to collaborate with the best HTML designer -- instead of
only allowing the best "generalists" to participate.
</blockquote>
http://www.cpan.org/authors/id/J/JE/JERLBAUM
<blockquote
edit-level="light"
what="Jesse's blurb for CGI::Application">
CGI::Application is intended to make it easier to create sophisticated,
reusable web-based applications. This module implements a methodology which,
if followed, will make your web software easier to design, easier to
document, easier to write, and easier to evolve.
CGI::Application builds on standard, non-proprietary technologies and
techniques, such as the Common Gateway Interface and Lincoln D. Stein's
excellent CGI.pm module. CGI::Application judiciously avoids employing
technologies and techniques which would bind a developer to any one set
of tools, operating system or web server.
The guiding philosophy behind CGI::Application is that a web-based
application can be organized into a specific set of "Run-Modes." Each
Run-Mode is roughly analogous to a single screen (a form, some output, etc).
All the Run-Modes are managed by a single "Application Module" which is a
Perl module. In your web server's document space there is an "Instance
Script" which is called by the web server as a CGI (or an Apache::Registry
script if you're using Apache + mod_perl).
CGI::Application is an Object-Oriented Perl module which implements an
Abstract Class. It is not intended that this package be instantiated
directly. Instead, it is intended that your Application Module will be
implemented as a Sub-Class of CGI::Application.
If you have any questions, comments, bug reports or feature suggestions,
post them to the support mailing list! To join the mailing list, simply
send a blank message to "cgiapp-subscribe@lists.vm.com".
</blockquote>
Upcoming events:
Monday 6 August 2001: At noon the New York Rally to Free Sklyarov
will start in front of the New York Public Library at Fifth Avenue and
41st Street.
<blockquote
from="http://www.eff.org/alerts/20010803_eff_sklyarov_alert.html#protest">
MONDAY, AUGUST 6: Join other freedom lovers in renewed protest against the
arrest of Russian software engineer Dmitry Sklyarov. Dmitry was arrested in
Las Vegas on July 16 by the FBI after presenting a paper on cryptography
software he developed in Russia. The US Attorney for the Northern District
of California (i.e., the Dept. of Justice) has filed criminal charges
against Dmitry in Calif., under the Digital Millennium Copyright Act (DMCA)
for providing software that decrypts Adobe eBook files so that their
content can be accessed in ways that Adobe's own software does not provide
(e.g. text-to-speech translation for the blind). We believe that this
prosecution is a reprehensible assault on the free expression rights of
programmers (and ultimately of end users), under a law that will not
withstand constitutional scrutiny.
</blockquote>
http://freesklyarov.org
http://www.nyfairuse.org
http://eff.org
http://cryptome.org
Wednesday 8 August 2001: David Sugar, head of Bayonne and head of DotGNU,
will address the GNUbies on "GNU/Linux Telephony and DotGNU for You" in the
IBM building. The meeting starts at 6:30 pm.
http://www.gnubies.org
http://www.gnu.org/software/bayonne/bayonne.html
http://www.dotgnu.org
Refund Day: The last Refund Day was a success. The next will carry the
battle into the courts. If you are considering buying an IBM style
"personal computer" from a large vendor who does not offer a choice of
operating systems, and you would like to help in the fight for fair dealing
in the mass market for peecees, come to the 7 August 2001 LXNY meeting.
Jay Sulzberger <secretary@lxny.org>
Corresponding Secretary LXNY
LXNY is New York's Free Computing Organization.
http://www.lxny.org
------------------------------
Date: 5 Aug 2001 01:55:31 -0500
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: using eval
Message-Id: <9kiql3$5ad$1@charity.cs.utexas.edu>
In article <pt2b7.9752$K6.3948128@news2>,
Clinton A. Pierce <clintp@geeksalad.org> wrote:
>In article <f8b445c0.0108041720.2cbbee7a@posting.google.com>,
> kenphilbrick@mindspring.com (Ken) writes:
>> I'm trying to use eval to execute all the code contained in a separate
>> file. I've tried the following:
>
>eval {
> require "file.pl";
>};
>
> or
>
> open(F, "file.pl") || die;
> {
> local $/;
> $a=<F>;
> }
> eval "$a";
>
> or, if you don't really need eval...
>
>do "file.pl";
"do" may be better than "require" anyway, since they have another
important difference: "do" runs the code every time, and "require" runs
it only a single time. So usually "do" is useful if you need to
actually run code, whereas "require" is useful if you want to do things
like define subroutines.
- Logan
--
"Our grandkids love that we get Roadrunner and digital cable."
(Advertisement for Time Warner cable TV and internet access, July 2001)
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 1446
***************************************