For Programmers: Free Programming Magazines  


Home > Archive > PERL Beginners > March 2006 > perl code help









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author perl code help
Irfan J Sayed

2006-03-23, 6:58 pm

Hi All,

I have written simple script in perl to get the user login name

Following is the script

$sessionobj = $entity->GetSession();
$username = $session->GetUserLoginName();
$entity->SetFieldValue("submitter_id", $username);

But when i am running my cq application this hook is not executing and i
am not getting proper value in field.

Can anybody plz help in this regard.

Regards
Irfan Sayed


Chas Owens

2006-03-23, 6:58 pm

On 3/23/06, Irfan J Sayed <irfsayed@in.ibm.com> wrote:
> Hi All,
>
> I have written simple script in perl to get the user login name
>
> Following is the script
>
> $sessionobj =3D $entity->GetSession();
> $username =3D $session->GetUserLoginName();
> $entity->SetFieldValue("submitter_id", $username);
>
> But when i am running my cq application this hook is not executing and i
> am not getting proper value in field.
>
> Can anybody plz help in this regard.
>
> Regards
> Irfan Sayed


Well, this can't be the entire program because $entity is never
assigned to. It would also help if you told us what you were
expecting (the proper value doesn't mean anything to us). Is cq
ClearQuest? Basically, there is a lot of missing information in your
question that makes it impossible to give you an answer.

You might want to read this article:
http://www.catb.org/~esr/faqs/smart-questions.html
Irfan J Sayed

2006-03-23, 6:58 pm

Hi Chas,

This is the only program i am using.

Plz tell me what i am doing wrong.

Regards
Irfan Sayed





"Chas Owens" <chas.owens@gmail.com>
03/23/2006 10:29 PM

To
Irfan J Sayed/India/IBM@IBMIN
cc
beginners@perl.org
Subject
Re: perl code help






On 3/23/06, Irfan J Sayed <irfsayed@in.ibm.com> wrote:
> Hi All,
>
> I have written simple script in perl to get the user login name
>
> Following is the script
>
> $sessionobj = $entity->GetSession();
> $username = $session->GetUserLoginName();
> $entity->SetFieldValue("submitter_id", $username);
>
> But when i am running my cq application this hook is not executing and i
> am not getting proper value in field.
>
> Can anybody plz help in this regard.
>
> Regards
> Irfan Sayed


Well, this can't be the entire program because $entity is never
assigned to. It would also help if you told us what you were
expecting (the proper value doesn't mean anything to us). Is cq
ClearQuest? Basically, there is a lot of missing information in your
question that makes it impossible to give you an answer.

You might want to read this article:
http://www.catb.org/~esr/faqs/smart-questions.html

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Chas Owens

2006-03-23, 6:58 pm

On 3/23/06, Irfan J Sayed <irfsayed@in.ibm.com> wrote:
>
>
> Hi Chas,
>
> This is the only program i am using.
>
> Plz tell me what i am doing wrong.
>

snip[color=darkred]
>
snip

If this is in fact the only code in your scriptname.pl file then you
have a host of problems.

All Perl scripts should start with "#!/path/to/perl" usually
"#!/usr/bin/perl". The next few lines are used to import modules
(chunks of code, like libraries in C). This is done with the use
statement. It is good practice to import the "strict" module as it
forces you to write better code. So, at the very least you should
have code that looks like

#!/usr/bin/perl

use strict;
use SomeModuleThatCreatesEntity;

my $entity =3D SomeModuleThatCreatesEntity->new;
my $sessionobj =3D $entity->GetSession();
my $username =3D $session->GetUserLoginName();
$entity->SetFieldValue("submitter_id", $username);

print "user is $username\n"; #debug code;

I have no idea what SomeModuleThatCreatesEntity will be for you as you
have not provided any information on it.
Irfan J Sayed

2006-03-23, 6:58 pm

Hi Chas,

Thanks for mail.

I am writting this script in clearquest application and i really don't
know what is the meaning of $entity. In clearquest language "An Entity
object representing a user data record"

and secound thing i am running this perl script on windows. so i really
don't know what all modules needs to be added to run this script.

plz help me.

Regards
Irfan Sayed





"Chas Owens" <chas.owens@gmail.com>
03/23/2006 10:53 PM

To
Irfan J Sayed/India/IBM@IBMIN
cc
beginners@perl.org
Subject
Re: perl code help






On 3/23/06, Irfan J Sayed <irfsayed@in.ibm.com> wrote:
>
>
> Hi Chas,
>
> This is the only program i am using.
>
> Plz tell me what i am doing wrong.
>

snip[color=darkred]
>
snip

If this is in fact the only code in your scriptname.pl file then you
have a host of problems.

All Perl scripts should start with "#!/path/to/perl" usually
"#!/usr/bin/perl". The next few lines are used to import modules
(chunks of code, like libraries in C). This is done with the use
statement. It is good practice to import the "strict" module as it
forces you to write better code. So, at the very least you should
have code that looks like

#!/usr/bin/perl

use strict;
use SomeModuleThatCreatesEntity;

my $entity = SomeModuleThatCreatesEntity->new;
my $sessionobj = $entity->GetSession();
my $username = $session->GetUserLoginName();
$entity->SetFieldValue("submitter_id", $username);

print "user is $username\n"; #debug code;

I have no idea what SomeModuleThatCreatesEntity will be for you as you
have not provided any information on it.

--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com