Re: Filling in an online form.

2011-03-29 Thread Shlomi Fish
Hi Dennis,

On Tuesday 29 Mar 2011 02:23:31 Dennis Wicks wrote:
 Greetings;
 
 I want to setup a form on a web page that a visitor can fill
 in then send it back to me by email so I can browse it
 online and print it out locally in the correct format. I
 have the way to define the input form figured out, but the
 transmission and browsing and printing the form are giving
 me trouble, to say the least!
 
 My public web server (Apache) is not local. I have a local
 Apache2 web server that I use for testing.
 
 Can anybody point me to a tutorial or example of how to do
 this? (Using perl, of course!)
 

in addition to what the other people said here, see the 
http://perl-begin.org/ resources for web-development:

http://perl-begin.org/uses/web/

I mention there Ovid's CGI course as well as Plack/PSGI (though I was told you 
can use a CGI.pm-like interface for it too now) and that you should not use 
Plack directly. 

Sawyer also gave a talk about web-devel in Perl to http://telaviv.pm.org/ but 
I cannot find the slides or notes online.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Funny Anti-Terrorism Story - http://shlom.in/enemy

Wikipedia has a page about everything including the
http://en.wikipedia.org/wiki/Kitchen_sink .

Please reply to list if it's a mailing list post - http://shlom.in/reply .

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Programmatically check for syntax errors without compiling the code

2011-03-29 Thread Magnus Woldrich


binuRX8OPobbD.bin
Description: application/pgp-encrypted


msg.asc
Description: Binary data


Re: Programmatically check for syntax errors without compiling the code

2011-03-29 Thread terry
2011-3-29 14:04, Magnus Woldrich:

Can't see any message body but with two attachments.
I'm using thunderbird 3.


-- 
terry - te...@geekmail.de

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: problem with naming of variables

2011-03-29 Thread Chas. Owens
On Mon, Mar 28, 2011 at 11:10, Katya Gorodinsky
katya.gorodin...@ecitele.com wrote:
 Maybe this way:

 @bet1 = (0,0,0,0);
 @bet2 = (0,0,0,1);
 @bet3 = (0,0,1,0);

  $random_bet_position = int(rand(3) + 1);

  $name = 'bet' . $random_bet_position;
  @selected_bet = @{$name};

Symbolic references are incredibly dangerous and mostly unnecessary in
Modern Perl.  This is why the [strict pragma][0] bans their use.  The
proper solution is to use the correct data structure (in this case an
array of arrays).

[0]: http://perldoc.perl.org/strict.html


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: perl dd

2011-03-29 Thread a b
Hey Chas,

Thanks much for your reply. I actually want to have some more control over
this.

Thinking in way to initiate some in parallel also to get rid of OS
specific things [if there]

thought of minimizing effort to run something which you suggested below. But
seems like, the only option in this galaxy :(

Thanks Everyone
Regards,
a b

On Mon, Mar 28, 2011 at 6:10 PM, Chas. Owens chas.ow...@gmail.com wrote:

 On Mon, Mar 28, 2011 at 05:22, a b testa...@gmail.com wrote:
  Thanks Rob
 
  I too was thinking that way. Just in case if any one might have face this
  issue and hence this email
 
  Well if no module i will live with it for time being
 snip

 The Unix dd command is a swiss army knife of copying data, could you
 narrow it down to what you want to use dd for?  A simple
 implementation would be

 #!/usr/bin/perl

 use strict;
 use warnings;

 die usage: $0 infile outfile\n unless @ARGV == 2;

 open my $in, :raw, $ARGV[0]
or die could not open $ARGV[0]: $!\n;
 open my $out, :raw, $ARGV[1]
or die could not open $ARGV[1]: $!\n;

 local $/ = \4096; #read 4k at a time

 print $out $_ while $in;



 --
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.



Re: perl dd

2011-03-29 Thread Filip Sneppe
Hi,

On Tue, Mar 29, 2011 at 4:57 PM, a b testa...@gmail.com wrote:
 Hey Chas,

 Thanks much for your reply. I actually want to have some more control over
 this.

 Thinking in way to initiate some in parallel also to get rid of OS
 specific things [if there]

dd is really pretty limited if you want to use it as a IO benchmarking tool
and automate stuff with it via Perl.

Perhaps you want to look at more powerful IO load tools like IOzone.
As it happens, a quick google search tells me that IOzone actually has
some Perl modules to parse its output.

Good luck  best regards,
Filip

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




transposing %d values to %x output

2011-03-29 Thread Noah Garrett Wallach

Hi there,

s/(\d+)\.(\d+)\.(\d+)\.(\d+)/$1:$2:$3:$4::0/

so is there a slick, easily readable way  to get the value $1, $2, $3, 
$4 to be rewriten as  %x instead of a %d?



Cheers,

Noah


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: transposing %d values to %x output

2011-03-29 Thread Shawn H Corey

On 11-03-29 07:50 PM, Noah Garrett Wallach wrote:

Hi there,

s/(\d+)\.(\d+)\.(\d+)\.(\d+)/$1:$2:$3:$4::0/

so is there a slick, easily readable way to get the value $1, $2, $3, $4
to be rewriten as %x instead of a %d?


s/(\d+)\.(\d+)\.(\d+)\.(\d+)/sprintf('%x:%x:%x:%x::0',$1,$2,$3,$4)/e;

See:
`perldoc -f sprintf`
`perldoc perlre` and search for /\/e/


--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

Programming is as much about organization and communication
as it is about coding.

The secret to great software:  Fail early  often.

Eliminate software piracy:  use only FLOSS.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: transposing %d values to %x output

2011-03-29 Thread Jim Gibson
On 3/29/11 Tue  Mar 29, 2011  4:50 PM, Noah Garrett Wallach
noah-l...@enabled.com scribbled:

 Hi there,
 
 s/(\d+)\.(\d+)\.(\d+)\.(\d+)/$1:$2:$3:$4::0/
 
 so is there a slick, easily readable way  to get the value $1, $2, $3,
 $4 to be rewriten as  %x instead of a %d?

Try this:

s/(\d+)\.(\d+)\.(\d+)\.(\d+)/sprintf('%x:%x:%x:%x::0',$1,$2,$3,$4/e;



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: transposing %d values to %x output

2011-03-29 Thread Chas. Owens
On Tue, Mar 29, 2011 at 19:50, Noah Garrett Wallach
noah-l...@enabled.com wrote:
snip
 s/(\d+)\.(\d+)\.(\d+)\.(\d+)/$1:$2:$3:$4::0/

 so is there a slick, easily readable way  to get the value $1, $2, $3, $4 to
 be rewriten as  %x instead of a %d?
snip

The [eval regex modifier (e)][0] will let you use an arbitrary
expression for the replacement.  You can then use [sprintf][1] to
print the captures in hexadecimal.  It is important to note that \d
doesn't match what you think it does.  Starting with Perl 5.8, \d
matches and digit character.  This includes characters such as
\x{1815} (Mongolian digit five).  To match the ASCII digit
characters you must use [0-9]:

s/([0-9]+)[.]([0-9]+)[.]([0-9]+)[.]([0-9]+)/sprintf
%02x:%02x:%02x:%02x::0, $1, $2, $3, $4/e;

It is also important to note that, if this is supposed to match an IP
Address, it will match invalid strings like 256.256.256.256.  If you
only want to match numbers between 0 and 255, it can be done using a
regex like this:

my $octet = (?:[1-9]?0-9|1[0-9]{2}|2[1-4][0-9]|25[0-5]);
s/\b($octet)[.]($octet)[.]($octet)[.]($octet)\b/sprintf
%02x:%02x:%02x:%02x::0, $1, $2, $3, $4/e;

[0]: http://perldoc.perl.org/perlop.html#s%2fPATTERN%2fREPLACEMENT%2fmsixpogce
[1]: http://perldoc.perl.org/functions/sprintf.html
-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: transposing %d values to %x output

2011-03-29 Thread Jim Gibson

At 9:18 PM -0400 3/29/11, Chas. Owens wrote:


It is important to note that \d
doesn't match what you think it does.  Starting with Perl 5.8, \d
matches and digit character.  This includes characters such as
\x{1815} (Mongolian digit five).  To match the ASCII digit
characters you must use [0-9]:


I have heard this advice before, and it just sounds silly to me. I 
deal exclusively with ASCII characters, so \d will only match the 
characters '0' through '9'. If any UTF characters have crept into my 
data unknowingly, then I have a bigger problem than too many matches. 
If I am dealing with Monogolian characters or with any other set of 
UTC characters, then I certainly want \d to match them as well. There 
is a good reason why the set of characters matched by \d was expanded.


In other words, I see no reason to avoid using \d. Advising beginners 
to avoid the use of \d is just plain wrong. Can you provide any 
example of a situation where something bad will happen from using \d?


The statement To match the ASCII digit characters you must use 
[0-9] is wrong. I believe you meant to say To match the ASCII digit 
characters and only those characters, you must use [0-9].



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: transposing %d values to %x output

2011-03-29 Thread Brian Fraser
On Tue, Mar 29, 2011 at 11:03 PM, Jim Gibson jimsgib...@gmail.com wrote:

 The statement To match the ASCII digit characters you must use [0-9] is
 wrong. I believe you meant to say To match the ASCII digit characters and
 only those characters, you must use [0-9].


Or \p{PosixDigit}; Teach new people Unicode character properties! They'll
hate/love you forever. Or (?a:\d) if they are running blead or some of the
latest releases in the 5.13 series!

Sorry, that you must use got a bit under my nails ; ) That aside though, I
agree with most of what you say. Warning beginners of the pitfalls of \d and
friends, however, is the way to go: I live in a country where ASCII doesn't
make up the entire character set, but everyone in my office seems to think
that it does. I constantly wish someone would've taught them better whenever
they started programming*.

Brian.

*(it's a Ruby job though, which makes things even more painful)


Re: transposing %d values to %x output

2011-03-29 Thread Chas. Owens
On Tue, Mar 29, 2011 at 22:03, Jim Gibson jimsgib...@gmail.com wrote:
snip
 I have heard this advice before, and it just sounds silly to me.
 I deal exclusively with ASCII characters, so \d will only match
 the characters '0' through '9'.
snip

If you are dealing exclusively with ASCII, then you should be using
the [bytes][0] pragma; however, just because you are dealing with only
ASCII today doesn't mean you will always be dealing only with ASCII.
At some point in the near future you will probably have to start
dealing with Unicode.  When that happens (and it really is a matter of
when, not if), do you want to go through all of your code and fix the
problems you could have easily avoided?

snip
 Can you provide any example of a situation where something bad
 will happen from using \d?
snip

Simple.  In the case we are talking about things will got terribly
astray if you happened to match something that wasn't [0-9]:

#!/usr/bin/perl

use strict;
use warnings;

binmode STDOUT, :utf8;

my $s = \x{ff15}.\x{ff15}.\x{ff15}.\x{ff15};

print $s\n;
$s =~ s/(\d+)[.](\d+)[.](\d+)[.](\d+)/sprintf %x.%x.%x.%x, $1, $2, $3, $4/e;
print $s\n;

5.5.5.5
Argument \x{ff15} isn't numeric in sprintf at w.pl line 11.
Argument \x{ff15} isn't numeric in sprintf at w.pl line 11.
Argument \x{ff15} isn't numeric in sprintf at w.pl line 11.
Argument \x{ff15} isn't numeric in sprintf at w.pl line 11.
0.0.0.0

The problem is that things that match \d just don't behave like
numbers.  Only ten of the hundreds of digits characters are actually
numbers.  They may look like numbers, as the Fullwidth Digit Five
characters I used here do, but Perl 5 still treats them like
non-number characters.

snip
 The statement To match the ASCII digit characters you must use [0-9] is
 wrong. I believe you meant to say To match the ASCII digit characters and
 only those characters, you must use [0-9].
snip

By your logic, it is perfectly fine to use . to match numbers.  After
all, . will match [0-9].  If you have bothered to specify \d, you most
likely mean [0-9].

[0]: http://perldoc.perl.org/bytes.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




Re: transposing %d values to %x output

2011-03-29 Thread Brian Fraser
On Wed, Mar 30, 2011 at 12:46 AM, Chas. Owens chas.ow...@gmail.com wrote:


 If you are dealing exclusively with ASCII, then you should be using
  the [bytes][0] pragma;


It's nitpicky, but I'd advice against ever recommending use bytes in the
beginners list. Or any list really. See:
http://www.nntp.perl.org/group/perl.perl5.porters/2011/03/msg170010.html

Brian.