[9548] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3142 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 13 15:10:32 1998

Date: Mon, 13 Jul 98 12:00:25 -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           Mon, 13 Jul 1998     Volume: 8 Number: 3142

Today's topics:
    Re: Arrays (Larry Rosler)
    Re: Code for deciding week number? (Greg Ward)
    Re: compare MS Word files (Steve)
    Re: directory name globbing with ActiveState Perl for W <blok@physics.ubc.ca>
    Re: First meeting of Dallas.pm <merlyn@stonehenge.com>
        Guidance.. <jpratt@command-central.nmsd.k12.nm.us>
    Re: HELP !!!!!!!!!!!! abraham@mpi.com
    Re: How do chang groups (Scott Anderson)
    Re: Lenght of string and array problem... Grehom@my-dejanews.com
        My script stops searching... <geoff_wild@dynapro.com>
        Perl 4 compilation on Solaris 2.6 <skrbec@cig.mot.com>
        Perl Control Codes <sbingham@miv.net>
        Perl Control Codes <sbingham@miv.net>
    Re: Perl Database Problem (Steve Linberg)
    Re: Permissions in Perl (brian moore)
    Re: print multiline strings (Jim Turner)
        Quickie: the number of occurences of a character in a s shapiroj@logica.com
    Re: Quickie: the number of occurences of a character in (Larry Rosler)
    Re: Quickie: the number of occurences of a character in (Steve)
        References to Anonymous subroutines <gil_brown@hp.com>
        RegExps: Check if string consists of EXACTLY 3 digits ? <karsten.no.123.spam@alpha.futurenet.co.za>
    Re: sending mail from within perl <ozette.brown@infotechfl.com>
        Signals (%SIG) on NT <js@ddre.dk>
        Threads in Perl? NEWBIE ? <spotter@remove-to-reply.ms.com>
    Re: Urgent!! Need Programmer for perm in Malibu, Ca <johnc@interactive.ibm.com>
    Re: Urgent!! Need Programmer for perm in Malibu, Ca (Andy Lester)
        Using PerlIO in XSUB module (Greg Ward)
    Re: What's the substitute for #! /usr/bin/perl in Win32 abraham@mpi.com
    Re: Why is Dave operating here? (was Re: REPOST: Re: ) <rra@stanford.edu>
    Re: Why is Dave operating here? (was Re: REPOST: Re: ) (John Stanley)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 13 Jul 1998 10:22:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Arrays
Message-Id: <MPG.1013e24a58a122db989704@nntp.hpl.hp.com>

In article <6odcvi$jim$1@nnrp1.dejanews.com> on Mon, 13 Jul 1998 16:34:58 
GMT, merzky@physik.hu-berlin.de <merzky@physik.hu-berlin.de> says...
> In article <slrn6qjdcp.825.arch@abts.net>,
>   arch@abts.net wrote:
> >     Quoting The Wildman - in comp.lang.perl.misc you wrote:
> >
> > > I'm having a little trouble with arrays. Okay, a LOT. I don't understand how
> > > they work in perl at all. I'm trying to do something like this:
> > > for ($i = 0;$i < MAX;$i++) {
> > >     $array[$i] = $i;
> > > }
> > >
> > > But of course it isn't working. You can see what my coding background is,
> > > too, I suppose. :D
> >
> > Weird that it isn't working for you.
> 
> I guess he just declared something like
> my ($array);
> before, or used it in scalar context...

No.  $array and $array[$i] and $array{$i} refer to three different 
entities that happen to have the same name -- a scalar, an array and a 
hash.

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 13 Jul 1998 18:29:25 GMT
From: greg@bic.mni.mcgill.ca (Greg Ward)
Subject: Re: Code for deciding week number?
Message-Id: <6odjm5$ob2@sifon.cc.mcgill.ca>

Thomas Albech (thomas@provideo.dk) wrote:
: How do you mathematically decide, which week number we are currently in?
: Is there any expression for it
: in combination with the Time module?

Get the Date::DateCalc module from CPAN.  Among many other interesting
and useful date compuations, it will compute the "week number" according
to some ISO standard.

        Greg

--
Greg Ward - Programmer/Analyst                     greg@bic.mni.mcgill.ca
Brain Imaging Centre (WB201)           http://www.bic.mni.mcgill.ca/~greg
Montreal Neurological Institute           voice: (514) 398-4965 (or 1996)
Montreal, Quebec, Canada  H3A 2B4           fax: (514) 398-8948


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

Date: Mon, 13 Jul 1998 18:31:08 GMT
From: ej345@SPAMPROOF.cleveland.freenet.edu (Steve)
Subject: Re: compare MS Word files
Message-Id: <35b35127.15312805@nnrp.digex.net>

On 13 Jul 1998 15:29:20 GMT, "Liming Wang" <wangli@nortel.ca> wrote:

>Hi, folks,
>
>I would like to compare two MS Word files in a Perl script.  Is anyone
>aware of a robust mechanism for doing this ?  
>
>Say, file1.doc and file2.doc are identical in contents, but some words in
>file1.doc are italic while the corresponding words in file2.doc are bold, 
>I would want to treat them as different. 
>
>Any advices, suggestions are appreciated.  TIA.
>

Hmm, this would likely involve reverse-engineering the entire MS-Word
 .doc format, which is certainly possible, but is far from trivial, and
I've never seen any documentation to get you started on the task.

One part of the problem is that when saving a new MS-Word document,
the application pads the file out to a minimum size by simply copying
a random chunk of user memory into the edit buffer (which is utterly
inexcusable from a security standpoint...  if you load an MS-Word
document into a binary editor, there's a chance you might find bits
from other documents, your unencrypted username & password, or who
knows what else?)  This also means that if user A and user B type the
exact same text into MS-Word on seperate machines, the files will not
be the same.

At the very least, you'd have to determine how MS-Word denotes the
beginning and end of the main body of the document, and constrain your
search to that.  Apart from the 'padding' mentioned above, MS-Word
documents also contain information like date/time stamps, undo buffer
history, and various other things you would want to exclude from your
search.


  -Steve



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

Date: Mon, 13 Jul 1998 10:48:12 -0700
From: Rik Blok <blok@physics.ubc.ca>
Subject: Re: directory name globbing with ActiveState Perl for Win32
Message-Id: <35AA485C.6F7F5B77@physics.ubc.ca>

Correction:

Sorry, when I use DosGlob the error message is actually "Missing $ on
loop variable at .../DosGlob.pm line 14."

Rik.


Rik Blok wrote:
> 
> I am trying to use some advanced filename globbing that supports
> wildcarded directory names (like /p*/*.pm) under ActiveState's Perl for
> Win32 (Perl version 5.00307).  I've seen a module called "DosGlob" that
> is apparently included in the standard release as of v5.004 which should
> do the trick.
> 
> I was hoping I could just download that module and ...ta da! it would
> work but it didn't (of course).  When I try to "use" it it complains
> "Bad command or filename" in the output.
> 
> Anyways, does anybody know how I can get directory globbing with the
> ActiveState release?
> 
> Please reply via email.
> Thanks in advance,
>         Rik.
> 
> --
> Rik Blok  <blok@physics.ubc.ca>
> Department of Physics and Astronomy,
> University of British Columbia, Canada
> http://www.physics.ubc.ca/~blok/

-- 
Rik Blok  <blok@physics.ubc.ca>
Department of Physics and Astronomy,
University of British Columbia, Canada
http://www.physics.ubc.ca/~blok/


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

Date: Mon, 13 Jul 1998 17:35:16 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: First meeting of Dallas.pm
Message-Id: <8c3ec564dt.fsf@gadget.cscaper.com>

>>>>> "Matthias" == Matthias Neeracher <neeri@iis.ee.ethz.ch> writes:

>> Yes, it's nice that all the new Perl Monger groups seem to be
>> following that fine old tradition established by the prototype PM
>> (NY.PM) of holding their meetings in a bar. :-)

Matthias> Hey, given your business investments, doesn't such a
Matthias> statement represent a conflict of interest? :-)

Only if we start LaGrande.pm.  And let me be the first to say, when I
visit LaGrande, the population of Perl Mongers goes from zero to one,
and when I leave, it's back to zero. :-)

print "Just another Perl hacker,"

-- 
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me


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

Date: Mon, 13 Jul 1998 13:18:08 -0700
From: "J. Pratt" <jpratt@command-central.nmsd.k12.nm.us>
Subject: Guidance..
Message-Id: <35AA6B80.96B0C459@command-central.nmsd.k12.nm.us>

Hey all, I'm working on a script using CGI.pm.  Any help would be
greatly appreciated..  I'm fairly new with Perl and especially CGI.pm. 
I'm an administrator, but my programming skills could use some
sharpening.  If someone could point me to a script that does something
along these lines, that would be great, too.

The script is an online entry editor..  With it, you can view entries
(which simply displays the text file), or add entries (each entry is
just a line of text).  However, I am wanting to implement a delete
feature.  This is not as easy as I had hoped it would be, though.  I
figured the best layout to do this would be to put a checkbox next to
each entry (each line).  To delete an entry, you would simply check the
checkbox next to the corresponing entry.  You would then submit,
confirm  (I'm clear on how to do the confirming part), and it would
delete the appropriate line from the text file.

How should I go about this?
Thanks in advance! .. And don't worry, sooner or later I'll be a quite
skillful programmer.  :)

- J. Pratt


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

Date: Mon, 13 Jul 1998 16:52:19 GMT
From: abraham@mpi.com
To: mabraham@kenan.com
Subject: Re: HELP !!!!!!!!!!!!
Message-Id: <6ode03$lhh$1@nnrp1.dejanews.com>

In article <35A7D65D.66CC@mail.connect.usq.edu.au>,
  Boon <d9732116@mail.connect.usq.edu.au> wrote:
> Can anyone of you please tell me how to develop a search engine by using
> JAVA ???????? Thank YOu .
>

I've seen this kind of thing on comp.lang.perl.misc as well, and I've always
wondered:  how can someone who doesn't know the first thing about a language,
or sometimes even about programming in general, know about the newsgroups?  I
mean, a guy will post to comp.lang.perl.misc something like: "Say, I'd like
to parse HTML form data?  How do I go about it?  BTW, where can I get perl?" 
How is it that newsgroup queries top the list of things to try?  Over RTFM,
try www.perl.com or java.sun.com, or gamelan, or perusing one of the million
books at the store?  Or knowing something about anything before getting
started? Because I figure than even a moderately experienced programmer would
strangle him/herself before sinking this low.

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 13 Jul 1998 17:24:25 GMT
From: scotan@selinc.com (Scott Anderson)
Subject: Re: How do chang groups
Message-Id: <6odfs9$16d$1@supernews.com>

I corrected a typo in my previous post. 
The version of perl is 5.004.04 not 5.00.04.

Also, the problem doesn't seem to be NIS related (see below).

I've tried both $( and $) with the same results.  That is, the
script works as root but not as a normal user.

Thanks for the help.

Regards,
Scott


>>>Hi,
>>>Is it possible to have perl change a users group id?
>>>
>>>$grp = $(;
>>>$groupname = getgrgid($grp); 
>>>
>>>gets the current group name correctly. So, I tried
>>>
>>> $( = $grpnum;
>>>
>>>and got an error message telling me setgid was not implemented. Is there 
>some
>>>other way to change groups?  I haven't had much luck finding info on this 
>>>topic so I would be grateful for any help.
>>>
>>Most usually when Perl claims that some function or other is not
>>implemented on your platform you can be pretty sure that it is telling
>>the truth - however if you did not compile Perl yourself and you are
>>sure that the setgid() C library function is available to you (which
>>is fairly certain on a SVR4 type system ) then you might want to
>>rebuild Perl yourself and check that it is doing the right thing.
>>
>>/J\
>>Jonathan Stowe
>>Some of your questions answered:
>><URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
>>
>Thanks for the suggestion.
>
>I compiled perl 5.004.04 using gcc 2.8.1 on a Solaris 2.5.1 computer and 
>have made some head way.
>
>The script now works correctly if I am super user. However, if I am a normal 
>user I can not change groups. I can switch groups from the command line
>using newgrp so I know that I am a member of both groups. We use NIS+, but I 
>haven't modified the tables. I added my test group to the local
>/etc/group file.
>
>By the way, I compiled perl as root if that makes any difference.
>
>Thanks,
>Scott
>



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

Date: Mon, 13 Jul 1998 18:28:20 GMT
From: Grehom@my-dejanews.com
Subject: Re: Lenght of string and array problem...
Message-Id: <6odjk3$1lo$1@nnrp1.dejanews.com>

You could always try the 'length' function for length of string !!!
(What? no manual - no excuse for that with Perl, me thinks!).

Till you get the hang of 'simplifying' everything.  Using the bare minimum of
code and the defaults like $_  you'd probably do better to insert a few
working storage variables in there. I know because I experienced a very
similar problem to yours with a foreach construct - I'm new to Perl myself
(Cobol programmer trying to see how the big boys play).

  foreach $a (@array)

doesn't copy a copy of the current array position into $a $a is actually a
reference to the value itself alter $a and you alter the array itself (at
least that's how a newbie like me reads it).

In article <kq90lzcb6z.fsf@atrey.karlin.mff.cuni.cz>,
  Ondrej Sury <shade@atrey.karlin.mff.cuni.cz> wrote:
>
> 1.  How do I find out length of string in Perl?
>
> 2.  Array @mages is filled with numbers.  But after I use this
> code each number in array rewritten by value of $mg_found{$_}.
> I use similar code on other place and it doesn't behave like
> this.  What is the problem?
>
>     foreach (@mages) {
>         $_ = $mg_found{$_};
>         @_ = split //;
>         for ($a = 0; $a < 10; $a++) {
>             $max{$a} = $_[$a] if ($max{$a} < $_[$a]);
>         }
>     }
>
> Ondrej Sury.
>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Mon, 13 Jul 1998 10:27:20 -0700
From: "Geoff Wild" <geoff_wild@dynapro.com>
Subject: My script stops searching...
Message-Id: <6odg2m$cij$1@nr1.vancouver.istar.net>

I am trying to search every text file on our system for a particular string.

The command line is: test.pl <STRING>

I'm using a script from Larry Wall's Programming Perl book.

The difference is I want the output to a file, I have tried the script with
the log file as well as to STDOUT - and once I have hit 94 files, the script
slowly loses cpu, until it uses nothing.

I thought maybe it was dying on a large file - but nope - I moved that file
to another directory - and the script still stops searching after 94 files.

I get no error messages.....

Anyone have any ideas I can try?

Thanks...Geoff

Here's the script:

#!/usr/bin/perl
$LOGFILE="/tmp/test.pl.log";
open(FIND, "find . -print |") || die "Couldn't run find: $!\n";
FILE:
while ($filename = <FIND>) {
        chop $filename;
        next FILE unless -T $filename;
        if (!open(TEXTFILE, $filename)) {
                print STDERR "Can't open $filename - continuing...\n";
                next FILE;
        }
        open(LOG, ">> $LOGFILE");
        while (<TEXTFILE>) {
                foreach $word (@ARGV) {
                        if (index($_, $word) >= 0) {
                                print LOG $filename, "\n";
                                next FILE;
                        }
                }
        }
}
close(LOG);





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

Date: Mon, 13 Jul 1998 12:35:16 -0500
From: Brad Skrbec <skrbec@cig.mot.com>
Subject: Perl 4 compilation on Solaris 2.6
Message-Id: <35AA4554.3C5DFB05@cig.mot.com>

Hi all,

Due to many older scripts being written in Perl 4 here, we are looking
at building Perl 4 on Solaris 2.6 for backward compatibility.
Unfortunately, Perl 4 is not overly compatible with the environment, and
there appear to be some problems  related to /usr/ucblib compatibility
libraries and the and dbm and flock calls.

Has anyone successfully compiled version 4.036 on Solaris 2.6?  If not,
can anyone clue me in on what Perl 4/Perl 5 incompatibility problems I
may run into?

Thanks in advance for your help!

Brad Skrbec
Lead Engineer
Motorola Inc




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

Date: Mon, 13 Jul 1998 13:40:57 -0400
From: "Scott Bingham" <sbingham@miv.net>
Subject: Perl Control Codes
Message-Id: <6odh1u$nat$1@jupiter.inter-view.net>


I was having a problem with Perl I thought you might be able to help me
with.  What we are doing is creating some interactive web applications which
involve passing the Query_string through a perl script to a program which
accesses a database.  In the program, we find the &'s and make everything to
the left of that the variable, and it works until we have an & in the value
of the variable.  To solve this we switched the value of the = to %~~% and
%~%, but to our further dismay it still didn't work.  The problem now was in
the cgi script...when we convert the special characters... like %28 etc.
the variable on the end of an =, now a %~%, could possibly be a 28 or 25, so
it would then convert it to a ( or whatever other simble %25 stands for.
Realizing that if we keep using common keyboard characters as delimiters and
equals signs, we decided to use a control code...ctrl a, ctrl b, for
example, something not associated in any way to a text character.  The
problem being, we don't know how to embed control codes in perl or use hex
characters...  Not wanting to write this cgi script in bash, we wondered if
you could help us if you knew how to embed control codes.
Thank you for your time and efforts...  Please reply as soon as possible if
you can provide any relevant information.
Thank You,
Scott Bingham
Michigan Inter-View, Inc.
sbingham@miv.net




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

Date: Mon, 13 Jul 1998 13:40:57 -0400
From: "Scott Bingham" <sbingham@miv.net>
Subject: Perl Control Codes
Message-Id: <6odh15$nam$1@jupiter.inter-view.net>


I was having a problem with Perl I thought you might be able to help me
with.  What we are doing is creating some interactive web applications which
involve passing the Query_string through a perl script to a program which
accesses a database.  In the program, we find the &'s and make everything to
the left of that the variable, and it works until we have an & in the value
of the variable.  To solve this we switched the value of the = to %~~% and
%~%, but to our further dismay it still didn't work.  The problem now was in
the cgi script...when we convert the special characters... like %28 etc.
the variable on the end of an =, now a %~%, could possibly be a 28 or 25, so
it would then convert it to a ( or whatever other simble %25 stands for.
Realizing that if we keep using common keyboard characters as delimiters and
equals signs, we decided to use a control code...ctrl a, ctrl b, for
example, something not associated in any way to a text character.  The
problem being, we don't know how to embed control codes in perl or use hex
characters...  Not wanting to write this cgi script in bash, we wondered if
you could help us if you knew how to embed control codes.
Thank you for your time and efforts...  Please reply as soon as possible if
you can provide any relevant information.
Thank You,
Scott Bingham
Michigan Inter-View, Inc.
sbingham@miv.net




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

Date: Mon, 13 Jul 1998 12:56:44 -0400
From: linberg@literacy.upenn.edu (Steve Linberg)
Subject: Re: Perl Database Problem
Message-Id: <linberg-1307981256440001@projdirc.literacy.upenn.edu>

In article <6odall$gda$1@nnrp1.dejanews.com>, mike@2f3.com wrote:

> I'm using Perl5 and an HTML form. The form is supposed to use Perl to
> append to a delimited text file that I'm using as a database. It
> seems to work fine, returning the correct HTML, but the text file has
> nothing written to it. I think it may be the permissions (although I
> set them to full control for everyone) but I was wondering if anyone had
> any ideas as to why it doesn't work.

Operating system?
Sample code?
_____________________________________________________________________
Steve Linberg                       National Center on Adult Literacy
Systems Programmer &c.                     University of Pennsylvania
linberg@literacy.upenn.edu              http://www.literacyonline.org


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

Date: 13 Jul 1998 18:04:02 GMT
From: bem@news.cmc.net (brian moore)
Subject: Re: Permissions in Perl
Message-Id: <slrn6qkj0k.cbv.bem@thorin.cmc.net>

On 13 Jul 1998 17:50:50 +0200, 
 Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at> wrote:
> [
> Personally I wouldn't want to do this except just maybe in a
> very very controlled, restricted, captive intranet type
> network.  Mail reading programs supporting proper
> authentication are available, why try to reinvent something
> like that in a typically anonymous environment?
> ]

What I do is use IMAP or POP3 to handle the rootly matters of looking up
passwords, handling locks and even seperating messages.

-- 
Brian Moore                             Kill A Spammer For Jesus
Sysadmin, C/Perl Hacker, Usenet Vandal 


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

Date: 13 Jul 1998 17:04:38 GMT
From: turnerj@cliffy.lmtas.lmco.com (Jim Turner)
Subject: Re: print multiline strings
Message-Id: <6oden6$kp81@quest.lmtas.lmco.com>

Howard Dierking (howard@vortexweb.com) wrote:
: I'm using something like *print <<Lots_of_HTML* to print HTML with tables
: and forms and all that--however, I wasn't really planning on using all of
: the associated CGI.pm functions.  I was just going to try and print.  Now, I
: know that I need to \" all of the quotes.  However, am I going to need to do
: that for all "=", " &", ";"  -- I keep getting an error saying that it can't
: find the *Lots_of_HTML* before EOF.  Thanks
: 
: howard
: 
: 

	No, you shouldn't have to do this for all those other special chars,
but two gotchas are:  "Lots_of_HTML" should start the very beginning of
a line by itself and not be followed by any spaces, tabs, semicolons or 
anything else.   Also, the print statement should be followed by a semicolon:

Example:

print <<END_HTML
<BR>Your html stuff here.
 ...
</HTML>
END_HTML

Best wishes,

Jim
 


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

Date: Mon, 13 Jul 1998 17:48:45 GMT
From: shapiroj@logica.com
Subject: Quickie: the number of occurences of a character in a string
Message-Id: <6odh9t$s2g$1@nnrp1.dejanews.com>

I want to find the number of occurences of a given character ($char) in a
particular string, ($text). I thought there would be some cool, quick method
to do this using m//, but all I've been able to come up with is:

$number_of_occur = scalar ( @temp = ($text =~ /$char/g));

which is nice because it's one-line, but the @temp array is ick. (And -w
doesn't like it either.) Any suggestions?

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: Mon, 13 Jul 1998 11:27:52 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Quickie: the number of occurences of a character in a string
Message-Id: <MPG.1013f184b9347946989705@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6odh9t$s2g$1@nnrp1.dejanews.com> on Mon, 13 Jul 1998 17:48:45 
GMT, shapiroj@logica.com <shapiroj@logica.com> says...
> I want to find the number of occurences of a given character ($char) in a
> particular string, ($text). I thought there would be some cool, quick method
> to do this using m//, but all I've been able to come up with is:
> 
> $number_of_occur = scalar ( @temp = ($text =~ /$char/g));
> 
> which is nice because it's one-line, but the @temp array is ick. (And -w
> doesn't like it either.) Any suggestions?

The following creates an anonymous array:

  $number_of_occur = scalar ( @{[$text =~ /$char/g]} );

If you want to get fancy (and considerably more efficient):

  $number_of_occur = eval "\$text =~ tr/$char//";

-- 
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 13 Jul 1998 18:36:15 GMT
From: ej345@SPAMPROOF.cleveland.freenet.edu (Steve)
Subject: Re: Quickie: the number of occurences of a character in a string
Message-Id: <35b45384.15918285@nnrp.digex.net>

On Mon, 13 Jul 1998 17:48:45 GMT, shapiroj@logica.com wrote:

>I want to find the number of occurences of a given character ($char) in a
>particular string, ($text). I thought there would be some cool, quick method
>to do this using m//, but all I've been able to come up with is:
>
>$number_of_occur = scalar ( @temp = ($text =~ /$char/g));
>
>which is nice because it's one-line, but the @temp array is ick. (And -w
>doesn't like it either.) Any suggestions?

Hmm, off the top of my head, that's roughly how I would have done it
too.

Couldn't you appease -w by making this into a function and declaring
the variables as local?


  -Steve



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

Date: Mon, 13 Jul 1998 14:13:31 -0400
From: "Gil Brown" <gil_brown@hp.com>
Subject: References to Anonymous subroutines
Message-Id: <6odiom$j7f$1@ocean.cup.hp.com>

Hi;

I was going through some litterature on Perl (Advanced Perl programmind by
O'reilly) and found that you can declare anonymous subs by omitting the name
in a sub declaration. The example was:

                $rs = sub {
                                    print "hello \n";
                                };

It's suppose to return a reference to the newly created sub. Can anyone tell
me how it works?? Let say you declare such a routine can it be referenced to
somewhere else in the program? And what would be the use in declaring an
anonymous sub (Real world application).

Thanks




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

Date: Mon, 13 Jul 1998 20:03:19 -0700
From: Karsten <karsten.no.123.spam@alpha.futurenet.co.za>
Subject: RegExps: Check if string consists of EXACTLY 3 digits ??
Message-Id: <35AACA77.D9C@alpha.futurenet.co.za>

Hi!

I am writing a CGI script which accepts input via QUERY_STRING. 
However, the input is only valid if it consists of EXACTLY 3 DIGITS!  No
more , no less, no other characters in front, after or in between the
digits.  Ive tried things such as:

if ($ENV{'QUERY_STRING'} =~ /[0-9]\{3\}/)
{
  print "String is valid";
}
else
{
  print "Invalid input";
}

which should look for 3 digits as far as i can tell.  But it doesnt
work.  Ive tried other variations, none of which work (i dont remember
them right now).  Im clearly missing some important aspect of reg exps.

Please could someone help me get this regexp right?
Thanks in advance!

Karsten
karsten@alpha.futurenet.co.za


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

Date: Mon, 13 Jul 1998 13:36:31 -0400
From: Ozette Brown <ozette.brown@infotechfl.com>
To: "Bob L." <newsonly@usa.net>
Subject: Re: sending mail from within perl
Message-Id: <35AA459F.AF31C8BF@infotechfl.com>

Bob,

I am using the "standard port" of Perl which includes the Net::Smtp module as
well as a host of others.  This port of Perl is also know as the "Gurusamy
Sarathy Perl port".  It's very good.

You can get it from:  http://www.perl.com/CPAN-local/authors/Gurusamy_Sarathy/
filename = perl5.005402-bindinst04-bc.zip.

Thanks,

Ozette

Bob L. wrote:

> Hi:
>
> I tried to use it but I get "Document Contains No Data".  I looked in the
> Perl directory and found other Net:  types but not SMTP.  Do I have to get
> the SMTP module?  I was told it would be part of Perl.  I'm using the latest
> version from activestate.
>
> Thanks for your help.
>
> Bob
>
> Mr. Ozette Brown <ozette@imaginative-creations.com> wrote in message
> 35A93858.7A4C0BCF@imaginative-creations.com...
> >Hello,
> >
> >I've used Net::Smtp under Win95 and it works just fine.
> >
> >Good luck,
> >
> >Ozette
> >
> >Jim Babbington wrote:
> >
> >> try Net::smtp. I use it under NT, never tried it under 95.
> >>
> >> Good luck,
> >>
> >> Jim
> >
> >
> >
> >--
> >Mr. Ozette J. Brown   <President>
> >Imaginative Creations <webmaster@imaginative-creations.com>
> >A Website Development and Consulting Company.
> >http://www.imaginative-creations.com
> >
> >



--
Ozette Brown <Ozette.Brown@Infotechfl.com>
Webmaster, Infotech Inc.
5700 S.W. 34th St. Suite 1235      Phone:  352-375-7624
Gainesville, FL 32608-5371         Fax:    352-373-9586




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

Date: Mon, 13 Jul 1998 19:42:32 +0200
From: Jens Stavnstrup <js@ddre.dk>
Subject: Signals (%SIG) on NT
Message-Id: <Pine.OSF.3.95.980713192956.26622E-100000@radon.ddre.dk>


In UNIX boxes, users have access to Signals. Some of those signalsare
known  work under NT. According to Perl 5.004_04 compiled undet NT, there
are 48 availible signals, can we use all of them ?

Jens 







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

Date: Mon, 13 Jul 1998 18:00:04 +0100
From: "Su Potter" <spotter@remove-to-reply.ms.com>
Subject: Threads in Perl? NEWBIE ?
Message-Id: <6odeeo$mtn@sanews1.morgan.com>

I'd like to know how how to create a thread in Perl and how it would be run.
Please reply directly to spotter@ms.com aswell as the newsgroup, thanks.
Su
--
email: spotter@ms.com




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

Date: Mon, 13 Jul 1998 13:29:46 +0000
From: John Call <johnc@interactive.ibm.com>
Subject: Re: Urgent!! Need Programmer for perm in Malibu, Ca
Message-Id: <35AA0BB7.251AFAFF@interactive.ibm.com>

> Why not post to alt.jobs.hairdressers?

Will my code need to be well manicured?



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

Date: 13 Jul 1998 18:44:56 GMT
From: petdance@maxx.mc.net (Andy Lester)
Subject: Re: Urgent!! Need Programmer for perm in Malibu, Ca
Message-Id: <6odkj8$57n$1@supernews.com>

: > Why not post to alt.jobs.hairdressers?
: Will my code need to be well manicured?

yes, and perlstyle takes on new significance.

xoxo,
Andy

--
-- 
Andy Lester:        <andy@petdance.com>       http://tezcat.com/~andy/
Chicago Shows List: <shows@ChicagoMusic.com>  http://ChicagoMusic.com/



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

Date: 13 Jul 1998 18:48:12 GMT
From: greg@bic.mni.mcgill.ca (Greg Ward)
Subject: Using PerlIO in XSUB module
Message-Id: <6odkpc$ob2@sifon.cc.mcgill.ca>

Hi all --

surely I'm not the first person to try to adapt his XSUB code to the
PerlIO abstraction layer -- however, there's very little help in
the perlapio or perlguts man pages on how to do this, and DejaNews
turned up *nothing* related to it.

Quite simply, I have this code:

     int
     _parse (entry_ref, filename, file, preserve=FALSE)
         SV *    entry_ref;
         char *  filename;
         FILE *  file;
         boolean preserve;

         PREINIT:
             ushort  options = 0;
             boolean status;
             AST *   top;

         CODE:

             top = bt_parse_entry (file, filename, options, &status);

which worked under 5.003, and under 5.004 compiled *without* PerlIO.
(bt_parse_entry() is a function in a C library which, naturally, uses
stdio calls.)  As I understand it, this works because the default
typemap for compiling XSUB code knows how to turn a Perl filehandle into
a stdio FILE pointer.

When I use this under 5.004 compiled with PerlIO and sfio, it compiles
just fine, but the underlying C library doesn't get any data from the
FILE pointer.

Presumably, I want to change this to something like the following:

     int
     _parse (entry_ref, filename, file, preserve=FALSE)
         SV *    entry_ref;
         char *  filename;
         PerlIO *file;
         boolean preserve;

         PREINIT:
             FILE *  stdio_file;
             ushort  options = 0;
             boolean status;
             AST *   top;

         CODE:

             stdio_file = PerlIO_exportFILE (file, 0);
             top = bt_parse_entry (file, filename, options, &status);

 ...and let Perl (or rather, the default typemap) take care of turning a
filehandle into a PerlIO pointer.  However, that code fails because
"PerlIO *" isn't in the typemap:

% make
/usr/local/bin/perl5 -I/usr/local/lib/perl5/mips-irix/5.00404 -I/usr/local/lib/perl5 /usr/local/lib/perl5/ExtUtils/xsubpp -prototypes -typemap /usr/local/lib/perl5/ExtUtils/typemap -typemap typemap BibTeX.xs >BibTeX.tc && mv BibTeX.tc BibTeX.c
Error: 'PerlIO *' not in typemap in BibTeX.xs, line 175
make: *** [BibTeX.c] Error 1

So: how the heck do I do this?  More importantly, why isn't this
documented anywhere obvious (like in perlapio).  Hasn't anyone else out
there tried to adapt their modules to the PerlIO layer yet?

Caveat: I know my original code works with non-PerlIO, stdio-based Perl.
And I know it doesn't work with PerlIO, sfio-based Perl.  I haven't
built a PerlIO, stdio-based Perl yet though -- of course, the whole
point of PerlIO (as I understand it) is that the stdio/sfio distinction
doesn't matter; if it does, that's a bug.  But I'll still try to figure
out if it does matter!

        Greg

--
Greg Ward - Programmer/Analyst                     greg@bic.mni.mcgill.ca
Brain Imaging Centre (WB201)           http://www.bic.mni.mcgill.ca/~greg
Montreal Neurological Institute           voice: (514) 398-4965 (or 1996)
Montreal, Quebec, Canada  H3A 2B4           fax: (514) 398-8948


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

Date: Mon, 13 Jul 1998 17:08:12 GMT
From: abraham@mpi.com
Subject: Re: What's the substitute for #! /usr/bin/perl in Win32 Perl?
Message-Id: <6odets$n4j$1@nnrp1.dejanews.com>

In article <35AA0B42.23CA@flash.net>,
  dtbaker_@flash.net wrote:
> James Moore wrote:
> >
> > Newby needs an answer to the following question:
> >
> > I'm using the ActiveState Win32 Perl on an NT 4.0 system... what do I
> > use in place of the first line (#! /usr/bin/perl) in Unix versions of
> > the script ?
> -----------
> I dunno about NT, but in win95 I installed Perl to the c:\usr directory
> so that I'd get a "normal" path the same as UNIX and would have the same
> #! line. You might want to consider re-installing?

The NT "shell" is not what you would call full-featured -- for one thing, it
doesn't support "shebangs".  To make your program executable in Bill's world,
you need to run perl2bat or some such on it first.  This is discussed in the
perl for win32 documentation.

Jim Abraham

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/rg_mkgrp.xp   Create Your Own Free Member Forum


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

Date: 13 Jul 1998 09:42:23 -0700
From: Russ Allbery <rra@stanford.edu>
Subject: Re: Why is Dave operating here? (was Re: REPOST: Re: )
Message-Id: <m37m1hr9cg.fsf@windlord.Stanford.EDU>

John Stanley <stanley@skyking.OCE.ORST.EDU> writes:
> Abigail <abigail@fnx.com> wrote:

>> To me, it looks like Dave is resurrecting rogue cancels. Unless you
>> have the conception that all articles are yours and you should have the
>> ability to cancel them all, I don't there's anything Dave is preventing
>> you to do.

> Except that when Dave controls a group, you don't get to cancel your own
> articles, either.

John, that wasn't Dave.  It was Buffy.  Buffy doesn't resurrect all
cancelled posts; it only resurrects the ones that were forge-cancelled by
someone.  In this case, HipCrime.  No one's running Dave here.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: 13 Jul 1998 18:16:13 GMT
From: stanley@skyking.OCE.ORST.EDU (John Stanley)
Subject: Re: Why is Dave operating here? (was Re: REPOST: Re: )
Message-Id: <6oditd$9ah$1@news.NERO.NET>

In article <m37m1hr9cg.fsf@windlord.Stanford.EDU>,
Russ Allbery  <rra@stanford.edu> wrote:
>> Except that when Dave controls a group, you don't get to cancel your own
>> articles, either.
>
>John, that wasn't Dave.  It was Buffy.  

Then Buffy has an identity crisis and calls herself Dave.



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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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

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