[23530] in Perl-Users-Digest
Perl-Users Digest, Issue: 5739 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 1 11:06:22 2003
Date: Sat, 1 Nov 2003 08:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 1 Nov 2003 Volume: 10 Number: 5739
Today's topics:
Re: Anybody using PERL to control their house ? (Bbirthisel)
Export of environment variables <yevgen.r@web.de>
Re: Export of environment variables (Tad McClellan)
Re: Get Windows Task-Names?! <usenet@repsak.de>
Re: Get Windows Task-Names?! <usenet@repsak.de>
How to find a word in wordlist <VP@yahoo.com>
Re: How to find a word in wordlist <twid@bibulus.org>
Re: How to find a word in wordlist <VP@yahoo.com>
Re: How to find a word in wordlist <jurgenex@hotmail.com>
Re: How to find a word in wordlist <REMOVEsdnCAPS@comcast.net>
Re: How to find a word in wordlist <REMOVEsdnCAPS@comcast.net>
Re: How to find a word in wordlist (Anno Siegel)
Re: How to find a word in wordlist <twid@bibulus.org>
Re: Human verifiable image of numbers, for CGI <REMOVEsdnCAPS@comcast.net>
is there the simplest way to do this: logon to my email <mizhael@yahoo.com>
Re: is there the simplest way to do this: logon to my e <yevgen.r@web.de>
neuronal pattern / network <sm-ml@mediascape.de>
substitutions using a string variable <colin_doigREMOVE@hotmail.com>
Re: substitutions using a string variable <jurgenex@hotmail.com>
Re: substitutions using a string variable <tassilo.parseval@rwth-aachen.de>
Re: substitutions using a string variable <jurgenex@hotmail.com>
Re: User Security <REMOVEsdnCAPS@comcast.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 01 Nov 2003 14:57:00 GMT
From: bbirthisel@aol.com (Bbirthisel)
Subject: Re: Anybody using PERL to control their house ?
Message-Id: <20031101095700.15059.00000132@mb-m13.aol.com>
>During YAPC::NA::2000, Larry presented a talk about the X10
>system he had installed at his house. It was Perl driven
>(perl4-ish, no warnings, no strict).
Not so much perl4-ish as "quick and dirty" (and very linux-specific). I helped
someone port parts of it to Windows back in 2001 (actually, to anything running
*::SerialPort). And Larry gave permission to release the port as a module - but
I ran out of tuits.
If someone wants to pick it up, and is looking for something much smaller than
Misterhouse, I can dig up the code. It is client-server (since X10 is real
slow). At the end of my article in TPJ (reprinted in the O'Reilly "Games,..."
volume), I outlined the architectural issues this code needs to solve to be
robust. The code covered many of them - but would need work before general
release. Note - a proper implementation is not purely X10-specific. There are
several other hardware/software protocols available.
-bill
------------------------------
Date: Sat, 01 Nov 2003 14:59:13 +0100
From: Yevgen Reznichenko <yevgen.r@web.de>
Subject: Export of environment variables
Message-Id: <bo0e7q$17228m$1@ID-198732.news.uni-berlin.de>
Hello,
i am new here and perl is new for me too. I try to make my first small
program in perl, it should display me how many new mails are in my
mailbox. Only the number of _new_(number of mails now - number of mails
before) emails should be displayed. For this case i want to create a
environment variable and export it. I know that must be very simple, but
i can't find anything in the web. I know how can i get an existent
variable, but i don't know how can i export the new value of this, after
the changes was made. Additionally i don't know how i can create a new one.
Regards,
Yevgen
------------------------------
Date: Sat, 1 Nov 2003 08:29:39 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Export of environment variables
Message-Id: <slrnbq7gqj.lcd.tadmc@magna.augustmail.com>
Yevgen Reznichenko <yevgen.r@web.de> wrote:
> i am new here
Have a look at the Posting Guidelines when you have time:
http://mail.augustmail.com/~tadmc/clpmisc.shtml
> and perl is new for me too.
perl comes with lots of documentation. You should try to find
answers there before looking elsewhere.
You can search for words that appear in Perl FAQs with
the "-q" switch to "perldoc".
> I try to make my first small
> program in perl, it should display me how many new mails are in my
> mailbox. Only the number of _new_(number of mails now - number of mails
> before) emails should be displayed. For this case i want to create a
> environment variable and export it.
If I understand you correctly, you cannot do that on any sensible
operating system.
Are you asking this FAQ?
perldoc -q env
I {changed directory, modified my environment} in a perl
script. How come the change disappeared when I exited the
script? How do I get my changes to be visible?
You appear to want to use an env var for persistence. That is
a bad choice as it will go away on a reboot. Use a file instead.
> I know that must be very simple, but
It is simply impossible :-)
> i can't find anything in the web. I know how can i get an existent
> variable, but i don't know how can i export the new value of this, after
> the changes was made. Additionally i don't know how i can create a new one.
If you want the _children_ of your Perl program to see the env var,
you must do nothing more than put it into %ENV before launching
the child process:
$ENV{SEEN} = 'mumble mumble';
system 'prog_that_wants_SEEN';
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 01 Nov 2003 12:31:28 +0100
From: Kasper Dziurdz <usenet@repsak.de>
Subject: Re: Get Windows Task-Names?!
Message-Id: <bo05ie$157fd1$1@ID-210032.news.uni-berlin.de>
Thanks for the information! The only problem is, I never programmed in
C. I thought about using Win32::API and searched the MSDN but I did not
find what I was looking for (perhaps I have to search again).
Win32::ToolHelp seems to be good enough but returns only the processes
name like "mozilla.exe" and not "Google - Mozilla". Same with other
modules I found on CPAN.
Kasper
--
HTML::KTemplate | Perl module to process HTML templates.
http://search.cpan.org/dist/HTML-KTemplate/
Kopierschutz-Nein-Danke.de | Gegen kopiergeschützte Un-CDs!
http://www.kopierschutz-nein-danke.de/
------------------------------
Date: Sat, 01 Nov 2003 15:56:41 +0100
From: Kasper Dziurdz <usenet@repsak.de>
Subject: Re: Get Windows Task-Names?!
Message-Id: <bo0hj7$16lf6j$1@ID-210032.news.uni-berlin.de>
I got a solution and it is easier than I thought :-)
@tasks = split "\n", `tasklist.exe /v`;
@tasks = @tasks[3..$#tasks];
Kasper
--
HTML::KTemplate | Perl module to process HTML templates.
http://search.cpan.org/dist/HTML-KTemplate/
Kopierschutz-Nein-Danke.de | Gegen kopiergeschützte Un-CDs!
http://www.kopierschutz-nein-danke.de/
------------------------------
Date: Sat, 01 Nov 2003 10:28:16 +0100
From: VP <VP@yahoo.com>
Subject: How to find a word in wordlist
Message-Id: <3fa37c8c$0$1854$ba620e4c@reader0.news.skynet.be>
Hi all,
I have wordlist file having format:
...
abc
abd
abf
abg
abh
...
So there is one word (utf-8) for each line and all lines were ordered by alphabet.
I would like to make a Perl script for checking a word:
# check.pl abc
if the word is found => ouput OK
if the word is not found => output two words above and below of this word. For example:
# check.pl abe => output: abd abf
The word list has about 70,000 words. I don't know how to search it quickly.
Any suggestion will be welcome.
TIA
VP
------------------------------
Date: 01 Nov 2003 09:39:46 +0000
From: Thomas Widmann <twid@bibulus.org>
Subject: Re: How to find a word in wordlist
Message-Id: <m3fzh8pgv1.fsf@bibulus.org>
VP <VP@yahoo.com> writes:
> [...]
> Any suggestion will be welcome.
E.g.,
#!/usr/local/bin/perl -w
use strict;
my $s = shift @ARGV or die "Please specify a search term!\n";
my $prev = '<BEGINNING>';
while (<>) {
chomp;
if ($_ eq $s) {
print "OK\n";
exit 0;
} elsif ($_ le $s) {
$prev = $_;
} else {
print "$prev $_\n";
exit 0;
}
}
print "$prev <END>\n";
/Thomas
--
Thomas Widmann twid@bibulus.org http://www.twid.bibulus.org
Flat 3/2, 54 Mavisbank Gardens, Glasgow G51 1HL, Scotland, EU
*** Ny gruppe om nordiske sprog: europa.linguas.germanic.nord ***
------------------------------
Date: Sat, 01 Nov 2003 11:05:39 +0100
From: VP <VP@yahoo.com>
Subject: Re: How to find a word in wordlist
Message-Id: <3fa3854f$0$1861$ba620e4c@reader0.news.skynet.be>
Thomas Widmann wrote:
> VP <VP@yahoo.com> writes:
>
>
>>[...]
>>Any suggestion will be welcome.
>
>
> E.g.,
>
> #!/usr/local/bin/perl -w
>
> use strict;
>
> my $s = shift @ARGV or die "Please specify a search term!\n";
>
> my $prev = '<BEGINNING>';
> while (<>) {
> chomp;
> if ($_ eq $s) {
> print "OK\n";
> exit 0;
> } elsif ($_ le $s) {
> $prev = $_;
> } else {
> print "$prev $_\n";
> exit 0;
> }
> }
> print "$prev <END>\n";
>
> /Thomas
thank you for your reply so quickly.
With your script, if i look for a word "z***" (at the end of my 70,000 words list) so the script
should parse all terms from a->y, right?
Is there another method for quick search in this case?
Thank you,
------------------------------
Date: Sat, 01 Nov 2003 10:26:04 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to find a word in wordlist
Message-Id: <0TLob.47264$AU.3994@nwrddc01.gnilink.net>
VP wrote:
> I have wordlist file having format:
[sorted list]
> So there is one word (utf-8) for each line and all lines were ordered
> by alphabet. I would like to make a Perl script for checking a word:
The typical approach to search for an element in a sorted list is to use
bisection:
- look at the middle element in the list
- is it larger than the word you are looking for? Then search again in
the lower half of the list.
- is it smaller than the word you are looking for? Then search again in
the upper half of the list
- is it the word itself? Then you are done
- are there no elements left in the list? Sorry, word does not exist in
the list.
Usually you would keep the list in a global array (used read-only) and the
boundaries for the active still-to-be-searched list are two indices into the
array.
Then it is just a matter of iterating and changing the upper or the lower
index until either the word is found or the upper index is smaller than the
lower index. BTW: In the later case you automatically got the indeces for
the two neighbour elements of your word.
For details you may want to check any book about algorithms.
jue
------------------------------
Date: Sat, 01 Nov 2003 07:02:42 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How to find a word in wordlist
Message-Id: <Xns942651D386219sdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
Thomas Widmann <twid@bibulus.org> wrote in news:m3fzh8pgv1.fsf@bibulus.org:
> VP <VP@yahoo.com> writes:
>
> my $prev = '<BEGINNING>';
> while (<>) {
> chomp;
> if ($_ eq $s) {
> print "OK\n";
> exit 0;
> } elsif ($_ le $s) {
> $prev = $_;
> } else {
> print "$prev $_\n";
> exit 0;
> }
> }
> print "$prev <END>\n";
The OP did say he wanted to search the list "quickly". A linear search is
not quick.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP6Ou7GPeouIeTNHoEQIyUgCgqT+fk9VKI8VRVLEf5VQxMnXhoK0AoPMS
p1vafsNNNkKSSxypMrpf+mNx
=/7fK
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 01 Nov 2003 07:11:26 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: How to find a word in wordlist
Message-Id: <Xns9426534E58C5Csdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
VP <VP@yahoo.com> wrote in
news:3fa37c8c$0$1854$ba620e4c@reader0.news.skynet.be:
> Hi all,
> I have wordlist file having format:
>
> ...
> abc
> abd
> abf
> abg
> abh
> ...
>
> So there is one word (utf-8) for each line and all lines were ordered
> by alphabet. I would like to make a Perl script for checking a word:
>
> # check.pl abc
>
> if the word is found => ouput OK
> if the word is not found => output two words above and below of this
> word. For example: # check.pl abe => output: abd abf
>
> The word list has about 70,000 words. I don't know how to search it
> quickly.
>
> Any suggestion will be welcome.
The "classic" way to do this is an algorithm called a "binary search".
You locate the middle record, and then move up or down in the file
depending on whether the record you just read is less than or greater
than your search string. Then you move to the record 1/4 of the way
though the file or 3/4 of the way through the file, and so on, each time
dividing the search space by two. In this way, a list of 70,000 items
can be searched in a maximum of 17 lookups.
In Perl, if memory is not a concern (and with 70,000 items, it probably
will be), you could read the entire file into a hash. This takes lots
of memory, but thereafter, lookups are very fast. Also, the time to load
the data into the hash may be significant, so this method is only useful
if you plan to do many word lookups during a single run of the program.
Probably the best all-around solution would be to store the wordlist into
a database of some sort; perhaps a DBM file. Then you could tie a hash
to the DBM file, giving you the speed of a hash lookup without the
overhead of loading it into memory each run of your program.
HTH,
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA+AwUBP6Ow92PeouIeTNHoEQJt3QCfQ7PEVdwE3hB08a7D9X4jvMRVVNoAl20G
dXKCt1eJXlB9Kmd8SbsO2fM=
=YQKv
-----END PGP SIGNATURE-----
------------------------------
Date: 1 Nov 2003 13:17:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to find a word in wordlist
Message-Id: <bo0bpt$cj2$1@mamenchi.zrz.TU-Berlin.DE>
VP <VP@yahoo.com> wrote in comp.lang.perl.misc:
> Hi all,
> I have wordlist file having format:
>
> ...
> abc
> abd
> abf
> abg
> abh
> ...
>
> So there is one word (utf-8) for each line and all lines were ordered by
> alphabet.
> I would like to make a Perl script for checking a word:
>
> # check.pl abc
>
> if the word is found => ouput OK
> if the word is not found => output two words above and below of this
> word. For example:
> # check.pl abe => output: abd abf
>
> The word list has about 70,000 words. I don't know how to search it quickly.
As Juergen Exner has noted, this practically shouts "binary search". The
salient point is that you want the neighboring words in case of a mismatch.
This is the one thing binary search does better than hash searching: In
binary search you are left with an approximation when the search fails,
with a hash you know nothing.
The direct application of binary search requires the whole file to be read
into memory. With 70,000 words this should be no problem.
With a large file, a space-time tradeoff is possible by storing only a
fraction (every tenth, hundredth) of the words together with their
position in the file. A single pass over the file with tell() will
create that index. The binary search goes only over the words in memory
and finds the section of the file where the word must be, if it is in
the file. A linear search over ten (a hundred) subsequent entries
decides this.
Anno
------------------------------
Date: 01 Nov 2003 14:12:36 +0000
From: Thomas Widmann <twid@bibulus.org>
Subject: Re: How to find a word in wordlist
Message-Id: <m3vfq4npnv.fsf@bibulus.org>
VP <VP@yahoo.com> writes:
> With your script, if i look for a word "z***" (at the end of my 70,000
> words list) so the script should parse all terms from a->y, right?
Right. 70.000 lines doesn't take that long to process on my computer,
though (but YMMV).
> Is there another method for quick search in this case?
It depends a bit. In your usage example, it seemed that you would run
it from the command-line with just one search term. That makes it a
bit complex to speed up. (If you'd use the program to make a lot of
queries within the same run, it'd be trivial to read the list into an
array and then use binary search as suggested by other people
elsewhere in this thread.)
If you want to have a fast look-up tool on the commandline, you have
several options.
1) Instead of reading the wordlist sequentially, you might try to use
random access to the file. Basically, you'd jump right into the
middle of the file, search forward to the next newline character,
read a line, compare it to your search term, and depending on the
result jump to somewhere else. However, this kind of low-level
file access is not really Perl's strong side.
2) You can preprocess the file into something than can be read a lot
faster.
3) You can write a client/server application, where your server reads
the wordlist once and then waits for client queries.
4) As (3), but using an database as the server, as somebody else
suggested.
For (2)-(4), you have to make additional checks to find out whether
the wordlist has changed since it was last read.
/Thomas
--
Thomas Widmann twid@bibulus.org http://www.twid.bibulus.org
Flat 3/2, 54 Mavisbank Gardens, Glasgow G51 1HL, Scotland, EU
*** Ny gruppe om nordiske sprog: europa.linguas.germanic.nord ***
------------------------------
Date: Sat, 01 Nov 2003 07:31:31 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: Human verifiable image of numbers, for CGI
Message-Id: <Xns942656B5EDFCCsdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
brendan@symonty.org (brendan) wrote in
news:282ee219.0310311507.5f2d0b3b@posting.google.com:
> hi all,
>
> I want to make sure it's a human posting to my webpage, by doing what
> PayPal (and lots of other websites) now do: displaying a bitmap of
> some numbers and asking the user to enter these numbers.
>
> Are there any Perl scripts and/or tutorials explaining how to do this?
Just be aware of the fact that sight-impaired persons are "humans" too, and
that they will likely not be able to use this mechanism.
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP6O1rGPeouIeTNHoEQKh1QCcCncgj4vHY5ZW2OJkM7neQTiOsKAAoN0S
GzWYMbpkRev8QwbmfxTM2ZW9
=WKzQ
-----END PGP SIGNATURE-----
------------------------------
Date: Sat, 1 Nov 2003 09:08:35 -0500
From: "walala" <mizhael@yahoo.com>
Subject: is there the simplest way to do this: logon to my email account and delete bulk emails?
Message-Id: <bo0eoc$b05$1@mozo.cc.purdue.edu>
Dear all,
I got too many spam email every day...
Is there such a utility/program, or can I do some programming in the
simplest way, to do the following:
1) automatically logon to my mail.yahoo.com account with my account username
and password;
2) click on the "empty bulk email folder" link to empty the folder;
3) then log out the account;
I only know a little programming on Windows, such as VC++, etc. Very little
about Perl. Let me know
if I can write several lines to do the above task, or there is some
automated software to do the task(don't tell me to use macro recorder, those
utility relies on windows position and mouse position, which are stupid and
not very reliable... I have previously recorded some daily actions, but they
always made a mess)
Thanks,
-Walala
------------------------------
Date: Sat, 01 Nov 2003 16:05:27 +0100
From: Yevgen Reznichenko <yevgen.r@web.de>
Subject: Re: is there the simplest way to do this: logon to my email account and delete bulk emails?
Message-Id: <bo0i3t$16o8oj$3@ID-198732.news.uni-berlin.de>
Hi,
Am 01.11.2003 15:08 schrieb walala:
> I got too many spam email every day...
If you want delete SWEN's from your account you can take a look here:
http://www.hashref.com/prj/swendeleter/
You can modify the script to solve your problem.
> Thanks,
>
> -Walala
Yevgen
------------------------------
Date: Sat, 1 Nov 2003 15:17:15 +0100
From: "Stefan Mohr" <sm-ml@mediascape.de>
Subject: neuronal pattern / network
Message-Id: <bo0f9b$arg$1@news1.transmedia.de>
hello,
does anybody of you have had the opportunity to program a neuronal pattern /
network in perl? has anybody some hints for me where to find some info about
that?
thanks,
stefan
------------------------------
Date: Sat, 1 Nov 2003 21:55:34 +1300
From: "Colin Doig" <colin_doigREMOVE@hotmail.com>
Subject: substitutions using a string variable
Message-Id: <3fa37549$1@clear.net.nz>
Hi, can anyone help me out with this? I want to use a string variable in a
substitution. When I run the code below I get "$1 world" instead of "hello
world" which is what I want. How do I get perl to interpolate $1??
my $str = "hello world";
my $regexp = '(\w+)';
my $replace = '$1';
$str =~ s/$regexp/$replace/;
print $str;
Thanks
------------------------------
Date: Sat, 01 Nov 2003 09:16:23 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: substitutions using a string variable
Message-Id: <HRKob.31070$%e3.4877@nwrddc03.gnilink.net>
Colin Doig wrote:
> Hi, can anyone help me out with this? I want to use a string
> variable in a substitution. When I run the code below I get "$1
> world" instead of "hello world" which is what I want. How do I get
> perl to interpolate $1??
>
[...]
> my $replace = '$1';
[...]
Quite simple: by not telling perl to not interpolate it.
Single quotes don't interpolate, therefore $replace will contain a literal
dollar sign and the digit 1.
Either use double quotes or in this case (as there is no other
concatenation/value/...) just do
my $replace = $1;
jue
------------------------------
Date: 1 Nov 2003 09:48:14 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@rwth-aachen.de>
Subject: Re: substitutions using a string variable
Message-Id: <bnvvgu$gpe$1@nets3.rz.RWTH-Aachen.DE>
Also sprach Jürgen Exner:
> Colin Doig wrote:
>> Hi, can anyone help me out with this? I want to use a string
>> variable in a substitution. When I run the code below I get "$1
>> world" instead of "hello world" which is what I want. How do I get
>> perl to interpolate $1??
>>
> [...]
>> my $replace = '$1';
> [...]
>
> Quite simple: by not telling perl to not interpolate it.
> Single quotes don't interpolate, therefore $replace will contain a literal
> dollar sign and the digit 1.
>
> Either use double quotes or in this case (as there is no other
> concatenation/value/...) just do
> my $replace = $1;
Did you test this at all? You can't do that because perl will simply
assign the current value of $1 to $replace and later use this as
substitution.
To the OP: You can use double /e.
my $str = "hello world";
my $pat = '(\w+)'
my $replace = '$1';
$str =~ s/$pattern/$replace/ee;
Or you use a closure for the replacement and a single /e:
...
my $replace = sub { $1 };
$str =~ s/$pattern/$replace->()/e;
This is in fact the safer way of doing it.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
------------------------------
Date: Sat, 01 Nov 2003 10:28:29 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: substitutions using a string variable
Message-Id: <hVLob.47289$AU.15529@nwrddc01.gnilink.net>
Tassilo v. Parseval wrote:
> Also sprach Jürgen Exner:
>
>> Colin Doig wrote:
>>> Hi, can anyone help me out with this? I want to use a string
>>> variable in a substitution. When I run the code below I get "$1
>>> world" instead of "hello world" which is what I want. How do I get
>>> perl to interpolate $1??
>>>
>> [...]
>>> my $replace = '$1';
>> [...]
>>
>> Quite simple: by not telling perl to not interpolate it.
>> Single quotes don't interpolate, therefore $replace will contain a
>> literal dollar sign and the digit 1.
>>
>> Either use double quotes or in this case (as there is no other
>> concatenation/value/...) just do
>> my $replace = $1;
>
> Did you test this at all? You can't do that because perl will simply
> assign the current value of $1 to $replace and later use this as
> substitution.
Maybe I was mistaken, but it was my understanding that this was exactly what
the OP wanted to do.
My appologies if he was looking for something different.
jue
------------------------------
Date: Sat, 01 Nov 2003 07:29:07 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: User Security
Message-Id: <Xns9426564DC3AF9sdn.comcast@216.196.97.136>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"Robert TV" <ducott_99@yahoo.com> wrote in
news:DiFob.239793$9l5.30508@pd7tw2no:
> I'm trying to build the best possible security for my perl script. The
> main page of my web site has a login and password box. When submitted,
> the userid and password are compared against valid accounts, and the
> programs runs if successful. I forsee a potentail security hole in
> the, and it has to do with someone accessing the perl script from
> their own web page or server using a false login and password form
> that would have the same form names as my own. I would like my script
> to check the refferrer of the login submission and take action based
> on that result. EG:
>
> #!/usr/bin/perl
>
> if (refferring web page does not eq "myserver.com/login.pl") {
> print "Access Denied";
> exit;
> } else {
> allow access to my program, and verify username and password
> }
>
> Can someone please help me out with the syntax I would need to
> correctly accomplish this?
Syntax is not your problem.
"Referer" is an OPTIONAL field; user agents (eg browsers) are not
required to provide it. Also, user agents can represent it to be
anything they want. It's as reliable as politicians' campaign promises.
You could try the REMOTE_IP, but that has problems too. Nowadays, it
usually contains the address of an ISP's proxy, so everyone using that
ISP (ior at least that particular proxy) will appear to you as though
they came from the same IP. Also, with modern dynamic IP schemes, a
valid user's IP can change during a session.
You should if possible use an https page for the user login, so that
crackers cannot snoop valid UIDs and passwords from the http traffic.
What are you really trying to accomplish? If someone has a valid user ID
and password, why do you care what web page or server they're coming
from? Maybe they hate part of your interface and have written their own
way around it for their own convenience. I do this with bank and
cellphone status websites that make it a pain to check my balance (e.g.).
- --
Eric
$_ = reverse sort $ /. r , qw p ekca lre uJ reh
ts p , map $ _. $ " , qw e p h tona e and print
-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
iQA/AwUBP6O1G2PeouIeTNHoEQJPAwCdEHJ7NwEv1Lu3vGzAKjnXH2n0mWsAoNLO
V6gIfWBQuC/fcnRicTq16nZC
=5kCi
-----END PGP SIGNATURE-----
------------------------------
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 5739
***************************************