CGI

2009-06-09 Thread Irfan Sayed
Hi ALL,

i have written sample cgi script in perl. here it is 

#!/usr/bin/perl 
print Content-type: text/html\n\n;
print HI;
HTML
HEAD
  TITLEWelcome to CGI scripting /TITLE
    /HEAD
  /HTML
    HI

but when i am trying to execute this script it throws me an error like 

Can't find string terminator HI anywhere before EOF at ./test1 line 5.
 
please adivce
 
Regards
Irf



  

Re: CGI

2009-06-09 Thread Owen

 Hi ALL,

 i have written sample cgi script in perl. here it is

 #!/usr/bin/perl
 print Content-type: text/html\n\n;
 print HI;
 HTML
 HEAD
   TITLEWelcome to CGI scripting /TITLE
     /HEAD
   /HTML
     HI

 but when i am trying to execute this script it throws me an error like

 Can't find string terminator HI anywhere before EOF at ./test1 line
 5.


I think the HI has to aligned to the left, eg,

print HI;
HTML
HEAD
  TITLEWelcome to CGI scripting /TITLE
   /HEAD
/HTML
HI


try that


-- 



Owen


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




Re: CGI

2009-06-09 Thread Dave Tang
On Tue, 09 Jun 2009 16:16:41 +1000, Irfan Sayed  
irfan_sayed2...@yahoo.com wrote:



Hi ALL,

i have written sample cgi script in perl. here it is

#!/usr/bin/perl
print Content-type: text/html\n\n;
print HI;
HTML
HEAD
  TITLEWelcome to CGI scripting /TITLE
    /HEAD
  /HTML
    HI


Try putting the HI at the start of the line.



but when i am trying to execute this script it throws me an error like

Can't find string terminator HI anywhere before EOF at ./test1 line 5.
 
please adivce
 
Regards
Irf






--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


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




Re: CGI

2009-06-09 Thread Irfan Sayed
Thanks . it worked. 

regards
irf





From: Owen rc...@pcug.org.au
To: Irfan Sayed irfan_sayed2...@yahoo.com
Cc: beginners@perl.org
Sent: Tuesday, June 9, 2009 12:03:49 PM
Subject: Re: CGI


 Hi ALL,

 i have written sample cgi script in perl. here it is

 #!/usr/bin/perl
 print Content-type: text/html\n\n;
 print HI;
 HTML
 HEAD
   TITLEWelcome to CGI scripting /TITLE
     /HEAD
   /HTML
     HI

 but when i am trying to execute this script it throws me an error like

 Can't find string terminator HI anywhere before EOF at ./test1 line
 5.


I think the HI has to aligned to the left, eg,

print HI;
HTML
HEAD
  TITLEWelcome to CGI scripting /TITLE
  /HEAD
    /HTML
HI


try that


-- 



Owen


  

Efficiently going through results

2009-06-09 Thread Dave Tang

Hello,

I have a problem, which I have put into an analogy.

Suppose a parent has 11 children. These children like chocolate. If 9 or  
more of the 11 children from the same parent like a particular chocolate,  
the parent will like the chocolate. I want to find out what types of  
chocolate each parent likes.


I have a file listing each child's preference of chocolate (which can be  
= 1). There are +45,000 parents, each parent has 11 children and there  

are +100,000 different types of chocolate.

I guess I could parse the file and store the results in something like this

$listOfParent{$parentOne}{$childOne} = @chocolate;
...
$listOfParent{$parentOne}{$childN} = @chocolate;
...
$listOfParent{$parentN}{$childN} = @chocolate;

Then

my %result = ();
foreach my $parent (keys %listOfParent){
   my $chocolate = '';
   foreach my $child (keys %{$listOfParent}{$parent}){
  foreach ($listOfParent{$parent}{$child}){
 $chocolate = $_;
 if (exists $result{$parent}{$chocolate}){
$result{$parent}{$chocolate}++;
 } else {
$result{$parent}{$chocolate} = '1';
 }
  }
   }
}

Then go through %result and print out the =9. Is there a better way of  
doing this?


Cheers,

Dave

--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/


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




Mac::Glue with Adobe Illustrator

2009-06-09 Thread Beau E. Cox
HI -

Has anyone on this list used Mac::Glue, specifically to script Adobe
Illustrator?
I have been trying and trying to get it to work, alas, no joy.

Simple things (start Illustrator, activate, quit, etc) work, but as
soon as I start using
parameters I run into a brick wall.

This script to open an existing .ai file:

#!/usr/bin/perl

use strict;
use warnings FATAL = all;

use Mac::Glue qw( :all );

my $ill = Mac::Glue::-new( Adobe Illustrator )
  or die cannot get Illustrator: $^E\n;
my $file = video-test.ai;
$ill-open( $file, ERRORS = 1 );

yields:

rocky:test beau$ perl hello.pl
Adobe Illustrator-open(DOBJ, video-test) event failed:
errAECoercionFail (-1700)
bad parameter data or unable to coerce the data supplied

I installed Mac::Glue 1.30 against perl 5.10 using macports, I
followed the instructions
to make the Illustrator glue and made the scripting addition glues.

Any hints would be appreciated.

Aloha = Beau;

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




AW: Efficiently going through results

2009-06-09 Thread Thomas Bätzler
Dave Tang d.t...@imb.uq.edu.au asked:


 my %result = ();
 foreach my $parent (keys %listOfParent){
 my $chocolate = '';
 foreach my $child (keys %{$listOfParent}{$parent}){
foreach ($listOfParent{$parent}{$child}){
   $chocolate = $_;

Why not foreach my $chocolate ($listOfParent{$parent}{$child}){?

   if (exists $result{$parent}{$chocolate}){
  $result{$parent}{$chocolate}++;
   } else {
  $result{$parent}{$chocolate} = '1';
   }

You can just say $result{$parent}{$chocolate}++; - non-existing keys will be 
created automagically.

If you don't need to know which child likes which chocolate later on, I would 
not bother with tracking that data. Just add the preference to the parents data 
while you're reading it from file.

HTH,
Thomas



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




Re: Efficiently going through results

2009-06-09 Thread Jim Gibson
On 6/9/09 Tue  Jun 9, 2009  1:24 AM, Dave Tang d.t...@imb.uq.edu.au
scribbled:

 Hello,
 
 I have a problem, which I have put into an analogy.
 
 Suppose a parent has 11 children. These children like chocolate. If 9 or
 more of the 11 children from the same parent like a particular chocolate,
 the parent will like the chocolate. I want to find out what types of
 chocolate each parent likes.
 
 I have a file listing each child's preference of chocolate (which can be
 = 1). There are +45,000 parents, each parent has 11 children and there
 are +100,000 different types of chocolate.
 
 I guess I could parse the file and store the results in something like this
 
 $listOfParent{$parentOne}{$childOne} = @chocolate;

More precisely,

$listOfParent{$parentOne}{$childOne} = [ @chocolate ];

since hash elements must be scalars.

 ...
 $listOfParent{$parentOne}{$childN} = @chocolate;
 ...
 $listOfParent{$parentN}{$childN} = @chocolate;
 
 Then
 
 my %result = ();
 foreach my $parent (keys %listOfParent){

  foreach my $parent (keys %$listOfParent) {

(note: $listOfParent and %listOfParent are two different variables)

 my $chocolate = '';
 foreach my $child (keys %{$listOfParent}{$parent}){

  foreach my $child ( keys %{$listOfParent-{$parent}} ) {

(note: $listOfParent{$parent} is an element of %listOfParent, not an element
of the hash referenced by $listOfParent)

foreach ($listOfParent{$parent}{$child}){

 foreach ( $listOfParent-{$parent}-{$child} ) {

   $chocolate = $_;
   if (exists $result{$parent}{$chocolate}){
  $result{$parent}{$chocolate}++;
   } else {
  $result{$parent}{$chocolate} = '1';
   }

You can replace the above 5 lines with just this:

   $result{$parent}-{$chocolate}++;

as Perl will treat an undef value as zero in an increment operation.

}
 }
 }
 
 Then go through %result and print out the =9. Is there a better way of
 doing this?

If you don't care about the names of the parents and children, you could use
an array of arrays instead of a hash-of-hashes to store the preference data.
Arrays will use a little less memory storage than hashes, and access will be
a little faster. If, however, you already have your hashes created for other
purposes, then converting to arrays will probably not help.

A little whitespace sprinkled into your source code makes it more readable,
which is always a good thing when you are looking for help.



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




TCP/IP client

2009-06-09 Thread Octavian Râşniţă

Hi,

I need to create a TCP/IP client that connects to a server which accepts 
messages made from 3 parts:

- a static start string of 9 bytes;
- the body (that can have a variable length)
- a static string of 9 bytes.

...and then it gives a response that I need to get.

I've searched the CPAN for a higher level module that can help me to create 
that client, but I couldn't find anything higher level than 
IO::Socket::INET.


Does anyone know a higher level module that can be used to create such a 
TCP/IP client?


Thanks.

Octavian


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




Re: TCP/IP client

2009-06-09 Thread Chas. Owens
2009/6/9 Octavian Râşniţă orasn...@gmail.com:
 Hi,

 I need to create a TCP/IP client that connects to a server which accepts
 messages made from 3 parts:
 - a static start string of 9 bytes;
 - the body (that can have a variable length)
 - a static string of 9 bytes.

 ...and then it gives a response that I need to get.

 I've searched the CPAN for a higher level module that can help me to create
 that client, but I couldn't find anything higher level than
 IO::Socket::INET.

 Does anyone know a higher level module that can be used to create such a
 TCP/IP client?
snip

What could do what you want and be higher level?  You aren't using a
known protocol, so there will be no help there.  All you are doing is
connecting a server printing 9 bytes, a variable number of bytes, then
another 9 bytes, and then reading a number of bytes from the server.
You don't need any higher level of abstraction than a file handle
(which is effectively what IO::Socket gives you).

-- 
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: CGI scripting

2009-06-09 Thread Eko Budiharto

Irfan,
please read the readme or the user guide. I think you should modify to 
specify the virtual directory name on the apache.


Irfan Sayed wrote:




*From:* Eko Budiharto eko.budiha...@gmail.com
*To:* Irfan Sayed irfan_sayed2...@yahoo.com
*Cc:* beginners@perl.org
*Sent:* Monday, June 8, 2009 1:17:59 PM
*Subject:* Re: CGI scripting

On Mon, Jun 8, 2009 at 2:06 PM, Irfan Sayedirfan_sayed2...@yahoo.com 
mailto:irfan_sayed2...@yahoo.com wrote:

 Hi All,

 I need to configure Apache web server to execute the CGI scripts (in 
perl). Servers has windows XP operating system.
 i have downloaded apache but i am not able to see any www folder in 
the installed dir. of apache.


 do i need to configure IIS on this machine? and then manualy create 
the cgi-bin dir. and keep the perl scripts inside that?
 please let me know the steps so that i can configure the same and 
execute perl script in web browser.


first, you have to decide which web server you want to use, IIS or
apache? If you will use apache, then you need to configure the apache.
if you will use IIS, then you need to configure IIS.

--
Regards,
Eko Budiharto
GMGWEB.NET/SANGATMURAH.NET http://gmgweb.net/SANGATMURAH.NET
Jl. Kalijudan Madya V/18
Surabaya 60114
Jawa Timur
Telp: +623160214440, +628175093588
http://www.sangatmurah.net
http://www.gmgweb.net
Email: eko.budiha...@gmgweb.net mailto:eko.budiha...@gmgweb.net

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

http://learn.perl.org/

I need to use apache. can you please let me know then how shud i 
configure it so that i can execute CGI script.
 
Regards

Irf





localtime

2009-06-09 Thread Rick
below is working code but is there way to shorten this code in more 
perlish way?


my($DAY, $MONTH , $YEAR ) = (localtime)[3,4,5];

my $day   = sprintf(%02d,$DAY);
my $month = sprintf(%02d, ($MONTH + '1'));
my $year  = sprintf(%04d, ($YEAR + '1900'));

my $current_dir = join('', $year, $month, $day);

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




Re: localtime

2009-06-09 Thread Tech W.

use POSIX's function strftime:

perl -le 'use POSIX qw/strftime/;$time = strftime %Y%m%d,localtime; print 
$time'


--- On Wed, 10/6/09, Rick rich.j...@gmail.com wrote:

 From: Rick rich.j...@gmail.com
 Subject: localtime
 To: Perl Beginners beginners@perl.org
 Received: Wednesday, 10 June, 2009, 9:55 AM
 below is working code but is there
 way to shorten this code in more perlish way?
 
 my($DAY, $MONTH , $YEAR ) = (localtime)[3,4,5];
 
 my $day   = sprintf(%02d,$DAY);
 my $month = sprintf(%02d, ($MONTH + '1'));
 my $year  = sprintf(%04d, ($YEAR + '1900'));
 
 my $current_dir = join('', $year, $month, $day);
 
 -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org
 For additional commands, e-mail: beginners-h...@perl.org
 http://learn.perl.org/
 
 
 


  Need a Holiday? Win a $10,000 Holiday of your choice. Enter 
now.http://us.lrd.yahoo.com/_ylc=X3oDMTJxN2x2ZmNpBF9zAzIwMjM2MTY2MTMEdG1fZG1lY2gDVGV4dCBMaW5rBHRtX2xuawNVMTEwMzk3NwR0bV9uZXQDWWFob28hBHRtX3BvcwN0YWdsaW5lBHRtX3BwdHkDYXVueg--/SIG=14600t3ni/**http%3A//au.rd.yahoo.com/mail/tagline/creativeholidays/*http%3A//au.docs.yahoo.com/homepageset/%3Fp1=other%26p2=au%26p3=mailtagline

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




Re: localtime

2009-06-09 Thread John W. Krahn

Rick wrote:
below is working code but is there way to shorten this code in more 
perlish way?


my($DAY, $MONTH , $YEAR ) = (localtime)[3,4,5];

my $day   = sprintf(%02d,$DAY);
my $month = sprintf(%02d, ($MONTH + '1'));
my $year  = sprintf(%04d, ($YEAR + '1900'));


Why are you using a string for mathematical addition?



my $current_dir = join('', $year, $month, $day);



my ( $day, $month, $year ) = ( localtime )[ 3 .. 5 ];

my $current_dir = sprintf '%04d%02d%02d', $year + 1900, $month + 1, $day;


Or:

use POSIX 'strftime';

my $current_dir = strftime '%Y%m%d', localtime;




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

2009-06-09 Thread Greg Eldridge

Hello,

 On Mon, 2009-06-08 at 23:38 -0700, Irfan Sayed wrote:
 
 From: Owen rc...@pcug.org.au
 To: Irfan Sayed irfan_sayed2...@yahoo.com
 Cc: beginners@perl.org
 Sent: Tuesday, June 9, 2009 12:03:49 PM
 Subject: Re: CGI
 
 
  Hi ALL,
 
  i have written sample cgi script in perl. here it is
 
  #!/usr/bin/perl
  print Content-type: text/html\n\n;
  print HI;
  HTML
  HEAD
TITLEWelcome to CGI scripting /TITLE
  /HEAD
/HTML
  HI
 
  but when i am trying to execute this script it throws me an error like
 
  Can't find string terminator HI anywhere before EOF at ./test1 line
  5.
 
 
 I think the HI has to aligned to the left, eg,
 
 print HI;
 HTML
 HEAD
   TITLEWelcome to CGI scripting /TITLE
   /HEAD
 /HTML
 HI
 
 
 try that
 
 
 -- 
 
 
 
 Owen


It It has always been my understanding that perl is whitespace
irrelevant


any help would be appreciated...

Thanks,

Greg


signature.asc
Description: This is a digitally signed message part


Re: CGI

2009-06-09 Thread Owen


 Hello,

 On Mon, 2009-06-08 at 23:38 -0700, Irfan Sayed wrote:
 
 From: Owen rc...@pcug.org.au
 To: Irfan Sayed irfan_sayed2...@yahoo.com
 Cc: beginners@perl.org
 Sent: Tuesday, June 9, 2009 12:03:49 PM
 Subject: Re: CGI


  Hi ALL,
 
  i have written sample cgi script in perl. here it is
 
  #!/usr/bin/perl
  print Content-type: text/html\n\n;
  print HI;
  HTML
  HEAD
TITLEWelcome to CGI scripting /TITLE
  /HEAD
/HTML
  HI
 
  but when i am trying to execute this script it throws me an error
 like
 
  Can't find string terminator HI anywhere before EOF at ./test1
 line
  5.


 I think the HI has to aligned to the left, eg,

 print HI;
 HTML
 HEAD
   TITLEWelcome to CGI scripting /TITLE
   /HEAD
 /HTML
 HI


 try that


 --



 Owen


 It It has always been my understanding that perl is whitespace
 irrelevant


 any help would be appreciated...



I think you could modify your statement by saying ..It It has
always been my understanding that perl is generally whitespace
irrelevant but note the exception above

Also note that white space as an aid to program readability is highly
recommended

And remember that a white space or spaces in the wrong place can cause
you all sorts of grief


-- 



Owen


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




Re: TCP/IP client

2009-06-09 Thread Octavian Rasnita

From: Chas. Owens chas.ow...@gmail.com
2009/6/9 Octavian Râşniţă orasn...@gmail.com:

Hi,

I need to create a TCP/IP client that connects to a server which accepts
messages made from 3 parts:
- a static start string of 9 bytes;
- the body (that can have a variable length)
- a static string of 9 bytes.

...and then it gives a response that I need to get.

I've searched the CPAN for a higher level module that can help me to 
create

that client, but I couldn't find anything higher level than
IO::Socket::INET.

Does anyone know a higher level module that can be used to create such a
TCP/IP client?

snip

What could do what you want and be higher level?  You aren't using a
known protocol, so there will be no help there.  All you are doing is
connecting a server printing 9 bytes, a variable number of bytes, then
another 9 bytes, and then reading a number of bytes from the server.
You don't need any higher level of abstraction than a file handle
(which is effectively what IO::Socket gives you).

--
Chas. Owens

Hi Chas,

I was hoping that I could find a module that allows me to do something like:

use The::Module;

my $client = The::Module-new(PeerAddr = 'localhost:9000');

$client-send('those 3 parts of the message I want to send');

while ($client-eof) {
my $result = $client-receive();
}

(The code might not be a good one, but I think you understand what I want.)

Or can you give or tell me where I can find an example about how to create 
this simple client using IO::Socket::INET?


IO::Socket::INET doesn't give too many details about the methods it 
supports, and I need to also study IO::Socket, and Socket and finally many 
other built in perl functions or perlipc. I will study them, but I told I 
was searching for a higher level module because I am sure I will need just a 
few methods from all those offered by IO::Socket::INET.


Thanks.

Octavian


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