Re: Newbie needs help

2011-03-22 Thread Randal L. Schwartz
> "Geospectrum" == Geospectrum   writes:

Geospectrum> Hi am am setting up a small website and have set up formmail.pl to
Geospectrum> create a way of people asking questions.

I'm so very much hoping that you're not using Matt Wright's original
formmail.pl, and instead using the one from NMS.  Even Matt now tells
you to go get NMS:

   http://www.scriptarchive.com/nms.html

Yes, Matt's a good guy... even he knows when he's been beaten. :)

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

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




Re: Newbie needs help

2011-03-22 Thread shawn wilson
On Tue, Mar 22, 2011 at 1:05 PM, Geospectrum  wrote:

> Hi am am setting up a small website and have set up formmail.pl to
> create a way of people asking questions.
>
> I'd like now to add a way of visitors to display a HTML page by
> entering a number (invoice number) into a HTML form and then retrieve
> a html page. So I create a html page called http://www.mysite/1234.html
> and the user types in 1234 into the form and the page
> http://www.mysite/1234.html
> is retrived and displayed.
>
> I imagine I could use the perl script to create the full url and
> display the page by conctenating the domain name, invoice number
> and .html but I really have no idea about how to do this. Can I use
> the GET method of the form? I am hoping someone can point me towards a
> tutorial or offer up some snippets.
>
>
> lets go simple and then go pro here.

simple (bad) use cgi get. so www.example.com/script.pl?1234

and do something like (untested, should work):
my $page = $cgi->param( 'page' );
print $cgi->redirect( $page . ".html" );

however, you probably want to use template toolkit if you're doing simple
perl pages. personally, i use catalyst and javascript to render data (so i
don't do too much in template toolkit).

if you do catalyst, you might setup a model that looks something like this:
my $page = $c->req->param->{page};
$c->forware( "View::" . $page );

which would forward you to that tt view when you get that request. i don't
like either of these ways of doing it and if you wanted to do exactly as you
asked, just open a file handle and dump. though, my preference really is to
return json data and use js to render :)

also, this is more meta code than code - you need to do checking and what
not. i'm not sure if cgi.pm does anything to prevent me from doing:
www.example.com/script.pl?page=rm%20-rf%20%20
which may do something like:
rm -rf / .html
(html wouldn't match but / would - not good)


Newbie needs help

2011-03-22 Thread Geospectrum
Hi am am setting up a small website and have set up formmail.pl to
create a way of people asking questions.

I'd like now to add a way of visitors to display a HTML page by
entering a number (invoice number) into a HTML form and then retrieve
a html page. So I create a html page called http://www.mysite/1234.html
and the user types in 1234 into the form and the page 
http://www.mysite/1234.html
is retrived and displayed.

I imagine I could use the perl script to create the full url and
display the page by conctenating the domain name, invoice number
and .html but I really have no idea about how to do this. Can I use
the GET method of the form? I am hoping someone can point me towards a
tutorial or offer up some snippets.

Thanks


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




Re: newbie needs help with first perl prog

2009-05-08 Thread John W. Krahn

Prince Mavi wrote:

Hi folks


Hello,


I am new to perl. this is my first real program in perl.
The program is not doing what i intend it to do.
The problem in nut shell is that:
I expect to see the menu first and then input my choice.
but
the program asks for my choice first and then displays the menu

Please have a look and see what am i doing wrong.

Thanks a ton for your time guys.


code
--
#!/usr/bin/perl
use strict;
use warnings;

sub dispBlanks {
print "\n\n";
}

sub clrScr {
system("clear");
}

sub dispMenu {
clrScr;
print "\n\n=== Student Manage Pro ===\n";
print "1. Display all students\n";
print "2. Display a particular student\n";
print "3. Add a new student\n";
print "4. Delete a student\n";
print "0. Exit\n";
print "Please choose one of the options\n";
}

while (1) {
dispMenu
my $choice = ;


Your problem is here.  You are calling the subroutine 'dispMenu' with 
the argument 'my $choice = '.  In order to pass the value of the 
expression 'my $choice = ' to the subroutine 'dispMenu' the 
expression must be evaluated first so you must provide an option before 
the menu is displayed.




chomp($choice); # to remove newline
print "you chose $choice";


Once that is fixed then this line will only diplay for a tiny fraction 
of a second as you loop around and clear the screen right away.




dispBlanks;
} 
--


I would do it using strings instead of subroutines:

# #!/usr/bin/perl
use strict;
use warnings;

my $dispBlanks = "\n\n";
my $clrScr = `clear`;
my $dispMenu   = <;
chomp $choice;  # to remove newline
last if $choice == 0;
print "you chose $choice", $dispBlanks;
}

__END__



John
--
Those people who think they know everything are a great
annoyance to those of us who do.-- Isaac Asimov

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




Re: newbie needs help with first perl prog

2009-05-07 Thread Steve Bertrand
Prince Mavi wrote:
> Hi folks
> 
> I am new to perl. this is my first real program in perl.
> The program is not doing what i intend it to do.
> The problem in nut shell is that:
> I expect to see the menu first and then input my choice.
> but
> the program asks for my choice first and then displays the menu
> 
> Please have a look and see what am i doing wrong.
> 
> Thanks a ton for your time guys.

Changes that I found to make it work:

#!/usr/bin/perl
use strict;
use warnings;

sub dispBlanks {
print "\n\n";
}

sub clrScr {
system("clear");
}

sub dispMenu {
#clrScr;  # <-- commented out
print "\n\n=== Student Manage Pro ===\n";
print "1. Display all students\n";
print "2. Display a particular student\n";
print "3. Add a new student\n";
print "4. Delete a student\n";
print "0. Exit\n";
print "Please choose one of the options\n";
}

while (1) {
dispMenu(); # < missing semi-colon
my $choice = ;
chomp($choice); # to remove newline
print "you chose $choice";
dispBlanks;
}

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




Re: newbie needs help with first perl prog

2009-05-07 Thread Rhinux.xu
Prince Mavi 写道:
> Hi folks
>
> I am new to perl. this is my first real program in perl.
> The program is not doing what i intend it to do.
> The problem in nut shell is that:
> I expect to see the menu first and then input my choice.
> but
> the program asks for my choice first and then displays the menu
>
> Please have a look and see what am i doing wrong.
>
> Thanks a ton for your time guys.
>
>
> code
> --
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> sub dispBlanks {
> print "\n\n";
> }
>
> sub clrScr {
>   system("clear");
> }
>
> sub dispMenu {
> clrScr;
> print "\n\n=== Student Manage Pro ===\n";
> print "1. Display all students\n";
> print "2. Display a particular student\n";
> print "3. Add a new student\n";
> print "4. Delete a student\n";
> print "0. Exit\n";
> print "Please choose one of the options\n";
> }
>
> while (1) {
> dispMenu
> my $choice = ;
> chomp($choice);   # to remove newline
> print "you chose $choice";
> dispBlanks;
> } 
> --
>
>
>   
1 #!/usr/bin/perl -w
2 use strict;
3 use warnings;
4
5 sub dispBlanks {
6 print "\n\n";
7 }
8
9 sub clrScr {
10 system("clear");
11 }
12
13 clrScr;/ #=
14 sub dispMenu {
15 print "\n\n=== Student Manage Pro ===\n";
16 print "1. Display all students\n";
17 print "2. Display a particular student\n";
18 print "3. Add a new student\n";
19 print "4. Delete a student\n";
20 print "0. Exit\n";
21 print "Please choose one of the options\n";
22 }
23
24 my $choice = 1;
25 while ($choice) {
26 dispMenu;
27 chomp($choice = );
28 print "you chose $choice";
29 dispBlanks;
30 }

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




newbie needs help with first perl prog

2009-05-07 Thread Prince Mavi
Hi folks

I am new to perl. this is my first real program in perl.
The program is not doing what i intend it to do.
The problem in nut shell is that:
I expect to see the menu first and then input my choice.
but
the program asks for my choice first and then displays the menu

Please have a look and see what am i doing wrong.

Thanks a ton for your time guys.


code
--
#!/usr/bin/perl
use strict;
use warnings;

sub dispBlanks {
print "\n\n";
}

sub clrScr {
system("clear");
}

sub dispMenu {
clrScr;
print "\n\n=== Student Manage Pro ===\n";
print "1. Display all students\n";
print "2. Display a particular student\n";
print "3. Add a new student\n";
print "4. Delete a student\n";
print "0. Exit\n";
print "Please choose one of the options\n";
}

while (1) {
dispMenu
my $choice = ;
chomp($choice); # to remove newline
print "you chose $choice";
dispBlanks;
} 
--


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




RE: Newbie needs help changing date format

2004-08-26 Thread John Bruin
Hi Wiggins and Gunnar

Thanks for your help. I come from an excel vba background where date
formatting is a simpler process. This is what I used:

$date_next_string = strftime("%d-%b-%Y %H:%M", localtime($date_next));



From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] 
Sent: Friday, 27 August 2004 9:35 a.m.
To: John Bruin; [EMAIL PROTECTED]
Subject: Re: Newbie needs help changing date format

> Hi
> 
> I have a list of dates that have been converted to epoch seconds,
processed
> and then converted back to a string (using timelocal). The resulting 
> date format is:-
> 
> "Wed Mar 16 22:10:16 2004"
> 
> What is the easiest way to convert this format (or epoch seconds) to
> "16-Mar-2004 22:10" - preferrably using a standard module as I don't 
> have administrator rights.
> 
> Thanks
> John
> 

There are any number of modules that can do this.

Alternatively you can either use 'localtime' to get the pieces you want and
then do the conversions yourself, or you can use the 'strftime'
function of the POSIX (standard on POSIX systems) module.

perldoc POSIX
perldoc -f localtime

For more information. Note that POSIX relies on the underlying C header for
your system so you may have to 'man strftime' for the exact details, despite
the fact that it should be standard at least one part of it is not across
all systems (grrr... %z/%Z for the curious, I hit this one before).

http://danconia.org


--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/>
<http://learn.perl.org/first-response>






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: Newbie needs help changing date format

2004-08-26 Thread Gunnar Hjalmarsson
John Bruin wrote:
I have a list of dates that have been converted to epoch seconds,
processed and then converted back to a string (using timelocal).
The resulting date format is:-
"Wed Mar 16 22:10:16 2004"
What is the easiest way to convert this format (or epoch seconds)
to "16-Mar-2004 22:10" -
The easiest way, I suppose, is to use epoch seconds as the starting
point and use some module. Pick one and give it a try.
Alternatively, the string is easily converted with the s/// operator:
s[\w{3}\s+(\w{3})\s+(\d{1,2})\s+(\d\d:\d\d):\d\d\s+(\d{4})]
 [$2-$1-$4 $3]
preferrably using a standard module as I don't have administrator
rights.
If you don't have root access, modules can be installed in a local
library.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: Newbie needs help changing date format

2004-08-26 Thread Wiggins d Anconia
> Hi
> 
> I have a list of dates that have been converted to epoch seconds,
processed
> and then converted back to a string (using timelocal). The resulting date
> format is:-
> 
> "Wed Mar 16 22:10:16 2004"
> 
> What is the easiest way to convert this format (or epoch seconds) to
> "16-Mar-2004 22:10" - preferrably using a standard module as I don't have
> administrator rights. 
> 
> Thanks
> John
> 

There are any number of modules that can do this.

Alternatively you can either use 'localtime' to get the pieces you want
and then do the conversions yourself, or you can use the 'strftime'
function of the POSIX (standard on POSIX systems) module.

perldoc POSIX
perldoc -f localtime

For more information. Note that POSIX relies on the underlying C header
for your system so you may have to 'man strftime' for the exact details,
despite the fact that it should be standard at least one part of it is
not across all systems (grrr... %z/%Z for the curious, I hit this one
before).

http://danconia.org


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Newbie needs help changing date format

2004-08-26 Thread John Bruin
Hi

I have a list of dates that have been converted to epoch seconds, processed
and then converted back to a string (using timelocal). The resulting date
format is:-

"Wed Mar 16 22:10:16 2004"

What is the easiest way to convert this format (or epoch seconds) to
"16-Mar-2004 22:10" - preferrably using a standard module as I don't have
administrator rights. 

Thanks
John



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: newbie needs help

2003-07-07 Thread Janek Schleicher
Dakenah Johnson wrote at Mon, 07 Jul 2003 10:11:37 +:

> I am writing a script that uses backquotes and the ps-ef command to print 
> the UID and command for all currently running processes.

You can also use a module instead of reinventing the wheel :-)
Have a look to the CPAN module
Proc::ProcessTable, e.g.:

use Proc::ProcessTable;

my $processes = Proc::ProcessTable->new;

foreach (@{ $processes->table }) {
   printf "Owner: %s, Command: %s\n", $_->uid, $_->cmndline;
}


Greetings,
Janek

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: newbie needs help

2003-07-07 Thread Sudarshan Raghavan
dakenah johnson wrote:

Hi
I am writing a script that uses backquotes and the ps-ef command to 
print the UID and command for all currently running processes.
#!/usr/bin/perl
use strict;
my $process = `ps -ef`;
while (<>);{ 


This should flag an error, note the semi-colon
What you are reading from is the null filehandle, perldoc perlop #Search 
for 'null filehandle'
The output of ps -ef is in the $process scalar, you should either split 
$process on newlines and loop through that array or use @processes 
instead of $process

push @process = spilt (/\|/,$_);
print "Owner:[1] command:[8]


You have not closed your while loop block, quotes missing in the print 
statement



where did I go wrong? 


For starters your syntax is all wrong
Field 8 need not always be the command, sometimes it can be field 7 
(check the output of ps -ef)

My advice to you is to take look at the Proc::ProcessTable module
http://search.cpan.org/author/DURIST/Proc-ProcessTable-0.38/ProcessTable.pm
thanks,
DJ
_
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: newbie needs help

2003-07-07 Thread Rob Dixon
Hi Dakenah

Dakenah Johnson wrote:
> Hi
> I am writing a script that uses backquotes and the ps-ef command to print
> the UID and command for all currently running processes.

> #!/usr/bin/perl
> use strict;

Good!, but also

  use warnings;

> my $process = `ps -ef`;

This will pull all the lines of the 'ps' output into a single string in
$process. Is that what you want or would it be easier to have each line
in a separate array element like this?

  my @process = `ps -ef`

> while (<>);{

This is trying to read data lines from all of the files that you specified
on the command line if there were none it will try to read from STDIN
(often the keyboard).

> push @process = spilt (/\|/,$_);

This will split each line from those files on the 'pipe' character. I'm
now lost as to what you're trying to do as, as far as I know, you have
no command-line parameters and there are no 'pipe' characters in the
output of 'ps'.

> print "Owner:[1] command:[8]

Curiouser and curiouser! It looks somhow like you're trying to access
arrays, but which ones? Evene if your quotation mark were terminated
above, what you would be printed is simply

  Owner:[1] command:[8]

which I doubt is what you want!

> where did I go wrong?

It depends on what you were trying to do! Why not start here
and see if you can get seomthing useful from it.


  my @process = `ps -ef`;

  foreach my $ps (@process) {
chomp;
print $ps, "\n";
  }

This will simply display the output of 'ps' as it is arrives, but
at least you have each line in a variable and can do with it as
you will.

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



newbie needs help

2003-07-07 Thread dakenah johnson
Hi
I am writing a script that uses backquotes and the ps-ef command to print 
the UID and command for all currently running processes.
#!/usr/bin/perl
use strict;
my $process = `ps -ef`;
while (<>);{
push @process = spilt (/\|/,$_);
print "Owner:[1] command:[8]

where did I go wrong?
thanks,
DJ
_
The new MSN 8: smart spam protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: Newbie needs help with cgi/perl/forms (Thank you)

2001-08-13 Thread Candyban

"Birgit Kellner" <[EMAIL PROTECTED]> wrote in message
news:1137665400.997570078@[10.0.0.140]...
> --On Samstag, 11. August 2001 14:09 +0200 Candyban

Thank you verry much. It seem to work.
Although

my @filenames;
foreach (@names) { #for each name in the query string
if (param('$_') eq "on") { #note the double quotes around on"! - here we
demand that the value of the name must be "on"
push (@filenames, $_; } # store all elements of @names where this is true
in the array @filenames
}
is not necessary because

use CGI qw(:standard);
my $query = new CGI;
my @names = $query->param;

Already fills the array "names" only with the selected checkboxes.


I hope this answer goes into the right "section" (Cause I never used
news-servers before (except to post my previous question offcourse))

Anyways I just wanted to thank Birgit Kellner for his/her fast reaction.

Tim



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]