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
>


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


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

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/




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/




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/




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/




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]
 




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]
 




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


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]
 




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]
 




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]
 



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]
 




Re: Doubt

2003-12-01 Thread drieux
On Dec 1, 2003, at 6:19 AM, Na wrote:

I am programmer and work with language VB. But I have
some doubts about Perl and in the internet I did not find solutions.
 I like to know if is possible to use dll's I writed (that access a usb
scanner) in perl. If I could, how can i referenciate it (in vbscript 
we use
 the CreateObject method)?
Sorry about my english.
What you are looking for is the XS section
of perl, since you will need to expose the
dll's interfaces in Perl. Then from that
module you will gain access to the compiled
dll in the way you arranged to do that.
My first recommendation is to do
perldoc h2xs


Which will help explain how to take
the header files you used to create
the dll and render them into XS so
as to start the process of building
the perl module that will be able to
interact with the dll.
You might want to also look at

Your English is better than my Brazilian,
my apologies for my limitations.
ciao
drieux
---

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


Re: doubt in pattern matching using variable

2003-02-05 Thread R. Joseph Newton
kasi ramanathen wrote:

> $t="perl";
> while($ln=~m/$t/g)

> {

>   print "it matches..";
> }
>

Hi Kasi,

The part above shoul;d work, because this does:

#!/usr/bin/perl -w

use strict;

my $Test = "Hi";
my $Greeting = "Hi, there.  How are you?";
if ($Greeting =~ /$Test/) {
  print "$Greeting\n";
} else {
  print "Nope\n";
}

I can assure you that the problem lies elswhere than whether variables interpolate 
within regeses--they do.  I would strongly suggest that you heed Robs advice about 
using whitespace in your code.  What you cannot see, you cannot debug.

Try printing out the string [$ln] you are examining before testing it with the regex.  
Is the test string actually there?  Exactly as assigned to the variable (since you 
used the global g modifier, but not the case-insensitive i?

Look throough your code again, because the problem lies elsewhere.  Whatever is in $t 
is not being found in $ln.

Joseph


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




Re: doubt in pattern matching using variable

2003-02-05 Thread Rob Dixon
Kasi ramanathen wrote:
> hi friends,
>
> i have a problem in work i want to use a variable in the place of
> pattern to be matched, but i don't know how? but some great brain
> some ware in the world will be knowing it.
>
> hear i explain the program, when i use the patter i get the right
> output when i store it in variable t and use it no output comes help
> me?
>
> open (H, " @a=;
> $ln=join('',@a);
> $t="
class=link>([\S\s]*?)<\/A><\/D
IV>[\s\S]*?15px\">(\w[\s\S]*?)<\/DIV>";
> while($ln=~m/$t/g)

Kasi.

A quick reply, I'm afraid.

Your pattern match will work if you quote your regex
with qr//. Also You'd be better off using the /x modifier
on your regex so that you can lay it out better, something
like this:

$t = qr/



([\S\s]*?)
<\/A>
<\/DIV>
[\s\S]*?15px\">
(\w[\s\S]*?)
<\/DIV>
/x;

where whitespace may be used without affecting the pattern,
although any spaces that must be matched have to be put in
explicitly.

But I'm a little worried about some of the stuff in your regex.
For instance [\s\S] is a character class containing all whitespace
characters and all non-whitespace characters, so it's the same as
'.'. Also you seem to be searching for two closing  tags
but only one opening one.

HTH,

Rob







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




RE: doubt in pattern matching

2003-01-21 Thread Dan Muey

> dear friends:
Howdy
> 
> i have a simple doubts in reguler exepration see the the 
> passage that follows is stored in a variable by name v. in 
> the fifth line see the words like this "Next 20 ^ " now i 
> want delete all the charecter before ^- sign in my variable v.
> 
> shall i use find and replace to find all the pattern before ^ 
> and repalce it with single space charecter. please mail me 
> the actual code of pattern
> 
> $v="Description:
> 
> /flash/hp/pb/pbhp_84x28_blu_yahoo.gif"; var pb_width=84; var 
> pb_height=28; var pb_FitNewWinHeight = new Array; var 
> pb_FitNewWinWidth = new Array; pb_FitNewWinWidth[1] = 790; 
> 

What is all of the code above? Since its using special chars that may have problems.

To simply delete everything before the '^'

$description =~ s/^.*\^//;
That will remove everything before the last ^ you have. So if there are two carets 
then it will remove both.

Is that what you're trying to do or maybe you could elaborate a smidge more?

> Description:
> 
> 20 of 31,900,000 | Next 20 ^
> 
> Title: Java .Sun.com 
> 
> Description:
> 
> Sun's Java page, featuring developer resources, community, 
> documentations, support, news, and more. java .sun.com/ 
> search within ";
> 
>  
> 
> Catch all the cricket action. Download Yahoo! Score tracker
> 

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




Re: doubt in requler expression

2003-01-20 Thread Rob Dixon
Kasi ramanathen wrote:
> $str='
href="Java.Sun.com'">http://srd.yahoo.com/S=2766679:WS1/R=1/K=java/SS=79
559/OCS=79428/H=0/T=1043090181/F=641685fa5455462d4f69450a6fd72ecc/*http:
//java.sun.com/">Java.Sun.com';
> if($str=~/[\w\W]*<(\W)/) {
> print $1;
> print "\n***\n";
> }
>

It's very hard to see where your regex starts and ends. To put slashes
within a regular expression use a pair of characters that don't appear
in the expression:

/regex/

is the same as

m[regex]

Also remember that you need to escape 'metacharacters' like dot and
star. Put a backslash before them like this:

m[srd\.yahoo\.com]

Try these things and see how you get on.

Rob




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




Re: doubt in mysql

2003-01-17 Thread Jenda Krynicky
From: kasi ramanathen <[EMAIL PROTECTED]>
> i'm to update a pearl programme using mysql, i know only less of the
> latter. i come across a statement 
> 
> $ver=$dbh->prepare(SELECT jobid, pid from jobs where exectime 
> now i want to know the perpose of " statement

The < is just a less than. Nothing special about it. The ? is a so-
called placeholder. It means "the parameter will be inserted here".

This allows you to do:

$ver=$dbh->prepare('SELECT jobid, pid from jobs where exectime < 
?');
...
$RS = $ver->execute('2003-1-13');

and it will execute the
SELECT jobid, pid from jobs where exectime < '2003-1-13'
statement and return the rows.

You should use ->prepare() and ->execute() if you plan to use the 
same statement many times and all you need is to change a few 
parameters.
This will allow the SQL server to "compile" the statement and prepare 
the "execution plan" just once and then reuse it.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Doubt

2001-08-30 Thread Brett W. McCoy

On Thu, 30 Aug 2001, Rajanikanth Dandamudi wrote:

>My doubt is  "How do  you identify whether  a  perl scalar variable
>contains a  numeric  value or  alphanumeric  string?" . I had  gone
>through   theexplanation available  atthe   URL
>http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html   ,  but I didn't
>understand that explanation. Thanks in advance.

What do you not understand?  As the page remarks, it's not as big a
problem as people make it out to be.  Perl does a fine job of being able
to automagically convert back and forth.  If you can remember that text
used in a == comparison will be 0 ($text == 0 is true), you should be
safe.  If you need to test against 0 itself, test to see if the string is
equal to '0'.

-- Brett
  http://www.chapelperilous.net/

Go 'way!  You're bothering me!


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




RE: Doubt

2001-08-30 Thread John Edwards

Sorry, hit the send button early :)

Ignore that mail...

-Original Message-
From: John Edwards 
Sent: 30 August 2001 16:52
To: 'Rajanikanth Dandamudi'; '[EMAIL PROTECTED]'
Subject: RE: Doubt 


It doesn't matter to Perl if you store alphanumerics or numbers or both in
scalar. When you want to perform a numeric function on the scalar, Perl
treats the data in it as numeric. When you want to perform an alphanumeric
on it, it treats the data as alphanumerics.

e.g

$data = "one";
$new = "$data + 10";
print $new;

You could use a regular expression to check the data. Here is some commented
sample code

# Initialize the scalar and store the string
$data

-Original Message-
From: Rajanikanth Dandamudi [mailto:[EMAIL PROTECTED]]
Sent: 30 August 2001 16:35
To: '[EMAIL PROTECTED]'
Subject: Doubt 


Hello,

   My doubt is  "How do  you identify whether  a  perl scalar variable
   contains a  numeric  value or  alphanumeric  string?" . I had  gone
   through   theexplanation available  atthe   URL
   http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html   ,  but I didn't
   understand that explanation. Thanks in advance.

Thanks and Regards,
Rajanikanth




--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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




RE: Doubt

2001-08-30 Thread John Edwards

It doesn't matter to Perl if you store alphanumerics or numbers or both in
scalar. When you want to perform a numeric function on the scalar, Perl
treats the data in it as numeric. When you want to perform an alphanumeric
on it, it treats the data as alphanumerics.

e.g

$data = "one";
$new = "$data + 10";
print $new;

You could use a regular expression to check the data. Here is some commented
sample code

# Initialize the scalar and store the string
$data

-Original Message-
From: Rajanikanth Dandamudi [mailto:[EMAIL PROTECTED]]
Sent: 30 August 2001 16:35
To: '[EMAIL PROTECTED]'
Subject: Doubt 


Hello,

   My doubt is  "How do  you identify whether  a  perl scalar variable
   contains a  numeric  value or  alphanumeric  string?" . I had  gone
   through   theexplanation available  atthe   URL
   http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html   ,  but I didn't
   understand that explanation. Thanks in advance.

Thanks and Regards,
Rajanikanth




--Confidentiality--.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



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




Re: Doubt in the perl module Storable.pm

2001-07-13 Thread Rajanikanth Dandamudi

Schwartz, Collier,

First let me thank you for helping me in this regard. Also, I am sorry for
sending you the mail in unformatted manner. Actually, I had formatted the mail
by using xemacs and had send it. But, I don't know how the message looked like
this. Coming to the point,

Schwartz, I had gone through the link
() given by you which
clearly explains the difference between deep copy and shallow copy. Also, I
understood the difference between deepcopy and shallow copy. But, the doubt I
raised is a different one. My question is : How come the Storable.pm module is
working even though the perl code for that module doesn't contain the definition
of the subroutine dclone()(As I understood the perl module Storable.pm) .

Collier, Thank you for your help.


--
Thanks and Regards,
D.Rajanikanth



"Randal L. Schwartz" wrote:

> > "Rajanikanth" == Rajanikanth Dandamudi <[EMAIL PROTECTED]> writes:
>
> Rajanikanth>  I
> Rajanikanth> am  able to see the
> Rajanikanth> definitions  of all the functions   except
> Rajanikanth> function dclone .  Can
> Rajanikanth> someone help me in understanding this? .
>
> For an explanation about "deep copy", see
>
>   
>
> If you're just missing how to use the parameters, ask again.
>
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
> <[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: Doubt in the perl module Storable.pm

2001-07-12 Thread C.J. Collier

Heya Rajanikanth,

It looks like the man page (perldoc Storable) gives a good description
of what dclone does:

__QUOTE__

MEMORY STORE
   The Storable engine can also store data into a Perl scalar
   instead, to later retrieve them. This is mainly used to
   freeze a complex structure in some safe compact memory
   place (where it can possibly be sent to another process
   via some IPC, since freezing the structure also serializes
   it in effect). Later on, and maybe somewhere else, you can
   thaw the Perl scalar out and recreate the original complex
   structure in memory.

   Surprisingly, the routines to be called are named `freeze'
   and `thaw'.  If you wish to send out the frozen scalar to
   another machine, use `nfreeze' instead to get a portable
   image.

   Note that freezing an object structure and immediately
   thawing it actually achieves a deep cloning of that
   structure:

   dclone(.) = thaw(freeze(.))

   Storable provides you with a `dclone' interface which does
   not create that intermediary scalar but instead freezes
   the structure in some internal memory space and then
   immediatly thaws it out.

__EOQUOTE__

If your perldoc entry doesn't have this section, perhaps you should
consider upgrading your local copy of Storable.  You should look into
the CPAN module (perldoc CPAN) to find out how to do this.  You can
also use the CPAN web page or ftp site (search.cpan.org, ftp.cpan.org)
to grab the latest version.

Hope this helps,

C.J.


On Thu, 12 Jul 2001, Rajanikanth Dandamudi wrote:

> Hello,
> 
> I had  got  a doubt  about the perl  module
> Storable.pm   . Incase
> someone  is not  aware  of what Storable.pm
> is  please  enter the
> following command(  on aunix
> machine)at  the  command
> prompt. Command to be  entered is "perldoc
> Storable.pm" (with  out
> quotes).  If you take a  look  at the   perl
> code for the  module
> Storable.pm  , it  specifies that  this   perl
> module defines  the
> functions such as  "store, retrieve, nstore,
> store_fd, nstore_fd,
> fd_retrieve,   freeze, nfreezethaw,
> dclone,   retrieve_fd,
> lock_store,  lock_nstore, lock_retrieve"  . I
> am  able to see the
> definitions  of all the functions   except
> function dclone .  Can
> someone help me in understanding this? .
> Thanks in advance.
> 
> --
> Thanks and Regards
> Rajanikanth
> 
> 
> 




Re: Doubt in understanding

2001-06-08 Thread Randal L. Schwartz

> "Rajanikanth" == Rajanikanth Dandamudi <[EMAIL PROTECTED]> writes:

Rajanikanth> Hello,
Rajanikanth> I had a problem understanding what the
Rajanikanth> expression ${1+"$@"} mean? can someone help me in
Rajanikanth> understanding this?

That's a very very old shell expression.  If $1 (the first shell
argument) is non-empty, then interpolate $@ (all the arguments) in
such a way as to retain their original quoting and whitespace.  It's
used a lot when one shell script wants to execute another command but
keep the precise argument structure.

As others in this thread have noted, it's also part of the "shell
exec" magic that you can place at the beginning of a Perl program to
tell the shell to run Perl on the file instead.  In this case, yes,
it's important that the shell pass the arguments *precisely* to Perl
in the same way that it got them -- hence the magic construct.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<[EMAIL PROTECTED]> http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!



Re: Doubt in understanding

2001-06-08 Thread Markus Peter

On Fri, 8 Jun 2001, Rajanikanth Dandamudi wrote:

> Hello,
>
> I had seen some of the perl files starting with the
> line :
>
> eval 'exec perl $0 -S ${1+"$@"}'
>
>and  here is where I got the doubt.

MakeMaker usually inserts the line into perl executables when they are
installed. On some systems, perl scripts _might_ be evaluated by sh
derivatives, and if that's the case, that line will try to pass control
from the sh interpreter to the perl interpreter.

-- 
Markus Peter - SPiN AG
[EMAIL PROTECTED]





Re: Doubt in understanding

2001-06-08 Thread Jean-Matthieu Guerin

hELLO,

$@ is a system variable that return error messages. If our statement
executed by the eval function (eval 'exec perl $0 -S ${1+"$@"}')
contains an error, or an error occurs during the execution of the
statement, the error message is stored in $@.

I.e: 
eval ("This is not a perl statement");
assigns $@ with :
syntax error in file (eval) at line 1, next 2 tokens "This is"


Rajanikanth Dandamudi wrote:
> 
> Hello,
> 
> I had a problem understanding what the
> expression ${1+"$@"} mean? can someone help me in
> understanding this?
> 
> --
> Thanks and Regards,
> D.Rajanikanth

-- 

 Jean-Matthieu Guerin
Brime Ingenierie
phone: 33-1-4898 8230
[EMAIL PROTECTED]




Re: Doubt in understanding

2001-06-08 Thread Rajanikanth Dandamudi

Hello,

I had seen some of the perl files starting with the
line :

eval 'exec perl $0 -S ${1+"$@"}'

   and  here is where I got the doubt.



--
Thanks and Regards,
D.Rajanikanth

Jeff Yoak wrote:

> At 02:16 PM 6/8/01 +0530, Rajanikanth Dandamudi wrote:
> >Hello,
> >
> > I had a problem understanding what the
> >expression ${1+"$@"} mean? can someone help me in
> >understanding this?
>
> That's bizarre.  In what context did you encounter it?
>
> Cheers,
> Jeff



Re: Doubt in understanding

2001-06-08 Thread n6tadam

Hi,

That expression looks more like something one would encouter in a BASH
script.

Thomas Adam

- Original Message -
From: Jeff Yoak <[EMAIL PROTECTED]>
To: Rajanikanth Dandamudi <[EMAIL PROTECTED]>; Perl beginners
<[EMAIL PROTECTED]>
Sent: Friday, June 08, 2001 10:22 AM
Subject: Re: Doubt in understanding


> At 02:16 PM 6/8/01 +0530, Rajanikanth Dandamudi wrote:
> >Hello,
> >
> > I had a problem understanding what the
> >expression ${1+"$@"} mean? can someone help me in
> >understanding this?
>
> That's bizarre.  In what context did you encounter it?
>
> Cheers,
> Jeff
>
>
>


Please note that the content of this message is confidential between the original 
sender and the intended recipient(s) of the message. If you are not an intended 
recipient and/or have received this message in error, kindly disregard the content of 
the message and return it to the original sender.

If you have any complaints about this message please reply to:
   [EMAIL PROTECTED]

The Purbeck School E-Mail server running:
   users.purbeck.dorset.sch.uk




Re: Doubt in understanding

2001-06-08 Thread Jeff Yoak

At 02:16 PM 6/8/01 +0530, Rajanikanth Dandamudi wrote:
>Hello,
>
> I had a problem understanding what the
>expression ${1+"$@"} mean? can someone help me in
>understanding this?

That's bizarre.  In what context did you encounter it?

Cheers,
Jeff




Re: doubt about do/until

2001-06-03 Thread Gerrit P. Haase

[EMAIL PROTECTED] schrieb am 2001-05-31, 18:30:

> Hi gurus,
> In http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html, ( Is it a 
> number? ), Tom Christiansen writes:
> 
>--
> If you do care about getting 0's, then do this: 
> do { 
>  print "Number, please: ";
>  $answer = ;
>  if ($answer == 0 && $answer ne '0') {
>  print "Bad number\n";
>  }
> } until $answer;
> 
>--
> 
> I tried this with ActiveState perl version 5.005_03. I entered 0 and got a 
> bad number. After thinking awhile, I chomped the $answer. This works for 
> 0,
> ( i.e. No "Bad number message"  and  the loop repeats ). I think we need a 
> chomp there ( so instead of '0\n' ne '0', it is '0' ne '0' ). Is it so or 
> am I missing something? 

I'm thinking about what it is doing
...
If you enter a number, it exits, if you enter a zero it gives you a
"Bad number", as it is if you enter some non-digits.
So, what is a number???
Obviously zero is no number, that is all this script is doing, checking
your input, if it is a number.

$ dountil.pl
Number, please: 123

Siebenschlaefer@LORELEY ~/script
$ dountil.pl
Number, please: 0
Bad number

Siebenschlaefer@LORELEY ~/script
$ dountil.pl
Number, please: 478

Siebenschlaefer@LORELEY ~/script
$ dountil.pl
Number, please: sdf
Bad number

-gph

-- 
=^..^=



RE: doubt about do/until

2001-05-30 Thread Peter Scott

At 11:32 AM 5/31/01 +1000, King, Jason wrote:
>I notice that the copyright notice is 1996 .. so perhaps my memory is
>failing me and that there was a version of Perl where  did NOT grab
>the line-ending character as well .. otherwise Tom really is human and has
>made a mistake :)

I would peg it as a mistake... but just for the edification of the list, if 
you use the -l option to perl, this code *will* work, because the \n will 
be autochomped.  So we could charitably say that it depended on the shebang 
line... except that that should have been noted.  Anyway, if you haven't 
heard of the -l option yet, do a perldoc perlrun and look it up, it's very 
handy.

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com




RE: doubt about do/until

2001-05-30 Thread King, Jason

[EMAIL PROTECTED] wrote ..

>In http://www.cpan.org/doc/FMTEYEWTK/is_numeric.html, 
>( Is it a number? ), Tom Christiansen writes:
>---
>If you do care about getting 0's, then do this: 
>  do { 
>   print "Number, please: ";
>   $answer = ;
>   if ($answer == 0 && $answer ne '0') {
> print "Bad number\n";
>   }
> } until $answer;
>---
>
>I tried this with ActiveState perl version 5.005_03. I entered 0 and
>got a bad number. After thinking awhile, I chomped the $answer. This
>works for 0, ( i.e. No "Bad number message" and the loop repeats ). I
>think we need a chomp there ( so instead of '0\n' ne '0', it is '0' ne
>'0' ). Is it so or am I missing something?

you haven't missed anything .. the code should definitely have a chomp in
there

I notice that the copyright notice is 1996 .. so perhaps my memory is
failing me and that there was a version of Perl where  did NOT grab
the line-ending character as well .. otherwise Tom really is human and has
made a mistake :)

basically any of the samples where a string comparison is done should be
chomping STDIN before the comparison because while the numeric comparison
will ditch the trailing garbage (which in this case is LF) the string
comparison obviously will not

-- 
  jason king

  In Spearfish, South Dakota, if three or more Indians are walking down
  the street together, they can be considered a war party and fired
  upon. - http://dumblaws.com/



Re: doubt about $ in perldoc perlvar

2001-05-17 Thread Jeff Pinyan

On May 17, [EMAIL PROTECTED] said:

> $
> Contains the subpattern from the corresponding set
> of parentheses in the last pattern matched, not
> counting patterns matched in nested blocks that have
> been exited already.  (Mnemonic: like \digits.)
> These variables are all read-only.
>
>I don't understand the second part ==> "not counting patterns matched in 
>nested blocks that have been exited already." Could I get some example 
>illustrating this point?

I believe it refers to using (??{ ... }) which is a new feature to Perl
5.6's regex engine.

  $_ = "foo bar blat";
  $re = qr/(\w+)/;  # create a compiled regex object

  /(\w+)\s*(??{ $re })\s*(\w+)/
  print "<$1> <$2> <$3>\n";

Even though the (??{ $re }) sequence has a (\w+) in it, that () is the $1
INSIDE the (??{ ... }), and it goes away when that nested block is left.

Thus, the program prints "  <>", and the (\w+) inside $re is
"lost", as far as we're concerned.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Are you a Monk?  http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
*** I need a publisher for my book "Learning Perl Regular Expressions" ***




Re: doubt about $ in perldoc perlvar

2001-05-17 Thread Jos I Boumans

Sure, just try running these 2 bits of code and you'll see what that means:

### example 1 ###
$foo = 'bar';

$foo =~ /(bar)/;
$firstmatch = $1;

$foo =~ /(quux/;
$secondmatch = $1;

print "$firstmatch and $secondmatch\n";

### example 2 ###

$foo = 'bar';

{   
$foo =~ /(bar)/;
$firstmatch = $1;
}

{
$foo =~ /(quux/;
$secondmatch = $1;
}

print "$firstmatch and $secondmatch\n";


### end examples ###

you'll notice the difference when you have the vars printed out...
the { } is the block the perldoc is talking about...

another solution would be to use a statement like this:
$firstmatch = $foo =~ /(bar)/;


Hope that helps,

Jos Boumans


- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, May 17, 2001 6:59 PM
Subject: doubt about $ in perldoc perlvar


> Gurus,
> perldoc perlvar says:
> 
>  $
>  Contains the subpattern from the corresponding set
>  of parentheses in the last pattern matched, not
>  counting patterns matched in nested blocks that have
>  been exited already.  (Mnemonic: like \digits.)
>  These variables are all read-only.
> 
> I don't understand the second part ==> "not counting patterns matched in 
> nested blocks that have been exited already." Could I get some example 
> illustrating this point?
> 
> -- Thanks,
> Atul
> 
>