[31384] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2636 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 14 18:09:53 2009

Date: Wed, 14 Oct 2009 15:09:19 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 14 Oct 2009     Volume: 11 Number: 2636

Today's topics:
    Re: FAQ 9.10 How do I decode or create those %-encoding <marc.girod@gmail.com>
    Re: Help needed with tough regular expression matching sln@netherlands.com
        hide information from the view "source" <kwan.jingx@gmail.com>
    Re: hide information from the view "source" <jurgenex@hotmail.com>
    Re: hide information from the view "source" <no@email.com>
    Re: hide information from the view "source" <tadmc@seesig.invalid>
        hide information from the view source" <kwan.jingx@gmail.com>
    Re: hide information from the view source" <kwan.jingx@gmail.com>
    Re: hide information from the view source" <ben@morrow.me.uk>
    Re: hide information from the view source" <kkeller-usenet@wombat.san-francisco.ca.us>
        How would I do this in perl? <laredotornado@zipmail.com>
    Re: How would I do this in perl? <ben@morrow.me.uk>
    Re: How would I do this in perl? <laredotornado@zipmail.com>
    Re: How would I do this in perl? sln@netherlands.com
    Re: regexp assistance (Randal L. Schwartz)
    Re: regexp assistance <smallpond@juno.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Oct 2009 03:12:23 -0700 (PDT)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: FAQ 9.10 How do I decode or create those %-encodings on the web?
Message-Id: <53228d94-dfa1-4cc4-baa9-8f79cd0c50ce@j24g2000yqa.googlegroups.com>

Typo?

On Oct 14, 5:00=A0am, PerlFAQ Server <br...@theperlreview.com> wrote:

> =A0 =A0 =A0 =A0 =A0 =A0 print "$string\n"; # 'Colon%20%3A%20Hash%20%23%20=
Percent%20%25%20'
                     ^^^^^^^
                     $escaped

Marc


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

Date: Wed, 14 Oct 2009 13:41:55 -0700
From: sln@netherlands.com
Subject: Re: Help needed with tough regular expression matching
Message-Id: <okdcd51ib63kk0vpm8f3okcds2p2oo6007@4ax.com>

On Mon, 12 Oct 2009 09:32:46 -0700 (PDT), Ramon F Herrera <ramon@conexus.net> wrote:

<snip>

>(2) My future feature will be based on "quarters" instead of integers.
>This is an instance of the most basic unit:
>
>4/2008
>
>(meaning the 4th. quarter of year 2008, of course).
>
>Therefore the notation (I don't allow spaces, btw) will look like
>this:
>
>2/2000,3/2000,4/2000,1/2005,2/2005-1/2006
>
>Which could be minimally expressed like this:
>
>2/2000-4/2000,1/2005-1/2006
>
>My failed attempt at dealing with calendar quarters is lifted entirely
>from the integer version, but for some reasons it doesn't seem to
>scale well.
>
>-Ramon

Below is my Validation Special version ..
-sln

--------------------
use strict;
use warnings;

my @qtrs = ();

while (<DATA>)
{
	@qtrs = m{ (?:^|,) ([1-4]) / ([12]\d{3}) (?=[,-]|$) .? ((?<=-)[1-4]|) .? ((?<=/)[12]\d{3}|) (?=$|,) }xg;
	if (@qtrs) {
		print "-------\n";
		while ( my ($q1,$y1,$q2,$y2) = map {defined() && length() ? $_ : 0} splice (@qtrs, 0, 4) )
		{
			printf "q:%2d  y:%5d   To   q:%2d  y:%5d\n", $q1,$y1, $q2,$y2;
		}
	}
	# OR ...

	@qtrs = m{ (?:^|,) ([1-4]) / ([12]\d{3}) (?=[,-]|$) .? (?:-([1-4]) / ([12]\d{3}))?  (?=$|,) }xg;
	if (@qtrs) {
		print "  ==\n";
		while ( my ($q1,$y1,$q2,$y2) = map {defined() && length() ? $_ : 0} splice (@qtrs, 0, 4) )
		{
			printf "q:%2d  y:%5d   To   q:%2d  y:%5d\n", $q1,$y1, $q2,$y2;
		}
	}
} 

__DATA__

1/1900

2/2000,3/2000,4/20073/2008,1/2005,2/2005-1/2006 asdf 2/2000-4/2000,1/2005-1/2006 wsefrgsd 2/2000-4/2000,1/2005-1/2006asdf,1/2008-2/2009

1/2000-2/2000, ,,3/2005-4/2006,2/2000

2/2000-4/2000, ,,6/2005-1/2006

1/2100-4/2200
2/2100-
,3/2100-
4/2100aadsfasdf

      (  [1-4]/[12][0-9]{3}  |  [1-4]/[12][0-9]{3} - [1-4]/[12][0-9]{3} )
(?: , 
      (  [ 1-4]/[12][0-9]{3} |  [1-4]/[12][0-9]{3} - [1-4]/[12][0-9]{3} )
)*



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

Date: Wed, 14 Oct 2009 11:00:24 -0700 (PDT)
From: kwan <kwan.jingx@gmail.com>
Subject: hide information from the view "source"
Message-Id: <1d035649-bb69-47bf-9c4d-f6e05932c482@k19g2000yqc.googlegroups.com>

Hello,

It is the problem with my entire Perl code; I wrote the Perl script to
retrieve the questions and answers from the database. It is possible
that the user can view "source" and retrieve the questions and answer
from the "view source" which is the pain html. At this point, I want
to convert my program into Java Applet, it is solve the problems. But,
before I do that, I hope that anyone here can give me some hint to
solve my problem.

Thank you,



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

Date: Wed, 14 Oct 2009 11:39:09 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: hide information from the view "source"
Message-Id: <ou5cd51229ojj5qotvcujh6ai6hg9mvme3@4ax.com>

kwan <kwan.jingx@gmail.com> wrote:
>It is the problem with my entire Perl code; I wrote the Perl script to
>retrieve the questions and answers from the database. It is possible
>that the user can view "source" and retrieve the questions and answer
>from the "view source" which is the pain html. 

I am assuming that you are talking about a web application (you didn't
say), using CGI (you didn't say), where your Perl code creates an HTTP
response aka web page.
And the problem is (you didn't say) that you coded all questions and
answers into that single HTTP response object and thus a user can see
them when reading the HTTP response directly ("View Source"). 

You do not have a Perl problem. You would have exactly the same problem
no matter which programming language you had chosen to write the CGI
scripts.
Also you do not have a CGI or programming problem in general, either.
Your problem is caused by a poor design of your system.

>At this point, I want
>to convert my program into Java Applet, it is solve the problems. But,
>before I do that, I hope that anyone here can give me some hint to
>solve my problem.

The solution is very simple: don't do that. Do not code all questions
and answers into the HTTP response. Instead do round-trips to the web
server for each answer and check the answer server-side only. Yes, that
does increase traffic quite a bit. Yes, it does introduce potentially
significant delays for each round-trip. But is the only way to not hand
out all questions and answers to the user because as soon as you send
them the user can read them one way or the other. 

Or you might try to encode/encrypt the data and have some client-side
process to decode it. That may deter the casual user, but it won't stop
a dedicated cracker because after all he is supposed to see the data in
clear text eventually, therefore you cannot block access to it totally.

jue


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

Date: Wed, 14 Oct 2009 20:29:59 +0100
From: Brian Wakem <no@email.com>
Subject: Re: hide information from the view "source"
Message-Id: <7jmn5tF363oe1U1@mid.individual.net>

kwan wrote:

> Hello,
> 
> It is the problem with my entire Perl code; I wrote the Perl script to
> retrieve the questions and answers from the database. It is possible
> that the user can view "source" and retrieve the questions and answer
> from the "view source" which is the pain html. At this point, I want
> to convert my program into Java Applet, it is solve the problems. But,
> before I do that, I hope that anyone here can give me some hint to
> solve my problem.
> 
> Thank you,


You cannot stop somebody from viewing the source.

Not that this is perl related of course.


-- 
Brian Wakem


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

Date: Wed, 14 Oct 2009 15:34:09 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: hide information from the view "source"
Message-Id: <slrnhdcchn.a70.tadmc@tadmc30.sbcglobal.net>

kwan <kwan.jingx@gmail.com> wrote:

> I want
> to convert my program into Java Applet, it is solve the problems.


That does NOT solve the problem!


-- 
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"


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

Date: Wed, 14 Oct 2009 10:56:31 -0700 (PDT)
From: kwan <kwan.jingx@gmail.com>
Subject: hide information from the view source"
Message-Id: <64aed62b-3aa2-4568-b6e2-97f2ea3d4e51@s31g2000yqs.googlegroups.com>


Hello,

I designed the examination system for the school. It is possible that
the user can retreive the questions and answer from the "view source"
which display as in a pain HTML text. It is the problem if the student
try to view the "source"; coz they will be able to copy the questions
and answers.

I used Perl CGI to write all the interface and to talk to the
database. As all the questions and answers are stored in the database.

Any hint so that I can hide the "Answers and Questions" from view
source?

Thank you


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

Date: Wed, 14 Oct 2009 11:01:07 -0700 (PDT)
From: kwan <kwan.jingx@gmail.com>
Subject: Re: hide information from the view source"
Message-Id: <1651c238-6263-421e-afd8-e95a529f6e05@o10g2000yqa.googlegroups.com>

On Oct 14, 12:56=A0pm, kwan <kwan.ji...@gmail.com> wrote:
> Hello,
>
> I designed the examination system for the school. It is possible that
> the user can retreive the questions and answer from the "view source"
> which display as in a pain HTML text. It is the problem if the student
> try to view the "source"; coz they will be able to copy the questions
> and answers.
>
> I used Perl CGI to write all the interface and to talk to the
> database. As all the questions and answers are stored in the database.
>
> Any hint so that I can hide the "Answers and Questions" from view
> source?
>
> Thank you

I not intend to post twice!!!


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

Date: Wed, 14 Oct 2009 20:36:14 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: hide information from the view source"
Message-Id: <eqlhq6-o6e.ln1@osiris.mauzo.dyndns.org>


Quoth kwan <kwan.jingx@gmail.com>:
> 
> I designed the examination system for the school. It is possible that
> the user can retreive the questions and answer from the "view source"
> which display as in a pain HTML text. It is the problem if the student
> try to view the "source"; coz they will be able to copy the questions
> and answers.
> 
> I used Perl CGI to write all the interface and to talk to the
> database. As all the questions and answers are stored in the database.
> 
> Any hint so that I can hide the "Answers and Questions" from view
> source?

Dont include them in the page? There is no way you can hide anything you
send to the user's computer from them.

Ben



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

Date: Wed, 14 Oct 2009 13:05:48 -0700
From: Keith Keller <kkeller-usenet@wombat.san-francisco.ca.us>
Subject: Re: hide information from the view source"
Message-Id: <shnhq6xp0v.ln2@goaway.wombat.san-francisco.ca.us>

On 2009-10-14, kwan <kwan.jingx@gmail.com> wrote:
> On Oct 14, 12:56 pm, kwan <kwan.ji...@gmail.com> wrote:
>> Hello,
>>
>> I designed the examination system for the school. It is possible that
>> the user can retreive the questions and answer from the "view source"
>> which display as in a pain HTML text. It is the problem if the student
>> try to view the "source"; coz they will be able to copy the questions
>> and answers.
>>
>> I used Perl CGI to write all the interface and to talk to the
>> database. As all the questions and answers are stored in the database.
>
> I not intend to post twice!!!

Three times?

As others have said, you absolutely can not hide the HTML source.  How
esle would the browser know how to render the page?

That being said, you can certainly hide the answers (and future
questions, if that's an issue) with design of the script itself.  You
would have the script send the relevant questions, but not the actual
solutions; on submitting the form, the script would then process the
answers (whether this involves simply storing them, or correcting the
responses and sending feedback to the user, is up to you) and show
whatever was relevant next.

Again, the browser can see whatever you send it.  So don't send it
information you don't want your students to see.

--keith


-- 
kkeller-usenet@wombat.san-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information



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

Date: Wed, 14 Oct 2009 13:31:23 -0700 (PDT)
From: laredotornado <laredotornado@zipmail.com>
Subject: How would I do this in perl?
Message-Id: <20e6537a-d947-4eaf-a669-e09f4103d3e0@h14g2000pri.googlegroups.com>

Hi,

I'm not so familiar with perl but it seems this is the kind of task it
is suited for.  I have a file of numbers, one number per line.  Then I
have a template file that contains ...

	public void testXMatchValid_UCASE() throws java.lang.Exception {
		_testMatchUpperCase(X);
	}

	public void testXMatchValid_lcase() throws java.lang.Exception {
		_testMatchLowerCase(X);
	}

I want the final file to have each number replace the "X" in the
template file and the template would repeat for the number of lines in
the numbers file.  So if the numbers file contained

10
20

the resulting output file would contain

	public void test10MatchValid_UCASE() throws java.lang.Exception {
		_testMatchUpperCase(10);
	}

	public void test10MatchValid_lcase() throws java.lang.Exception {
		_testMatchLowerCase(10);
	}

	public void test20MatchValid_UCASE() throws java.lang.Exception {
		_testMatchUpperCase(20);
	}

	public void test20MatchValid_lcase() throws java.lang.Exception {
		_testMatchLowerCase(20);
	}


HOw would I pull this off using perl?  Thanks, - Dave


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

Date: Wed, 14 Oct 2009 22:16:55 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How would I do this in perl?
Message-Id: <7nrhq6-hje.ln1@osiris.mauzo.dyndns.org>


Quoth laredotornado <laredotornado@zipmail.com>:
> 
> I'm not so familiar with perl but it seems this is the kind of task it
> is suited for.  I have a file of numbers, one number per line.  Then I
> have a template file that contains ...
> 
> 	public void testXMatchValid_UCASE() throws java.lang.Exception {
> 		_testMatchUpperCase(X);
> 	}
> 
> 	public void testXMatchValid_lcase() throws java.lang.Exception {
> 		_testMatchLowerCase(X);
> 	}
> 
> I want the final file to have each number replace the "X" in the
> template file and the template would repeat for the number of lines in
> the numbers file.  So if the numbers file contained

(untested)

    use File::Slurp qw/slurp/;

    my $template = slurp "template";
    my @n = slurp "numbers";

    for (@n) {
        (my $out = $template) = s/X/$_/g;
        print $out;
    }

Ben



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

Date: Wed, 14 Oct 2009 14:37:38 -0700 (PDT)
From: laredotornado <laredotornado@zipmail.com>
Subject: Re: How would I do this in perl?
Message-Id: <9daad6a5-c771-49c7-89bf-42eaddd7c162@r24g2000prf.googlegroups.com>

On Oct 14, 3:16=A0pm, Ben Morrow <b...@morrow.me.uk> wrote:
> Quoth laredotornado <laredotorn...@zipmail.com>:
>
>
>
>
>
> > I'm not so familiar with perl but it seems this is the kind of task it
> > is suited for. =A0I have a file of numbers, one number per line. =A0The=
n I
> > have a template file that contains ...
>
> > =A0 =A0public void testXMatchValid_UCASE() throws java.lang.Exception {
> > =A0 =A0 =A0 =A0 =A0 =A0_testMatchUpperCase(X);
> > =A0 =A0}
>
> > =A0 =A0public void testXMatchValid_lcase() throws java.lang.Exception {
> > =A0 =A0 =A0 =A0 =A0 =A0_testMatchLowerCase(X);
> > =A0 =A0}
>
> > I want the final file to have each number replace the "X" in the
> > template file and the template would repeat for the number of lines in
> > the numbers file. =A0So if the numbers file contained
>
> (untested)
>
> =A0 =A0 use File::Slurp qw/slurp/;
>
> =A0 =A0 my $template =3D slurp "template";
> =A0 =A0 my @n =3D slurp "numbers";
>
> =A0 =A0 for (@n) {
> =A0 =A0 =A0 =A0 (my $out =3D $template) =3D s/X/$_/g;
> =A0 =A0 =A0 =A0 print $out;
> =A0 =A0 }
>
> Ben

Thanks for this response.  Unfortunately, I get

Can't locate File/Slurp.pm in @INC (@INC contains: /opt/local/lib/
perl5/5.8.8/darwin-2level /opt/local/lib/perl5/5.8.8 /opt/local/lib/
perl5/site_perl/5.8.8/darwin-2level /opt/local/lib/perl5/site_perl/
5.8.8 /opt/local/lib/perl5/site_perl /opt/local/lib/perl5/vendor_perl/
5.8.8/darwin-2level /opt/local/lib/perl5/vendor_perl/5.8.8 /opt/local/
lib/perl5/vendor_perl .) at test.pl line 1

Is there a quick way to download and install the slurp module?  I'm on
a Mac OS X, using Perl 5.8.8.  Thanks, - Dave


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

Date: Wed, 14 Oct 2009 14:39:34 -0700
From: sln@netherlands.com
Subject: Re: How would I do this in perl?
Message-Id: <l3hcd5d83sg7d5gcbkuj75n2e4b2i21qip@4ax.com>

On Wed, 14 Oct 2009 13:31:23 -0700 (PDT), laredotornado <laredotornado@zipmail.com> wrote:

>Hi,
>
>I'm not so familiar with perl but it seems this is the kind of task it
>is suited for.  I have a file of numbers, one number per line.  Then I
>have a template file that contains ...
>
>	public void testXMatchValid_UCASE() throws java.lang.Exception {
>		_testMatchUpperCase(X);
>	}
>
>	public void testXMatchValid_lcase() throws java.lang.Exception {
>		_testMatchLowerCase(X);
>	}
>
>I want the final file to have each number replace the "X" in the
>template file and the template would repeat for the number of lines in
>the numbers file.  So if the numbers file contained
>
>10
>20
>
>the resulting output file would contain
>
>	public void test10MatchValid_UCASE() throws java.lang.Exception {
>		_testMatchUpperCase(10);
>	}
>
>	public void test10MatchValid_lcase() throws java.lang.Exception {
>		_testMatchLowerCase(10);
>	}
>
>	public void test20MatchValid_UCASE() throws java.lang.Exception {
>		_testMatchUpperCase(20);
>	}
>
>	public void test20MatchValid_lcase() throws java.lang.Exception {
>		_testMatchLowerCase(20);
>	}
>
>
>HOw would I pull this off using perl?  Thanks, - Dave

Its fairly easy, but if your iffy on Perl, this won't help much.
-sln
----------
use strict;
use warnings;

# Dummy template file ..
my $tfile = "
  public void testXMatchValid_UCASE() throws java.lang.Exception {
	_testMatchUpperCase(X);
  }
  public void testXMatchValid_lcase() throws java.lang.Exception {
	_testMatchLowerCase(X);
  }
";
# Dummy number file ..
my $nfile = "
  10
  20
";

# The program ..

open my $tfh, '<', \$tfile or die "can't open template file: $!";
open my $nfh, '<', \$nfile or die "can't open number file: $!";
#open my $outfh, '>', "output.txt" or die "can't open output file: $!";

while (<$nfh>)
{
	my ($number) = /(\d+)/;
	next if !defined($number);

	seek $tfh,0,0;
	while (my $line = <$tfh>)
	{
		$line =~ s/X/$number/;
		#print $outfh $line;
		print $line;
	}
}

close $tfh;
close $nfh;
#close $outfh;



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

Date: Wed, 14 Oct 2009 07:22:39 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: regexp assistance
Message-Id: <86r5t6jbrk.fsf@blue.stonehenge.com>

>>>>> "Peter" == Peter J Holzer <hjp-usenet2@hjp.at> writes:

Peter> Please open 'perldoc perlre' and search for \z.

"I keep searching for \z, but all I find is the end of string!"

:-)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion


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

Date: Wed, 14 Oct 2009 12:54:46 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: regexp assistance
Message-Id: <hb4vp1$ke6$1@news.eternal-september.org>

Randal L. Schwartz wrote:
>>>>>> "Peter" == Peter J Holzer <hjp-usenet2@hjp.at> writes:
> 
> Peter> Please open 'perldoc perlre' and search for \z.
> 
> "I keep searching for \z, but all I find is the end of string!"
> 
> :-)
> 


My problem is that I've been searching for $ for years and never
find enough.


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

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:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 V11 Issue 2636
***************************************


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