[10514] in Perl-Users-Digest
Perl-Users Digest, Issue: 4106 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 29 17:07:09 1998
Date: Thu, 29 Oct 98 14:00:20 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 29 Oct 1998 Volume: 8 Number: 4106
Today's topics:
ANN: "pgrep" = perl grep (Steffen Beyer)
Re: ANN: "pgrep" = perl grep <sb@sdm.de>
Re: ANN: "pgrep" = perl grep <sb@sdm.de>
Anything like /bin/bash -x for perl? <brannon@quake.usc.edu>
Re: CGI.pm and 5.003 for win32? <kprice@cardinal.co.nz>
Re: changing file timestamp in Win32 sfitzgerald@habaneros.com
DBD:ODBC Question (remote access?) <m-NoSpam-starlin@ibl.bm>
easy way to learn perl? <olavskolen.bibliotek@hl.telia.no>
Re: Getting HTTP headers barleyguy@my-dejanews.com
Help -- Need Sybperl <montyt@bestnet.com>
Re: Help -- Need Sybperl <mpeppler@mbay.net>
ICQ and Perl <edward@ch.twi.tudelft.nl>
need some help please w.wilson@mailexcite.com
Re: Not to start a language war but.. (Paul Jackson)
Re: pass array to sub <merlyn@stonehenge.com>
Re: Perl & Y2K - booby trap code <uri@fastengines.com>
Please help me - unknown script routine ... (David Rummel)
Re: Syntactic flexibility (was: Re: psychology of langu <laheadle@boguscs.uchicago.edu>
Re: system() function on PERL for Win32 grahams@wpds.com
Re: system() function on PERL for Win32 (Tye McQueen)
Testing for number of occurances nheagy@my-dejanews.com
Re: Testing for number of occurances <rootbeer@teleport.com>
Re: Testing for number of occurances (Patrick Timmins)
Re: Testing for number of occurances (Clinton Pierce)
Re: Win95 Script Mapping grahams@wpds.com
Write to/Read from serial port? <signal@shreve.net>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 29 Oct 1998 14:43:43 GMT
From: sb@engelschall.com (Steffen Beyer)
Subject: ANN: "pgrep" = perl grep
Message-Id: <719uuv$78o$3@en1.engelschall.com>
=======================
"pgrep" - perl grep
=======================
Did you ever want to have a "grep" combined with the power of Perl's
regular expressions?
Here it is!
This tool accepts the usual options for "grep":
-i ignore case
-l list filenames only
-v invert search
-- end of options
The tool prints a usage if called without parameters.
For more information on "grep", see its corresponding manual pages on
your UNIX system.
Note that this tool is not restricted to UNIX platforms, though, it will
run wherever Perl does!
Just install this tool somewhere in your search path, e.g. "/usr/local/bin".
Don't forget to adjust the shell-bang line (the first line of the script)
to match the path where Perl is installed on your system.
Non-UNIX users please refer to the documentation of their Perl installation
for instructions on how to install Perl scripts as executable applications.
Available from
http://www.perl.com/CPAN/authors/id/STBEY/
or
http://www.engelschall.com/u/sb/download/
Enjoy!
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download: www.engelschall.com/u/sb/download/
------------------------------
Date: 29 Oct 1998 19:49:03 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: ANN: "pgrep" = perl grep
Message-Id: <71agrf$23j$1@bsdti6.sdm.de>
In comp.lang.perl.modules Tom Christiansen <tchrist@mox.perl.com> wrote:
> [courtesy cc of this posting sent to cited author via email]
> In comp.lang.perl.moderated,
> sb@engelschall.com (Steffen Beyer) writes:
> :
> :Did you ever want to have a "grep" combined with the power of Perl's
> :regular expressions?
> Why yes. And that's why I years and years ago wrote tcgrep,
> which is in my scripts directory on CPAN and in PCB.
Where is something comparable to The Perl 5 Module List for
scripts?
That's the problem with the scripts directory on CPAN, nobody
knows what's in there...
What is PCB?
Thanks for the hints!
Yours,
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download: www.engelschall.com/u/sb/download/
------------------------------
Date: 29 Oct 1998 19:50:36 GMT
From: Steffen Beyer <sb@sdm.de>
Subject: Re: ANN: "pgrep" = perl grep
Message-Id: <71aguc$23j$2@bsdti6.sdm.de>
In comp.lang.perl.modules MBC <mcolbert@netgenics.knowspaaaamm.com> wrote:
> hey, cool! now there's (at least) "more than one way to do it!"
Great argument! ;-)
Thanks for your help!! :-)
Yours,
--
Steffen Beyer <sb@engelschall.com>
Free Perl and C Software for Download: www.engelschall.com/u/sb/download/
------------------------------
Date: 29 Oct 1998 12:40:16 -0800
From: tbrannon <brannon@quake.usc.edu>
Subject: Anything like /bin/bash -x for perl?
Message-Id: <ysiz7lxjw18w.fsf@nunki.usc.edu>
I would like for each line of my Perl program to to printed to stdout
just prior to execution.
I would also like to have the values of my variables printed as their
values change.
Please advise on the methods to achieve this.
Respectfully,
--
Terrence Brannon * brannon@quake.usc.edu * http://quake.usc.edu/~brannon
------------------------------
Date: Fri, 30 Oct 1998 09:31:14 +1300
From: Kelvin Price <kprice@cardinal.co.nz>
Subject: Re: CGI.pm and 5.003 for win32?
Message-Id: <3638D092.D5BC8D7D@cardinal.co.nz>
Brian P. Barnes wrote:
>
> C:/bin>perl
> use CGI qw/:standard/;
> Perl 5.004 required--this is only version 5.00307, stopped at
> The active state port is only at 5.003 (I just downloaded it yesterday).
> Where can I get 5.004 binaries for windoz?
I've got ActivePerl build 502 and perl -v and perl -V both proudly
proclaim it to be perl 5.00502. I suspect you downloaded ActiveState
perl build 316 or earlier. If that is true, go back and get the latest
version.
------------------------------
Date: Thu, 29 Oct 1998 18:56:11 GMT
From: sfitzgerald@habaneros.com
Subject: Re: changing file timestamp in Win32
Message-Id: <71adob$okp$1@nnrp1.dejanews.com>
In article <MPG.10a06e66ffbc52bc9898e3@nntp.hpl.hp.com>,
lr@hpl.hp.com (Larry Rosler) wrote:
> [Posted to comp.lang.perl.misc and copy mailed.]
>
> In article <7166tn$pqd$1@nnrp1.dejanews.com> on Wed, 28 Oct 1998
> 04:35:03 GMT, stevenfitz@my-dejanews.com <stevenfitz@my-dejanews.com>
> says...
> ...
> > utime ($newTime, $newTime, $dest_path);
> ...
> > It doesn't seem to matter what I set $newTime to, utime always seems to set
it
> > to the current time. Any thoughts on what I'm doing wrong or how I could do
> > this better?
>
> I don't have any thoughts on what you're doing wrong, but perhaps the
> 'utime' function has some. You should test its return value (just as
> you should for any system call, such as 'open'). If 'utime' fails, the
> value of $! might tell you why.
>
> --
> (Just Another Larry) Rosler
> Hewlett-Packard Laboratories
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
>
Sorry for the delay...
I changed my line to:
utime ($newTime, $newTime, $dest_path) or print "\nutime failed: $!\n\n";
but got nothing back (i.e. utime thinks it worked).
Steven
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Oct 1998 16:04:31 -0400
From: "NightWolf/Michael Starling" <m-NoSpam-starlin@ibl.bm>
Subject: DBD:ODBC Question (remote access?)
Message-Id: <71ahqi$30l$1@news0-alterdial.uu.net>
Hi, all...
I was hoping someone might be able to help with this question. I've been
experimenting with database access using DBI and DBD:ODBC, and it's working
on my local machine here. Is it possible to access a database on another
machine/host, however?
The ODBC "connect" function's $data_source string seems to only accept one
format (at least, I can't find anything else...) - "DBI:ODBC:<dsn-name>",
where <dsn-name> is the DSN I've set up from the ODBC control panel. Is
there a way to say something like:
$dbh->connect("DBI:ODBC:host=foo.bar.com;port=x;dsn=<dsn-name>",$user,$pass)
; ?
I'd like to have some database access from another machine. Any help would
be appreciated - thanks!
Mike.
------------------------------
Date: Thu, 29 Oct 1998 20:41:53 +0100
From: "Bibliotek" <olavskolen.bibliotek@hl.telia.no>
Subject: easy way to learn perl?
Message-Id: <3638c49c.0@d2o204.telia.com>
is it any web sites wher newbies can learn peral eas`?
whgat is stronges off java script and perl sdscript
------------------------------
Date: Thu, 29 Oct 1998 21:12:09 GMT
From: barleyguy@my-dejanews.com
Subject: Re: Getting HTTP headers
Message-Id: <71aln9$3t5$1@nnrp1.dejanews.com>
In article <719pam$r70$1@nnrp1.dejanews.com>,
keydet89@yahoo.com wrote:
There appears to be several HTTP utilities on CPAN. Just go to
www.cpan.org/modules
click on the index, and scroll down to HTTP. Hopefully one of those will
help.
> I have been trying to write a small script that I can use to
> quickly check some of the values of HTTP headers on my
> web servers. I haven't gotten anything working, and I haven't
> been able to find any code snippets.
>
> Could someone give me a clue or some other assistance? This is
> part of a continued monitoring of my web servers, and all I want
> to get is some of the HTTP header values, such as server, etc.
>
> Any help is greatly appreciated. I am using ActiveState's latest
> build (502) on NT...
>
> Thanks
> Carv
>
> -----------== Posted via Deja News, The Discussion Network ==----------
> http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Oct 1998 11:31:22 -0800
From: "Monty Taylor" <montyt@bestnet.com>
Subject: Help -- Need Sybperl
Message-Id: <71afqi$30618@roc344.ghc.org>
OK. I need some help from some nice person. I'm currently using perl to
construct dynamic sql based on the contents of other tables. This involved
creating temporary files, executing isql and reading in the results, then
creating more temporary files.
I'm getting sick of it.
I would like to play with Sybperl or DBD:Sybase to do things a tad more
directly. However, I don't have a compiler on the Windows side and the UNIX
admins here don't believe Perl should be used in production, so they won't
install any bits for me (SMITE THEM ALL! It's SO frustrating not being an
admin)
I do have Perl on my Windoze machine. (Win 95) I'm running the version I
downloaded from Solutionsoft with Perl Builder, if it makes any difference.
It is installed in C:\Perl I have the Sybase Libraries, so the modules would
be legal and all that, I just need someone to compile them for me.
PLEASE!!! You can email them to me, or I can ftp them from somewhere, or I
can let you ftp them to somewhere. I will be eternally grateful, and maybe
one day (on a different account) I can return the favor.
Thanks a million in advance. -- Post or email replies.
--
-----------------------------------------------
Monty Taylor
Sybase DBA, UNIX Admin
Best Consulting -- Seattle, WA
montyt@bestnet.com
------------------------------
Date: Thu, 29 Oct 1998 12:14:09 -0800
From: Michael Peppler <mpeppler@mbay.net>
Subject: Re: Help -- Need Sybperl
Message-Id: <3638CC91.B9EB8D6C@mbay.net>
Monty Taylor wrote:
>
> I would like to play with Sybperl or DBD:Sybase to do things a tad more
> directly. However, I don't have a compiler on the Windows side and the UNIX
> admins here don't believe Perl should be used in production, so they won't
> install any bits for me (SMITE THEM ALL! It's SO frustrating not being an
> admin)
That is the most backward policy I have seen in a long time!
> I do have Perl on my Windoze machine. (Win 95) I'm running the version I
> downloaded from Solutionsoft with Perl Builder, if it makes any difference.
If you get the ActiveState version of perl you can get binaries that
work
with it from their site. THis includes DBD::Sybase and sybperl.
I've not used it but I believe that ActiveState includes a special
little script that helps you to install the packages (I think it's
called
ppm.pl). Failing that the binaries are in
http://www.activestate/packages/zips...
Michael
--
Michael Peppler -||- Data Migrations Inc.
mpeppler@mbay.net -||- http://www.mbay.net/~mpeppler
Int. Sybase User Group -||- http://www.isug.com
Sybase on Linux mailing list: ase-linux-list@isug.com
------------------------------
Date: Thu, 29 Oct 1998 22:42:05 +0100
From: "Edward van Bilderbeek" <edward@ch.twi.tudelft.nl>
Subject: ICQ and Perl
Message-Id: <71aju9$c4o$1@news.news-service.com>
Hi,
does anyone know how to send an ICQ message via a perl-instruction?
love to hear it!
Edward
------------------------------
Date: Thu, 29 Oct 1998 21:24:40 GMT
From: w.wilson@mailexcite.com
Subject: need some help please
Message-Id: <71ameo$4pn$1@nnrp1.dejanews.com>
could someone help me with this snippit of code please??
Any help would be great, but in particular the info that's being written to
the $tmpfile is getting there after my system "vi $tmpfile"..along with what
appears to be a bunch of debugging-esque output Keep in mind this isn't the
complete script, so if it doesn't all seem to be there..it's not, but again
_any_ help would be great! =) Quick overview, basically I have a flat file
containing some info, the info is seperated by a \cC to make it easy to have
it outputted in paragraph format with extra newlines allowed. This section
basically finds all occurences of $keyword throughout the file and presents
them to the user with a corresponding number so that they can pick which
entry they want to edit...then it should print that entry to the $tmpfile,
put it in vi and when it's done being edited, throw it to a newfile...after
the entries which came before it have been printed there and before the
entries that came after it are. Then the newfile is moved to the old file.
I'm pretty new at this so...be gentle =).
my $tmpfile = "$logfile.tmp.$$";
my $newfile = "$logfile.new.$$";
my ($to_edit, @choice_array, $i, $option, $choice);
open(OLD, $logfile) or die "Couldn't open file: $!";
local $/ = "\cC";
while(<OLD>) {
push(@choice_array, $_) if (/$keyword/);
}
foreach $option (@choice_array) {
print "\n\n", $i++, $option;
}
$/ = "\n";
print "\nSelect an entry to edit: ";
chomp($choice = <STDIN>);
open(TMP, ">$tmpfile") or die "Couldn't open file: $!";
flock(TMP, LOCK_EX);
$to_edit = $choice_array[--$choice];
print "you chose: $to_edit";
print TMP $to_edit;
system "vi $tmpfile";
open(NEW, ">$newfile") or die "Couldn't open file: $!";
flock(NEW, LOCK_EX);
while(<OLD>) {
print NEW $_ until $_ =~ $to_edit;
}
while(<TMP>) {
print NEW $_;
}
while(<OLD>) {
next if $_ =~ $to_edit;
print NEW $_;
}
flock(TMP, LOCK_UN);
flock(NEW, LOCK_UN);
close(<OLD>);
close(<TMP>);
close(<NEW>);
unlink($tmpfile);
rename($newfile, $logfile);
unlink($newfile);
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Oct 1998 20:25:28 GMT
From: pj@sgi.com (Paul Jackson)
Subject: Re: Not to start a language war but..
Message-Id: <71aivo$1n69a@fido.engr.sgi.com>
klassa@aur.alcatel.com (John Klassa) wrote:
|> The $, @ and % tell you what you're getting when all the dereferencing is
|> done... Thus, @a is an array and $a[0] is the 0th element of @a, which is
|> a scalar.
ah -- that's (part of) what bothers me about the $, @ and %.
The precedence is visually misleading.
These 3 symbols look like they bind tightly - high precedence.
So $a[0] looks like it binds "($a)([0])" or in Quine's dot
notation, "$a.[0]". But actually they have low precedence, applying
to "all the dereferencing" term, as in "$(a[0])", or "$.a[0]".
Strange -- very strange.
--
=======================================================================
I won't rest till it's the best ... Software Production Engineer
Paul Jackson (pj@sgi.com; pj@usa.net) 3x1373 http://sam.engr.sgi.com/pj
------------------------------
Date: Thu, 29 Oct 1998 19:50:09 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: pass array to sub
Message-Id: <8cvhl3tafp.fsf@gadget.cscaper.com>
>>>>> "Matthew" == Matthew Bafford <dragons@scescape.net> writes:
Matthew> print "Array1 Before: ", join(" ", @array1), "\n";
Typing optimization:
join " ", @foo
is easier typed as
"@foo"
making that statement:
print "Array1 before: @array1\n";
Much easier. :)
--
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: 29 Oct 1998 14:22:25 -0500
From: Uri Guttman <uri@fastengines.com>
Subject: Re: Perl & Y2K - booby trap code
Message-Id: <sarpvbb6umm.fsf@camel.fastserv.com>
>>>>> "Z" == Zenin <zenin@bawdycaste.org> writes:
Z> John Porter <jdporter@min.net> wrote:
Z> >snip<
Z> : There can be no reason to use => in a construction like
Z> : push @array => $item
Z> : other than sheer (attempted) cuteness.
Z> bless $self => 'Class';
this is borderline in my book. but i don't do much work with perl
objects so i don't care much.
Z> $HashObject->addElement ($name => $value);
as i said, hash related uses of => are what it is for and this
qualifies. but larry the other's complaint about -f being quoted by =>
is a bug (docs or code?) IMO
uri
--
Uri Guttman Fast Engines -- The Leader in Fast CGI Technology
uri@fastengines.com http://www.fastengines.com
------------------------------
Date: Thu, 29 Oct 1998 20:13:31 GMT
From: dave.vs@writeme.com (David Rummel)
Subject: Please help me - unknown script routine ...
Message-Id: <3638c30f.99322909@news.jena.deh.de>
Hello,
my name is David and I'm a novice in writing
scripts in perl and now I have a problem, I'm
sure it exists, but I haven't found it...
What I mean is the command-sequence to
do "POST" fromin perl-scripts.
I only know the one for "GET", but I
need the one for "POST" - it maybe is
only a little changing?
Again, I don't mean the way to read
the variables into my script, I want
to give variables away from my script
to another by "POST".
Is there someone able to help me???
I'm a little desperate now!!!
Please help me with your hints,
many, many thanks in advance,
David.
mailto:dave.vs@writeme.com
------------------------------
Date: Thu, 29 Oct 1998 19:53:09 GMT
From: Lyn A Headley <laheadle@boguscs.uchicago.edu>
Subject: Re: Syntactic flexibility (was: Re: psychology of language choice (was Re: language war ...))
Message-Id: <wr33e876t7e.fsf@yeenoghu.cs.uchicago.edu>
John Porter <jdporter@min.net> writes:
> Well, I didn't test the code I posted, but not because it isn't easy.
> The perl "debugger" is actually a very nice full-featured* interactive
> development environment.
no, it's a passable approximation to an interactive development
environment. you have to enter all your functions on one line!
-Lyn
------------------------------
Date: Thu, 29 Oct 1998 20:14:18 GMT
From: grahams@wpds.com
Subject: Re: system() function on PERL for Win32
Message-Id: <71aiaq$ub2$1@nnrp1.dejanews.com>
In article <36369e46.0@news.redrose.net>,
mprice@netconexinc.com (Mike Price) wrote:
> I am trying to use perl's system() function to copy files on a Windows NT
> server but the command is not working. It appears as if parameters are not
> processed when the program being called is an internal to the operating
> system. For example, when I execute the command
>
> system("copy");
>
> I get an error message back stating the number of parameters is invalid.
This
> is what I would expect from this call. However, the following command does
> nothing
>
> system("copy","d:\\temp\\*.*","c:\\temp\\*.*");
>
> ahtough files do exist in the d:\temp directory. Ironically, commands that
> are not internal to the operating system work just fine. In the same script,
> I use the following command to send email:
>
> system("d:\\temp\\batmail.exe","d:\\temp\\config.txt","d:\\temp\\messages.
> txt");
>
> The only fix to the problem I've found is to use back ticks for all internal
> operating system calls. Although I have a fix, I would like to know if I am
> doing something wrong with the system() function or if this is a known
issue.
> Thanks.
>
> Mike.
>
I'm a Perl newbie myself but I found this works quite nicely on WIN95
platform:
#!/usr/bin/perl
$source = "junk";
$sink = "more_junk";
$status = system("copy $source $sink");
#
# I know you unix users would like to see this but I couldn't get it to work!
# or die "couldn't execute system command: $!\n";
#
if ($status) {
print "couldn't execute system: $status\n";
}
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Oct 1998 14:41:24 -0600
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: system() function on PERL for Win32
Message-Id: <71ajtk$b4t@fohnix.metronet.com>
) > Mike Price (mprice@netconexinc.com) wrote:
) >
) > > system("copy","d:\\temp\\*.*","c:\\temp\\*.*");
) In article <363713f8.0@news.new-era.net> on 28 Oct 1998 12:54:16 GMT,
) scott@softbase.com <scott@softbase.com> says...
) > System takes a single parameter, not a list.
) >
) > Scott
lr@hpl.hp.com (Larry Rosler) writes:
)
) RTFM, Scott.
Quickly becoming a pet peave of mine is how people who use Perl
under Win32 figure out that
system( ... )
is the same as
system( join " ", ... )
(under Win32) and then they get sloppy about how they break up the
command line they pass in, doing things like:
system("copy","d:\\temp\\*.* c:\\temp\\*.*");
Since, under Win32, system() with a list of arguments doesn't
serve the function that it is supposed to (ie. preventing
reinterpretation of the command line arguments), I'd suggest
you stick to passing in single strings.
I think multi-arg system() under Win32 should do what it can to
try to preserve the argument structure by putting double quotes
around arguments that seem to need them.
It is really sad that Microsoft can't follow the quoting scheme
defined in its own C library, and can't even implement that one
correctly (so that it matches what the documentation says it
does).
--
Tye McQueen Nothing is obvious unless you are overlooking something
http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
------------------------------
Date: Thu, 29 Oct 1998 19:32:47 GMT
From: nheagy@my-dejanews.com
Subject: Testing for number of occurances
Message-Id: <71afsv$r2a$1@nnrp1.dejanews.com>
I am trying to find a way to find the number of underscores a string contains.
eg:
"home_about_news1" contains 2.
"this_that_and_the_other_thing" contains 5.
I thought I could use regexps, but I haven't found a way to return the number
of occurances. Can anyone please help me with this?
Thanks,
Nathan
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Oct 1998 19:50:04 GMT
From: Tom Phoenix <rootbeer@teleport.com>
Subject: Re: Testing for number of occurances
Message-Id: <Pine.GSO.4.02A.9810291149390.3421-100000@user2.teleport.com>
On Thu, 29 Oct 1998 nheagy@my-dejanews.com wrote:
> I am trying to find a way to find the number of underscores a string
> contains.
Use tr///, as documented in perlop. Hope this helps!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Thu, 29 Oct 1998 20:39:28 GMT
From: ptimmins@netserv.unmc.edu (Patrick Timmins)
Subject: Re: Testing for number of occurances
Message-Id: <71ajq1$10b$1@nnrp1.dejanews.com>
In article <71afsv$r2a$1@nnrp1.dejanews.com>,
nheagy@my-dejanews.com wrote:
> I am trying to find a way to find the number of underscores a string contains.
from perlfaq4 - Data Manipulation:
How can I count the number of occurrences of a substring within a string?
Patrick Timmins
$monger{Omaha}[0]
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 29 Oct 1998 20:18:55 GMT
From: cpierce1@cp500.fsic.ford.com (Clinton Pierce)
To: nheagy@my-dejanews.com
Subject: Re: Testing for number of occurances
Message-Id: <71aijf$sca3@eccws1.dearborn.ford.com>
In article <71afsv$r2a$1@nnrp1.dejanews.com>,
nheagy@my-dejanews.com writes:
>I am trying to find a way to find the number of underscores a string contains.
>
>eg:
>
>"home_about_news1" contains 2.
>"this_that_and_the_other_thing" contains 5.
>
>I thought I could use regexps, but I haven't found a way to return the number
>of occurances. Can anyone please help me with this?
Check out "tr" (or "y") in the perl documentation.
perldoc perlop
--
+------------------------------------------------------------------------+
| Clinton A. Pierce | "If you rush a Miracle Man, | http://www. |
| | you get rotten miracles" | dcicorp.com/ |
| fubar@ameritech.net |--Miracle Max, The Princess Bride| ~clintp |
+------------------------------------------------------------------------+
GCSd-s+:+a-C++UALIS++++P+++L++E---t++X+b+++DI++++G++e+>++h----r+++y+++>y*
------------------------------
Date: Thu, 29 Oct 1998 21:27:20 GMT
From: grahams@wpds.com
Subject: Re: Win95 Script Mapping
Message-Id: <71amjo$5ci$1@nnrp1.dejanews.com>
In article <01be0362$c8fc2a40$07221ca5@B19592-WS.kcc.com>,
"John Reynolds" <john@Ihavenomail.com> wrote:
> Hello,
>
> Does anyone know how to make Win95 run a perl script from a DOS window
> without having to preface the script with perl each time? (e.g. "perl
> scriptName.pl" works, "scriptName.pl" alone does not).
>
> I've seen a fix for NT that requires a change to the registry to map a file
> extension to an executable. I have associated the ".pl" extension to perl
> in Win Explorer but that does not translate to the DOS prompt.
>
> TIA for any help!
> -- John
>
I'm fairly new to perl - but I read in the Activeware documentation about a
utility called 'pl2bat.bat' when I tried it with a little test perl script
(on WIN95!!) it gave me following results: pl2bat test1.pl dir test1.* /w
test1.bat test1.pl
some of things you can do in perl are pretty nifty aren't they!!! read the
doc....
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 29 Oct 1998 21:26:29 +0000
From: Brian <signal@shreve.net>
Subject: Write to/Read from serial port?
Message-Id: <3638DD84.E08B90FE@shreve.net>
I am trying to write some data to the serial port, and read from the
serial port.
I took two serial ports, /dev/cua0 and /dev/cua1 and connected them with
a cross-over cable. I can fire up a terminal program on each and type
back and forth no problem.
The operating system is Intel Linux redhat 5.1.
I read perlfaq8, but still can't get this to work. I know with Linux
you can do reading and writing with /dev/cua? just as if it were any
other file. I am root when I am attempting to do this, so I know its
not permisions, and their is nothing else using the devices (minicom
works etc).
If anyone can help me with this elementry problem, I would really
appreciate it.
In perl, I can't seem to write to the port and read, I know i have done
this before. I want to write to /dev/cua0 and then read it from
/dev/cua1:
WRITER
=======
#!/usr/bin/perl
use Fcntl;
$port='/dev/cua0';
sysopen(FEED,"$port", O_WRONLY|O_NDELAY|O_NOCTTY);
$oldh = select(FEED);;
$|=1;
select($oldh);
while(1) {
print FEED "TEST\r\n";
}
close(FEED);
READER
======
#!/usr/bin/perl
use Fcntl;
$port='/dev/cua1';
sysopen(NEWS,"$port", O_RDONLY);
while(<NEWS>) {
print $_;
}
close(NEWS);
------------------------------
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 4106
**************************************