Re: Doubt

2015-03-29 Thread John SJ Anderson
Please show exactly what commands you ran and what output you got. In what
you're reporting, there's a typo, and it's not clear if that's a copy-paste
error or a problem in the actual command.

chrs,
john.


On Mon, Mar 30, 2015 at 1:16 AM, Frank Vino  wrote:

> When i try to install Alias.pm file from environment i was getting an
> error message as cannot locate alimas.pm file, then i checked in cpan it
> was showing, In case how to fix this and update the Alias.pm file.
>
> Frank
>


Doubt

2015-03-29 Thread Frank Vino
When i try to install Alias.pm file from environment i was getting an error
message as cannot locate alimas.pm file, then i checked in cpan it was
showing, In case how to fix this and update the Alias.pm file.

Frank


RE: First Mech script: entering a form value (another simple thing no doubt)

2013-03-14 Thread G M

Hi,

Thanks for that, yeah I can see there are no  tags on that page, I'll 
give your suggestion a go.  Thank you very much!


G :)

> Date: Thu, 14 Mar 2013 16:56:37 +
> From: dav...@preshweb.co.uk
> To: beginners@perl.org
> Subject: Re: First Mech script: entering a form value (another simple thing 
> no doubt)
> 
> On Thu, 14 Mar 2013 16:42:52 +
> G M  wrote:
> 
> > 
> > Hi,
> > 
> > Thanks for replying.  As far as I understand it will return undef if
> > no form is found.  The form is there so it should do something I
> > would've though, I tried adding in that line anyway using 1 to
> > signify the first (and only) form on the page, still get the same
> > error though :(
> 
> There are no forms on the page.
> 
>   DB<6> $mech = WWW::Mechanize->new;
>   DB<7> $mech->get(
> 'http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279');
>   DB<8> x $mech->forms;
>   empty array
> 
> See also:
> 
> [davidp@supernova:~]$ wget -q -O-
> http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279 |
> grep -i ' [davidp@supernova:~]$
> 
> WWW::Mechanize wants to be able to find a form to actually submit.
> 
> You may be able to just fake the request yourself - at a quick glance,
> it looks like it submits to http://www.easyjet.com/EN/Booking.mvc, so
> take the field names from the source of the URL you gave before, and
> POST them at that URL, and see what happens.
> 
> Failing that, you'll have to use the form in your browser while using
> an addon like Firebug or something, or capturing HTTP traffic off the
> wire, and see what happens, and make your script do the same.
> 
> 
> 
> -- 
> David Precious ("bigpresh") 
> http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
> www.preshweb.co.uk/linkedinwww.preshweb.co.uk/facebook
> www.preshweb.co.uk/cpanwww.preshweb.co.uk/github
> 
> 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
  

Re: First Mech script: entering a form value (another simple thing no doubt)

2013-03-14 Thread David Precious
On Thu, 14 Mar 2013 16:42:52 +
G M  wrote:

> 
> Hi,
> 
> Thanks for replying.  As far as I understand it will return undef if
> no form is found.  The form is there so it should do something I
> would've though, I tried adding in that line anyway using 1 to
> signify the first (and only) form on the page, still get the same
> error though :(

There are no forms on the page.

  DB<6> $mech = WWW::Mechanize->new;
  DB<7> $mech->get(
'http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279');
  DB<8> x $mech->forms;
  empty array

See also:

[davidp@supernova:~]$ wget -q -O-
http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279 |
grep -i 'http://www.easyjet.com/EN/Booking.mvc, so
take the field names from the source of the URL you gave before, and
POST them at that URL, and see what happens.

Failing that, you'll have to use the form in your browser while using
an addon like Firebug or something, or capturing HTTP traffic off the
wire, and see what happens, and make your script do the same.



-- 
David Precious ("bigpresh") 
http://www.preshweb.co.uk/ www.preshweb.co.uk/twitter
www.preshweb.co.uk/linkedinwww.preshweb.co.uk/facebook
www.preshweb.co.uk/cpanwww.preshweb.co.uk/github



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




RE: First Mech script: entering a form value (another simple thing no doubt)

2013-03-14 Thread G M

Hi,

Thanks for replying.  As far as I understand it will return undef if no form is 
found.  The form is there so it should do something I would've though, I tried 
adding in that line anyway using 1 to signify the first (and only) form on the 
page, still get the same error though :(


Cheers,

G :)


> Subject: Re: First Mech script: entering a form value (another simple thing 
> no doubt)
> From: jimsgib...@gmail.com
> Date: Thu, 14 Mar 2013 09:27:27 -0700
> To: beginners@perl.org
> 
> 
> On Mar 14, 2013, at 8:27 AM, G M wrote:
> 
> > 
> > Hi all,
> > 
> > I managed to get the problem with my script not connecting to the page last 
> > night, turned out my web host wouldn't allow it.  Got that sorted.  Filling 
> > in the form should be really simple but I'm getting the following error 
> > when trying to set the "acOriginAirport" field, I thought it might be to do 
> > with the javascript on the page but I'm entering a value that the form 
> > accepts.
> > 
> > The form is being found on the page as I can dump out $agent->forms();
> > 
> > Any ideas anyone?
> > 
> > Status: 500
> > Content-type: text/html
> > 
> > Software error:
> > Can't call method "value" on an undefined value at 
> > /usr/local/lib/perl5/site_perl/5.8.8/WWW/Mechanize.pm line 1407.
> > 
> > 
> > This is my script:
> > #!/usr/bin/perl -w
> > 
> > use strict;
> > use CGI qw(:standard);
> > use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
> > use WWW::Mechanize;
> > use HTML::TokeParser;
> > use Data::Dumper;
> > print "Content-type: text/html\n\n";
> > print "setting up mech";
> > my $agent = WWW::Mechanize->new();
> >   $agent->agent_alias('Windows Mozilla');
> > print "mech setup";
> >   
> > $agent->get('http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279');
> > print "setting up airports ";
> > $agent->field("acOriginAirport", "Glasgow GLA");
> 
> I have not used WWW::Mechanize, but from reading the documentation, it would 
> seem you must call $agent->form_number($number) with a form number before 
> making any calls to field().
> 
> Line 1407 of Mechanize.pm is part of the field method:
> 
> sub field {
> my ($self, $name, $value, $number) = @_;
> $number ||= 1;
> 
> my $form = $self->current_form();
> if ($number > 1) {
> $form->find_input($name, undef, $number)->value($value);
> }
> else {
> if ( ref($value) eq 'ARRAY' ) {
> $form->param($name, $value);
> }
> else {
> $form->value($name => $value);  # line 1407
> }
> }
> }
> 
> The current_form() method is returning null because you have not specified 
> (with a call to form_number()) which form you are using. Hence the error 
> message you are seeing.
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
> 
> 
  

Re: First Mech script: entering a form value (another simple thing no doubt)

2013-03-14 Thread Jim Gibson

On Mar 14, 2013, at 8:27 AM, G M wrote:

> 
> Hi all,
> 
> I managed to get the problem with my script not connecting to the page last 
> night, turned out my web host wouldn't allow it.  Got that sorted.  Filling 
> in the form should be really simple but I'm getting the following error when 
> trying to set the "acOriginAirport" field, I thought it might be to do with 
> the javascript on the page but I'm entering a value that the form accepts.
> 
> The form is being found on the page as I can dump out $agent->forms();
> 
> Any ideas anyone?
> 
> Status: 500
> Content-type: text/html
> 
> Software error:
> Can't call method "value" on an undefined value at 
> /usr/local/lib/perl5/site_perl/5.8.8/WWW/Mechanize.pm line 1407.
> 
> 
> This is my script:
> #!/usr/bin/perl -w
> 
> use strict;
> use CGI qw(:standard);
> use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
> use WWW::Mechanize;
> use HTML::TokeParser;
> use Data::Dumper;
> print "Content-type: text/html\n\n";
> print "setting up mech";
> my $agent = WWW::Mechanize->new();
>   $agent->agent_alias('Windows Mozilla');
> print "mech setup";
>   
> $agent->get('http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279');
> print "setting up airports ";
> $agent->field("acOriginAirport", "Glasgow GLA");

I have not used WWW::Mechanize, but from reading the documentation, it would 
seem you must call $agent->form_number($number) with a form number before 
making any calls to field().

Line 1407 of Mechanize.pm is part of the field method:

sub field {
my ($self, $name, $value, $number) = @_;
$number ||= 1;

my $form = $self->current_form();
if ($number > 1) {
$form->find_input($name, undef, $number)->value($value);
}
else {
if ( ref($value) eq 'ARRAY' ) {
$form->param($name, $value);
}
else {
$form->value($name => $value);  # line 1407
}
}
}

The current_form() method is returning null because you have not specified 
(with a call to form_number()) which form you are using. Hence the error 
message you are seeing.




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




First Mech script: entering a form value (another simple thing no doubt)

2013-03-14 Thread G M

Hi all,

I managed to get the problem with my script not connecting to the page last 
night, turned out my web host wouldn't allow it.  Got that sorted.  Filling in 
the form should be really simple but I'm getting the following error when 
trying to set the "acOriginAirport" field, I thought it might be to do with the 
javascript on the page but I'm entering a value that the form accepts.

The form is being found on the page as I can dump out $agent->forms();

Any ideas anyone?

Status: 500
Content-type: text/html

Software error:
Can't call method "value" on an undefined value at 
/usr/local/lib/perl5/site_perl/5.8.8/WWW/Mechanize.pm line 1407.


This is my script:
#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use WWW::Mechanize;
use HTML::TokeParser;
use Data::Dumper;
print "Content-type: text/html\n\n";
print "setting up mech";
my $agent = WWW::Mechanize->new();
   $agent->agent_alias('Windows Mozilla');
print "mech setup";
   
$agent->get('http://www.easyjet.com/en/searchpod.mvc/showborderless?aclwidth=279');
print "setting up airports ";
$agent->field("acOriginAirport", "Glasgow GLA");




Cheers in advance,

G :)
  

Re: XML::Twig Doubt

2012-03-20 Thread Anirban Adhikary
Thanks a lot Rob for your nice help.

Best Regards
Anirban Adhikary.

On Tue, Mar 20, 2012 at 4:38 PM, Rob Dixon  wrote:

> On 19/03/2012 14:45, Anirban Adhikary wrote:
>
>> On Mon, Mar 19, 2012 at 7:41 PM, Rob Dixon  wrote:
>>>

 XML::Twig uses callbacks to process pieces of the XML that you have
 defined. In this case you are interested only in the  start tag so
 you can define a "start tag handler". Using $twig->purge empties the
 data read so far. If you use this once you have accessed all the
 information you need from a given element there is no need to store the
 entire XML data in memory.

 The program below doeas what I think you want.

 HTH,

 Rob


 use strict;
 use warnings;

 use XML::Twig;

 my $twig = XML::Twig->new(start_tag_handlers =>  {

BSC =>  \&on_BSC
 });

 sub on_BSC {
  my($twig, $bsc)= @_;
  print $bsc->id, "\n";
  $twig->purge;
 }

 $twig->parsefile('ISProducts.xml');

>>>
>>> Thanks for your support.The code does exactly what I want
>>> .
>>> Can you please suggest me a tutorials with good examples on XML::Twig.
>>>
>>> Another thing can you please explain me this line in the code my($twig,
>>> $bsc)= @_;
>>>
>>>
>> When I am trying to print the value against the tag ALPHA it is not prints
>> anything,though it is not showing any warnings.
>>
>> use strict;
>> use warnings;
>>
>> use XML::Twig;
>>
>> my $twig = XML::Twig->new(start_tag_**handlers =>  {
>>BSC =>  \&on_BSC
>> });
>>
>> sub on_BSC {
>>  my($twig, $bsc)= @_;
>>  print $bsc->id, "\n";
>>  my $alpha = $bsc->field('ALPHA');
>>  print $alpha, "\n";
>>  $twig->purge;
>> }
>>
>> $twig->parsefile(ISProducts.**xml');
>>
>
> Hi Anirban
>
> I use the POD documentation supplied with the module, but I agree it is
> a little opaque. XML::Twig has its own website at http://xmltwig.org
> where you will find some tutorials that may help you.
>
> The line
>
>  my ($twig, $bsc)= @_;
>
> copies the values supplied as parameters to the callback into local
> variables. $twig is the XML::Twig object itself, and $bsc is an
> XML::Twig::Elt object representing the  XML element that has been
> found.
>
> You are unable to access the child elements of each  because I have
> suggested you specify "start_tag_handlers" for which only the start tag
> is available. That was fine when you just wanted the "id" attribute from
> the tag, but there is no information about any other part of the XML.
>
> You need to use "twig_handlers" instead, when the entire  element
> will be accessible using
>
>  $bsc->first_child_trimmed_**text('ALPHA')
>
> HTH,
>
> Rob
>


Re: XML::Twig Doubt

2012-03-20 Thread Rob Dixon

On 19/03/2012 14:45, Anirban Adhikary wrote:

On Mon, Mar 19, 2012 at 7:41 PM, Rob Dixon  wrote:


XML::Twig uses callbacks to process pieces of the XML that you have
defined. In this case you are interested only in the  start tag so
you can define a "start tag handler". Using $twig->purge empties the
data read so far. If you use this once you have accessed all the
information you need from a given element there is no need to store the
entire XML data in memory.

The program below doeas what I think you want.

HTH,

Rob


use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new(start_tag_**handlers =>  {
BSC =>  \&on_BSC
});

sub on_BSC {
  my($twig, $bsc)= @_;
  print $bsc->id, "\n";
  $twig->purge;
}

$twig->parsefile('ISProducts.**xml');


Thanks for your support.The code does exactly what I want .
Can you please suggest me a tutorials with good examples on XML::Twig.

Another thing can you please explain me this line in the code my($twig,
$bsc)= @_;



When I am trying to print the value against the tag ALPHA it is not prints
anything,though it is not showing any warnings.

use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new(start_tag_handlers =>  {
BSC =>  \&on_BSC
});

sub on_BSC {
  my($twig, $bsc)= @_;
  print $bsc->id, "\n";
  my $alpha = $bsc->field('ALPHA');
  print $alpha, "\n";
  $twig->purge;
}

$twig->parsefile(ISProducts.xml');


Hi Anirban

I use the POD documentation supplied with the module, but I agree it is
a little opaque. XML::Twig has its own website at http://xmltwig.org
where you will find some tutorials that may help you.

The line

  my ($twig, $bsc)= @_;

copies the values supplied as parameters to the callback into local
variables. $twig is the XML::Twig object itself, and $bsc is an
XML::Twig::Elt object representing the  XML element that has been
found.

You are unable to access the child elements of each  because I have
suggested you specify "start_tag_handlers" for which only the start tag
is available. That was fine when you just wanted the "id" attribute from
the tag, but there is no information about any other part of the XML.

You need to use "twig_handlers" instead, when the entire  element
will be accessible using

  $bsc->first_child_trimmed_text('ALPHA')

HTH,

Rob

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




Re: XML::Twig Doubt

2012-03-20 Thread Rob Dixon

On 19/03/2012 15:12, Anirban Adhikary wrote:

Hi,
When I am trying to print the value against the tag ALPHA it is not prints
anything,though it is not showing any warnings.


use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new(start_tag_handlers =>  {
BSC =>  \&on_BSC
});

sub on_BSC {
  my($twig, $bsc)= @_;
  print $bsc->id, "\n";
  my $alpha = $bsc->field('ALPHA');
  print $alpha, "\n";
  $twig->purge;
}

$twig->parsefile(ISProducts.xml');


Hi List,
When I have changed the method
from my $twig = XML::Twig->new(start_tag_
handlers =>  {
BSC =>  \&on_BSC
});
  to
my $twig = XML::Twig->new(TwigHandlers =>  {
BSC =>  \&on_BSC
});

I am able to print the value against the ALPHA tag.

Thanks to you for your support.


Hi Anirban

I suggested using start_tag_handlers because what you wanted to do was
extract the id attribute from the start tag of all  elements, so
there was no point in having any more of the element in store that just
that start tag. It is also more efficient

Changing to twig_handlers makes entirety of each "twig" (the 
element) available, so you are able to access the child elements as you
have found.

Rob

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




Re: XML::Twig Doubt

2012-03-19 Thread Anirban Adhikary
Hi List,
When I have changed the method
from my $twig = XML::Twig->new(start_tag_
handlers => {
   BSC => \&on_BSC
});
 to
my $twig = XML::Twig->new(TwigHandlers => {
   BSC => \&on_BSC
});

I am able to print the value against the ALPHA tag.

Thanks to you for your support.

Best Regards
Anirban Adhikary.


On Mon, Mar 19, 2012 at 8:15 PM, Anirban Adhikary <
anirban.adhik...@gmail.com> wrote:

> Hi,
> When I am trying to print the value against the tag ALPHA it is not prints
> anything,though it is not showing any warnings.
>
>
> use strict;
> use warnings;
>
> use XML::Twig;
>
> my $twig = XML::Twig->new(start_tag_handlers => {
>BSC => \&on_BSC
> });
>
> sub on_BSC {
>  my($twig, $bsc)= @_;
>  print $bsc->id, "\n";
>  my $alpha = $bsc->field('ALPHA');
>  print $alpha, "\n";
>  $twig->purge;
> }
>
> $twig->parsefile(ISProducts.xml');
>
>
> On Mon, Mar 19, 2012 at 7:54 PM, Anirban Adhikary <
> anirban.adhik...@gmail.com> wrote:
>
>> Hi Rob,
>> Thanks for your support.The code does exactly what I want
>> .
>> Can you please suggest me a tutorials with good examples on XML::Twig.
>>
>> Another thing can you please explain me this line in the code my($twig,
>> $bsc)= @_;
>>
>> Best Regards
>> Anirban Adhikary.
>>
>>
>> On Mon, Mar 19, 2012 at 7:41 PM, Rob Dixon  wrote:
>>
>>> On 19/03/2012 13:10, Anirban Adhikary wrote:
>>>
 Hi List,
 I have a XML file which looks like as follows

 
 

   10
   1,3,4,7
   12,16,21
   2,3,3
   1,3,6,8
   12,17,25
   50
   AMI_BRANLY_B_1
 
 .
 .

 Now my question is how to extract the value of id in a variable using
 XML::Twig.
 Since the xml file is quite large I like to print the value of id using
 a
 loop.

>>>
>>> XML::Twig uses callbacks to process pieces of the XML that you have
>>> defined. In this case you are interested only in the  start tag so
>>> you can define a "start tag handler". Using $twig->purge empties the
>>> data read so far. If you use this once you have accessed all the
>>> information you need from a given element there is no need to store the
>>> entire XML data in memory.
>>>
>>> The program below doeas what I think you want.
>>>
>>> HTH,
>>>
>>> Rob
>>>
>>>
>>> use strict;
>>> use warnings;
>>>
>>> use XML::Twig;
>>>
>>> my $twig = XML::Twig->new(start_tag_**handlers => {
>>>BSC => \&on_BSC
>>> });
>>>
>>> sub on_BSC {
>>>  my($twig, $bsc)= @_;
>>>  print $bsc->id, "\n";
>>>  $twig->purge;
>>> }
>>>
>>> $twig->parsefile('ISProducts.**xml');
>>>
>>>
>>>
>>>
>>
>


Re: XML::Twig Doubt

2012-03-19 Thread Anirban Adhikary
Hi,
When I am trying to print the value against the tag ALPHA it is not prints
anything,though it is not showing any warnings.

use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new(start_tag_handlers => {
   BSC => \&on_BSC
});

sub on_BSC {
 my($twig, $bsc)= @_;
 print $bsc->id, "\n";
 my $alpha = $bsc->field('ALPHA');
 print $alpha, "\n";
 $twig->purge;
}

$twig->parsefile(ISProducts.xml');

On Mon, Mar 19, 2012 at 7:54 PM, Anirban Adhikary <
anirban.adhik...@gmail.com> wrote:

> Hi Rob,
> Thanks for your support.The code does exactly what I want .
> Can you please suggest me a tutorials with good examples on XML::Twig.
>
> Another thing can you please explain me this line in the code my($twig,
> $bsc)= @_;
>
> Best Regards
> Anirban Adhikary.
>
>
> On Mon, Mar 19, 2012 at 7:41 PM, Rob Dixon  wrote:
>
>> On 19/03/2012 13:10, Anirban Adhikary wrote:
>>
>>> Hi List,
>>> I have a XML file which looks like as follows
>>>
>>> 
>>> 
>>>
>>>   10
>>>   1,3,4,7
>>>   12,16,21
>>>   2,3,3
>>>   1,3,6,8
>>>   12,17,25
>>>   50
>>>   AMI_BRANLY_B_1
>>> 
>>> .
>>> .
>>>
>>> Now my question is how to extract the value of id in a variable using
>>> XML::Twig.
>>> Since the xml file is quite large I like to print the value of id using a
>>> loop.
>>>
>>
>> XML::Twig uses callbacks to process pieces of the XML that you have
>> defined. In this case you are interested only in the  start tag so
>> you can define a "start tag handler". Using $twig->purge empties the
>> data read so far. If you use this once you have accessed all the
>> information you need from a given element there is no need to store the
>> entire XML data in memory.
>>
>> The program below doeas what I think you want.
>>
>> HTH,
>>
>> Rob
>>
>>
>> use strict;
>> use warnings;
>>
>> use XML::Twig;
>>
>> my $twig = XML::Twig->new(start_tag_**handlers => {
>>BSC => \&on_BSC
>> });
>>
>> sub on_BSC {
>>  my($twig, $bsc)= @_;
>>  print $bsc->id, "\n";
>>  $twig->purge;
>> }
>>
>> $twig->parsefile('ISProducts.**xml');
>>
>>
>>
>>
>


Re: XML::Twig Doubt

2012-03-19 Thread Anirban Adhikary
Hi Rob,
Thanks for your support.The code does exactly what I want .
Can you please suggest me a tutorials with good examples on XML::Twig.

Another thing can you please explain me this line in the code my($twig,
$bsc)= @_;

Best Regards
Anirban Adhikary.

On Mon, Mar 19, 2012 at 7:41 PM, Rob Dixon  wrote:

> On 19/03/2012 13:10, Anirban Adhikary wrote:
>
>> Hi List,
>> I have a XML file which looks like as follows
>>
>> 
>> 
>>
>>   10
>>   1,3,4,7
>>   12,16,21
>>   2,3,3
>>   1,3,6,8
>>   12,17,25
>>   50
>>   AMI_BRANLY_B_1
>> 
>> .
>> .
>>
>> Now my question is how to extract the value of id in a variable using
>> XML::Twig.
>> Since the xml file is quite large I like to print the value of id using a
>> loop.
>>
>
> XML::Twig uses callbacks to process pieces of the XML that you have
> defined. In this case you are interested only in the  start tag so
> you can define a "start tag handler". Using $twig->purge empties the
> data read so far. If you use this once you have accessed all the
> information you need from a given element there is no need to store the
> entire XML data in memory.
>
> The program below doeas what I think you want.
>
> HTH,
>
> Rob
>
>
> use strict;
> use warnings;
>
> use XML::Twig;
>
> my $twig = XML::Twig->new(start_tag_**handlers => {
>BSC => \&on_BSC
> });
>
> sub on_BSC {
>  my($twig, $bsc)= @_;
>  print $bsc->id, "\n";
>  $twig->purge;
> }
>
> $twig->parsefile('ISProducts.**xml');
>
>
>
>


Re: XML::Twig Doubt

2012-03-19 Thread Rob Dixon

On 19/03/2012 13:10, Anirban Adhikary wrote:

Hi List,
I have a XML file which looks like as follows




   10
   1,3,4,7
   12,16,21
   2,3,3
   1,3,6,8
   12,17,25
   50
   AMI_BRANLY_B_1
 
.
.

Now my question is how to extract the value of id in a variable using
XML::Twig.
Since the xml file is quite large I like to print the value of id using a
loop.


XML::Twig uses callbacks to process pieces of the XML that you have
defined. In this case you are interested only in the  start tag so
you can define a "start tag handler". Using $twig->purge empties the
data read so far. If you use this once you have accessed all the
information you need from a given element there is no need to store the
entire XML data in memory.

The program below doeas what I think you want.

HTH,

Rob


use strict;
use warnings;

use XML::Twig;

my $twig = XML::Twig->new(start_tag_handlers => {
BSC => \&on_BSC
});

sub on_BSC {
  my($twig, $bsc)= @_;
  print $bsc->id, "\n";
  $twig->purge;
}

$twig->parsefile('ISProducts.xml');




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




XML::Twig Doubt

2012-03-19 Thread Anirban Adhikary
Hi List,
I have a XML file which looks like as follows



   
  10
  1,3,4,7
  12,16,21
  2,3,3
  1,3,6,8
  12,17,25
  50
  AMI_BRANLY_B_1

.
.

Now my question is how to extract the value of id in a variable using
XML::Twig.
Since the xml file is quite large I like to print the value of id using a
loop.

Best Regards
Anirban Adhikary.


Re: doubt in substring

2011-01-15 Thread Kenneth Wolcott
On Sat, Jan 15, 2011 at 03:20, Dr.Ruud  wrote:
> On 2011-01-15 08:52, Emeka wrote:
>
>> rmicro@RMICRO-PC C:\Program Files\xampp
>> # perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
>> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> On Windows it should probably look like:
>
> # perl -wle "$s=q{abc def ghi jkl};print substr($s,4,-4)"
>
> (untested)
>
> --
> Ruud

That worked for me on the Windoze console.

Ken Wolcott

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




Re: doubt in substring

2011-01-15 Thread Dr.Ruud

On 2011-01-15 08:52, Emeka wrote:


rmicro@RMICRO-PC C:\Program Files\xampp
# perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
Can't find string terminator "'" anywhere before EOF at -e line 1.


On Windows it should probably look like:

# perl -wle "$s=q{abc def ghi jkl};print substr($s,4,-4)"

(untested)

--
Ruud

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




Re: doubt in substring

2011-01-15 Thread Emeka
*If I were beginning with Perl, I certainly would not practise in the
console but get an editor, such as  SciTE*
Yes, I am.

On Sat, Jan 15, 2011 at 3:04 PM, John Delacour wrote:

> On 15 January 2011 07:52, Emeka  wrote:
>
> > # perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
> > Can't find string terminator "'" anywhere before EOF at -e line 1.
> >
> > rmicro@RMICRO-PC C:\Program Files\xampp
> > #
> >
> > It failed to work for me. Why?
>
> Because you can't use single quotes for the script-string in Windows
> cmd.exe.  If you must work in the command line, then you can either
> escape all your double quotes within the string or use
> qq~double-quoted string~ , where "~" can be any ascii character that
> is not in the string itself.
>
> perl -le "$str =  qq~the cat sat on the mat~; print substr( $str, 4, -4 )"
>
> If I were beginning with Perl, I certainly would not practise in the
> console but get an editor, such as  SciTE
>
> 
>
> and run the scripts from the editor (using F5) in the case of SciTE.
>
> JD
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*Satajanus  Nig. Ltd


*


Re: doubt in substring

2011-01-15 Thread John Delacour
On 15 January 2011 07:52, Emeka  wrote:

> # perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
> Can't find string terminator "'" anywhere before EOF at -e line 1.
>
> rmicro@RMICRO-PC C:\Program Files\xampp
> #
>
> It failed to work for me. Why?

Because you can't use single quotes for the script-string in Windows
cmd.exe.  If you must work in the command line, then you can either
escape all your double quotes within the string or use
qq~double-quoted string~ , where "~" can be any ascii character that
is not in the string itself.

perl -le "$str =  qq~the cat sat on the mat~; print substr( $str, 4, -4 )"

If I were beginning with Perl, I certainly would not practise in the
console but get an editor, such as  SciTE



and run the scripts from the editor (using F5) in the case of SciTE.

JD

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




Re: doubt in substring

2011-01-14 Thread Emeka
Setting environment for using XAMPP for Windows.

rmicro@RMICRO-PC C:\Program Files\xampp
# perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
Can't find string terminator "'" anywhere before EOF at -e line 1.

rmicro@RMICRO-PC C:\Program Files\xampp
#

It failed to work for me. Why?



rmicro@RMICRO-PC C:\Program Files\xampp
# perl -v

This is perl, v5.10.1 (*) built for MSWin32-x86-multi-thread

Copyright 1987-2009, Larry Wall

Perl may be copied only under the terms of either the Artistic License or
the
GNU General Public License, which may be found in the Perl 5 source kit.

Complete documentation for Perl, including FAQ lists, should be found on
this system using "man perl" or "perldoc perl".  If you have access to the
Internet, point your browser at http://www.perl.org/, the Perl Home Page.




On Thu, Jan 13, 2011 at 3:16 PM, Shawn H Corey wrote:

> On 11-01-12 11:27 PM, Sunita Rani Pradhan wrote:
>
>> I have a string as; $str =  "the cat sat on the mat" .
>>
>>
>>
>> How the following command works substr($str , 4, -4)  on the string ?
>> What should be the output?
>>
>
> TITS (Try It To See)
>
> perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'
>
>
> --
> Just my 0.0002 million dollars worth,
>  Shawn
>
> Confusion is the first step of understanding.
>
> Programming is as much about organization and communication
> as it is about coding.
>
> The secret to great software:  Fail early & often.
>
> Eliminate software piracy:  use only FLOSS.
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


-- 
*Satajanus  Nig. Ltd


*


Re: doubt in substring

2011-01-13 Thread Shawn H Corey

On 11-01-12 11:27 PM, Sunita Rani Pradhan wrote:

 I have a string as; $str =  "the cat sat on the mat" .



How the following command works substr($str , 4, -4)  on the string ?
What should be the output?


TITS (Try It To See)

perl -le '$str =  "the cat sat on the mat";print substr( $str, 4, -4 )'


--
Just my 0.0002 million dollars worth,
  Shawn

Confusion is the first step of understanding.

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

The secret to great software:  Fail early & often.

Eliminate software piracy:  use only FLOSS.

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




Re: doubt in substring

2011-01-12 Thread C.DeRykus
On Jan 12, 8:27 pm, sunita.prad...@altair.com ("Sunita Rani Pradhan")
wrote:
> Hi All
>
>             I have a string as; $str =  "the cat sat on the mat" .
>
> How the following command works substr($str , 4, -4)  on the string ?
> What should be the output?
>

See: perldoc -f substr

Check the docs first  for explanations and examples of any
Perl builtin function.

--
Charles DeRykus


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




Re: doubt in substring

2011-01-12 Thread ashwin ts
the output will be

cat sat on the

all the characters in the string $str except four characters from the left
and right will be displayed...

Regards
Ashwin Thayyullathil Surendran



On Thu, Jan 13, 2011 at 9:57 AM, Sunita Rani Pradhan <
sunita.prad...@altair.com> wrote:

> Hi All
>
>
>
>I have a string as; $str =  "the cat sat on the mat" .
>
>
>
> How the following command works substr($str , 4, -4)  on the string ?
> What should be the output?
>
>
>
>
>
>
>
> Thanks
>
> Sunita
>
>


doubt in substring

2011-01-12 Thread Sunita Rani Pradhan
Hi All

 

I have a string as; $str =  "the cat sat on the mat" . 

 

How the following command works substr($str , 4, -4)  on the string ?
What should be the output? 

 

 

 

Thanks

Sunita



Re: Net::SNMP OID doubt

2009-11-18 Thread Venkat Saranathan
Yes, you can use the OID octets instead.

with warm regards,
Venkat Saranathan
Gulf Breeze Software.


On Wed, Nov 18, 2009 at 8:19 AM, Shameem Ahamed wrote:

> On checking the SNMPv2-SMI MIB, i found out that, corresponding to
>
> SNMPv2-SMI::enterprise i can use the 1.3.6.1.4.1
>
> Is it correct ?. Can i replace the string with this decimal values ?.
>
> Shammi
>
>
>
> - Original Message 
> > From: Shameem Ahamed 
> > To: beginners@perl.org
> > Sent: Wed, November 18, 2009 6:36:42 PM
> > Subject: Net::SNMP OID doubt
> >
> > Hi All,
> >
> > I am trying to create a script to get the logical disk status using
> Net::SNMP.
> >
> > My snmpget query is
> >
> > snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161
> > SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1
> >
> > In this , OID part is SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1
> >
> > In the Net::SNMP get_request function, I am not able to use the OID as
> above.
> > Can anyone please advise on this?. Also, how can i specify the MIB files
> to be
> > used while creating a snmp session.
> >
> > Regards,
> > Shameem
>
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>


Re: Net::SNMP OID doubt

2009-11-18 Thread Shameem Ahamed
Hi,

Thanks for the replies.  I asked in this list, because initially i thought it 
was a problem with the Net::SNMP module. Sorry for the same.

I have one more doubt. Is there any tool, which i can use for automatically 
converting this strings to OIDs.

Regards,
Shammi



- Original Message 
> From: "Hack, Gabi (ext)" 
> To: Shameem Ahamed ; "beginners@perl.org" 
> 
> Sent: Wed, November 18, 2009 7:22:52 PM
> Subject: RE: Net::SNMP OID doubt
> 
> > From: Shameem Ahamed [mailto:shameem.aha...@yahoo.com] 
> 
> > 
> > SNMPv2-SMI::enterprise i can use the 1.3.6.1.4.1
> > 
> > Is it correct ?. Can i replace the string with this decimal values ?.
> > 
> 
> It's the wrong list for your question, but yes, you can substitute all names 
> with the corresponding OIDs (e.g. if the MIB isn't available on the system). 
> And 
> yes again, it's the correct OID for  SNMPv2-SMI::enterprise
> 
> PRIVATE ENTERPRISE NUMBERS
> 
> (last updated 2009-11-18)
> 
> SMI Network Management Private Enterprise Codes:
> 
> Prefix: iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)
> 
> This file is http://www.iana.org/assignments/enterprise-numbers
> 
> > > 
> > > My snmpget query is
> > > 
> > > snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161 
> > > SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1
> 
> To find out the OID, use the output modifier "-O n". e.g.:
> 
> snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161 
> SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1 -O n
> 
> gabi



  

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




RE: Net::SNMP OID doubt

2009-11-18 Thread Hack, Gabi (ext)
> From: Shameem Ahamed [mailto:shameem.aha...@yahoo.com] 

> 
> SNMPv2-SMI::enterprise i can use the 1.3.6.1.4.1
> 
> Is it correct ?. Can i replace the string with this decimal values ?.
> 

It's the wrong list for your question, but yes, you can substitute all names 
with the corresponding OIDs (e.g. if the MIB isn't available on the system). 
And yes again, it's the correct OID for  SNMPv2-SMI::enterprise

PRIVATE ENTERPRISE NUMBERS

(last updated 2009-11-18)

SMI Network Management Private Enterprise Codes:

Prefix: iso.org.dod.internet.private.enterprise (1.3.6.1.4.1)

This file is http://www.iana.org/assignments/enterprise-numbers

> > 
> > My snmpget query is
> > 
> > snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161 
> > SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1

To find out the OID, use the output modifier "-O n". e.g.:

snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161 
SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1 -O n

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




Re: Net::SNMP OID doubt

2009-11-18 Thread Shameem Ahamed
On checking the SNMPv2-SMI MIB, i found out that, corresponding to 

SNMPv2-SMI::enterprise i can use the 1.3.6.1.4.1

Is it correct ?. Can i replace the string with this decimal values ?.

Shammi



- Original Message 
> From: Shameem Ahamed 
> To: beginners@perl.org
> Sent: Wed, November 18, 2009 6:36:42 PM
> Subject: Net::SNMP OID doubt
> 
> Hi All,
> 
> I am trying to create a script to get the logical disk status using Net::SNMP.
> 
> My snmpget query is
> 
> snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161 
> SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1
> 
> In this , OID part is SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1
> 
> In the Net::SNMP get_request function, I am not able to use the OID as above. 
>  
> Can anyone please advise on this?. Also, how can i specify the MIB files to 
> be 
> used while creating a snmp session.
> 
> Regards,
> Shameem



  

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




Net::SNMP OID doubt

2009-11-18 Thread Shameem Ahamed
Hi All,

I am trying to create a script to get the logical disk status using Net::SNMP.

My snmpget query is

snmpget -v2c -t 1 -r 9 -m ALL -v 1 -c public localhost:161 
SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1

In this , OID part is SNMPv2-SMI::enterprises.1714.1.1.2.1.6.1

In the Net::SNMP get_request function, I am not able to use the OID as above.  
Can anyone please advise on this?. Also, how can i specify the MIB files to be 
used while creating a snmp session.

Regards,
Shameem



  

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




RE: Doubt in Spreadsheet::ParseExcel

2008-10-29 Thread Stewart Anderson
 

  _  

From: anitha victor [mailto:[EMAIL PROTECTED] 
Sent: 29 October 2008 08:54
To: beginners@perl.org
Subject: Doubt in Spreadsheet::ParseExcel

 

Hi Team,

  I want a code snippet for retrieving the content in xcel sheet in a
variable.

Thanks in advance 

The CPAN documentation for this module is  great.

 

I used it forst time without any major difficulties - except  being a
noob to Perl!!

 

Stu

 

Information in this email including any attachments may be privileged, 
confidential and is intended exclusively for the addressee. The views expressed 
may not be official policy, but the personal views of the originator. If you 
have received it in error, please notify the sender by return e-mail and delete 
it from your system. You should not reproduce, distribute, store, retransmit, 
use or disclose its contents to anyone. Please note we reserve the right to 
monitor all e-mail communication through our internal and external networks. 
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and 
are used under licence. British Sky Broadcasting Limited (Registration No. 
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home 
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited 
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky 
Broadcasting Group plc (Registration No. 2247735). All of the companies 
mentioned in this paragraph are incorporated in England and Wales and share the 
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.
<>

Doubt in Spreadsheet::ParseExcel

2008-10-29 Thread anitha victor
Hi Team,

  I want a code snippet for retrieving the content in xcel sheet in a
variable.

Thanks in advance[?]

---
Anitha victor
<<328.png>>

Re: doubt in code

2008-08-22 Thread Dr.Ruud
"Irfan J Sayed (isayed)" schreef:


Irfan, trim your postings. Cut out any piece of text that is no longer
relevant. You quoted all the nonsense that Stewart Anderson thinks he
needs to include. Clean up your act.


> Agree, but where is the file name??
> $server will just store the server name right?

There is no file involved. Did you read `perldoc IO::Socket`?

-- 
Affijn, Ruud

"Gewoon is een tijger."


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




RE: doubt in code

2008-08-21 Thread Irfan J Sayed (isayed)

Hi,

Can somebody please help.

Regards
Irfan. 

-Original Message-
From: Irfan J Sayed (isayed) 
Sent: Friday, August 22, 2008 11:12 AM
To: 'Stewart Anderson'; beginners@perl.org
Subject: RE: doubt in code

Agree, but where is the file name??
$server will just store the server name right?

Regards
Irf 

-Original Message-
From: Stewart Anderson [mailto:[EMAIL PROTECTED]
Sent: Thursday, August 21, 2008 8:25 PM
To: beginners@perl.org
Cc: Stewart Anderson
Subject: RE: doubt in code


> -Original Message-
> From: Irfan J Sayed (isayed) [mailto:[EMAIL PROTECTED]
> Sent: 21 August 2008 15:49
> To: beginners@perl.org
> Subject: doubt in code
> 
> Hi All,
> 
> I have sample code like this:
> 
> #!/usr/bin/perl
> 
> # file: lgetr.pl
> 
> # Figure 1.2: Read the first line from a remote server
> 
> use IO::Socket;
> 
> my $server = shift;
> 
> my $fh = IO::Socket::INET->new($server);
> 
> my $line = <$fh>;
> 
> print $line;
> 
> As per comment it says that, it prints the first line of a file from 
> remote server. So my understanding is that, it will go to remote 
> server,read the file and then prints the first line of a file on the 
> existing console. is it right ?? if yes then in the code where are we 
> giving the filename??
> 
> Please suggest.
> 
> Regards
> 
> Irfan.
> 
> 

[Stewart Anderson] 

 my $fh = IO::Socket::INET->new($server);

is   where the  file handle $fh gets assigned



Information in this email including any attachments may be privileged,
confidential and is intended exclusively for the addressee. The views
expressed may not be official policy, but the personal views of the
originator. If you have received it in error, please notify the sender
by return e-mail and delete it from your system. You should not
reproduce, distribute, store, retransmit, use or disclose its contents
to anyone. Please note we reserve the right to monitor all e-mail
communication through our internal and external networks. SKY and the
SKY marks are trade marks of British Sky Broadcasting Group plc and are
used under licence. British Sky Broadcasting Limited (Registration No.
2906991), Sky Interactive Limited (Registration No. 3554332),
Sky-In-Home Service Limited (Registration No. 2067075) and Sky
Subscribers Services Limited (Registration No. 2340150) are direct or
indirect subsidiaries of British Sky Broadcasting Group plc
(Registration No. 2247735). All of the companies mentioned in this
paragraph are incorporated in England and Wales and share the same
registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

--
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: doubt in code

2008-08-21 Thread Irfan J Sayed (isayed)
Agree, but where is the file name??
$server will just store the server name right?

Regards
Irf 

-Original Message-
From: Stewart Anderson [mailto:[EMAIL PROTECTED] 
Sent: Thursday, August 21, 2008 8:25 PM
To: beginners@perl.org
Cc: Stewart Anderson
Subject: RE: doubt in code


> -Original Message-
> From: Irfan J Sayed (isayed) [mailto:[EMAIL PROTECTED]
> Sent: 21 August 2008 15:49
> To: beginners@perl.org
> Subject: doubt in code
> 
> Hi All,
> 
> I have sample code like this:
> 
> #!/usr/bin/perl
> 
> # file: lgetr.pl
> 
> # Figure 1.2: Read the first line from a remote server
> 
> use IO::Socket;
> 
> my $server = shift;
> 
> my $fh = IO::Socket::INET->new($server);
> 
> my $line = <$fh>;
> 
> print $line;
> 
> As per comment it says that, it prints the first line of a file from 
> remote server. So my understanding is that, it will go to remote 
> server,read the file and then prints the first line of a file on the 
> existing console. is it right ?? if yes then in the code where are we 
> giving the filename??
> 
> Please suggest.
> 
> Regards
> 
> Irfan.
> 
> 

[Stewart Anderson] 

 my $fh = IO::Socket::INET->new($server);

is   where the  file handle $fh gets assigned



Information in this email including any attachments may be privileged,
confidential and is intended exclusively for the addressee. The views
expressed may not be official policy, but the personal views of the
originator. If you have received it in error, please notify the sender
by return e-mail and delete it from your system. You should not
reproduce, distribute, store, retransmit, use or disclose its contents
to anyone. Please note we reserve the right to monitor all e-mail
communication through our internal and external networks. SKY and the
SKY marks are trade marks of British Sky Broadcasting Group plc and are
used under licence. British Sky Broadcasting Limited (Registration No.
2906991), Sky Interactive Limited (Registration No. 3554332),
Sky-In-Home Service Limited (Registration No. 2067075) and Sky
Subscribers Services Limited (Registration No. 2340150) are direct or
indirect subsidiaries of British Sky Broadcasting Group plc
(Registration No. 2247735). All of the companies mentioned in this
paragraph are incorporated in England and Wales and share the same
registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

--
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: doubt in code

2008-08-21 Thread Stewart Anderson

> -Original Message-
> From: Irfan J Sayed (isayed) [mailto:[EMAIL PROTECTED]
> Sent: 21 August 2008 15:49
> To: beginners@perl.org
> Subject: doubt in code
> 
> Hi All,
> 
> I have sample code like this:
> 
> #!/usr/bin/perl
> 
> # file: lgetr.pl
> 
> # Figure 1.2: Read the first line from a remote server
> 
> use IO::Socket;
> 
> my $server = shift;
> 
> my $fh = IO::Socket::INET->new($server);
> 
> my $line = <$fh>;
> 
> print $line;
> 
> As per comment it says that, it prints the first line of a file from
> remote server. So my understanding is that, it will go to remote
> server,read the file and then prints the first line of a file on the
> existing console. is it right ?? if yes then in the code where are we
> giving the filename??
> 
> Please suggest.
> 
> Regards
> 
> Irfan.
> 
> 

[Stewart Anderson] 

 my $fh = IO::Socket::INET->new($server);

is   where the  file handle $fh gets assigned



Information in this email including any attachments may be privileged, 
confidential and is intended exclusively for the addressee. The views expressed 
may not be official policy, but the personal views of the originator. If you 
have received it in error, please notify the sender by return e-mail and delete 
it from your system. You should not reproduce, distribute, store, retransmit, 
use or disclose its contents to anyone. Please note we reserve the right to 
monitor all e-mail communication through our internal and external networks. 
SKY and the SKY marks are trade marks of British Sky Broadcasting Group plc and 
are used under licence. British Sky Broadcasting Limited (Registration No. 
2906991), Sky Interactive Limited (Registration No. 3554332), Sky-In-Home 
Service Limited (Registration No. 2067075) and Sky Subscribers Services Limited 
(Registration No. 2340150) are direct or indirect subsidiaries of British Sky 
Broadcasting Group plc (Registration No. 2247735). All of the companies 
mentioned in this paragraph are incorporated in England and Wales and share the 
same registered office at Grant Way, Isleworth, Middlesex TW7 5QD.

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




doubt in code

2008-08-21 Thread Irfan J Sayed (isayed)
Hi All,
 
I have sample code like this:
 
#!/usr/bin/perl

# file: lgetr.pl

# Figure 1.2: Read the first line from a remote server

use IO::Socket;

my $server = shift;

my $fh = IO::Socket::INET->new($server);

my $line = <$fh>;

print $line;

As per comment it says that, it prints the first line of a file from
remote server. So my understanding is that, it will go to remote
server,read the file and then prints the first line of a file on the
existing console. is it right ?? if yes then in the code where are we
giving the filename??

Please suggest.

Regards

Irfan.

 



RE: doubt

2008-08-20 Thread Mr. Shawn H. Corey
On Wed, 2008-08-20 at 19:42 +0530, Irfan J Sayed (isayed) wrote:
> Thank you very much. Really helped.
> Regards
> Irfan.

You can look up:
  perldoc -f shift
  pelrdoc perlvar (and search for "@ARGV')


-- 
Just my 0.0002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."

"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster


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




RE: doubt

2008-08-20 Thread Irfan J Sayed (isayed)
Thank you very much. Really helped.
Regards
Irfan.
 

-Original Message-
From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 20, 2008 7:35 PM
To: Irfan J Sayed (isayed)
Cc: beginners@perl.org
Subject: Re: doubt

On Wed, 2008-08-20 at 19:03 +0530, Irfan J Sayed (isayed) wrote:
> Hi All,
> 
> Can you please tell me what is the value of $file. When i execute this

> script . it says "Can't open : No such file or directory"
> 
> Please suggect.
> 
> Regards
> 
> Irf.
> 
> #!/usr/bin/perl
> 
> # file: count_lines.pl
> 
> # Figure 1.4: Count the lines of a file
> 
> use strict;
> 
> use IO::File;
> 
> my $file = shift;

This is a shortcut for:

  my $file = shift @ARGV;

$file is assign the first command-line argument.  When you run the
script try placing the name of a file after it:

  perl count_lines.pl some_file.txt


--
Just my 0.0002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."

"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster


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




Re: doubt

2008-08-20 Thread Mr. Shawn H. Corey
On Wed, 2008-08-20 at 19:03 +0530, Irfan J Sayed (isayed) wrote:
> Hi All,
> 
> Can you please tell me what is the value of $file. When i execute this
> script . it says "Can't open : No such file or directory"
> 
> Please suggect.
> 
> Regards
> 
> Irf.
> 
> #!/usr/bin/perl
> 
> # file: count_lines.pl
> 
> # Figure 1.4: Count the lines of a file
> 
> use strict;
> 
> use IO::File;
> 
> my $file = shift;

This is a shortcut for:

  my $file = shift @ARGV;

$file is assign the first command-line argument.  When you run the
script try placing the name of a file after it:

  perl count_lines.pl some_file.txt


-- 
Just my 0.0002 million dollars worth,
  Shawn

"Where there's duct tape, there's hope."

"Perl is the duct tape of the Internet."
Hassan Schroeder, Sun's first webmaster


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




RE: doubt

2008-08-20 Thread Irfan J Sayed (isayed)
Do I need to really give the full pathname of the file and store in the
$file.
What does this line means
my $file = shift;

Regards
Irf.


-Original Message-
From: Andrew Curry [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, August 20, 2008 7:06 PM
To: Irfan J Sayed (isayed); beginners@perl.org
Subject: RE: doubt

Im going with empty string or null. 

-Original Message-
From: Irfan J Sayed (isayed) [mailto:[EMAIL PROTECTED]
Sent: 20 August 2008 14:34
To: beginners@perl.org
Subject: doubt

Hi All,

Can you please tell me what is the value of $file. When i execute this
script . it says "Can't open : No such file or directory"

Please suggect.

Regards

Irf.

#!/usr/bin/perl

# file: count_lines.pl

# Figure 1.4: Count the lines of a file

use strict;

use IO::File;

my $file = shift;

my $counter = 0;

my $fh = IO::File->new($file) or die "Can't open $file: $!\n";

while ( defined (my $line = $fh->getline) ) {

$counter++;

}

STDOUT->print("Counted $counter lines\n");


This e-mail is from the PA Group.  For more information, see
www.thepagroup.com.
This e-mail may contain confidential information.  
Only the addressee is permitted to read, copy, distribute or otherwise
use this email or any attachments.  
If you have received it in error, please contact the sender immediately.

Any opinion expressed in this e-mail is personal to the sender and may
not reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or
monitoring for operational reasons or for lawful business practices.


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




RE: doubt

2008-08-20 Thread Andrew Curry
Im going with empty string or null. 

-Original Message-
From: Irfan J Sayed (isayed) [mailto:[EMAIL PROTECTED] 
Sent: 20 August 2008 14:34
To: beginners@perl.org
Subject: doubt

Hi All,

Can you please tell me what is the value of $file. When i execute this
script . it says "Can't open : No such file or directory"

Please suggect.

Regards

Irf.

#!/usr/bin/perl

# file: count_lines.pl

# Figure 1.4: Count the lines of a file

use strict;

use IO::File;

my $file = shift;

my $counter = 0;

my $fh = IO::File->new($file) or die "Can't open $file: $!\n";

while ( defined (my $line = $fh->getline) ) {

$counter++;

}

STDOUT->print("Counted $counter lines\n");


This e-mail is from the PA Group.  For more information, see www.thepagroup.com.
This e-mail may contain confidential information.  
Only the addressee is permitted to read, copy, distribute or otherwise use this 
email or any attachments.  
If you have received it in error, please contact the sender immediately.  
Any opinion expressed in this e-mail is personal to the sender and may not 
reflect the opinion of the PA Group.
Any e-mail reply to this address may be subject to interception or monitoring 
for operational reasons or for lawful business practices.


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




doubt

2008-08-20 Thread Irfan J Sayed (isayed)
Hi All,

Can you please tell me what is the value of $file. When i execute this
script . it says "Can't open : No such file or directory"

Please suggect.

Regards

Irf.

#!/usr/bin/perl

# file: count_lines.pl

# Figure 1.4: Count the lines of a file

use strict;

use IO::File;

my $file = shift;

my $counter = 0;

my $fh = IO::File->new($file) or die "Can't open $file: $!\n";

while ( defined (my $line = $fh->getline) ) {

$counter++;

}

STDOUT->print("Counted $counter lines\n");



RE: Doubt in Perl CGI

2008-07-16 Thread Thomas Bätzler
Prabu Ayyappan <[EMAIL PROTECTED]> asked:
> My Perl CGI script is working fine when i run the code in the 
> command prompt as "perl myscript.cgi" . However when i run 
> the same code in the browser(Internet Explorer), It is not 
> working properly.

Have you tried running the script as the user id the web
server is running under?

> I am using "YAML::Syck" module in my CGI Script to parse the 
> YAML file. So i use this module to read the YAML file and 
> store it in a hash 
> 
> $data = LoadFile($fpath)
> 
> I will place some logic here and list the values in a select box.
> 
> The code is working fine till this select box after that it 
> is not displaying anything in the browser(view source 
> displays till the select). However the same code is running 
> in the  command prompt with the complete HTML generated.

I would suggest you install the CGI::Carp module and

  use CGI::Carp qw(fatalsToBrowser);

in your code if you aren't using it yet.

Add some code to verify that $fpath points to a file and that
you can actually open it. Check if $data is valid.

HTH,
Thomas

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




Doubt in Perl CGI

2008-07-16 Thread Prabu Ayyappan
Hi All,

My Perl CGI script is working fine when i run the code in the command prompt as 
"perl myscript.cgi" . However when i run the same code in the browser(Internet 
Explorer), It is not working properly.

I am using "YAML::Syck" module in my CGI Script to parse the YAML file. So i 
use this module to read the YAML file and store it in a hash 

$data = LoadFile($fpath)

I will place some logic here and list the values in a select box.

The code is working fine till this select box after that it is not displaying 
anything in the browser(view source displays till the select). However the same 
code is running in the  command prompt with the complete HTML generated.

Is that we need to add this module somewhere in the APACHE configuration?
Or do we need to add somewhere in the code.

I hope since this is working with the command prompt. Probably the error is 
with the APACHE or some include.

Please help.

Thanks,
Prabu



  Explore your hobbies and interests. Go to 
http://in.promos.yahoo.com/groups/

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




doubt in my web spider

2008-06-17 Thread Manasi Bopardikar
http://sac.edu/Schedule/search/results.asp?semester=Fall2008

&department=Accounting&AddTitle=-+Browse&RtnURL=%2Fschedule%2Fbrowse.asp?Sel
ected=Fall2008&RtnTxt=New+Browse

 

I need to scrape unique id fields viz 0103501 etc and 'AND' following it
under QUICKBOOKS  to be put in one record and then write it to output
file.is there a simple way to do it.

 

Manasi Bopardikar

Software Engineer

Persistent Systems Ltd

Cell No:(+91)9767218759
Extn:+91-020-3023(4497)
Email:[EMAIL PROTECTED]

 


DISCLAIMER
==
This e-mail may contain privileged and confidential information which is the 
property of Persistent Systems Ltd. It is intended only for the use of the 
individual or entity to which it is addressed. If you are not the intended 
recipient, you are not authorized to read, retain, copy, print, distribute or 
use this message. If you have received this communication in error, please 
notify the sender and delete all copies of this message. Persistent Systems 
Ltd. does not accept any liability for virus infected mails.


Re: Doubt on Pattern Matching

2007-08-28 Thread Dharshana Eswaran
On 8/28/07, Chas Owens <[EMAIL PROTECTED]> wrote:
>
> On 8/28/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
> > When i write the condition
> > my @m = $fullStruct =~ /$DLstatement/g;
> > and try printing the array,
> > print "\nThe array is @m\n";
> > It prints nothing This is the problem...
> >
> > Thanks and Regards,
> > Dharshana
> snip
> > > That is not the behaviour I am seeing.  Please post a full example
> > > that demonstrates your problem.
> snip
>
> Again, please post the smallest complete program that exhibits the
> problem you are seeing as I cannot reproduce the problem you are
> talking about.




Actually, i was reading the input from a different location, and the input
was not being read properly. I found that out and corrected it. Thanks for
your suggestions. I am sorry that i was unable to produce a full program
regarding the issue.

Thanks and Regards,
Dharshana


Re: Doubt on Pattern Matching

2007-08-28 Thread Chas Owens
On 8/28/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
> When i write the condition
> my @m = $fullStruct =~ /$DLstatement/g;
> and try printing the array,
> print "\nThe array is @m\n";
> It prints nothing This is the problem...
>
> Thanks and Regards,
> Dharshana
snip
> > That is not the behaviour I am seeing.  Please post a full example
> > that demonstrates your problem.
snip

Again, please post the smallest complete program that exhibits the
problem you are seeing as I cannot reproduce the problem you are
talking about.

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




Re: Doubt on Pattern Matching

2007-08-28 Thread Rob Dixon

Dharshana Eswaran wrote:

On 8/28/07, Chas Owens <[EMAIL PROTECTED]> wrote:

On 8/28/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:


I have a pattern, which reads as shown below:

my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
my $identifier = qr{ [A-Za-z_]\w* }xs;
my $statement  = qr{
   \s*
   ($identifier)
   \s+
   ($identifier)
   \s*
   (?: \[ (.*?) \] )?
   \s*
   ;
   \s*
   $comment?
}xs;

my @m = $abc =~ /$statement/g;

My string reads as shown below:

$abc = "typedef struct  _MSG_S
{
CALL_ID  callId; /**< call id */
VOICE_STATUSstatus; /**< Call status */
id_t   id;/**< The id of process call */
} TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";


The condition $abc =~ /$statement/g; is not satisfied. The array @m is
not being filled.

I am unable to find out the mistake. Is the pattern regex wrong
somewhere?


That is not the behaviour I am seeing.  Please post a full example
that demonstrates your problem.  The following code prints out:

callId is of type CALL_ID
status is of type VOICE_STATUS
id is of type id_t

as expected.

#!/usr/bin/perl

use strict;
use warnings;


my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
my $identifier = qr{ [A-Za-z_]\w* }xs;
my $statement  = qr{
  \s*
  ($identifier)
  \s+
  ($identifier)
  \s*
  (?: \[ (.*?) \] )?
  \s*
  ;
  \s*
  $comment?
   }xs;

my $abc = "typedef struct  _MSG_S
{
   CALL_ID  callId; /**< call id */
   VOICE_STATUSstatus; /**< Call status */
   id_t   id;/**< The id of process call */
} TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";

while ($abc =~ /$statement/g) {
my ($type, $name, $size) = ($1, $2, $3);
$type = "array of $type with $size elements" if defined $size;
print "$name is of type $type\n";
}


When i write the condition
my @m = $fullStruct =~ /$DLstatement/g;
and try printing the array,
print "\nThe array is @m\n";
It prints nothing This is the problem...


If I use the variable names in your original code:

my @m = $abc =~ /$statement/g;
print "\nThe array is @m\n";

then I get

Use of uninitialized value in join or string at E:\Perl\source\x.pl line 30.
Use of uninitialized value in join or string at E:\Perl\source\x.pl line 30.
Use of uninitialized value in join or string at E:\Perl\source\x.pl line 30.

The array is CALL_ID callId  VOICE_STATUS status  id_t id 


which is what I would expect. Every third array element is undefined because
the optional array index is absent.

HTH,

Rob

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




Re: Doubt on Pattern Matching

2007-08-27 Thread Dharshana Eswaran
When i write the condition
my @m = $fullStruct =~ /$DLstatement/g;
and try printing the array,
print "\nThe array is @m\n";
It prints nothing This is the problem...

Thanks and Regards,
Dharshana
On 8/28/07, Chas Owens <[EMAIL PROTECTED]> wrote:
>
> On 8/28/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
> > Hi All,
> >
> > I have a pattern, which reads as shown below:
> >
> > my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
> > my $identifier = qr{ [A-Za-z_]\w* }xs;
> > my $statement  = qr{
> >\s*
> >($identifier)
> >\s+
> >($identifier)
> >\s*
> >(?: \[ (.*?) \] )?
> >\s*
> >;
> >\s*
> >$comment?
> > }xs;
> >
> > my @m = $abc =~ /$statement/g;
> >
> > My string reads as shown below:
> >
> > $abc = "typedef struct  _MSG_S
> > {
> > CALL_ID  callId; /**< call id */
> > VOICE_STATUSstatus; /**< Call status */
> > id_t   id;/**< The id of process call */
> > } TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";
> >
> >
> > The condition $abc =~ /$statement/g; is not satisfied. The array @m is
> not
> > being filled.
> >
> > I am unable to find out the mistake. Is the pattern regex wrong
> somewhere?
> >
> > Thanks and Regards,
> > Dharshana
> >
>
>
> That is not the behaviour I am seeing.  Please post a full example
> that demonstrates your problem.  The following code prints out:
>
> callId is of type CALL_ID
> status is of type VOICE_STATUS
> id is of type id_t
>
> as expected.
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
>
> my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
> my $identifier = qr{ [A-Za-z_]\w* }xs;
> my $statement  = qr{
>   \s*
>   ($identifier)
>   \s+
>   ($identifier)
>   \s*
>   (?: \[ (.*?) \] )?
>   \s*
>   ;
>   \s*
>   $comment?
>}xs;
>
> my $abc = "typedef struct  _MSG_S
> {
>CALL_ID  callId; /**< call id */
>VOICE_STATUSstatus; /**< Call status */
>id_t   id;/**< The id of process call */
> } TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";
>
> while ($abc =~ /$statement/g) {
> my ($type, $name, $size) = ($1, $2, $3);
> $type = "array of $type with $size elements" if defined $size;
> print "$name is of type $type\n";
> }
>


Re: Doubt on Pattern Matching

2007-08-27 Thread Chas Owens
On 8/28/07, Dharshana Eswaran <[EMAIL PROTECTED]> wrote:
> Hi All,
>
> I have a pattern, which reads as shown below:
>
> my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
> my $identifier = qr{ [A-Za-z_]\w* }xs;
> my $statement  = qr{
>\s*
>($identifier)
>\s+
>($identifier)
>\s*
>(?: \[ (.*?) \] )?
>\s*
>;
>\s*
>$comment?
> }xs;
>
> my @m = $abc =~ /$statement/g;
>
> My string reads as shown below:
>
> $abc = "typedef struct  _MSG_S
> {
> CALL_ID  callId; /**< call id */
> VOICE_STATUSstatus; /**< Call status */
> id_t   id;/**< The id of process call */
> } TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";
>
>
> The condition $abc =~ /$statement/g; is not satisfied. The array @m is not
> being filled.
>
> I am unable to find out the mistake. Is the pattern regex wrong somewhere?
>
> Thanks and Regards,
> Dharshana
>


That is not the behaviour I am seeing.  Please post a full example
that demonstrates your problem.  The following code prints out:

callId is of type CALL_ID
status is of type VOICE_STATUS
id is of type id_t

as expected.

#!/usr/bin/perl

use strict;
use warnings;


my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
my $identifier = qr{ [A-Za-z_]\w* }xs;
my $statement  = qr{
  \s*
  ($identifier)
  \s+
  ($identifier)
  \s*
  (?: \[ (.*?) \] )?
  \s*
  ;
  \s*
  $comment?
   }xs;

my $abc = "typedef struct  _MSG_S
{
   CALL_ID  callId; /**< call id */
   VOICE_STATUSstatus; /**< Call status */
   id_t   id;/**< The id of process call */
} TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";

while ($abc =~ /$statement/g) {
my ($type, $name, $size) = ($1, $2, $3);
$type = "array of $type with $size elements" if defined $size;
print "$name is of type $type\n";
}

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




Doubt on Pattern Matching

2007-08-27 Thread Dharshana Eswaran
Hi All,

I have a pattern, which reads as shown below:

my $comment= qr{\s* (?:/\* .*? \*/ \s*)*}xs;
my $identifier = qr{ [A-Za-z_]\w* }xs;
my $statement  = qr{
   \s*
   ($identifier)
   \s+
   ($identifier)
   \s*
   (?: \[ (.*?) \] )?
   \s*
   ;
   \s*
   $comment?
}xs;

my @m = $abc =~ /$statement/g;

My string reads as shown below:

$abc = "typedef struct  _MSG_S
{
CALL_ID  callId; /**< call id */
VOICE_STATUSstatus; /**< Call status */
id_t   id;/**< The id of process call */
} TAPI_VOICE_NOTIFY_CALL_STATUS_MSG_S;";


The condition $abc =~ /$statement/g; is not satisfied. The array @m is not
being filled.

I am unable to find out the mistake. Is the pattern regex wrong somewhere?

Thanks and Regards,
Dharshana


doubt on time structures

2006-12-20 Thread pradeep reddy
Hello,

I used the follwoing code:

struct rusage startusage, stopusage;
getrusage(RUSAGE_SELF, &startusage);




   getrusage(RUSAGE_SELF, &stopusage);

cpu_delta_user=((stopusage.ru_utime.tv_sec*100) + 
stopusage.ru_utime.tv_usec) -(startUsage.ru_utime.tv_sec*100) + 
startUsage.ru_utime.tv_usec);
cpu_delta_sys=((stopusage.ru_stime.tv_sec*100) + 
stopusage.ru_stime.tv_usec) -((startUsage.ru_stime.tv_sec*100) + 
startUsage.ru_stime.tv_usec);

And the options I used in makefile to compile my code:

CFLAGS = -c -Wall -DUNIX -DLINUX -D_GNU_SOURCE -DFLOATING_POINT_SUPPORT=1 - 
DTHREAD_SAFE -D_REENTRANT -DLINK_AMS -DLINK_DPC -DLINK_DMS -DRW_MUL
TI_THREAD -DMMII -include /usr/include/features.h -O2 -I. -I/hap/active/include
LFLAGS = -L/hap/active/lib -L/hap/active/goahead/lib/LINUX -L/usr/app/ha/lib 
-lHapComponent -lGoAhead -llog -lcevm -levl -lha -O0 -lplatformServices


But stopusage.ru_utime.tv_sec & stopusage.ru_utime.tv_usec...all are giving 
NULL values.

I know this is perl group.But Iam giving my last trial , if I get any help..


-reddy.

Send free SMS to your Friends on Mobile from your Yahoo! Messenger. Download 
Now! http://messenger.yahoo.com/download.php

Re: doubt in quote-like operators

2006-08-07 Thread anand kumar
Hi,
   
  Thanks alot for the detailed explanation.
   
  Regards
  Anand Kumar

Prabu <[EMAIL PROTECTED]> wrote:
  anand kumar wrote:
> hi all,
> 
> I could not understand clearly the functions 
> qw(),qq(),qr(),qx(),q(),quotemeta(). I 
> have read the explanation for these functions in the perl documentation but i 
> could not get idea of where exactly we can use these functions. So please 
> send some other links or examples for these functions.
> 
> Thanks in advance for the help
> 
> Regards
> Anand Kumar 

Hello Anand,

q/STRING/
’STRING’

A single-quoted, literal string.A generalized single-quote operation.

A backslash represents a backslash unless followed by the delimiter or 
another backslash, in which case the delimiter or backslash is interpolated.

for example
$foo = q!Hello World!; This is equivalent to $foo='hello world';

_
qq/STRING/
"STRING"

A double-quoted, interpolated string.

for example
$foo = qq!Hello World!; This is equivalent to $foo='hello world';

_
qr/STRING/imosx

This operator quotes (and possibly compiles) its STRING as a regular 
expression. STRING is interpolated the same way as PATTERN in "m/PATTERN/"

Options are:
i Do case-insensitive pattern matching.
m Treat string as multiple lines.
o Compile pattern only once.
s Treat string as single line.
x Use extended regular expressions.

For example
$rex = qr/my.STRING/is;
s/$rex/foo/;

This is equivalent too

s/my.STRING/foo/is;

_
qx/STRING/
‘STRING‘

A string which is (possibly) interpolated and then executed as a system 
command with "/bin/sh" or its equivalent. Shell wildcards, pipes, and 
redirections will be honored. The collected standard output of the 
command is returned; standard error is unaffected.

qx(ls); This is equivalent to `ls` (backtics)

qw/STRING/
Evaluates to a list of the words extracted out of STRING, using embedded 
whitespace as the word delimiters.

@a=qw(foo bar baz); This is equivalent too @a=("foo", "bar", "baz");

_
quotemeta EXPR

Returns the value of EXPR with all non-"word" characters backslashed.
_

A Small Example

PROGRAM

$ cat func.pl
#!/usr/bin/perl
$foo = q!Hello World\n!;
print "single-quote operation\n\t",$foo."\n";
$foo = qq!Hello World\n!;
print "double-quote operation\n\t",$foo;
$foo = "Hello world";
$pattern = qr!Hello!is;
$foo=~s/$pattern/HELL0/;
print "Regex operation\n\t",$foo;
@a=qw(hello perl world);
print "\nTurn a space-delimited string of words into a list\n\t";
foreach(@a){
print "$_\n\t";
}
$foo="Hello*world";
$non_word_char = quotemeta($foo);
print "\nBackslashed non-word characters\n\t",$non_word_char."\n";
print qx/ps/;


OUTPUT

$ perl func.pl
single-quote operation
Hello World\n
double-quote operation
Hello World
Regex operation
HELL0 world
Turn a space-delimited string of words into a list
hello
perl
world

Backslashed non-word characters
Hello\*world
PID TTY TIME CMD
20453 pts/5 00:00:00 bash
20737 pts/5 00:00:00 perl
20738 pts/5 00:00:00 ps





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






-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Re: doubt in quote-like operators

2006-08-06 Thread Prabu

anand kumar wrote:

hi all,
   
  I could not understand clearly the functions qw(),qq(),qr(),qx(),q(),quotemeta(). I 
  have read the explanation for these functions in the perl documentation but i 
  could not get idea of where exactly we can use these functions. So please 
  send some other links or examples for these functions.
   
  Thanks in advance for the help
   
  Regards

  Anand Kumar   


Hello Anand,

q/STRING/
’STRING’

A single-quoted, literal string.A generalized single-quote operation.

A backslash represents a backslash unless followed by the delimiter or 
another backslash, in which case the delimiter or backslash is interpolated.


for example
$foo = q!Hello World!; This is equivalent to $foo='hello world';

_
qq/STRING/
"STRING"

A double-quoted, interpolated string.

for example
$foo = qq!Hello World!; This is equivalent to $foo='hello world';

_
qr/STRING/imosx

This operator quotes (and possibly compiles) its STRING as a regular 
expression. STRING is interpolated the same way as PATTERN in "m/PATTERN/"


Options are:
i Do case-insensitive pattern matching.
m Treat string as multiple lines.
o Compile pattern only once.
s Treat string as single line.
x Use extended regular expressions.

For example
$rex = qr/my.STRING/is;
s/$rex/foo/;

This is equivalent too

s/my.STRING/foo/is;

_
qx/STRING/
‘STRING‘

A string which is (possibly) interpolated and then executed as a system 
command with "/bin/sh" or its equivalent. Shell wildcards, pipes, and 
redirections will be honored. The collected standard output of the 
command is returned; standard error is unaffected.


qx(ls); This is equivalent to `ls` (backtics)

qw/STRING/
Evaluates to a list of the words extracted out of STRING, using embedded 
whitespace as the word delimiters.


@a=qw(foo bar baz); This is equivalent too @a=("foo", "bar", "baz");

_
quotemeta EXPR

Returns the value of EXPR with all non-"word" characters backslashed.
_

A Small Example

PROGRAM

$ cat func.pl
#!/usr/bin/perl
$foo = q!Hello World\n!;
print "single-quote operation\n\t",$foo."\n";
$foo = qq!Hello World\n!;
print "double-quote operation\n\t",$foo;
$foo = "Hello world";
$pattern = qr!Hello!is;
$foo=~s/$pattern/HELL0/;
print "Regex operation\n\t",$foo;
@a=qw(hello perl world);
print "\nTurn a space-delimited string of words into a list\n\t";
foreach(@a){
print "$_\n\t";
}
$foo="Hello*world";
$non_word_char = quotemeta($foo);
print "\nBackslashed non-word characters\n\t",$non_word_char."\n";
print qx/ps/;


OUTPUT

$ perl func.pl
single-quote operation
Hello World\n
double-quote operation
Hello World
Regex operation
HELL0 world
Turn a space-delimited string of words into a list
hello
perl
world

Backslashed non-word characters
Hello\*world
PID TTY TIME CMD
20453 pts/5 00:00:00 bash
20737 pts/5 00:00:00 perl
20738 pts/5 00:00:00 ps





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




doubt in quote-like operators

2006-08-06 Thread anand kumar
hi all,
   
  I could not understand clearly the functions 
qw(),qq(),qr(),qx(),q(),quotemeta(). I 
  have read the explanation for these functions in the perl documentation but i 
  could not get idea of where exactly we can use these functions. So please 
  send some other links or examples for these functions.
   
  Thanks in advance for the help
   
  Regards
  Anand Kumar


-
 Here’s a new way to find what you're looking for - Yahoo! Answers 

Re: doubt..

2006-07-19 Thread Prasad
Hi Ramesh,

Yes. Here they have used '|' is a delimiter. Take a look at 'perlre'.


""Ankam, Ramesh Babu"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
..
Hi,

  Can any one please tell me what this pattern means  "  s|.*/||  ".



Is it that '|' represents '/'. Please reply me soon. Thanks in advance



--- Ramesh










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




Re: doubt..

2006-07-19 Thread Prasad
Ramesh,

Here they have used '|' as a delimiter because already they are using the
metacharacter '/' in the find pattern. In order to avoid backslashing the
metacharacter '/' , they have used '|' as delimiter.

Regards,
Prasad


""Ankam, Ramesh Babu"" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
..
Hi,

  Can any one please tell me what this pattern means  "  s|.*/||  ".



Is it that '|' represents '/'. Please reply me soon. Thanks in advance



--- Ramesh










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




Re: doubt..

2006-07-19 Thread Ranish George

Ankam, Ramesh Babu wrote:
Hi, 


  Can any one please tell me what this pattern means  "  s|.*/||  ".

 


Is it that '|' represents '/'. Please reply me soon. Thanks in advance

 


--- Ramesh

 

 

 



  

Hello Ramesh,

   In your example "|" is used as the delimiter instead of the 
general "/" delimiter since the pattern to match contains a "/".


For example

perl -le '$string="Hello /World"; $string =~  s|.*/|| ;print $string;'

will print  World as output.

-Ranish George





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




Re: doubt..

2006-07-19 Thread Xavier Noria

On Jul 19, 2006, at 13:59, Ankam, Ramesh Babu wrote:


  Can any one please tell me what this pattern means  "  s|.*/||  ".


Assuming there are no newlines in the string, that s/// means remove  
everything up to, and including, the last slash. It's a typical  
regexp for getting the basename of a filename. If that's the usage  
please delegate to File::Basename instead.


-- fxn




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




doubt..

2006-07-19 Thread Ankam, Ramesh Babu
Hi, 

  Can any one please tell me what this pattern means  "  s|.*/||  ".

 

Is it that '|' represents '/'. Please reply me soon. Thanks in advance

 

--- Ramesh

 

 

 



Re: split doubt

2006-05-25 Thread John W. Krahn
Saurabh Singhvi wrote:
> Hi

Hello,

> the format of split() defines that one
> can split a string into a fixed number
> of specifies strings. for eg
> 
> ($login, $passwd, $remainder) = split(/:/, $_, 3);
> 
> Now, the thing is, it splits on first 3 parts.
> Can i do the reverse?? as in instead of the output
> being the first 3 parts of split, the last 3 parts of
> split for the same string.

$ perl -le'
$_ = q[a:b:c:d:e:f:g];
( $login, $passwd, $remainder ) = split /:/, $_, 3;
print "$login, $passwd, $remainder";
( $login, $passwd, $remainder ) = map scalar reverse, split /:/, reverse, 3;
print "$login, $passwd, $remainder";
'
a, b, c:d:e:f:g
g, f, a:b:c:d:e




John
-- 
use Perl;
program
fulfillment

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




Re: split doubt

2006-05-25 Thread Mr. Shawn H. Corey
On Thu, 2006-25-05 at 13:17 -0700, Joshua Colson wrote:
> On Thu, 2006-05-25 at 19:38 +, Saurabh Singhvi wrote:
> > Hi
> > 
> > the format of split() defines that one
> > can split a string into a fixed number
> > of specifies strings. for eg
> > 
> > ($login, $passwd, $remainder) = split(/:/, $_, 3);
> > 
> > Now, the thing is, it splits on first 3 parts.
> > Can i do the reverse?? as in instead of the output
> > being the first 3 parts of split, the last 3 parts of
> > split for the same string.
> 
> I'm sure there is a cleaner way to write this, but try:
> 
> ($gecos, $home, $shell) = ( split(/:/, $_) )[-3..-1];
> 
> 

Wrong!

There is no way split can do the reverse of splitting of the first 2
parts of a string and placing the rest in the third part. Something that
may come close is:

my @data = split /:/, $_;
my $last = pop @data;
my $next_to_last = pop @data;
my $remainder = join( ':', @data );


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




Re: split doubt

2006-05-25 Thread Joshua Colson
On Thu, 2006-05-25 at 19:38 +, Saurabh Singhvi wrote:
> Hi
> 
> the format of split() defines that one
> can split a string into a fixed number
> of specifies strings. for eg
> 
> ($login, $passwd, $remainder) = split(/:/, $_, 3);
> 
> Now, the thing is, it splits on first 3 parts.
> Can i do the reverse?? as in instead of the output
> being the first 3 parts of split, the last 3 parts of
> split for the same string.

I'm sure there is a cleaner way to write this, but try:

($gecos, $home, $shell) = ( split(/:/, $_) )[-3..-1];


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




Re: split doubt

2006-05-25 Thread Chris Charley


- Original Message - 
From: ""Saurabh Singhvi"" <[EMAIL PROTECTED]>

Newsgroups: perl.beginners
To: "Perl FAq" 
Sent: Thursday, May 25, 2006 3:38 PM
Subject: split doubt



Hi

the format of split() defines that one
can split a string into a fixed number
of specifies strings. for eg

($login, $passwd, $remainder) = split(/:/, $_, 3);

Now, the thing is, it splits on first 3 parts.
Can i do the reverse?? as in instead of the output
being the first 3 parts of split, the last 3 parts of
split for the same string.

thanks
Saurabh



Sure, the code below will do that.

Chris


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

my $string = "a;b;c;d;e;f";

my ($stuff1, $stuff2, $stuff3) = (split /;/, $string)[-3..-1];

print "$stuff1 $stuff2 $stuff3\n";

__END__
this prints...

d e f



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




split doubt

2006-05-25 Thread Saurabh Singhvi

Hi

the format of split() defines that one
can split a string into a fixed number
of specifies strings. for eg

($login, $passwd, $remainder) = split(/:/, $_, 3);

Now, the thing is, it splits on first 3 parts.
Can i do the reverse?? as in instead of the output
being the first 3 parts of split, the last 3 parts of
split for the same string.

thanks
Saurabh


Re: forking doubt

2006-03-14 Thread Jeff Pang
It's not so easy to do that.
you should use the signal to communicate between childs and parent.

-Original Message-
>From: Saurabh Singhvi <[EMAIL PROTECTED]>
>Sent: Mar 14, 2006 3:57 AM
>To: Perl FAq 
>Subject: forking doubt
>
>Hi all,
>
>
>   my $child = fork ();
>
>   unless ($child) {
>   sleep 5;
>   print "child\n";
>   }
>
>   print "parent\n" if $child;
>   print "parent2\n" if $child;
>
>
>the above code prints the parent lines followed by the child. Now what i
>want to do is print the parent
>line1 and then the child followed by the parent2 line. So what changes do i
>need to do??
>
>thanks
>Saurabh


--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

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




Re: forking doubt

2006-03-14 Thread Paul Johnson
On Tue, Mar 14, 2006 at 08:57:03AM +, Saurabh Singhvi wrote:

>my $child = fork ();
> 
>unless ($child) {
>sleep 5;
>print "child\n";
>}
> 
>print "parent\n" if $child;
>print "parent2\n" if $child;
> 
> 
> the above code prints the parent lines followed by the child. Now what
> i want to do is print the parent line1 and then the child followed by
> the parent2 line. So what changes do i need to do??

Your processes need to communicate.

Fortunately there is an entire manpage devoted to this subject:

  perldoc perlipc

You might find the section on "Bidirectional Communication with
Yourself" useful.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net

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




forking doubt

2006-03-14 Thread Saurabh Singhvi
Hi all,


   my $child = fork ();

   unless ($child) {
   sleep 5;
   print "child\n";
   }

   print "parent\n" if $child;
   print "parent2\n" if $child;


the above code prints the parent lines followed by the child. Now what i
want to do is print the parent
line1 and then the child followed by the parent2 line. So what changes do i
need to do??

thanks
Saurabh


Re: Doubt

2005-12-11 Thread Ricardo SIGNES
* anand kumar <[EMAIL PROTECTED]> [2005-12-11T22:38:00]
>  I am new to perl .i have a doubt in analysing the following regex.
>(my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//;
>
>   here i want to know the meaning of '?:'

Normally, something enclosed in parentheses would be "captured" for
later use.

For example:

  (my $altered_string = $string) =~ s/\A123(\d+)\z/321$1/;

This would change "1238302938" to "3218302938" by capturing the digits
after 123 into $1, which is later interpolated in the right-hand side of
the s/// expression.

?: inside the parentheses indicates that you don't want to capture.

  (my $altered_string = $string) =~ s/\A123(?:\d+)\z/321something/;

Here, since we don't care about the digits after 123, we can throw them
away, so we don't need to capture them.  For this reason, we use ?: to
say "group these together, but don't capture them.

There are many uses for this.  In the example you provided, it is
probably being done for the small optimization it provides.

-- 
rjbs


pgptyegtLuESK.pgp
Description: PGP signature


Doubt

2005-12-11 Thread anand kumar

  Hi 
 I am new to perl .i have a doubt in analysing the following regex.
   (my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//;
   
  here i want to know the meaning of '?:'
   
  thanks in advance
  Anand


-
 Yahoo! India Matrimony: Find your partner now.

Doubt

2005-12-11 Thread anand kumar

  Hi 
 I am new to perl .i have a doubt in analysing the following regex.
   (my $book = $ref_string) =~ s/\s*(\d+(?::\d+(?:-\d+(?::\d+)?)?)?)\Z//;
   
  here i want to know the meaning of '?:'
   
  thanks in advance
  Anand


-
 Yahoo! India Matrimony: Find your partner now.

Re: doubt with hash

2005-01-13 Thread Tor Hildrum
On Fri, 14 Jan 2005 12:09:03 +0530, Anish Kumar K.
<[EMAIL PROTECTED]> wrote:
> Hi All
> 
> I have a hash say. %browserType in which assume there are values...
> 
> %browserType=(
> "IE"=>2,
> "NETSCAPE"=>3,
> "FIREFOX"=>5
> );
> 
> I need to calculate one morething say percentage utilisation for each 
> browser..
> 
> ie..If IE is 2 = the percentage is calculated as (2/(2+3+5))*100
>NETSCAPE=(3/(2+3+5))*100
>FIREFOX=(5/(2+3+5))*100
> 
> and pass this in this single hash...I am new to this hash...I thought there 
> are two values possible, KEY and VALUE in hash
> is there a way I can add one more
> 
> "IE"=>2=>10
> "NETSCAPE=>3=>20
> 
> Please help
> 
> Anish

## calculate total
my $total = 0;

foreach keys (%hash) {
$total += $hash{$_};
}

## create a new hash to an anonymous array
foreach keys (%hash) {
 $percentage = ($hash{$_}/$total) * 100;
$browsertype{$_} = [$hash{$_}, $percentage];
}

## access
foreach keys (%browsertype) {
   print "Value: $_: $browsertype{$_}[0]\n";
   print "Percentage: $_: $browsertype{$_}[1]\n";
}

Untested though :)

Tor
Tor

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




doubt with hash

2005-01-13 Thread Anish Kumar K.
Hi All

I have a hash say. %browserType in which assume there are values...

%browserType=(
"IE"=>2,
"NETSCAPE"=>3,
"FIREFOX"=>5
);

I need to calculate one morething say percentage utilisation for each browser..

ie..If IE is 2 = the percentage is calculated as (2/(2+3+5))*100
   NETSCAPE=(3/(2+3+5))*100
   FIREFOX=(5/(2+3+5))*100

and pass this in this single hash...I am new to this hash...I thought there are 
two values possible, KEY and VALUE in hash
is there a way I can add one more 

"IE"=>2=>10
"NETSCAPE=>3=>20

Please help

Anish


Addition to doubt: File Upload using CGI

2004-12-01 Thread Manas Kulkarni
Hi,
I made a slight mistake in my previous post. I am not getting the key
value, I am getting the name of the file instead(not the absolute path).

Thanks,
Manas.

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




How can I do to concatenate 2 strings?, was Re: Doubt

2004-10-04 Thread Chris Devers
Please use a constructive subject line.
On Mon, 4 Oct 2004, Sprogis, Rubens (V-Emeritis) wrote:
How can I do to concatenate 2 strings?
There are many ways to do it.
Here's one of them:
$foo = $a . $b;
This should be introductory material in any beginner's Perl book.

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



Re: Doubt

2004-10-04 Thread Errin Larsen
On Mon, 4 Oct 2004 18:33:51 -0300, Sprogis, Rubens (V-Emeritis)
<[EMAIL PROTECTED]> wrote:
> How can I do to concatenate 2 strings?
> 
>  
Hi!

Glad you are trying Perl!  Welcome to the group!

Let me offer you some advice.  This mailing list works best when you
write some of your own code, try it, test it and debug it yourself. 
THEN, if you still have trouble, post you code to this list and we'll
help you.

If you send us no code, we can't tell where your problem is.

If you haven't written any code yet, keep in mind that we are NOT a
free, code-writing service.

Now, I am SURE you can find some answers to your problems on the net. 
I'll give you a hint.  Try this web site first:

  http://learn.perl.org/

--Errin

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




Doubt

2004-10-04 Thread Sprogis, Rubens \(V-Emeritis\)
How can I do to concatenate 2 strings? 
  
 
***
 
Esta mensagem pode conter informacoes confidenciais e privadas. A nao ser que voce 
seja o destinatario (ou autorizado pelo destinatario para receber esta mensagem), voce 
nao podera usar, copiar, distribuir ou divulgar para ninguem esta mensagem ou qualquer 
informacao nela contida. Se voce recebeu esta mensagem por engano, por favor comunique 
ao remetente, e apague a mensagem. Muito obrigado. 
  
This message contains information which may be confidential and privileged.  Unless 
you are the intended recipient (or authorized to receive this message for the intended 
recipient), you may not use, copy, disseminate or disclose to anyone the message or 
any information contained in the message.  If you have received the message in error, 
please advise the sender by reply e-mail, and delete the message.  Thank you very 
much. 
***
 


Re: doubt in Definition of sub routine.

2004-08-06 Thread Jeff 'japhy' Pinyan
On Aug 5, Jose Alves de Castro said:

>sub trim($), for instance, means that trim will work on a scalar.

It means that trim() expects ONE argument and will enforce scalar context
on it.  trim($foo) and trim(@bar) both work.

>This is useful to, instead of something such as
>
>trim($var)
>
>use something such as
>
>trim $var

That has nothing to do with prototypes.  That is only the case when trim()
is defined before it's used (or before that specific use of the function).

>Also,
>
>trim
>
>by itself is interpreted as trim($_)

Not so; trim($) means it *must* have an argument sent to it.

-- 
Jeff "japhy" Pinyan %  How can we ever be the sold short or
RPI Acacia Brother #734 %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %-- Meister Eckhart


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




Re: doubt in Definition of sub routine.

2004-08-05 Thread Jose Alves de Castro
On Thu, 2004-08-05 at 11:07, [EMAIL PROTECTED] wrote:
> Hi All,

Hi

> I am using code written by some one else. I didn't understand the difference
> between these subroutines, the way they were defined.
> 
> 1. sub addToLog  {  Some code  }  Any specific reason where we should
> not use braces ??
> 2. sub displayEnv( ) {"  }Any specific reason why we should
> use braces  ??
> 3. sub trim($) {  "  }Any specific reason why we should
> use a brace with a $ sign  in it ??

Those are prototypes. Basically, you use them to specify how your
subroutine is to be treated.

sub trim($), for instance, means that trim will work on a scalar.

This is useful to, instead of something such as

trim($var)

use something such as

trim $var

Also,

trim

by itself is interpreted as trim($_)

trim $var1, $var2

is the same as

trim($var1), $var2

> sub displayEnv( ) {   "  }

This makes displayEnv by itself (that is, with no braces) work in your
code, not munching up anything following it :-)

> Could some one specify reason when to use braces and when not to use .
> Replies are highly appreciated and thanks in advance for your help.

You're the one who has to choose, I guess :-)

> Regards
> Anand

HTH,

jac


-- 
José Alves de Castro <[EMAIL PROTECTED]>
  http://natura.di.uminho.pt/~jac


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


Re: doubt in Definition of sub routine.

2004-08-05 Thread Gunnar Hjalmarsson
Anand V wrote:
I am using code written by some one else. I didn't understand the difference
between these subroutines, the way they were defined.
1. sub addToLog  {  Some code  }Any specific reason where we should
not use braces ??
2. sub displayEnv( ) {  " }Any specific reason why we should
use braces  ??
3. sub trim($)   {  " }Any specific reason why we should
use a brace with a $ sign  in it ??
Could some one specify reason when to use braces and when not to use .
That's already explained in the docs. Read about prototypes in 
"perldoc perlsub".

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



doubt in Definition of sub routine.

2004-08-05 Thread Anand . V
Hi All,

I am using code written by some one else. I didn't understand the difference
between these subroutines, the way they were defined.

1. sub addToLog  {  Some code  }Any specific reason where we should
not use braces ??
2. sub displayEnv( ) {  "  }Any specific reason why we should
use braces  ??
3. sub trim($)   {  "  }Any specific reason why we should
use a brace with a $ sign  in it ??

Could some one specify reason when to use braces and when not to use .
Replies are highly appreciated and thanks in advance for your help.

Regards
Anand



[Doubt] : Validate Printer Port

2004-06-23 Thread suresh.pasupula
Hi,

 

How to validate the given printer port?

I want to know if it is a TCP/IP or local port. If it is a TCP/IP Port
then I wan to validate if it exists (Raw port 9100).

Also I want to validate the format of IP-Address.

 

Could anyone let me know how can I achieve this?

 

Thanks and Regards

Suresh



RE: [Doubt]: Retrieve System Info like Which OS and type

2004-06-22 Thread Tim Johnson

Check out the Win32::TieRegistry module.  It's pretty easy to get that
info from the Registry.

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, June 22, 2004 11:32 AM
To: [EMAIL PROTECTED]
Subject: [Doubt]: Retrieve System Info like Which OS and type

Hi,


I need to retrieve the following system Info from the current system.

1. Operating System

2. Localization

3. 32 Bit or 64 Bit



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




[Doubt]: Retrieve System Info like Which OS and type

2004-06-22 Thread suresh.pasupula
Hi,

 

I need to retrieve the following system Info from the current system.

1. Operating System

2. Localization

3. 32 Bit or 64 Bit

 

I searched but could get only this info "$^O". This gives only MSWINNT
but nut much info.

Could anyone let me know where can I such info?

 

Thanks and Regards

Suresh



Re: a doubt

2003-12-15 Thread Ajey
Too good. thanks John.

On Mon, 15 Dec 2003, John W. Krahn wrote:

> Ajey wrote:
> > 
> > Hi,
> 
> Hello,
> 
> > How can i catch the difference in 2 files on a perl stmt?
> > I want to do somethign like,
> > if (there is some diff in 2 files)
> > do something1
> > else
> > do something2
> > Both files are simple text files
> 
> use File::Compare;
> 
> if ( compare( 'file1', 'file2' ) == 0 ) {
> print "They are the same\n";
> }
> else {
> # do something else
> }
> 
> 
> John
> -- 
> use Perl;
> program
> fulfillment
> 
> -- 
> 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: a doubt

2003-12-15 Thread John W. Krahn
Ajey wrote:
> 
> Hi,

Hello,

> How can i catch the difference in 2 files on a perl stmt?
> I want to do somethign like,
> if (there is some diff in 2 files)
> do something1
> else
> do something2
> Both files are simple text files

use File::Compare;

if ( compare( 'file1', 'file2' ) == 0 ) {
print "They are the same\n";
}
else {
# do something else
}


John
-- 
use Perl;
program
fulfillment

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




a doubt

2003-12-15 Thread Ajey
Hi,
How can i catch the difference in 2 files on a perl stmt?
I want to do somethign like,
if (there is some diff in 2 files)
do something1
else
do something2
Both files are simple text files

TIA
-Ajey


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




Re: some doubt

2003-12-12 Thread Jim Burnett
Yes, do a search on google. I did this.

-Jim

- Original Message - 
From: "Ajey Kulkarni" <[EMAIL PROTECTED]>
To: "drieux" <[EMAIL PROTECTED]>
Cc: "Perl Perl" <[EMAIL PROTECTED]>
Sent: Saturday, December 13, 2003 6:20 AM
Subject: some doubt


> hi,
> How can i rename a file and check the size of file using perl?
> Also is there a way to call unix commands/system calls from perl?(Say i
> want to fstat() on a file and grab the stat struct results). Is there any
> way??
>
> TIA
> -Ajey
>
>
>
> -- 
> 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>




Some Doubt

2003-12-12 Thread Rob Dixon
Ajey Kulkarni wrote:
>
> How can i rename a file and check the size of file using perl?
> Also is there a way to call unix commands/system calls from perl?(Say i
> want to fstat() on a file and grab the stat struct results). Is there any
> way??

You can grab the size of a file using the -s operator on either
a filename or an open filehandle. Check out:

  perldoc -f -s

You can rename using the built-in 'rename' function on a filename.
Check out

  perldoc -f rename

You can execute shell commands using either the built-in 'system'
call or the qx// operator. Check out:

  perldoc -f system
or
  perldoc perlop

and search for 'qx'. However I would /very strongly/ discourage you
from shelling out of Perl unless there's something you can really
cannot simply do otherwise.

HTH,

Rob









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




File Operations and System Calls in Perl (WAS: some doubt)

2003-12-12 Thread Tim Johnson

Okay, I'll give you a few pointers, but first, please use a more
descriptive subject line and start a new message when you start a new
thread.

The Perl documentation is found by running perldoc.  To find the answers
to your questions, try checking out:

perldoc -f stat
perldoc -q extern
perldoc -f rename

That should get you started




-Original Message-
From: Ajey Kulkarni [mailto:[EMAIL PROTECTED] 
Sent: Saturday, December 13, 2003 3:21 AM
To: drieux
Cc: Perl Perl
Subject: some doubt

hi,
How can i rename a file and check the size of file using perl?
Also is there a way to call unix commands/system calls from perl?(Say i
want to fstat() on a file and grab the stat struct results). Is there
any way??

TIA
-Ajey

 



Re: some doubt

2003-12-12 Thread Rob Dixon
Ajey Kulkarni wrote:

[some stuff]

Before this gets lost as a subthread I'm reposting it.

I hope I catch most potential responses.

Rob



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




Re: Messing with Files [Was: some doubt]

2003-12-12 Thread Casey West
It was Saturday, December 13, 2003 when Ajey Kulkarni took the soap box, saying:
: hi,
: How can i rename a file and check the size of file using perl?

Use the rename() function.

  rename( $oldfile, $newfile );

  perldoc -f rename()

Use the file test operators, particularly -s.

  my $size = -s $file;

  perldoc -f -S

: Also is there a way to call unix commands/system calls from perl?(Say i 
: want to fstat() on a file and grab the stat struct results). Is there any 
: way??

What you really want is the stat() function.

  my @properties = stat($file);

  perldoc -f stat

If you want it to look more like a struct, use File::stat.

  use File::stat;
  my $prop = stat($file);
  print $prop->size;

  perldoc File::stat

  Casey West

-- 
"So we went to Atari and said, 'Hey, we've got this amazing thing,
even built with some of your parts, and what do you think about
funding us? Or we'll give it to you. We just want to do it. Pay our
salary, we'll come work for you.' And they said, 'No.' So then we went
to Hewlett-Packard, and they said, 'Hey, we don't need you. You
haven't got through college yet.'"
 -- Apple Computer Inc. founder Steve Jobs on attempts to get Atari
and H-P interested in his and Steve Wozniak's personal computer.


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




some doubt

2003-12-12 Thread Ajey Kulkarni
hi,
How can i rename a file and check the size of file using perl?
Also is there a way to call unix commands/system calls from perl?(Say i 
want to fstat() on a file and grab the stat struct results). Is there any 
way??

TIA
-Ajey



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




Re: 1 doubt.

2003-12-11 Thread Yannick Warnier
Le jeu 11/12/2003 à 10:27, Ajey Kulkarni a écrit :
> perl t.pl
> Name "main::FH" used only once: possible typo at t.pl line 6.
> 
> cat t.pl
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> open FH, "out.dat";
> 
> 
> Why am i getting this warning? When i remove the warnings,this goes off?
> Is there any problem if i not include "use warnings" line?

This is just a warning saying that you are using FH only once (well,
it's written so). Indeed, why would you need to open the file if you are
not writing or reading or accessing it anyway?
Just, for example, close it using
  close FH;
unless you wanna do something special with that?

Yannick


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




Re: 1 doubt.

2003-12-10 Thread R. Joseph Newton
Ajey Kulkarni wrote:

> perl t.pl
> Name "main::FH" used only once: possible typo at t.pl line 6.
>
> cat t.pl
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
>
> open FH, "out.dat";
>
> Why am i getting this warning?

Because the compiler thinks that you are probably doing something
pointless.  You are loading a filehandle, but never accessing it.  Since it
can't see why you would be creating a filehandle without using it, iot
guesses that you may have mistyped some other name.

> When i remove the warnings,this goes off?
> Is there any problem if i not include "use warnings" line?

Better to either do something with the filehandle, or get rid of it.  Don't
shoot the messenger.

Joseph


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




RE: 2nd doubt.

2003-12-10 Thread Paul Kraus
Not to be a pest but try and be more descriptive in your subject. It
saves everyone time in trying to decide on what they can help you with.


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




2nd doubt.

2003-12-10 Thread Ajey Kulkarni
HI again.
I'm tryign to modify the .procmailrc file


Initially the file looks liek this
--

:0:
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0:
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0:
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0:
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0:
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0
| dmail +INBOX



the file after modificatin should look like
:0 w
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0 wB
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0 w
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0 w
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0 w
* ^X-Spam-Status: Yes
| dmail +mail/junk

:0 w
| dmail +INBOX


This is my first realtime use of perl,and i'm kinda stomped. 
I'm able to read each line in the procmailrc file,but just ened to parse 
the (line by line) and modify the contents.

Help required.
-Aj



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




RE: 1 doubt.

2003-12-10 Thread Ned Cunningham
It's a warning. If you turn it off you wont get it   :) 

Ned Cunningham
POS Systems Development
Monro Muffler Brake
200 Holleder Parkway
Rochester, NY 14615
(585) 647-6400 ext. 310
[EMAIL PROTECTED]

-Original Message-
From:   Ajey Kulkarni [mailto:[EMAIL PROTECTED]
Sent:   Thursday, December 11, 2003 4:28 AM
To: [EMAIL PROTECTED]
Subject:    1 doubt.

perl t.pl
Name "main::FH" used only once: possible typo at t.pl line 6.

cat t.pl

#!/usr/bin/perl

use strict;
use warnings;

open FH, "out.dat";


Why am i getting this warning? When i remove the warnings,this goes 
off?
Is there any problem if i not include "use warnings" line?

Quick reply is highly appreciated

regards
-Ajey


-- 
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: 1 doubt.

2003-12-10 Thread perl-beginners
On Thu, Dec 11, 2003 at 09:27:48AM +, Ajey Kulkarni wrote:
> perl t.pl
> Name "main::FH" used only once: possible typo at t.pl line 6.

You opened a file, but you do not read from the file. Just opened
it. This doesn't make much sense. So you get a warning.

> cat t.pl
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> 
> open FH, "out.dat";

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




Re: 1 doubt.

2003-12-10 Thread James Edward Gray II
On Dec 11, 2003, at 3:27 AM, Ajey Kulkarni wrote:

perl t.pl
Name "main::FH" used only once: possible typo at t.pl line 6.
cat t.pl

#!/usr/bin/perl

use strict;
use warnings;
open FH, "out.dat";

Why am i getting this warning? When i remove the warnings,this goes 
off?
Is there any problem if i not include "use warnings" line?
As the warning say, you used FH only once.  You open() a file and do 
nothing with it.  Perl's just making sure you are aware of the issue.  
Once you start using the file Perl will be quite about it.

While you're at it, don't forget to check that the file opened properly:

open FH, 'out.dat' or die "File error:  $!\n";

James

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



  1   2   >