[19390] in Perl-Users-Digest
Perl-Users Digest, Issue: 1585 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 22 06:16:43 2001
Date: Wed, 22 Aug 2001 03:10:12 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <998475012-v10-i1585@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 22 Aug 2001 Volume: 10 Number: 1585
Today's topics:
Re: Passing code pieces to program (Chas Friedman)
Re: Passing code pieces to program (Eric Bohlman)
Paying for these custom Perl scripts. <mrblue@pd.jaring.my>
Perl from setuid scripts (Tony Edwardson)
Re: Perl OO needs the opposite of SUPER:: <joe+usenet@sunstarsys.com>
Re: Perl OO needs the opposite of SUPER:: (John Lin)
Re: Perl OO needs the opposite of SUPER:: <goldbb2@earthlink.net>
Re: Perl PGP routines <goldbb2@earthlink.net>
Re: Prevent module SNMP_Session to generate a die by wh <c.w.vandervelden@kpn.com>
references and strict <mike_solomon@lineone.net>
Re: references and strict <l_pantin@hotmail.com>
Re: references and strict (Tad McClellan)
Re: references and strict <krahnj@acm.org>
Re: references and strict <goldbb2@earthlink.net>
Re: regular expression people. <ilya@martynov.org>
Search a file (line by line) for String/text (Pete Sohi)
Re: Search a file (line by line) for String/text (Rafael Garcia-Suarez)
Re: Search a file (line by line) for String/text <philippe.perrin@sxb.bsf.alcatel.fr>
Re: String Parsing > Remove everything after the first (Ian Boreham)
Re: This is not a question ... call me slow if you like (David Combs)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 22 Aug 2001 02:12:21 GMT
From: friedman@math.utexas.edu (Chas Friedman)
Subject: Re: Passing code pieces to program
Message-Id: <3b831308.23438069@news.itouch.net>
On Wed, 22 Aug 2001 01:39:18 -0000, Craig Berry <cberry@cinenet.net>
wrote:
>friedman@math.utexas.edu (Chas Friedman) wrote in news:3b82ed5c.13792869
>@news.itouch.net:
>
>> Is there a way to pass pieces of code to a script as arguments? For
>> example, I have a script that uses File::Find, and contains the
>> expression: if (-M $_<1)....
>> I would like to be able to pass the "-M$_<1" to the script when it is
>> run (so I could also pass in other conditions.) I suppose I could
>> use an eval on some string made up partly of the passed in arg,
>> but I wondered if there is any other way. Thanks for any comments.
>
>Nope, eval() is about your only choice if you allow arbitrary code from the
>user. Be sure to use taint checking and well-thought-out qualifying tests
>to avoid eval-ing something deadly.
>
>--
>Craig Berry <http://www.cinenet.net/~cberry/>
>"That which is now known, was once only imagined." - William Blake
>
It isn't a CGI script, just an ordinary perl script. I've thought
about it several times and never could come with anything except
'evaling'. For example:
#!/usr/bin/perl -w
use strict;
use File::Find;
my $passed=shift;
find(\&wanted, '.');
sub wanted {
eval "if ($passed) {
print \"$File::Find::name\n\";
}"
}
Then I can say:
filefind '-M$_<1' or
filefind '/\.txt$/' etc.
(Need to use ' ' on Unix, " " on Windows for the arg passed, though.)
------------------------------
Date: 22 Aug 2001 08:29:36 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: Passing code pieces to program
Message-Id: <9lvqhg$t4g$3@bob.news.rcn.net>
Chas Friedman <friedman@math.utexas.edu> wrote:
> On Wed, 22 Aug 2001 01:39:18 -0000, Craig Berry <cberry@cinenet.net>
> wrote:
>>Nope, eval() is about your only choice if you allow arbitrary code from the
>>user. Be sure to use taint checking and well-thought-out qualifying tests
>>to avoid eval-ing something deadly.
> It isn't a CGI script, just an ordinary perl script. I've thought
The fact that it isn't a CGI script doesn't mean that taint checks are
necessarily unnecessary (hehe). You need them, or similar defensive
measures, unless the input to your program is as trusted as the source to
your program.
------------------------------
Date: Wed, 22 Aug 2001 14:40:15 +0800
From: "Blue ©" <mrblue@pd.jaring.my>
Subject: Paying for these custom Perl scripts.
Message-Id: <9lvjo9$4eq$1@news4.jaring.my>
We need a few custom-built Perl scripts. The details can be found at
www.upoint.net/projects/
Please quote us your best price.
UPDN Network Sdn Bhd
------------------------------
Date: 22 Aug 2001 01:06:30 -0700
From: tony.edwardson@usa.net (Tony Edwardson)
Subject: Perl from setuid scripts
Message-Id: <6f23a121.0108220006.1abeae6a@posting.google.com>
We have several versions of perl installed so to ensure the correct
version of perl is invoked for our live scripts, I have written a ksh
wrapper script to invoke thge correct perl version and check that all
of the essential modules are installed.
I am doing this via
perl -e "require <VERSION>;" and
perl -e "use <MODULE>;" or perl -M<MODULE>;"
Unfortunately my wrapper script is being called by some setuid scripts
and taint checking is not allowing perl to run -e and -M from these
setuid scripts.
Is there any way to get round this as the taint security is not an
issue in our strictly controlled environment ?
Regards
Tony
------------------------------
Date: 22 Aug 2001 00:11:08 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <m3ofp8d99f.fsf@mumonkan.sunstarsys.com>
johnlin@chttl.com.tw (John Lin) writes:
> I think it is one typical type of programming in polymorphism,
> so I ask here. But if you think all this kind of programming
> can be avoided or converted into other types, I will still accept.
> But how?
If I haven't misunderstood your problem, there are a lot of ways to
solve it in Perl without rewriting the Report, EvenReport, and
OddReport packages. Here's one approach:
#!/usr/bin/perl -w
use strict;
package Report;
sub report { die "override me" }
package EvenReport;
use base 'Report';
sub report { "even" }
package ExtendedReport; # an abstract "interface"
sub report {
local *report;
"extended " . shift() -> report; # similar to SUPER::report
}
# ... sample usage >>>
package MyReport;
use base qw/ExtendedReport EvenReport/; # "implements" ExtendedReport
my $foo = bless {};
print $foo->report;
__END__
~> extended even
HTH
--
Joe Schaefer "A man cannot be too careful in the choice of his enemies."
--Oscar Wilde
------------------------------
Date: 21 Aug 2001 21:11:38 -0700
From: johnlin@chttl.com.tw (John Lin)
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <a73bcad1.0108212011.62027867@posting.google.com>
Martien Verbruggen wrote
> John Lin wrote:
>> What I am talking about is just like Java's "interface".
>
> You are, possibly, but you're also talking about abstract
> superclasses, and inheritance. They are different solutions to the
> same or similar problems.
I mentioned "interface" just to clarify that "Not only derived class will call
base class (that's SUPER::). There are situations that base class may call
derived class". Yes, "interface" as well as abstract super-class with virtual
methods are ones of them. I admit those using of "interface" too much in my
posts were really misleading. What about calling it "call-down"?
We often use SUPER:: to call-up to base class, but in some situations
call-down to derived class is also needed.
<snip of good explanation on "interface">
After reading it, I know "interface" is a "class" ready to be implemented.
Here, my "call-down" is a "method". The method is called from base to derived.
For example, Report::gen calls derived-class's sub report(), so that the
derived-class can decide the behavior of report() by overriding it.
I'll say "sub report" is a "call-down".
>> I mean "the problem" (or restriction) by
>>
>> ### Perl's simplex (SUPER:: only) OO ###
>> The same "interface" in an inheritance hierarchy MUST NOT have the same name.
>>
>> ### Extended duplex (SUPER::+VIRTUAL::) OO ###
>> The same "interface" in an inheritance hierarchy WITH THE SAME NAME supported.
>
> I don't follow this, sorry..
Ah, it was really misleading. Let me say it again without using "interface".
>> The same "interface" in an inheritance hierarchy MUST NOT have the same name.
If you want to override a "call-down" to change the behavior, and it still
calls down to the original overriding, then it is impossible in current Perl OO.
In the inheritance hierarchy, those same "call-downs" cannot have the same name
because the lowerest one will mask away all others.
My proposal is to support the up-to-down call-chaining by allowing the base
methods to be called first.
sub Base::report;
sub Derived::report : virtual; <-- Don't mask away. Instead, do a up-tracing.
sub Lowest::report : virtual; <-- Don't mask away. Do a up-tracing.
The calling of Lowest->report will cause a trace-up. Itself is pushed into
the stack, and traced-up to find Derived->report.
Before Derived->report is executed, again, itself is pushed into the stack
and traced-up to find Base::report.
Finally, the actual executing sequence becomes
Base->report;
Derived->report;
Lowest->report;
Instead of Lowest->report masks away every other report().
Then my problem can be solved.
Thank you.
John Lin
------------------------------
Date: Wed, 22 Aug 2001 04:04:13 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl OO needs the opposite of SUPER::
Message-Id: <3B83677D.10FB30DB@earthlink.net>
John Lin wrote:
[snip]
> sub print_to_printer {
> open STDOUT,">=PRN" or die $!;
> $self->report;
> close STDOUT;# Huh? I'm not sure what to do after the dup is done
> }
While this has nothing to do with your OO stuff, the way you save and
restore STDOUT would be as follows:
sub print_to_printer {
local *OLDSTDOUT;
open OLDSTDOUT, ">&STDOUT"; # make a dup.
open STDOUT, ">=PRN"; # doesn't harm OLDSTDOUT
$self->report;
open STDOUT, ">&OLDSTDOUT"; # restore.
}
Or you could cheat, by taking advantage of knowing that STDOUT is
filedescriptor 1:
sub print_to_printer {
open STDOUT, ">=PRN";
$self->report;
open STDOUT, ">&=1";
}
The difference is, the first one is like doing
{ local $/ = ""; $x = <fh> }
while the second one is like doing
{ $/ = ""; $x = <fh>; $/ = "\n" }
The second restores it to something "sane" but not necessarily what it
was when you entered the block, and thus not necessarily what you want.
A third possible solution is:
sub print_to_printer {
local *PRINTER;
open PRINTER, ">=PRN";
my $stdout = select PRINTER;
$self->report;
select $stdout;
}
This doesn't actually change STDOUT, but rather changes what the default
filehandle for print and printf is. Assuming most of your code does
print "xxx", not print STDOUT "xxx", then this should work fine.
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Wed, 22 Aug 2001 04:39:44 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Perl PGP routines
Message-Id: <3B836FD0.1EE4DA74@earthlink.net>
Jay Flaherty wrote:
>
> "Tom Leitch" <tom@leitchy.com> wrote in message
> news:8sac7.875$tq.136858@news6-win.server.ntlworld.com...
> > > Anyone know where I can get hold of a perl.cgi PGP encryption
> > > routine so I can encrypt emails to myself from my ISP's server?
> >
> >
> > http://search.cpan.org/doc/BTROTT/Crypt-OpenPGP-0.13/lib/Crypt/OpenPGP.pm
> >
> > ...that should do what you are looking for. It's a pure Perl implementation
> > of PGP.
>
> Wrong. Crypt::OpenPGP is a pure-Perl implementation of the OpenPGP standard
> (RFC2440). You still need the PGP software to encrypt/decrypt files.
He doesn't want to encrypt files, he wants to send email containing
encrypted data.
my $ciphertext = $pgp->encrypt(
Data => $plaintext,
KeyID => $key_id,
Armour => 1,
);
Then attach $ciphertext to the message using Mime::Lite or whatever.
--
I'm not a programmer but I play one on TV...
------------------------------
Date: Wed, 22 Aug 2001 09:47:00 +0200
From: "Karel van der Velden" <c.w.vandervelden@kpn.com>
Subject: Re: Prevent module SNMP_Session to generate a die by which my CGI script stops running
Message-Id: <#lza99tKBHA.307@net037s.hetnet.nl>
Thx all,
I'm going to experiment with it. I'm sure I'll succeed.
Regards,
Karel van der Velden
"Ilya Martynov" <ilya@martynov.org> wrote in message
news:874rr1pdwd.fsf@abra.ru...
>
> AS> Quite, a module should avoid them (there are exceptions). In the
> AS> main program, __WARN__ and __DIE__ handlers are fine.
>
> Suppose your main program uses a module which uses exceptions
> (i.e. die and eval) a lot. SIG{__DIE__} can easily break such module.
>
> And BTW - just noticed this in perlvar in perl 5.6.1:
>
> BUGS
> ... "$SIG{__DIE__}" as currently implemented invites grievous
> and difficult to track down errors. Avoid it and use an
> "END{}" or CORE::GLOBAL::die override instead.
>
> To be fair I'm not sure what does it means.
>
> --
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> | Ilya Martynov (http://martynov.org/)
|
> | GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6
|
> | AGAVA Software Company (http://www.agava.com/)
|
> -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Tue, 21 Aug 2001 11:47:13 +0100
From: "Mike Solomon" <mike_solomon@lineone.net>
Subject: references and strict
Message-Id: <3b823c33_1@mk-nntp-1.news.uk.worldonline.com>
Depending on the value of a variable I want to call different sub routines.
The only way I have managed this is by turning off strict refs as shown
below.
I am sure there must be a better way of doing this but I can't work it out.
I have been looking at Hard references in the manual but that is not getting
me anywhere.
Any help would be appreciaceted.
use strict;
my $mike = "a2";
no strict 'refs';
&$mike;
sub a1 {print "a1\n";}
sub a2 {print "a2 \n";}
sub a3 {print "a3\n";}
use strict 'refs';
Regards
Mike Solomon
------------------------------
Date: Wed, 22 Aug 2001 04:44:26 GMT
From: "Kevin Bartz" <l_pantin@hotmail.com>
Subject: Re: references and strict
Message-Id: <KMGg7.28680$1p1.2080797@bgtnsc04-news.ops.worldnet.att.net>
How about an eval?
#!/usr/bin/perl
use strict;
my $mike = "a2";
eval("&$mike;");
sub a1 {print "A1\n";}
sub a2 {print "A2\n";}
sub a3 {print "A3\n";}
Kevin
In article <3b823c33_1@mk-nntp-1.news.uk.worldonline.com>, "Mike Solomon"
<mike_solomon@lineone.net> wrote:
> Depending on the value of a variable I want to call different sub
> routines.
>
> The only way I have managed this is by turning off strict refs as shown
> below.
>
> I am sure there must be a better way of doing this but I can't work it
> out.
>
> I have been looking at Hard references in the manual but that is not
> getting me anywhere.
>
> Any help would be appreciaceted.
>
> use strict;
>
> my $mike = "a2";
>
> no strict 'refs';
> &$mike;
>
> sub a1 {print "a1\n";}
> sub a2 {print "a2 \n";}
> sub a3 {print "a3\n";}
>
> use strict 'refs';
>
> Regards
>
>
> Mike Solomon
>
>
>
------------------------------
Date: Wed, 22 Aug 2001 00:16:52 -0400
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: references and strict
Message-Id: <slrn9o6chk.19o.tadmc@tadmc26.august.net>
[ First text moved to second. Second text moved to first.
Now what came first comes first and what came second
comes second.
]
Kevin Bartz <l_pantin@hotmail.com> wrote:
>In article <3b823c33_1@mk-nntp-1.news.uk.worldonline.com>, "Mike Solomon"
><mike_solomon@lineone.net> wrote:
>
>> Depending on the value of a variable I want to call different sub
>> routines.
[snip]
>> Any help would be appreciaceted.
>>
>> use strict;
>>
>> my $mike = "a2";
>>
>> no strict 'refs';
>> &$mike;
>>
>> sub a1 {print "a1\n";}
>> sub a2 {print "a2 \n";}
>> sub a3 {print "a3\n";}
>How about an eval?
A string eval is the course of last resort, to be used only
when all else fails. A dispatch table will do nicely here,
with less danger.
my %subs = (
a1 => \&a1,
a2 => \&a2,
a3 => \&a3,
);
$subs{$mike}->();
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 22 Aug 2001 05:14:47 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: references and strict
Message-Id: <3B834035.73968968@acm.org>
Mike Solomon wrote:
>
> Depending on the value of a variable I want to call different sub routines.
>
> The only way I have managed this is by turning off strict refs as shown
> below.
>
> I am sure there must be a better way of doing this but I can't work it out.
>
> I have been looking at Hard references in the manual but that is not getting
> me anywhere.
>
> Any help would be appreciaceted.
>
> use strict;
>
> my $mike = "a2";
>
> no strict 'refs';
> &$mike;
>
> sub a1 {print "a1\n";}
> sub a2 {print "a2 \n";}
> sub a3 {print "a3\n";}
>
> use strict 'refs';
my %subs = (
a1 => sub {print "a1\n"},
a2 => sub {print "a2\n"},
a3 => sub {print "a3\n"},
);
my $mike = "a1";
$subs{$mike}();
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 22 Aug 2001 05:06:21 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: references and strict
Message-Id: <3B83760D.5E5455EF@earthlink.net>
Mike Solomon wrote:
>
> Depending on the value of a variable I want to call different sub
> routines.
>
> The only way I have managed this is by turning off strict refs as
> shown below.
>
> I am sure there must be a better way of doing this but I can't work it
> out.
>
> I have been looking at Hard references in the manual but that is not
> getting me anywhere.
>
> Any help would be appreciaceted.
>
> use strict;
>
> my $mike = "a2";
>
> no strict 'refs';
> &$mike;
>
> sub a1 {print "a1\n";}
> sub a2 {print "a2 \n";}
> sub a3 {print "a3\n";}
>
> use strict 'refs';
Replace
my $mike = "a2";
With
my $mike = \&a2;
Or else use a dispatch table, as others have suggested.
my $mike = "a2";
my %dispatch = (
a1 => sub {print "a1\n";},
a2 => sub {print "a2 \n";},
a3 => sub {print "a3\n";},
);
&$dispatch{$mike};
--
I'm not a programmer but I play one on TV...
------------------------------
Date: 22 Aug 2001 12:05:48 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: regular expression people.
Message-Id: <87n14smsdf.fsf@abra.ru>
MW> Hello
MW> I have a script in perl that I want to send the sudo command a password.
MW> like:
MW> $out = ` sudo chown me file_name` ;
MW> In unix the sudo comand takes a password so I try thing like:
MW> $out = ` sudo chown me file_name < ./pwd ` ;
MW> where pwd is the password. or
MW> $out = ' sudo chown me file_name | cat ./pwd ' ;
MW> but neither work. How do I do this in a script.
MW> Thank you very much.
Read 'man sudo'. Hint: read about -S switch.
P.S. I wonder how it relates to regexps?
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: 22 Aug 2001 00:51:14 -0700
From: amanpreet.sohi@sbs.siemens.co.uk (Pete Sohi)
Subject: Search a file (line by line) for String/text
Message-Id: <1ab8c4be.0108212351.15578250@posting.google.com>
Calling all Perl Gurus...(Why is it always with religious connotations
- why not Perl Studs?!...)
Calling all Perl Studs
I wonder if you can take a few minutes out a novice. I need to search
through a file (or a dir of files) looking for text matching a
particular string. Lets say I want to search file.txt (line by line)
for each occurrence of the words
"Error Type: authentication"
or
"Error Type: log"
Its another one thats proving a pain to uncover.
Cheers v.much.
Pete.
------------------------------
Date: 22 Aug 2001 08:40:03 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Search a file (line by line) for String/text
Message-Id: <slrn9o6s9h.jgk.rgarciasuarez@rafael.kazibao.net>
Pete Sohi wrote in comp.lang.perl.misc:
> Calling all Perl Gurus...(Why is it always with religious connotations
> - why not Perl Studs?!...)
AFAIK, in classical sanskrit, guru only means master or professor.
> I wonder if you can take a few minutes out a novice. I need to search
> through a file (or a dir of files) looking for text matching a
> particular string. Lets say I want to search file.txt (line by line)
> for each occurrence of the words
> "Error Type: authentication"
>
> or
> "Error Type: log"
Well, the Unix grep program does that. sed or awk can also be used for
this problem. Those programs are also available on Windows if you
download the cygwin Unix-like environment. But, this is a Perl
newsgroup, so here's the Perl way to do it :
perl -nle 'print if /Error type: (authentication|log)/' file.txt
This prints all matching lines to standard output. For anything more
complicated, I suggest to learn Perl (at least the basics) first.
--
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
------------------------------
Date: Wed, 22 Aug 2001 10:26:53 +0200
From: Philippe PERRIN <philippe.perrin@sxb.bsf.alcatel.fr>
Subject: Re: Search a file (line by line) for String/text
Message-Id: <3B836CCD.7251DB3@sxb.bsf.alcatel.fr>
Pete Sohi wrote:
> I wonder if you can take a few minutes out a novice. I need to search
> through a file (or a dir of files) looking for text matching a
> particular string. Lets say I want to search file.txt (line by line)
> for each occurrence of the words
> "Error Type: authentication"
> or
> "Error Type: log"
and what do you want to do with these matchine lines ? print them ? try
:
$search = 'Error Type: authentication';
open(LOG, "file.txt");
while(<>) { # read line by line in case of large log files
print $_ if(/\Q$search\E/);
}
close(LOG);
and for a whole directory, see :
perldoc -f opendir
--
PhP
($r1,$r2,$r3,$r4)=("19|20","0|1","28|29","5|24");($r5,$r6)=("9|10|15|16|$r1|$r2","9|10|$r3");%h=("1|",$r6,"1=","[1-5]|2[0-4]","1/","0|19","1\\","6|25","2|","0|6|19|25|$r6","2/","1|20","2\\",$r4,"3|","$r2|6|$r1|25|$r6","3/",$r4,"4|","$r2|$r1|$r6","4=","2|3|4|11|12|13|14|21|22|23","4/",$r4,"4\\",15,"5|","$r2|9|15|$r1|20|$r3","5/",10,"6|",$r5,"7|",$r5,"7/",$r3);for($l=1;$l<8;$l++){b:for($i=0;$i<30;$i++){c:foreach(keys
%h){next c if(!(/^$l(.*)$/));$a=$1;if($i=~/^($h{$_})$/){print $a;next
b;}}print " ";}print "\n";}
------------------------------
Date: 22 Aug 2001 01:14:33 -0700
From: ianb@ot.com.au (Ian Boreham)
Subject: Re: String Parsing > Remove everything after the first non-number
Message-Id: <f02c4576.0108220014.3ebdb262@posting.google.com>
gorilla@elaine.furryape.com (Alan Barclay) wrote in message news:<998275150.939528@elaine.furryape.com>...
> $string="1234567221%sk23$823498as22"
> $string += 0;
This occurred to me too, but then I discounted it due to cases like
these:
$ perl -e '$string="01234567221%sk23+823498as22"; $string+=0; print
"%%$string%%\n";'
%%1234567221%%
$ perl -e '$string="0x1234567221%sk23+823498as22"; $string+=0; print
"%%$string%%\n";'
%%1.13777775365452%%
$ perl -e '$string="21.1234567221%sk23+823498as22"; $string+=0; print
"%%$string%%\n";'
%%21.1234567221%%
$ perl -e '$string="21e1234567221%sk23+823498as22"; $string+=0; print
"%%$string%%\n";'
%%inf%%
With more knowledge of the data, it might be possible to verify this
won't happen, but by that stage, you might as well have used a
regex-based technique.
Regards,
Ian
------------------------------
Date: 22 Aug 2001 09:17:04 GMT
From: dkcombs@panix.com (David Combs)
Subject: Re: This is not a question ... call me slow if you like...
Message-Id: <9lvtag$ond$1@news.panix.com>
In article <998311456.28496@itz.pp.sci.fi>,
Ilmari Karonen <usenet11554@itz.pp.sci.fi> wrote:
>In article <9lqtjq$mnd$1@kujawiak.man.lodz.pl>, Przemyslaw Brojewski wrote:
>>I get:
>>Modification of a read-only value attempted at cosik line 2.
>>
>>perl 5.6.1.
>
>Sorry. Try the one in my .sig -- the original breaks under perl v5.6.
>
>--
># Ilmari Karonen -- http://www.sci.fi/~iltzu/
>s''n4|9|21|3|n1\2||2|(_-<2_|4_`1|3\3_1\2_|3\3-_)2_|n\__/\_,_|___/\__|2\__,_|_|
>1_|\___/\__|_|1_|\___|_|nn4_1\9|3|14|n4__/1-_)2_|1|5\3_`1|2_|1!1/2-_)2_|n3_|1\
>___|_|2_|2_|1_|\__,_|\__|_i_\\\___|_|1)n45/n',y/n\n/\n/d,s/\d+/$"x$&/eg,print;
>
Now, just what do we have to do to turn
those three lines into a perl program?
(especially great would be the exact command line or
lines we must type in.)
Thanks
David
PS: if you could make some of those prior things
work on 5.6.1, it'd be real nice, as we
could *try* them -- which would be fun.
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 1585
***************************************