[17462] in Perl-Users-Digest
Perl-Users Digest, Issue: 4882 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 14 03:06:57 2000
Date: Tue, 14 Nov 2000 00:05:12 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <974189111-v9-i4882@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 14 Nov 2000 Volume: 9 Number: 4882
Today's topics:
Re: about reference <greatest@i-cable.com>
Re: accessing hardware ports with perl under linux i386 <bkennedy@hmsonline.com>
Re: creating an error log help (Chris Fedde)
Re: dbm file problem <bwalton@rochester.rr.com>
Re: display shell alias in perl? <quantum_mechanic@my-deja.com>
Does sub foo { 'A'..'Z' } return a list? <johnlin@chttl.com.tw>
Re: Escaping a "$" <bwalton@rochester.rr.com>
Re: Hanging when reading from socket <bkennedy@hmsonline.com>
Re: Help with regexp <quantum_mechanic@my-deja.com>
HTML download form - CGI/Perl (dionysus)
Installing Perl mods from Perl CGI zfer@my-deja.com
Re: IP geography (Chris Fedde)
Re: IP geography <elephant@squirrelgroup.com>
Re: Looking for idiom for getting value from @ARGV, or ()
Re: Looking for idiom for getting value from @ARGV, or (Garry Williams)
Re: perl -> vbscript (Tim Hammerquist)
Re: perl -> vbscript <mdkersey@hal-pc.org>
perl and db limits <schrockk@win2linux.net>
Re: perl and db limits (Chris Fedde)
Perl32 <kuma@whidbey.net>
Re: Perl32 <wyzelli@yahoo.com>
Re: pos with s/// (Charles DeRykus)
Re: pos with s/// (Charles DeRykus)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 14 Nov 2000 16:01:51 +0800
From: charlie <greatest@i-cable.com>
Subject: Re: about reference
Message-Id: <3A10F16F.44852B56@i-cable.com>
Many Thanks.
MNJP wrote:
>
> You're reading the file one line at a time into a variable, modifying the
> variable, then repeating the process again.
>
> Notice that the modifications only happen to the variable ? You need to
> write that back to a file somewhere, possibly a temporary file or an array,
> and when the loop is done dump the array or copy the temporary file back
> over the original.
>
> "charlie" <greatest@i-cable.com> wrote in message
> news:3A103C92.933E6349@i-cable.com...
> Hello All, I am new to perl and have a question about reference..
> I would like to search a file for some pattern and make substitution.
> my code below can not make change to the file. do i miss something about
> reference ?
> Many Thanks.
> $template = "+< c:/perl/acc.txt" ;
> open(TP, $template) or die "can't open the file";
> while ($line = <TP>) {
> $line =~ s/^mget.+/yyyyyyyy/;
> }
------------------------------
Date: Tue, 14 Nov 2000 03:04:50 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: accessing hardware ports with perl under linux i386 + daemons
Message-Id: <mZ1Q5.111323$td5.17065729@news1.rdc2.pa.home.com>
"Nathan Ward" <nward@nfmail.com> wrote in message
news:wSlP5.1142$gVqd.26869852@news.xtra.co.nz...
> i am trying to access hardware ports under linux on an i386, I read
> somewhere, (coffee howto i think :) )that /dev/port can be used or is
there
> another way to do it that is faster/better?
>
> The reason i am trying to do this is for a 3x4 matrix keypad and a 2x16
lcd
> screen for ppp link status readout and control for my family :)
>
> also, is it possible to make a perl script run as a daemon in the
> background? if so how?
Dunno about the hardware thing, but here is a web site with a perl daemon
tutorial:
http://www.webreference.com/perl/tutorial/9/
--Ben Kennedy
------------------------------
Date: Tue, 14 Nov 2000 04:28:38 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: creating an error log help
Message-Id: <Wb3Q5.410$Bf7.178934784@news.frii.net>
In article <8up93a$5t5$1@nnrp1.deja.com>, <menorevs@my-deja.com> wrote:
> creating a Telnet session to be able to change a password for over
>200 routers, the only trouble i am having is that i can not create an
>error log. So far i have:
>
Maybe you could give more of an indication of the method you are using
for telneting to the routers?
--
This space intentionally left blank
------------------------------
Date: Tue, 14 Nov 2000 02:32:07 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: dbm file problem
Message-Id: <3A10A533.2AD484F8@rochester.rr.com>
Roderick Clay wrote:
>
> We recently discovered some irregularities with values being stored in
> a dbm file accessed by some of our cgi scripts. We are seeing
> duplicate key-value pairs and seeing keys whose values seem to have
> disappeared.
>
> We believe the problem is due to the fact that we recently made a
> change in which we included the line "use SDBM_File". Previously, we
> were not explicitly "using" any DBM related modules. (If we now run a
> test script to view the contents of the dbm file, we get different
> results depending on whether we "use SDBM_File" at the top of our test
> script or not. In each case, some of the values are blank where there
> should be a value. These blank values show up for different keys
> depending on whether or not we included "use SDBM_File".) We are
> using the commands dbmopen and dbmclose to access the file. Could the
> switch to SDBM_File be the cause of our irregularities and is there a
> straightforward way to fix them?
Hmmmm...first question is: do you do appropriate file locking? Have
you verified that your file locking scheme works? Recognize that CGI
scripts can be run in multiple simultaneous processes, and that if more
than one process has a file open for write at the same time (or even one
process has it open for write while other processes are reading), you
*will* lose data sooner or later. It can be one of things that works
fine for months and then all of a sudden: corruption city. Proper file
locking is essential. perldoc -f flock, perldoc -q lock, read your OS's
stuff on file locking (like flock, lockf, fcntl, etc). Understand if
locking will work across networked filesystems on your OS. Etc.
You don't say what your platform or OS is or which version of Perl you
are using. You will definitely want to stick with one method of
accessing a given DBM-type file -- they are not binary compatible.
Let's say you are using Windoze NT with ActiveState Perl build 618,
which defaults to DB_File for dbmopen if nothing else was use'd. Then
you switch to SDBM_File by putting in use SDBM_File; but retain the same
file. I would be amazed if that didn't generate anything but garbage
(which garbage you verify above). You definitely don't want to mix and
match between the DBM file types -- use only one type to read and write
your file. Heck, you can't even count on DBM-type files of the same
type working from one platform to another, or even from one OS version
to another -- or even on the same OS version if your sysadmin changed
the defaults (like bucket size etc) during install.
------------------------------
Date: Tue, 14 Nov 2000 03:58:43 GMT
From: Quantum Mechanic <quantum_mechanic@my-deja.com>
Subject: Re: display shell alias in perl?
Message-Id: <8uqd9g$4mv$1@nnrp1.deja.com>
In article <V9XP5.388$xb1.21276@eagle.america.net>,
garry@zvolve.com wrote:
> On 13 Nov 2000 18:21:05 +0000, nobull@mail.com <nobull@mail.com>
wrote:
> >"Philip Tsai" <tsailipu@home.com> writes:
> >
> >> This looks to be a simple operation yet I spent hours reading
documentation
> >> and searching using different combinations of keywords on
www.perl.com,
> >> google and other search engines to no avail: how can one assign
the value
> >> of a shell "alias [some alias name]" inside a Perl program?
> >
> >You can't.
> >
> >This is covered by the FAQ: ...
> >
> >The aliases are part of the shell environment (although they are not
> >actually environment variables[1] so are not inherited by subshells).
>
> Some shells allow you to "inherit" aliases by defining a variable that
> names a file that is sourced by each new-generation shell. If you
> place your alias commands and any other environment variable settings
> you require in this file, they will be set when the shell is started.
> In ksh it's ENV and in bash it's BASH_ENV. Of course, this doesn't
> help the original poster because perl invokes /bin/sh (on most Unix
> systems) to implement qx//.
>
> The answer "You can't" is correct, of course.
>
> --
> Garry Williams
>
Not being at my *nix box right now, I can't try this, but...
In csh, can you pipe some alias settings to source to "activate" them?
For instance,
my_alias_generating_perl_script | source
Or does this not DWIW because source is now a subshell?
Incidentally, I don't think it was all that clear whether the original
poster was trying to *read* aliases already set, or *set* aliases to be
effective out in the parent shell once a script terminated. (We're all
sure that they can't be *set* this way.)
-QM
--
Quantum Mechanics: The dreams stuff is made of.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 14:42:49 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Does sub foo { 'A'..'Z' } return a list?
Message-Id: <8uqn3m$459@netnews.hinet.net>
Dear all,
Q1: Is it possible to write the following pieces of code in
one statement (so we can save two variables $begin,$end).
my ($begin,$end) = $object->iterate;
print $object->get($_) for $begin..$end;
Q2: My original version was like:
print $object->get($_) for $object->iterate;
with
sub iterate { return $begin..$end }
I was afraid the iterate() would return a huge list, so I
changed it into the { return ($begin,$end) } version.
Actually, will the range operator sub return a list? Even if it is
in a scalar context?
Q3: How can we test to see whether it will return a list or not?
Thank you.
John Lin
P.S. Hey, I just did a test:
sub foo { 'A'..'Z' }
print scalar foo;
Guess what the result is? 26? 'Z'? or 1? 0?
Could someone explain why the result is like this?
------------------------------
Date: Tue, 14 Nov 2000 02:11:06 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Escaping a "$"
Message-Id: <3A10A046.A6AB85FB@rochester.rr.com>
Mike Flaherty wrote:
>
> The following command doesn't work within Perl. It is actually a RSH call
> to run a script on a VMS machine. On VMS, the command would be (minus
> quotes) "@disk$admin:[ora_db]db_query.com parameter_1". However, it looks
> like Perl is treating the string after the "$" as a scalar - despite the
> slash. Since $admin isn't defined (null), the file spec is invalid.
>
> How do I get perl to recognize the correct path to my script?
>
> print `rsh -l scriptuser my_node \@disk\$admin:[ora_db]db_query.com
> $unique_id`;
>
> Thanks in Advance,
> Mike Flaherty
Hmmmm...if I've got it right, you are running this on some flavor of
Unix running some shell or other, and the rsh target is a VMS machine.
When the line above is executed, Perl will eat the \ in front of the $
and supply your Unix shell with @disk$admin:[ora_db]... Then, I
suspect, your shell tries to do a substitution of *its* $admin
(depending on which shell it is and all). To test if that is the case,
try putting \@disk\\\$admin:... in the Perl code in order to make Perl
supply a \ in front of the $ to your shell. Does it work then? Quoting
can get pretty tricky. It could even be that that is not sufficient.
You might have to play around and see. For debug, judicious use of echo
(or its VMS equivalent, which I have forgotten for 15 years now) can
help a lot.
--
Bob Walton
------------------------------
Date: Tue, 14 Nov 2000 03:00:29 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Hanging when reading from socket
Message-Id: <hV1Q5.111322$td5.17063111@news1.rdc2.pa.home.com>
"Owen Sullivan" <owen.sullivan@worldzap.com> wrote in message
news:FiUP5.3208$Nw6.9791@news.iol.ie...
> So instead I have used the code below to read the responses. The
responses
> are successfully read. However, the program appears to hang after reading
> the responses received. Does anyone know what the fix for this is?
Thanks.
>
> for (;;) {
> for ($curpos = tell($remote); $_ = <$remote>;
> $curpos = tell($remote)) {
> print LOGFILE "Read: $_";
> }
> $remote->clearerr;
> }
Why are you using tell() and a for() loop? Look at the perl documentation
(perldoc perlipc) for some basic examples
while(<$sock>) {
print;
}
print "Socket is closed\n";
Hope this helps
--Ben Kennedy
------------------------------
Date: Tue, 14 Nov 2000 03:49:30 GMT
From: Quantum Mechanic <quantum_mechanic@my-deja.com>
Subject: Re: Help with regexp
Message-Id: <8uqco8$491$1@nnrp1.deja.com>
In article <slrn90vc7p.1bf.tjla@thislove.dyndns.org>,
tjla@guvfybir.qlaqaf.bet (Gwyn Judd) wrote:
> I was shocked! How could Aitor Garcia <a58289@yahoo.com>
> say such a terrible thing:
>
> >line and would like to match the word
> >"Warning" and then, print this line and
> >the subsequent lines until I find a ")".
>
> Sounds like a job for the flip-flop '..' operator:
>
> print if (/Warning/ .. /\)/);
Good call!
By the way, Aitor seemed taken aback by your auto-preface ;)
>
> --
> Gwyn Judd (print `echo 'tjla@guvfybir.qlaqaf.bet' | rot13`)
> Bipolar, adj.:
> Refers to someone who has homes in Nome, Alaska, and Buffalo,
New York.
>
--
Quantum Mechanics: The dreams stuff is made of.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 02:28:36 GMT
From: dionysus39@hotmail.com (dionysus)
Subject: HTML download form - CGI/Perl
Message-Id: <3a10a0d6.111690646@nntp.unsw.edu.au>
Since apparently noone in the world can help me with my win9x
passthrough query (probably not all that surprising, since when I went
looking for a package allowing me to use perl to access my win9x
TCP/IP LAN a while ago I found nothing), I am changing my approach. I
now need to know if it is possible to use a CGI/Perl script containing
a HTML form to setup a download to the client. The idea is that the
client looks up the site and chooses a resource, and the script sets
up the download (presumably using the socket function somehow?) of the
file(s), which are stored somewhere on my machine (not necessarily
under the webserver's directory, and not at a location that can be
aliased, so using the script to print hyperlinks will not work), and
then performs some other stuff after the download is complete. I
assume I would just read the file into an array in the usual fashion,
but I have no idea how to create a file descriptor that is linked to a
socket going to the client's machine....
any help much appreciated,
-d
------------------------------------------------------------
"One World, one Web, one Program" - Microsoft promotional ad
"Ein Volk, ein Reich, ein Fuhrer" - Adolf Hitler .
------------------------------
Date: Tue, 14 Nov 2000 02:49:44 GMT
From: zfer@my-deja.com
Subject: Installing Perl mods from Perl CGI
Message-Id: <8uq987$1la$1@nnrp1.deja.com>
Hi,
my ISP doesn't give me a telnet access, but I need to install more
Perl modules than what is available.
Of course I haven't a root login, my Perl CGIs run into a Suexec
environment, so I think to find a way to do it from a Perl CGI.
I suppose that I can install my favourite Perl modules in my directory
and in someway require them from future CGI.
Are there suggestions?
Thank you in advance, \zfer
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 14 Nov 2000 03:13:32 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: IP geography
Message-Id: <w52Q5.408$Bf7.135467520@news.frii.net>
In article <8uprqv$n1n$1@nnrp1.deja.com>, <tcblue@my-deja.com> wrote:
>Hi,
>does any know if there is a perl module or script that can 'try' and
>detect the physical location of a given IP address or hostname? I
>found this site that gives a pretty good description of how to make an
>educated guess on it. I know there is no real solid way of doing this,
>but i'd like to start collecting geographical information of IP
>address. please let me know If you have any ideas or if there is
>already something out there that does this. Thanks,
>
package IP::Location
sub loc
{
return "98.9% probability that $_[0] is within 20037.54 km of Tucson AZ US";
}
It's realy hard to do much better.
--
This space intentionally left blank
------------------------------
Date: Tue, 14 Nov 2000 14:46:39 +1100
From: jason <elephant@squirrelgroup.com>
Subject: Re: IP geography
Message-Id: <MPG.147b60aff9e1eef3989894@localhost>
tcblue@my-deja.com wrote ..
>does any know if there is a perl module or script that can 'try' and
>detect the physical location of a given IP address or hostname? I
>found this site that gives a pretty good description of how to make an
>educated guess on it. I know there is no real solid way of doing this,
>but i'd like to start collecting geographical information of IP
>address. please let me know If you have any ideas or if there is
>already something out there that does this. Thanks,
how closely do you want to be able to identify the IP ? .. and what's
this web site that you're talking about ?
IP addresses can quite easily be classified by country of designation
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: 14 Nov 2000 07:11:20 GMT
From: kmead@socrates.Berkeley.EDU ()
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <8uqoio$kqg$1@agate.berkeley.edu>
In article <m3aebef2xf.fsf@flash.localdomain>,
Mark Atwood <mra@pobox.com> wrote:
>I've seen somewhere a neat little one line expression idiom using
>"defined", "shift", and "||" that does something like
I saw this code in DBI::Shell
$sh->{data_source} = shift(@args) || $ENV{DBI_DSN} || '';
$sh->{user} = shift(@args) || $ENV{DBI_USER} || '';
$sh->{password} = shift(@args) || $ENV{DBI_PASS} || undef;
Compact, but actually causes a bug: my password happened to
be "" so this sets it to undef.
Keith
------------------------------
Date: Tue, 14 Nov 2000 07:34:56 GMT
From: garry@zweb.zvolve.net (Garry Williams)
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <AW5Q5.432$xb1.25810@eagle.america.net>
On 14 Nov 2000 07:11:20 GMT, kmead@socrates.Berkeley.EDU
<kmead@socrates.Berkeley.EDU> wrote:
>In article <m3aebef2xf.fsf@flash.localdomain>,
>Mark Atwood <mra@pobox.com> wrote:
>>I've seen somewhere a neat little one line expression idiom using
>>"defined", "shift", and "||" that does something like
>
>I saw this code in DBI::Shell
>
> $sh->{data_source} = shift(@args) || $ENV{DBI_DSN} || '';
> $sh->{user} = shift(@args) || $ENV{DBI_USER} || '';
> $sh->{password} = shift(@args) || $ENV{DBI_PASS} || undef;
>
>Compact, but actually causes a bug: my password happened to
>be "" so this sets it to undef.
Does this fix the bug?
$sh->{password} = shift(@args) || exists $ENV{DBI_PASS}
? $ENV{DBI_PASS}
: undef;
--
Garry Williams
------------------------------
Date: Tue, 14 Nov 2000 02:10:17 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: perl -> vbscript
Message-Id: <slrn9118m6.uur.tim@degree.ath.cx>
AP <alex@hoopsie2.com> wrote:
> Can anyone recommend a book for learning vbscript for someone (i.e me)
> coming from a perl background?
>
> (I hope I don't get chewed out for posting this in perl NG--I didn't know
> who would know better--ex perlers, or current perlers :) )
"ex perlers"...hm, those might me pretty hard to find. ;)
I'm not chewing you out. Although, I fear we've failed. You tasted
Perl, and now you want to use VBScript. Do you have a fever? =) *j/k*
Ask on another newsgroup would my best advice.
Good luck¸ and don't be gone long.
--
-Tim Hammerquist <timmy@cpan.org>
Diplomacy -- the art of saying "Nice doggie"
'til you can find a stick.
-- Wynn Catlin
------------------------------
Date: Mon, 13 Nov 2000 20:36:25 -0600
From: "Michael D. Kersey" <mdkersey@hal-pc.org>
Subject: Re: perl -> vbscript
Message-Id: <3A10A529.5A33A290@hal-pc.org>
AP wrote:
> Can anyone recommend a book for learning vbscript for someone (i.e me)
> coming from a perl background?
> (I hope I don't get chewed out for posting this in perl NG--I didn't know
> who would know better--ex perlers, or current perlers :) )
> Thanks!
> Alex
Well, I *do* think you're moving in the wrong direction!-))
I recommend "ASP Active Server Pages" by Andrew M. Fedorchek & David K.
Rensin, IDG Books Worldwide, Inc., 1997. It's a black book about 7/8 of
an inch thick with a galaxy cluster on the front cover. This book
remains IMO the best and quickest introduction to ASP/VBScript for
someone who is already a programmer. The authors are developers, don't
mince words but point out where all the landmines are located so you can
avoid them. It is smaller than most books on ASP and VBScript. It points
out the details you need to know to understand ASP, includes an appendix
on JavaScript and thoroughly covers the ASP framework. There are short
but complete chapters showing how to create COM objects with Visual
Basic and Visual C++, although I just skimmed those chapters. If I need
anything that ASP doesn't have built-in, I try to use PerlScript, which
also runs under the ASP framework.
Note that ASP is to be replaced by ASP+, and that VBScript will no
longer be supported in that framework. So it's legacy code already.
------------------------------
Date: Tue, 14 Nov 2000 02:14:49 GMT
From: Ken Schrock <schrockk@win2linux.net>
Subject: perl and db limits
Message-Id: <3A10E647.D1B59588@win2linux.net>
I have a small, simple program to build...
I see no reason why perl and a text database won't do the job...
Can I have some input on anyone's theories of...
Limits for load or records on such system?
1000 accesses a day? 10,000? 100,000?
1000 records? 10,000? 100,000?
Please e-mail me.
--
Ken Schrock
schrockk@win2linux.net
------------------------------
Date: Tue, 14 Nov 2000 04:20:49 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: perl and db limits
Message-Id: <B43Q5.409$Bf7.188921344@news.frii.net>
[A copy of this note was cc'd to Ken Schrock]
In article <3A10E647.D1B59588@win2linux.net>,
Ken Schrock <schrockk@win2linux.com> wrote:
>I have a small, simple program to build...
>
>I see no reason why perl and a text database won't do the job...
>
>Can I have some input on anyone's theories of...
>
>Limits for load or records on such system?
>
>1000 accesses a day? 10,000? 100,000?
>
>1000 records? 10,000? 100,000?
>
>Please e-mail me.
>
This is not fundamentally a Perl question. It's more of a capacity planning
question. Suffice it to say that Perl does not impose many limits beyond
what the hardware, os or libraries themselves impose. Look at the
perltraps manual page for a few details on these lines.
good luck
chris
--
This space intentionally left blank
------------------------------
Date: Mon, 13 Nov 2000 20:36:41 -0800
From: "R & Y" <kuma@whidbey.net>
Subject: Perl32
Message-Id: <t11gfgjreh6k8b@corp.supernews.com>
I know that with the Unix systems you would use #!/usr/bin/perl. But, I'm
trying to expand myself with Perl for windows. What I have not found is how
do I call up Perl in Windows? is it something like #!d:/perl/bin? I have
ActiveState Perl installed on my D: drive under it's own file (d:/perl/bin).
Thanks for your help in advance.
Robert
------------------------------
Date: Tue, 14 Nov 2000 16:09:51 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Perl32
Message-Id: <q25Q5.8$eK.4849@vic.nntp.telstra.net>
"R & Y" <kuma@whidbey.net> wrote in message
news:t11gfgjreh6k8b@corp.supernews.com...
> I know that with the Unix systems you would use #!/usr/bin/perl. But,
I'm
> trying to expand myself with Perl for windows. What I have not found
is how
> do I call up Perl in Windows? is it something like #!d:/perl/bin? I
have
> ActiveState Perl installed on my D: drive under it's own file
(d:/perl/bin).
> Thanks for your help in advance.
>
Under Win32 the 'shebang' is not required, with a few notable exceptions
(Apache for win32 requires it).
However it is a good idea to use it as standard, because it enables
command line switches (like -w and T).
#!perl-w # would probably be OK
#!/usr/bin/perl -w # Works OK for me and is ever so slightly easier to
port to a *nix server (it has just become a habit followed by 'use
strict;')
BTW my Perl is also in d:/perl/bin
Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";
------------------------------
Date: Tue, 14 Nov 2000 00:51:23 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: pos with s///
Message-Id: <G3zp1n.Ly6@news.boeing.com>
In article <3A0FE588.FB85DFAB@cocoon.ulpgc.es>,
Juan Eliseo Carrasco =?iso-8859-1?Q?D=EDaz?= <eliseo@cocoon.ulpgc.es> wrote:
> There is any way to use s/// and get the pos.
>
> I use s/// to find and replace a word, then I would like to find (with
>m//g) from the last match.
>
If you don't mind the speed penalty:
use English;
s/foo/bar/;
pos() = length("foo") + length($PREMATCH);
m/baz/g;
perldoc perlre for discussions of the speed penalty.
See $`,$',$&.
--
Charles DeRykus
------------------------------
Date: Tue, 14 Nov 2000 03:01:04 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: pos with s///
Message-Id: <G3zv1s.1uM@news.boeing.com>
In article <G3zp1n.Ly6@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>
>If you don't mind the speed penalty:
>
> use English;
>
> s/foo/bar/;
> pos() = length("foo") + length($PREMATCH);
> m/baz/g;
>
I meant:
pos() = length("bar") + length($PREMATCH);
--
Charles DeRykus
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4882
**************************************