Re: SSI errors?

2001-12-14 Thread Shawn

Hey Steven,
  Try this: 

  Then you can pull it from the %ENV hash.
Shawn

> There is one thing left, and I've tried Omi's suggestion, but I'm not sure
> how to capture the name/value pair or parameter in my Perl program.
>
> How do I capture:
> 
>
> -or-
>
> 
>
> I've tried capturing it in @ARGV but it returns 1 or 0 which I assume is
> giving me a boolean and not the string. I've searched perldoc -q ssi and
> others, but I'm not finding any clues.
>
> Thanks for your help.
> Steven



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




Re: SSI errors?

2001-12-15 Thread Shawn

Exactly why not include any params after the include?  I do it on several
sites right now...  You can't include the query string on an exec SSI, but
the include virt works just fine.

Shawn
- Original Message -
From: "Omi" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, December 15, 2001 12:39 AM
Subject: RE: SSI errors?


> > How do I capture:
> > 
> They are in %ENV.
> In this example, $ENV{'file'} is set to 'home'.
>
> And do not add query string (?file=home) after the file name
> in #include directive:
> 
>
> Omi Kikuchi
> [EMAIL PROTECTED]


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




Re: splitting a vector... or something like that!?

2002-02-06 Thread Shawn


- Original Message - 
From: "Terje Bremnes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 06, 2002 6:11 AM
Subject: splitting a vector... or something like that!?


> Hi, 
> 
> I am a beginner in writing Perl-cgi scripts, and hope you can help me
> with the following problem. I have been writing a script that uses
> the Unix "grep" function to search for a word posted to the script from
> a web form, and return the search results to a web page.
> 
> The script works well, but I am not satisfied with the layout of the
> returned website. When typing the grep command in a Unix terminal I
> get the results nicely lined up under eachother, i.e. one file per
> line, like this :
> 
> Testfile1
> Testfile2
> 
> 
> However, when printing to the web page, the resulting files are printed
> next to eachother, only separated by a blank space, like this:
> 
> Testfile1 Testfile2 ...
> 
> 
> The essence of the code is as follows : 
> 
> > $testvalue=$value[0];
> > $word = `grep -inlsh $testvalue *`;
> > print "The string $testvalue was found in these files : $word";

Try print "The string $testvalue was found in these files : $word";

Shawn

> 
> 
> Thus, what I need is a procedure that splitsthe parameter word, which stores
> the result as a vector of filenames, into separate values. I image I must
> use some kind of for-loop to do this, but exactly how I do not know...
> 
> Any help would be greatly appreciated!
> 
> Sincerely,
> Ted
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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




Re: regular expressions

2002-02-07 Thread Shawn


- Original Message -
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 07, 2002 4:37 PM
Subject: regular expressions


> Hi all,
> Do you know where I can find a good free tutorial or manual for the regular
> expressions in Perl?
> Thank you.

I don't know of a free one that is anywhere near the caliber of Mastering Regular 
Expression by
Jeffrey Friedl.  There are lots out there, but this book, after you have read it, will 
allow you to
make regex's effortlessly...

The book is by O'Reilly ISBN:1565922573 and can be had at bookpool.com for a very 
reasonable
price...

Shawn

>
> Teddy,
> My dear email address is [EMAIL PROTECTED]
>



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




Re: Passing Arrays In CGI

2002-02-07 Thread Shawn

- Original Message -
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 07, 2002 1:25 PM
Subject: Passing Arrays In CGI


> Hi there:
>
> I'm currently in a programming situation where my Perl CGI program a)
> displays an online merchandise database ... b) allows the end-user to
> select items from that database listing on an HTML page ...  c) displays a
> summary screen ... and then d) sends the info to a secured server socket.
>
> One problem I'm having now, is passing an array (a.k.a. a list) containing
> merchandise items selected to another CGI program which will then create a
> dynamic HTML summary screen.
>
> Let's say the end-user selects "milk" , "butter" ,  "eggs"
>
>  and I store those items in the array @FOOD
>
>  can I pass and entire array from one CGI Perl program to another CGI
> Perl program?
>
> How would the second program "parse out" the array variables from the
> non-array scalar variables?

Are you planning on having them go from one cgi script to another via the HTML form, 
or are you
going to call the second script directly from the first script?

Shawn

>
> Thanks.
>
> -- Al Willen
>
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


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




Re: regular expression

2002-05-17 Thread Shawn

Hey Chaoz,

  
#!/usr/bin/perl

use strict;
open(FILE,');
close(FILE);

for(@text) {
  /(d+)$/; # Match only the numbers at the end of the string
   # and store them in '$1' to be printed out on the
   # next line followed by a new line character
  print $1,"\n";
}

exit;


shawn
- Original Message - 
From: "ChaoZ InferNo" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 17, 2002 4:01 AM
Subject: regular expression


> hi all,
> 
> i am working to split the data in my array as follows but ended up clueless, 
> hoope some of u can help.
> 
> @text # contains values of a phone directory
> $text[0] contains john=012345678
> 
> $phone1 = ?
> 
> let say i wanted to grab just the values'012345678'.
> how should i go on truncating the values?
> 
> kindly advice pls.
> 
> thanks!
> 
> 
> _
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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




Re: regular expression

2002-05-17 Thread Shawn

Ok, first, thanks for the correction and input David...  I agree 100% with what you 
say.

Secondly, am I just crazy, or doesn't split USE regex?  Since this is the second 
mention the regex is overkill, and that split will work, I am a bit confused...  When 
you can say $var=split(/=|:/); it tells me this IS a regex...  hence the '//'s.  So 
how exactly is this any less overkill (powerful) than a regex?

shawn

- Original Message - 
From: "Scot Robnett" <[EMAIL PROTECTED]>
To: "ChaoZ Inferno" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, May 17, 2002 9:52 AM
Subject: RE: regular expression


> Regular expressions are overkill for what you're trying to do. It seems like
> using 'split' should do exactly what you need.
> 
> #!/usr/bin/perl -W
> 
> use strict;
> open(IN," my @list = ;
> close(IN);
> 
> for(@list) {
>  chomp;
>  my($field,$value) = split(/=/,$_); # split each line on '='
>  print "Your $field is $value. \n";
> }
> 
> 
> Scot Robnett
> inSite Internet Solutions
> [EMAIL PROTECTED]
> [EMAIL PROTECTED]
> 
> 
> -Original Message-
> From: ChaoZ Inferno [mailto:[EMAIL PROTECTED]]
> Sent: Friday, May 17, 2002 11:38 AM
> To: [EMAIL PROTECTED]
> Subject: Re: regular expression
> 
> 
> Actually, the content of the file looks something like:-
> name=john
> id=12345
> password=12345
> colour=blue
> 
> I am trying to grab the value field of each line and assigned it to be a
> variable.
> 
> I tried the regular expressions, but seems like the syntax is wrong or
> something,
> 
> @file = ; #small file anyway
> 
> $file[0] is equal to 'name=john'  but i just wanna extract john to be my
> scalar variable.
> 
> like print $name but returns john only and the same extraction method for
> the rest of the other 3 fields as well.
> 
> kindly advice!... million thanks!
> 
> 
> 
> 
> - Original Message -
> From: "David Gray" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Cc: "'ChaoZ InferNo'" <[EMAIL PROTECTED]>; "'Shawn'" <[EMAIL PROTECTED]>
> Sent: Friday, May 17, 2002 10:16 PM
> Subject: RE: regular expression
> 
> 
> > > 
> > ...
> > > for(@text) {
> > >   /(d+)$/; # Match only the numbers at the end of the string
> >  ^^
> >   this should actually be (\d+)
> >
> > I would actually conditionally print also, like so:
> >
> >  print $1 if /(\d+)$/;
> >
> > And depending on the size of the file, instead of reading the whole
> > thing into memory with
> >
> >  my @text = ();
> >
> > I would do:
> >
> >  while() {
> >print $1 if /(\d+)$/;
> >  }
> >
> > ># and store them in '$1' to be printed out on the
> > ># next line followed by a new line character
> > ...
> > > > @text # contains values of a phone directory
> > > > $text[0] contains john=012345678
> > > >
> > > > $phone1 = ?
> > > >
> > > > let say i wanted to grab just the values'012345678'.
> > > > how should i go on truncating the values?
> >
> > Cheers,
> >
> >  -dave
> >
> >
> >
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> ---
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
> 
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.351 / Virus Database: 197 - Release Date: 4/19/2002
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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




Re: regular expression

2002-05-17 Thread Shawn

> Actually, the content of the file looks something like:-
> name=john
> id=12345
> password=12345
> colour=blue

Ok, how about this then...

This is based on the fact that name, id, password, colour appear for every record 
whether they have a value or not, and that none of the values after the '=' will have 
an '=' in them.

  
#!/usr/bin/perl

use strict;
my(@name,@id,@password,@colour);
open(FILE,');
close(FILE);

for(@text) { s/.*=//; }

for(my $x=0; $x < $#text; $x+4;) {
  push @name, $text[$x];
  push @id, $text[$x+1];
  push @passowrd, $text[$x+2];
  push @colour, $text[$x+3];
}

for(@name) { print if($_); }

exit;



It is still way too early, so if you catch any errors, let me know David (or anyone 
else for that matter) :-)

shawn


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




Re: Regular expression again 8P

2002-05-20 Thread Shawn

Hey ChaoZ,

> my $var="
> GET http://us.a1.yimg.com/us.yimg.com/i/mntl/lnch/britney.jpg HTTP/1.0
> Host: us.a1.yimg.com
> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.4) Gecko/20011126 
> Netscape6/6.2.1
> Accept: text/xml, application/xml, application/xhtml+xml, text/html;q=0.9, 
> image/png, image/jpeg, image/gif;q=0.2, text/plain;q=0.8, text/css, 
> */*;q=0.1
> Accept-Language: en-us
> Accept-Encoding: gzip, deflate, compress;q=0.9
> Accept-Charset: ISO-8859-1, utf-8;q=0.66, *;q=0.66
> Connection: Close
> Proxy-Authorization: Basic 893263JHGjhgjhggjghgjh
> Referer: http://www.yahoo.com/";;
> 
> I would like to retrieve the line of Proxy Authorization:  Basic and 
> truncate it to only:-

To get just the Auth...

(my $var2=$var)=~s/^.*Proxy-Authorization: Basic //ms;
$var2=~s/\n.*$//ms;

This is unetested...

Shawn

> my $var = m/Proxy-Authorization:.+/; #should return true
> 
> But how do i truncated to only the line? and if possible, work to the below?
> 
> my $var2 = "893263JHGjhgjhggjghgjh";



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




Re: return =1

2002-06-23 Thread Shawn

Hello Octavian,
  You need to say return(0) or return(1), not return = 0 or 1.

Shawn

- Original Message - 
From: "Octavian Rasnita" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Sunday, June 23, 2002 1:33 AM
Subject: return =1


> Hi all,
> 
> If I put at the end of a subroutine a line:
> return = 0;
>  or 
> return =1;
> 
> How can I check if the return value is true or false?
> 
> I've tried with 
> if (subroutine_name) {
> 
> }
> 
> But it always give me the true value.
> 
> Am I missing something, or am I doing something wrong?
> 
> 
> Thanks.
> 
> Teddy Center for the blind: http://teddy.fcc.ro/
> Mail: [EMAIL PROTECTED]
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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




Re: Accessing Extra Information in die()

2002-07-12 Thread Shawn

> why aren't you using:
> 
> use CGI::Carp 'fatalsToBrowser';

This is VERY limited, and doesn't even catch some signals...  The best solution is to 
build a custom SIG handler that makes reference to the caller function as it is dieing 
(can be used very nicely with warnings as well).

Shawn

[snip]


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




Re: Ternary Regex Evaluation

2002-07-12 Thread Shawn

my $title;
open (FH, HTML_HOME . $directory . $content) or die "Cannot open file : $!";
while (){
  chomp;
  $title=m/(.*)<\/title>/i?$1:$content;
}
print $title;

But, I don't see how this will work to well if this file has more than one line 
(unless the title tag is on the last line of the file...)  You are iterating over 
every line, and constantly replacing $title with each pass...

Maybe add this below the $title=m/...:
last if($title ne $content); 

Shawn


- Original Message - 
From: "John Pitchko" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, July 08, 2002 11:57 AM
Subject: Ternary Regex Evaluation


Hello,

I am trying to do some pattern matching in a ternary evaluation, but it does not seem 
to work. If I place the regex into a structured if statement, it evaluates fine, but 
not in a ternary evaluation. Here is what I have so far.

my $title;
...
...
...
open FH, HTML_HOME . $directory . $content or die "Cannot open file : $!";
while ()
{
chomp;
(m/(.*)<\/title>/i) ? $title = $1 : $title = $content;
}
print $title;

Does anyone have any suggestions?

TIA

John Pitchko
Data Services
Saskatchewan Government Insurance



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




Re: "tail -f" with cgi

2002-07-12 Thread Shawn


- Original Message - 
From: "Max Clark" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, July 11, 2002 6:43 PM
Subject: "tail -f" with cgi


> Hi,

Hello Max,

> 
> I am trying to write a cgi program to "tail -f" a log file. I have a perl
> script that will open and print the log file, however it closes as soon as
> it reads whatever is in the file at that particular time. How do I mimic
> "tail -f" functionality?

This is a quick snippet of code I threw together to view file info on a win32 platform 
from the command line, that works on *nix as well.  It should be easy enough to 
convert to use from within a program.

use strict;
print "\n\n";
my $size;
open(F,"<$ARGV[0]") or die "Can't open $ARGV[0]: $!\n";
while() { $size++; }
close(F);
my ($s1,$s2)=((stat($ARGV[0]))[7],'');
for(;;){
  do {
select(undef,undef,undef,0.25);
$s2=(stat($ARGV[0]))[7];
  } until($s1!=$s2);
  $s1=$s2;
  open(F,"<$ARGV[0]") or die "Can't open $ARGV[0]: $!\n";
  my $row;
  while() {
$row++;
print "$row: $_" if($size < $row);
  }
  $size=$row;
  close(F);
}

Shawn

> 
> Thanks,
> Max



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




Re: "tail -f" with cgi

2002-07-12 Thread Shawn


- Original Message - 
From: "Bob Showalter" <[EMAIL PROTECTED]>
To: "'Max Clark'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Friday, July 12, 2002 11:08 AM
Subject: RE: "tail -f" with cgi


> > -Original Message-
> > From: Max Clark [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, July 11, 2002 7:44 PM
> > To: '[EMAIL PROTECTED]'
> > Subject: "tail -f" with cgi
> > 
> > 
> > Hi,
> > 
> > I am trying to write a cgi program to "tail -f" a log file. I 
> > have a perl
> > script that will open and print the log file, however it 
> > closes as soon as
> > it reads whatever is in the file at that particular time. How 
> > do I mimic
> > "tail -f" functionality?
> 
> CPAN has a File::Tail module.
> 
> But a CGI script isn't designed to be long-running like this. The
> web server will eventually time out the request and kill your script.

I don't think he was running from the web server, but will the shell time out in the 
same fashion?

Shawn

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


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




Re: Viruses

2002-07-18 Thread Shawn

"zentara" <[EMAIL PROTECTED]> wrote in message 
[EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> On Wed, 17 Jul 2002 23:21:06 -0400, [EMAIL PROTECTED] (Admin)
> wrote:
> 
> >Please ensure your computers are virus free before sending attachments
> >through this mailing list.  In the past 2 weeks I have received
> >notification from my Microtrend PC-cillin of no less than 6 worm/trojan
> >infected files sent through this group.  If others on this list do not have
> >adequate virus protection please beware of possible viruses circulating
> >through this email list.
> 
> I havn't received any viruii thru this list, exactly which messages are
> you talking about. Maybe you should get rid of MS Windows.

Hey, while your at it, why not stop breathing, since they come that way too...

Or maybe that is a bit harsh, I guess you could get an antibiotic instead.

Norton has seemed to work quite well for the past several years.

Shawn


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




Re: Viruses

2002-07-18 Thread Shawn

You get my point.  The business world uses MS, live with it.  I use Win2K, OS X, and 
*nix, but to say "Maybe you should get rid of MS Windows" a not even an option for 
most businesses.  Be prepared when *nix gets to a point of the average Joe being able 
to use it for the viruses to start appearing on non-MS platforms.

Shawn

- Original Message - 
From: "Camilo Gonzalez" <[EMAIL PROTECTED]>
To: "'Shawn'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, July 18, 2002 9:37 AM
Subject: RE: Viruses


> Antibiotics won't work against viruses. Like the anti-windows message
> though.
> 
> -Original Message-
> From: Shawn [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, July 18, 2002 9:21 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Viruses
> 
> 
> "zentara" <[EMAIL PROTECTED]> wrote in message
> [EMAIL PROTECTED]">news:[EMAIL PROTECTED]...
> > On Wed, 17 Jul 2002 23:21:06 -0400, [EMAIL PROTECTED] (Admin)
> > wrote:
> > 
> > >Please ensure your computers are virus free before sending attachments
> > >through this mailing list.  In the past 2 weeks I have received
> > >notification from my Microtrend PC-cillin of no less than 6 worm/trojan
> > >infected files sent through this group.  If others on this list do not
> have
> > >adequate virus protection please beware of possible viruses circulating
> > >through this email list.
> > 
> > I havn't received any viruii thru this list, exactly which messages are
> > you talking about. Maybe you should get rid of MS Windows.
> 
> Hey, while your at it, why not stop breathing, since they come that way
> too...
> 
> Or maybe that is a bit harsh, I guess you could get an antibiotic instead.
> 
> Norton has seemed to work quite well for the past several years.
> 
> Shawn
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 
> 


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




Packages, classes, cgi

2001-07-18 Thread shawn

I am in need of some direction when working with .pm(s). I have had a couple
years experience with writing straight perl scripts, but am having a hard
time with using and writing packages. I don't understand the overall process
of calling a method from an object. I've been given a project to write a
cgi/linux/perl/mysql/barcode data-center inventory application and need
guidance quick.

Can someone point me in the right direction (book or website) to learn the
internal workings of packages, classes, objects, etc...

Thanks much!
Shawn


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




double quotes within a cgi-argument

2001-08-07 Thread shawn

I've been scrounging the internet for this answer, but can't find one




EDIT




This code works, if, and only if there are _no_ double_quotes( " ) received
from the database. Yes you guessed it, there are some things that have ("'s
i.e. 17" monitor, 24" cable). As you know, double quotes end the href
string.

Question being, how to include a double quote into the href string(s)?

Thanks,
Shawn


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




FW:

2001-08-10 Thread shawn



-Original Message-
From: shawn [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 10, 2001 10:40 AM
To: perlcgi
Subject:


I'm stuck...

-using CGI.pm

I've created an "edit" cgi-forms-page to edit values/items in a database.
What I want to happen is to have the form fields ( there are several )
populated with the current value that the DB holds for the editing record.
Reason being, I don't want the user to have to fill-out everything again,
especially when they only want/need to change one  value.

The below prints out a text box and fills in the default value with the
original, why? I dunno, I haven't told CGI.pm what the -default=> is...and
yet it puts in the original value.

print $output->textfield(-name=>'title');

but

When I try the below it never has the default selected  - yes I know that
the below doesn't have -default=> , which I have tried and that doesn't
work. Why would the above have the default and the below not.

print $output->popup_menu(  -name   =>  'status',
-values =>  %status,
-size   =>  1);
Thanks,
-Shawn


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




RE: default named parameter values

2001-08-10 Thread shawn

Well I found my problem

Had nothing to do with CGI.pm. My database structure was different for one
column in two different tables( int(2) , int(3) ) and CGI was looking for a
3digit to match and was only finding a 2digit, so no default was ever
matched to the .

Also, forcing the default

print $output->popup_menu(  -name   =>  'manufacturer',
-values =>  \%manufacturer,
-default=>  $input{mftnum},
-force  =>  1,
-size   =>  1);

It took another pair of eye (co-worker) to raise the question about the
padded 2digit number.

Hope this may help someone else also.

Thanks,
-Shawn



-Original Message-
From: Moon, John [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 10, 2001 11:39 AM
To: 'shawn'; perlcgi
Subject: RE: default named parameter values


So was I ...

I could not find a very good discussing on the topic so maybe someone
else can supply some references but the "answer" is the
"-nosticky" option and pragma ... "use CGI qw/-nosticky/;"

I would guess that the idea was for the CGI user NOT to have to re-reference
a "named" parameter on a responce to a post so you may what to look at the
topic "Setting the value(s) of a named parameter" ... This was not a way I
was "use to thinking" ... I had to get out of my box ...

Hope this helps ...

I'm stuck...

-using CGI.pm

I've created an "edit" cgi-forms-page to edit values/items in a database.
What I want to happen is to have the form fields ( there are several )
populated with the current value that the DB holds for the editing record.
Reason being, I don't want the user to have to fill-out everything again,
especially when they only want/need to change one  value.

The below prints out a text box and fills in the default value with the
original, why? I dunno, I haven't told CGI.pm what the -default=> is...and
yet it puts in the original value.

print $output->textfield(-name=>'title');

but

When I try the below it never has the default selected  - yes I know that
the below doesn't have -default=> , which I have tried and that doesn't
work. Why would the above have the default and the below not.

print $output->popup_menu(  -name   =>  'status',
-values =>  %status,
-size   =>  1);
Thanks,
-Shawn


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


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




Loading an array

2004-09-01 Thread Shawn Sharp
I need some help, I am running this code to load values into the
$ArrayofCompareHex [$g] array.  Currently it is not working.  The
$comparevalue gets the correct value but the value is not past into the
array.  Here is a portion of my code.  Any ideas

 

230 my $g =0;

231 for ($g = 0; $g < $mps; ++$g)

 

{

239 $value = hex($ArrayofInput [$g]);

240 $ArrayofInputHex [$g] = $value;

241 $comparevalue = hex($ArrayofCompare [$g]);

242 $ArrayofCompareHex [$g] =$comparevalue;

}

 

thanks in advance



Apache vs Boa error LFLF

2004-09-09 Thread Shawn Sharp
I am working on some perl cgi code that works on an apache webserver but
I get the following error when I run it on a boa webserver 

 

[08/Sep/2004:23:41:09 +] cgi_header: unable to find LFLF.

 

I have tried the following change 

 

From:

print "content-type: text/html\n\n";

 

changed to:

 

 print "content-type: text/html\r\n\r\n";

 

any ideas.

 

Has anyone else seen code that works on an apache webserver but not on a
Boa server



Ignoring enter/newline in forms

2005-06-03 Thread Shawn Smith
I am attempting to write an interface to a SQL database where the user 
will be able to scan in serial numbers and such and the database will 
keep track of it.  Unfortunately, the bar code scanners that will be 
used always add {W at the beginning of what they scan, and a newline at 
the end.  I have already succeeded at removing the {W when they exist 
(it's possible the user may just type the numbers in the form instead of 
scanning it) with a regular expression ($_[0] =~ 
/(\}W)?(17)?0?-?(\d\d\d\d)/), then pulling out the desired $3.  This 
might give you an idea of how far along I am with this whole thing. I've 
only been working on this on and off for about a week.


As it is, the newline is what is giving me trouble.  See, when they scan 
it in the HTML form, the newline causes the form to submit prematurely 
(before any other fields can be filled).  I can't figure out a way to 
make it ignore these. Idealy it would just make the curser move to the 
next field.   I'm afraid I might have to use Javascript, and I'd like to 
avoid that if at all possible, because I don't know any Javascript, and 
I've already had to teach myself Perl and CGI and SQL just to do this 
thing, but I don't see how it's possible to do this server-side (or even 
if I should do this server-side).  If anyone has any ideas I'd be very 
appreciative.


-syco

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




Correct Way to read POST data

2005-08-09 Thread Shawn Devlin

Hello,

I need to read the, for lack of a better term, raw post data sent to a 
CGI script. I have the following code:


use CGI;

my $Cgi = CGI->new();

my $PostData = $Cgi->query_string;


Is this the correct/best way?

The reason I ask is that, for one user calling my script, the $PostData 
contents have the string ';keywords=' in place of any space character. 
For example, if the user was calling my script and passing 'hello 
world', $PostData would contain 'hello;keywords=world'.



Thanks,

Shawn



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




Re: uninitialized variable

2005-11-01 Thread Shawn Corey

Adedayo Adeyeye wrote:

Hello,

I'm getting an error when trying to run a script. Part of the scripts is

Line 10 my $action = param('form_action');

 .

 Line 14 Search_DB()  if($action eq 'search');

The error I get is:

 


[Tue Nov  1 16:28:41 2005] connect_script.cgi: Use of uninitialized value in
string eq at connect_rodopi.cgi line 14. 

 


How am I supposed to initialize this value?

 


Kind regards

 


Dayo

 

 






Two things you can do:

line 10: my $action = param('form_action') || '';

or

line 14: Search_DB() if( defined( $action ) && $action eq 'search' );

The first solution implies that the value '' for $action will never be 
tested for. I prefer the second one. You can always put it in its own if 
statement:


if( defined( $action )){
  # list of actions
  ...
  Search_DB() if $action eq 'search';
  ...
}else{
  # page for no action
  ...
}


--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

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




Re: indexing... in some way

2005-12-11 Thread Shawn Corey

Adriano Allora wrote:

`sort tagged_files/* | uniq > word+tag.txt`;


???

All files in tagged_files/* are unique. This looks like a lot of make 
work. Try File::Find instead. See `perldoc File::Find`.



open(IDX, ")
{
next if /^\W.+/;
open(TMP, ">indexes/$_.txt");
$where = `grep -L '$_' tagged_files/*`;


This says you are looking for the file _NOT_ in the files' content. 
Perhaps you want '-l' instead? See `man grep`.



print TMP $where;
close(TMP);
}

someone would tell me why the line with grep does not work?
Is this the fastest way?


Considering the amount of work this does outside of Perl, no. A shell 
script would be faster. (But, of course, anything written in Perl is 
automatically better than everything else ;)



--

Just my 0.0002 million dollars worth,
   --- Shawn

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_

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




Re: difference web/cli

2005-12-27 Thread Shawn Corey

Chris Devers wrote:

On Tue, 27 Dec 2005, Brano Gerzo wrote:
I am programming one script. It should be accessible as cgi-bin from 
web, and also as commandline from shell.


But I don't know how to properly handle arguments and to know, if 
script was called from commandline, or from web.


Anyone could help me ?



Probably.

Are you examining the %ENV hash ?

It will have hints as to how the script was invoked. 





If the script is called via the web server, it probably does not have 
any arguments. It could also be invoked from different users. See 
`perldoc perlvar` and search for '$<' and '$>'.



--

Just my 0.0002 million dollars worth,
   --- Shawn

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is available at http://perldoc.perl.org/

* Always write your code as though you aren't going to see it
* for another 25 years and then one day your boss comes up to you
* and says, "I want these changes and I want them yesterday!"

"Probability is now one. Any problems that are left are your own."
   SS Heart of Gold, _The Hitchhiker's Guide to the Galaxy_


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




Unsubscribing...

2006-01-19 Thread Shawn Hinchy
If you are smart enough to subscribe you should be smart enough to unsubscribe. 
Just because you are lazy, don't fill our inboxes.

Here's some help...
http://lists.cpan.org/showlist.cgi?name=beginners-cgi

Shawn





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




RE: How do I populate a form field based on the value entered in a different field

2006-09-23 Thread Shawn Hinchy
Would you mind sharing the answer?  I would assume it would have to be  
some sort of Javascript, am I wrong?


Thanks,

Shawn

Shawn Michael Hinchy
[EMAIL PROTECTED]






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




CGI Scripts and IE

2006-09-25 Thread Shawn Hinchy

Hello,

I have a script that manages a form submission.  In order to reuse the  
form creation and validation functions, I am calling the same script  
from the form using the post method.


Everything works fine in Mozilla/Firefox but when I try to use IE 6,  
it doesn't seem to call the script when the submit button is pressed,  
kind of like it knows it is already loaded and just reloads it from  
cache.  Is this possible?  How do I overcome it?


Example:

File is  : http://site.com/cgi-bin/script.cgi
.htaccess translates : http://site.com/script/ to the above address

Script calls 'http://site.com/script/' (itself) using post method.

The script acts differently whether it is called with no parameters or  
whether it is called after the submit button press and has parameters  
(action=validate, etc).


I hope my question is clear, I can help clarify as needed.

Thanks,

Shawn
----
Shawn Michael Hinchy
[EMAIL PROTECTED]






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




Re: CGI Scripts and IE

2006-09-25 Thread Shawn Hinchy

Quoting David Dorward <[EMAIL PROTECTED]>:


On Mon, Sep 25, 2006 at 10:53:15AM -0400, Shawn Hinchy wrote:

Everything works fine in Mozilla/Firefox but when I try to use IE 6,
it doesn't seem to call the script when the submit button is pressed,
kind of like it knows it is already loaded and just reloads it from
cache.  Is this possible?  How do I overcome it?



The script acts differently whether it is called with no parameters or
whether it is called after the submit button press and has parameters
(action=validate, etc).


I'd /guess/ that you have something like Bar, and you are testing for
$q->param('foo') eq 'baz' and falling over IE's problem of sending
"Bar" as the value.

... but you haven't provided anywhere near enough information about
the problem to say for sure. Real URL? HTML? Perl?

--
David Dorward  http://dorward.me.uk


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




Hi David,

That looks like it could be the culprit.  I can only wonder what it  
would send if I had a custom button there instead of text?  I will  
look at it when I get home and let you know if that is the answer, but  
that makes perfect sense now that I know IE behaves that way.  I was  
trying to get an intelligent 'action' from the script while providing  
the user with the standard 'submit' type button.  I suppose a hidden  
field would also do the same thing but with a different parameter name.


Thanks,

Shawn


Shawn Michael Hinchy
[EMAIL PROTECTED]


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




Including a file with common variables...

2006-10-07 Thread Shawn Hinchy

Hello all,

I am writing many cgi scripts and need to have the same variables  
included in each of them.  I was going to put all these 'global'  
variables in a separate file that could then be included in the top of  
each cgi script.  I am already doing a similar thing with functions  
and requiring that .pl file.  The problem is that I cannot get the  
variables to show in the main cgi script.


To include the subroutines I do this:

require './utilities.pl';

In the utilities.pl file I have this:

#!/usr/bin/perl -wT
sub foo {}
1;

I tried adding the variables to the top of this file, declared as my,  
local and our.  None of them worked.


I tried making a separate variables.pl file such as:

my globalvariable = '';

which I then tried to include using:

require './variables.pl';
use './variables.pl';
do './variables.pl';

None of these worked.  I read the perldoc for each of these functions  
and 'do' looks like the best candidate but I cannot get it to work.  I  
am sure it is something small I am overlooking.


Any suggestions?

Thanks,

Shawn

Shawn Michael Hinchy
[EMAIL PROTECTED]






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




Re: Including a file with common variables...

2006-10-08 Thread Shawn Hinchy

Quoting Ovid <[EMAIL PROTECTED]>:

--- Shawn Hinchy <[EMAIL PROTECTED]> wrote:


Hello all,

I am writing many cgi scripts and need to have the same variables
included in each of them.  I was going to put all these 'global'
variables in a separate file that could then be included in the top
of each cgi script.


I've seen people do this many times and it leads to clunky,
hard-to-debug systems.  Globals should be avoided.  Because they wind
up being spread throughout your code, it's easy for them to get altered
in one spot and not be able to figure out who altered them.  Plus,
programmers can sometimes get confused about where those variables come
from, making bugs with them more difficult to figure out.  Also, any
functions which rely on the existence of globals becomes harder to
refactor/use (e.g., moving it to a module which doesn't have the
globals causes things to break).

Sometimes you *do* have data which everything needs to know about.
Here are some suggestions:



Thank you Mumia and Ovid.  I appreciate both of your responses.  I  
agree with you Ovid, you make some very good points.  The point I  
forgot to include is that these variables are actually  
configuration-type constants.  I misnamed them by calling them  
variables.



1.  Put those variables in constants or use the 'Readonly' module from
the CPAN.
2.  If a function needs one of them, pass it as an argument.
3.  Maybe put the variables in a module where you need to explicitly
request them via Exporter.
4.  Alternately, do number 3 with a config file.



I think maybe the best solution may be to use the Readonly module.  It  
was unclear to me, however, exactly how to use it from the readme.   
I'll have to play around with it.


I have been avoiding modules because they seemed to complicate things  
a bit and I guess I don't know exactly how they work.  Besides, if I  
make a module, don't I have to install it?  I don't think I have  
access to install my own modules on my hosting server.  I guess it's  
time to do some more reading...



To include the subroutines I do this:

require './utilities.pl';


This is Perl 4 syntax.  Actually, it's Perl 3.  Please don't use that.
http://www.oreillynet.com/onlamp/blog/2006/08/please_stop_using_perl_3.html.
 I know there's still a lot of stuff out there which teaches that and
I'm sorry you've learned from that, but the sooner you avoid that, the
better.


In the utilities.pl file I have this:

#!/usr/bin/perl -wT
sub foo {}
1;


Rename that to something like 'My::Utilities' and try giving Exporter a
try, or any of its competitors.  Here's an example:

  package My::Utilities;

  use strict;
  use warnings; # if your version of Perl supports it

  use base 'Exporter';
  use vars qw(
@EXPORT_OK
$BAD_GLOBAL_VAR
some_sub
  );

  @EXPORT_OK = qw(
$BAD_GLOBAL_VAR
COMPANY_NAME
some_sub
some_other_sub
  );

  $BAD_GLOBAL_VAR = 'try to avoid globals';
  use constant COMPANY_NAME => 'Acme, Inc';

  sub some_sub {}
  sub some_other_sub {}
  sub cant_get_exported {}

  1;

And in the calling code:

  #!/usr/bin/perl -T

  use strict;
  use warnings;
  use lib 'path/to/your/modules';

  use My::Utilities qw(COMPANY_NAME some_sub $BAD_GLOBAL_VAR);

With that, you have cleaner namespaces.  You only pollute your
namespace with the specific subroutines or constants you're asking for.
 It's obvious where things are coming from.



Is that a package or a module?  I will give that a try after doing a  
little more reading.



One problem with 'utilities' modules is that they tend to get very
bloated and programmers start shoving a bunch of stuff in them with no
rhyme or reason.  Then, when you do "require './utilities.pl'", you
wind up getting a bunch of extra subroutines and if you make the
mistake of reusing *any* subroutine name in any of your files, you can
get very mysterious errors, particularly if you forget to turn warnings
on (which, to your credit, you did not :)

I've worked on systems like this and they're not fun.  I recently had a
problem on a legacy system like this where I found a sub  not declared
in the code.  Then I found it was not declared in any of the code which
was 'require'd.  Then I found it wasn't in any of the modules *they've*
required.  I found it in a module which one of the *last* one's
required.  Of course, I first tried grepping through the code, only to
find that the function name in question was reused in a number of
places, so that didn't help, either.  It was very frustrating to work
on.  The system uses some of the "features" you're asking for help
with.  Please don't make the same mistakes :)

Cheers,
Ovid


Thank you Ovid, I appreciate you taking the time to respond.   
Hope

Re: Using DBI in a web context

2006-11-14 Thread Shawn Hinchy
That's funny, I just read about this today...  See Tim Bunce's  
tutorial from the Perl 3.0 Conference.  I think it will answer some of  
your questions...


Actually I couldn't find it from 99 but here is one from 2004.

http://search.cpan.org/src/TIMB/DBI_AdvancedTalk_2004/index.htm

Shawn
----
Shawn Michael Hinchy
[EMAIL PROTECTED]


Quoting Tyler Gee <[EMAIL PROTECTED]>:


On 11/14/06, Steve Green <[EMAIL PROTECTED]> wrote:

Robert Hicks wrote:

How is it best to catch errors when doing DBI stuff in web applications?
Wrap the insert "code" in an eval statement? Croak or die statements? I
am thinking eval because I can set autocommit to "off" and then do
rollbacks if $@ has an error.


You should probably avoid eval just because it spawns a separate perl
process each time, so if this is some code that is getting hit a lot,
you could really tax your server.



The PrintError, RaiseError, and HandleError attributes of a DBI handle
provide useful ways of dealing with errors that the database returns.


This is the standard way of detecting errors with DBI.


--  SG

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






--
~Tyler

--
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>




Turning text array into variables?

2006-12-03 Thread Shawn Hinchy

Hello all,

Is there any way to turn text from an array into variables?

ie.

my @array = qw(one two three);
my $array = '$' . join(',$', @array); # should give $one,$two,$three
my ($array); # should instantiate?
$one = 1;
$two = 2;
$three = 3;
my $ans = $one + $two + $three;
print "Answer is : $ans.";

I run this but apparently 'my ($array);' doesn't really instantiate  
the variables.


Is there any way to do this?

Thanks,

Shawn


Shawn Michael Hinchy
[EMAIL PROTECTED]


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




Re: Odd select box behaviour

2007-05-02 Thread Shawn Hinchy


Quoting Jonathan Mangin <[EMAIL PROTECTED]>:



- Original Message -
From: "Jonathan Mangin" <[EMAIL PROTECTED]>
To: ; <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2007 9:51 AM
Subject: Re: Odd select box behaviour




- Original Message -
From: <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, May 01, 2007 8:21 PM
Subject: Odd select box behaviour


> This one has me stumped, and it shouldn't.
>
> I'm trying to validate data from a simple select box:
>
> 
> United States
> Canada
> 
>
> When I do:
>
> foreach my $Item (param())
> {
> my $input=param($Item);
> print "$Item  --$input--\n";
> }
>
> the data is printed out with the expected leading and trailing '--'.
>
> But when I try to validate the incoming data:
>
> my $Country=param('country');
> if ($Country ne 'Canada' || $Country ne 'United States')
> {
>$Status=1;
>$ErrMsg .= "$Mandatory{country} must be either Canada or United
> States.";
> }
>
Shouldn't that be:

if ($Country ne 'Canada' && $Country ne 'United States') {


No, I guess not.  Ignore me...



It looks to me like you were right, you want to enter the error block  
when the selected country does not match both cases, not whether you  
don't match one or the other - that'll always be true.


Shawn



And, is validation really necessary here?

--Jon


> it *always* falls through into the code block.
>
> I've stripped leading and trailing spaces from $Country. I've chomped
> $Country.
>
> This is driving me crazy, especially since there are only 2 choices in
> the select list, and one of them is already selected.
>
> Am I missing something really stupid here?
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> http://learn.perl.org/
>
>

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




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








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




Re: Odd select box behaviour

2007-05-02 Thread Shawn Hinchy

Quoting [EMAIL PROTECTED]:


Shawn Hinchy wrote:


Quoting Jonathan Mangin <[EMAIL PROTECTED]>:



- Original Message -
From: "Jonathan Mangin" <[EMAIL PROTECTED]>
To: ; <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2007 9:51 AM
Subject: Re: Odd select box behaviour




- Original Message -
From: <[EMAIL PROTECTED]>
To: 
Sent: Tuesday, May 01, 2007 8:21 PM
Subject: Odd select box behaviour



This one has me stumped, and it shouldn't.

I'm trying to validate data from a simple select box:


United States
Canada


When I do:

foreach my $Item (param())
{
my $input=param($Item);
print "$Item  --$input--\n";
}

the data is printed out with the expected leading and trailing '--'.

But when I try to validate the incoming data:

my $Country=param('country');
if ($Country ne 'Canada' || $Country ne 'United States')
{
   $Status=1;
   $ErrMsg .= "$Mandatory{country} must be either Canada or United
States.";
}


Shouldn't that be:

if ($Country ne 'Canada' && $Country ne 'United States') {


No, I guess not.  Ignore me...



It looks to me like you were right, you want to enter the error   
block when the selected country does not match both cases, not   
whether you don't match one or the other - that'll always be true.


Shawn


OMG! :) Sometimes I wonder how I dress myself. Thank you.



LOL!

We all do things like that ... well at least I do them too.  Imagine  
what programming must have been like before compilers had error  
messages?



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




Perl/DBI

2007-06-24 Thread Shawn Hinchy

Hello all,

I am getting to the point where I need to start thinking about doing  
pagination for search results.


I did some searches and it looks like there are some pagination  
modules, but I am not quite interested in going that route yet.  I am  
using a handful of columns from the search so I do not think that  
retrieving all results and then only showing a subset will be very  
efficient.  It also looks like you can execute FOUND_ROWS() after  
doing your initial query and it will give you the total results.  This  
is probably the best route, but it is not easily implemented with the  
way I have set up my functions.


Are there any other options that I have missed?  Suggestions?

Thanks,

Shawn


Shawn Michael Hinchy
[EMAIL PROTECTED]

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




Re: Perl/DBI

2007-06-24 Thread Shawn Hinchy

Quoting Tyler Gee <[EMAIL PROTECTED]>:


On 6/24/07, Shawn Hinchy <[EMAIL PROTECTED]> wrote:


Hello all,

I am getting to the point where I need to start thinking about doing
pagination for search results.

I did some searches and it looks like there are some pagination
modules, but I am not quite interested in going that route yet.  I am
using a handful of columns from the search so I do not think that
retrieving all results and then only showing a subset will be very
efficient.  It also looks like you can execute FOUND_ROWS() after
doing your initial query and it will give you the total results.  This
is probably the best route, but it is not easily implemented with the
way I have set up my functions.

Are there any other options that I have missed?  Suggestions?



If you are not interested in using the modules, it is not actually that hard
to roll your own.  In the past I have done different things for total
counts, either two separate queries, one just a 'SELECT COUNT(*)' and the
other to actually fetch the data.  Depending on your data you might be able
to add the count into your data fetching query but probably not.

Why do you not want to use the modules?


Thank you Tyler, I hadn't though about just using select COUNT(*).

I was shying away from using the modules because I knew that it wasn't  
too hard and I was afraid that I wouldn't find one that would do  
exactly what i wanted.  Then there is the concern that my needs will  
change in the future and I'll have to find and re-implement another  
module instead of just tweaking my own code.  Or maybe I just like to  
go through the pain on my own. :)


I think two separate queries will work fine for me now, I just didn't  
want to have to load all the results for fear it would be a memory hog  
and slow things down since searches will be frequent.


Thanks,

Shawn


Shawn Michael Hinchy
[EMAIL PROTECTED]

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




[beginners-cgi] Development environment?

2007-09-19 Thread Shawn Hinchy

Hello all,

I was wondering what development environment you use?  I am stuck in a  
rut using KWrite and then uploading with an FTP program.  I find that  
I use the FTP app as a launch tool and I can edit or upload the files  
from it.  Probably the biggest problem is moving back and forth  
between the cgi-bin and html folders.


Can anyone recommend one of the other linux development toolsets?   
Should I be using Kate or KDevelop?


Thanks!

Shawn


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




Re: [beginners-cgi] Development environment?

2007-09-20 Thread Shawn Hinchy
Thank you for the recommendations, Greg and Bruce.  I will take a  
closer look at them and see if one of them fits my needs from an  
editor/project management point of view.


When you get to the point that a modified file needs to be uploaded to  
the server, do any of these support this file transfer to the remote  
server?  Bruce, you said that you use svn/rsync, is it overkill to use  
rsync to upload a file that I am modifying every couple minutes to the  
server for testing?


Thank you for the help,

Shawn


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




searching for files using perl

2003-04-01 Thread Shawn Sharp
Can someone help on this one?

I created the following code to search for extention .PBD files in the
htdocs/PBD folder while using the apache webserver.  However it will only
search in the cgi-bin folder for these files.  What am I doing wrong?

#!/perl/bin/perl

use warnings;
use strict;
use CGI qw( :standard );

my $root = qq{c:/Program Files/Apache Group/Apache2/htdocs/PBD/};
opendir (DIRHANDLE, "$root");
my $glob = "*.PBD*";
my @files = glob($glob);
my $files = @files;
closedir (DIRHANDLE);

thanks



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



Loading libraies into static Perl

2004-01-19 Thread Shawn Sharp
Hey,

 

I am trying to create a stand alone (static) program in Perl (no shared
libraries).  I have tried perlcc -L /lib perl.pl but am not have any
luck. This will create an executable but you still need the shared
libraries.  I have also typing in the path of each library (ie perlcc -L
/lib/libperl.so -L /lib/libns1.so.1 perl.pl) This complied the perl
program the same.

 

Any Ideas.

 

Thanks

 

 



Re: How to do a static variable that persists from page to page

2006-04-28 Thread Mr. Shawn H. Corey
On Fri, 2006-28-04 at 14:27 -0400, Jay Savage wrote:
> It's actually Data::Dumper, and yes, it's a cpan module. It turns Perl
> data structures into a format that can be evaled to recreate the
> original structure. Storable is another cpan module--no, it's not part
> of Data::Dumper--that is designed specificaly to save complex Perl
> data structures to disk, and read them back in later.

Both Storable and Data::Dumper are part of the standard Perl install.
You should already have them on your machine. To check if a module is
already loaded:

  perl -M -e ""

Replace  with the module full name, e.g: perl -MStorable -e ""

If the module is not loaded, you will get an error message.


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Re: How to do a static variable that persists from page to page

2006-04-28 Thread Mr. Shawn H. Corey
On Fri, 2006-28-04 at 14:45 -0400, Mr. Shawn H. Corey wrote:
> Both Storable and Data::Dumper are part of the standard Perl install.
> You should already have them on your machine. To check if a module is
> already loaded:
> 
>   perl -M -e ""
> 
> Replace  with the module full name, e.g: perl -MStorable -e ""
> 
> If the module is not loaded, you will get an error message.

The documentation for any module can be read with perldoc. E.g:

  perldoc Storable
  perldoc Data::Dumper

See `perldoc perldoc` and perldoc perl` for details.


You may want to add this to all your CGIs, at least for development:

  use CGI::Carp 'fatalsToBrowser';

This will send any fatal error message to browser. This saves you the
trouble of looking thru your web server's error log to find out why your
program isn't working. See `perldoc CGI::Carp` for details.



-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Re: Multiple .cgi scripts vs. one large script

2006-06-14 Thread Mr. Shawn H. Corey
On Wed, 2006-14-06 at 16:40 -0700, Hardly Armchair wrote:
> Hello All,
> 
> I was wondering if it is more efficient (in terms of speed and processor 
> load) to have two different scripts of approximately the same size 
> called to handle two different functions, or to have one large script 
> handle all cgi functions using subroutines.  Or perhaps these situations 
> are equivalent.

And what, exactly, do you mean by efficient?

Most definitions of efficient mean getting the maximum benefit from
available resources. So, does that mean the users have minimal response
time? Or does it mean your code maintainers can fix bugs easily? Or does
it mean your site has minimal cost on the internet?

Normally, compartizing your site would mean you can deal with only one
problem at a time, without worrying about its effects on the rest of the
site. But you would have to decide exactly what efficient really means.


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Re: What is the reason for different outputs for a cgi script run from a browser and run from the command line?

2006-06-20 Thread Mr. Shawn H. Corey
On Tue, 2006-20-06 at 13:58 +0200, sfantar wrote:
> "CGIs are forked off of the web server, which normally runs under a
> "different user."
> 
> I understand the fact that's the CGIs are run by a different user.
> Is this user the same as the one who launched Apache?
> 

Maybe, it depends on the configuration of your machine. Normally,
daemons like web servers are started by init(8) which has root
privileges. This means it can change the UID of itself. When a fork
occurs, a copy of the same process is created. So, init creates a copy
of itself via fork. It changes its UID and GID. Then it exec's the
daemon. The daemon, in this case, the web server, ends up running under
its own UID and GID.

The other way for a process to run with other UID privileges is for it
to have its effective UID bit set. (See `perldoc -f stat` and search for
"mode".) This means that it is running under the UID of its file, not
its parent. Normally, theses program do a security test first thing, to
ensure the one who is running it actually should be running it. An
example is sudo(8). Take a look at its file:

  ls -l /usr/bin/sudo

Notice that its mode is : -rwsr-xr-x
The 's' means its effective UID is set.

References:
  perldoc -f stat
  perldoc -f chmod
  perldoc perlvar (and search for '$<', '$>' )

> How about mod_perl? If I run under mod_perl a script, is this one forked 
> off as well?
> 

I haven't use mod_perl in years; someone else will have to answer this.


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Re: Regex Help.

2006-06-24 Thread Mr. Shawn H. Corey
On Sun, 2006-25-06 at 00:14 +0500, Sara wrote:
> Need help to remove EVERY thing (non-alphabets, symbols, ASCII codes etc) 
> from a string except for a-zAZ, 0-9, dash and underscore.
> 
> $string =~ s/??
> 
> Thanks,
> Sara.
> 

By dash, I assume you mean ASCII character 0x2D.

English version:

  $string =~ s/[^-0-9A-Za-z_]//g;

Non-English version:

  use locale;
  use POSIX;

  $string =~ s/[^-[:alnum:]]//g;

See:
  perldoc perlretut
  perldoc perlre
  perldoc locale
  perldoc POSIX


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/



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




Re: Flushing output buffer under mod_perl

2006-07-10 Thread Mr. Shawn H. Corey
Ibrahim Dawud wrote:
> Hello,
> 
> The following code works great using normal perl but does not work
> under mod_perl:
> 
> #!/usr/bin/perl
> 
> use CGI;
> my $cgi = new CGI;
> print $cgi->header();
> print $cgi->start_html();
> $| = 1;
> print $cgi->h2("test1");
> sleep 1;
> $| = 1;
> print $cgi->h2("test2");
> sleep 1;
> $| = 1;
> print $cgi->h2("test3");
> print $cgi->end_html();
> 
> The purpose of the code is print periodic messages to the browser
> during long processing. Can someone please explain or show an example
> of how I can flush the output buffer when running the same code under
> mod_perl. According to my understanding, I have to do this at the
> level of the Apache API using rflush. The problem is that I don't know
> how to write such a handler and even if i did, i don't know how to
> call it into my existing CGI code in place of $|=1.
> 
> Suggestions are highly appreciated.
> 
> Thanks
> 

$| sets autoflush for the selected filehandle, default is STDOUT. You
need only set it once, before any output.

See:
  perldoc -q flush
  perldoc perlvar (and search for "$|")
  perldoc IO::handle


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by
doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/

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




Re: Flushing output buffer under mod_perl

2006-07-10 Thread Mr. Shawn H. Corey
Mr. Shawn H. Corey wrote:
> Ibrahim Dawud wrote:
> 
>>Hello,
>>
>>The following code works great using normal perl but does not work
>>under mod_perl:
>>

Oops, I overlooked the fact that you are using mod_perl. I haven't use
it for years but I seem to recall that STDOUT is redirected to the
socket. If that is the case (check your reference manual for mod_perl)
you would have to use the socket flush method. See `perldoc Socket` and
`perldoc IO::Socket` for details.

Also note that some web servers disable setting autoflush on their
sockets. This is because they may be handling more than one request at a
time and sending full buffers is more efficient.


-- 
__END__

Just my 0.0002 million dollars worth,
   --- Shawn

"For the things we have to learn before we can do them, we learn by
doing them."
  Aristotle

* Perl tutorials at http://perlmonks.org/?node=Tutorials
* A searchable perldoc is at http://perldoc.perl.org/

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




Re: packing an array of hashes

2007-08-07 Thread Mr. Shawn H. Corey

Chris Cosner wrote:

If you put a hash reference into an array
push @array, \%hash;
you do not store any actual hash data in the array.
So if you change the hash, then later pull the hash reference from the 
array and access it, you get changed data.


push @array, { %hash };

This creates an anonymous hash and populates it with the contents of %hash.  It 
makes a copy of %hash.  Of course, if %hash has any references, they will be 
copied but not their contents.


--
Just my 0.0002 million dollars worth,
 Shawn

"For the things we have to learn before we can do them, we learn by doing them."
 Aristotle

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




Re: about CGI

2007-08-16 Thread Mr. Shawn H. Corey

joker wrote:

I don't know Perl to build a CGI script but I know C++.  I need to
know how the server use a "file.exe" and the html page from the client
browser. In C++ the data I need to consider is stored in arrays or
variables. The html page inside the server how is stored? How a
CGI .exe can find that data? Maybe you can tell me how the Perl find
data.




OK, English is not your best language.  And you work in M$ Windows.  These are 
not criticisms.  These are facts.  If you disagree, please say so.  (No 
arguments, just facts.)

A CGI runs within the environment of the web server.  This is true whether is 
M$ Windows or *NIX.  Its current directory is either the the starting directory 
of the web server (not common) or the directory of the CGI (more common).  You 
can find your data relative to your working directory or by absolute path.

As sample of your code would help.


--
Just my 0.0002 million dollars worth,
 Shawn

"For the things we have to learn before we can do them, we learn by doing them."
 Aristotle

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