RE: Perl Certifications and some help

2001-05-28 Thread King, Jason

Sanchit Bhatnagar writes ..

> Is there something like a "Perl Certified Professional" or 
>does there exists some other credible certification you can 
>get for perl. 

competency


>Also can someone please provide me help and/or links which 
>have tutorials (maybe a single para) on the perl's function 
>"map" and "grep". 

a single para we can do - Perl has that itself .. perldoc is installed when
you install Perl on most operating systems .. type the following at a
command prompt to see the help

  perldoc -f map
  perldoc -f grep

-- 
  jason king

  In Denmark, if a horse carriage is trying to pass a car and the horse
  gets uneasy, the car is required to pull over and stop. If necessary
  to ease the horse down, you are required to cover the car up. -
  http://dumblaws.com/



Re: Perl Certifications and some help

2001-05-28 Thread Randal L. Schwartz

> "Sanchit" == Sanchit Bhatnagar <[EMAIL PROTECTED]> writes:

Sanchit>  Is there something like a "Perl Certified Professional" or
Sanchit>  does there exists some other credible certification you can
Sanchit>  get for perl.

No.  And it'll likely stay that way.  Thank goodness.

Sanchit> Also can someone please provide me help and/or links which
Sanchit> have tutorials (maybe a single para) on the perl's function
Sanchit> "map" and "grep".

"perldoc perlfunc" is a good start.  If you need something more,
there's the discussion in Effective Perl Programming, and the upcoming
"Learning Perl, third edition".

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



Perl Certifications and some help

2001-05-28 Thread Sanchit Bhatnagar

Hi,
 Is there something like a "Perl Certified Professional" or does there exists some 
other credible certification you can get for perl. 

Also can someone please provide me help and/or links which have tutorials (maybe a 
single para) on the perl's function "map" and "grep". 

thanks,
san.



Re: Regex problem

2001-05-28 Thread Paul Dean

At 05:29 PM 28/05/2001 +0100, Bornaz, Daniel wrote:
>Dear all,
>
>I am trying the following code using ActivePerl 5.6.1.626, in my quest to
>find the minimal string between "bar" and "river":
>
>$stt="The food is under the bar in the barn in the river.";
>$stt=~/bar(.*?)river/;
>print "$&";
>
>The output is:
>bar in the barn in the river
>
>Instead of the expected:
>barn in the river

 From what I read this would be correct, you are asking for everything but 
don't be greedy in between "bar" and "river"...
"bar" is an explicit match, if you want to match "barn" then I suggest this...

$stt="The food is under the bar in the barn in the river.";
$stt=~/barn(.*?)river/; # looks for barn not bar.
print "$&";


/* Experience is that marvelous thing that enables you to recognize a 
mistake when you make it again.
Franklin P. Jones */




RE: Fileposting

2001-05-28 Thread King, Jason

Bernhard writes ..

>Hi! I'm using a html form, where you can enter a file (a 
>picture) and upload it, but when i send the form the Perl 
>script only gets the local Adress of the file, but not the 
>Data (so the picture) of the file. How can i save the picture 
>in a new file on my Disk?
>I have programmed it so that the new file will be saved in a 
>new Folder.

if you use the standard CGI module that's shipped with the later versions of
Perl then that parameter is both the filename and a filehandle to the file
contents

as well since version 2.47 of CGI.pm there's an additional method called
'upload' which explicitly retrieves the filehandle

see the CGI documentation for an example of the file-upload mechanism


references:

  perldoc CGI

-- 
  jason king

  In Denmark, if a horse carriage is trying to pass a car and the horse
  gets uneasy, the car is required to pull over and stop. If necessary
  to ease the horse down, you are required to cover the car up. -
  http://dumblaws.com/



RE: Can I tell how a program is called?

2001-05-28 Thread Tom Watson


Wow, thanks for the quick answer!

Now that I see it in black and white, $0 does cause the vaguest of 
stirrings of recognition.

I'll go and try it now!

Thanks again,

Lucy said:
 > The special variable
 > $0
 > contains the name of the script being executed.
 > ..or the link if you do that.
 > :-)
 > --lucy
Tom Watson
Go to : www.abaselivemusic.com




Re: Can I tell how a program was called?

2001-05-28 Thread Lucy

The special variable 
$0
contains the name of the script being executed.

..or the link if you do that.
:-)

--lucy


> Firstly, HI to everyone - and thanks to the gurus for all the good advice 
> for us beginners :)
> 
> Now, the problem.
> 
> I was working on a project and realized that if I created a simple shell 
> program I could make things easier for myself. However, when I started to 
> code I found myself with a dilemma:
> 
> The program has to behave like two different programs depending on how it 
> was called. i.e. it has to know what the instruction used to start it was - 
> ignoring command-line parameters and such like. It would have two 
> instructions for starting it, one the name of the program, the other a link 
> to the same program but using a different name.
> 
> For example, from the command-line I could run the program by typing
> 
> [linux]# A -params  OR
> 
> [linux]# B -params
> 
> I want to be able to know if the program was started using program name A 
> or program name B. In pseudo-code:
> 
> if (called by A){ do something }
> elsif (called by B){ do a something else }
> 
> The program shares and stores the parameters for use with, (as it appears 
> to the user), either A or B, but both parts of the program can access any 
> of the parameters - they just act differently depending on the name used to 
> start the program.
> 
> I know that I could write two separate programs but the idea of doing it as 
> one just seemed less untidy.. plus now I'm not going to be happy until 
> I find an answer!
> 
> I have searched, ok, glanced, you caught me ;), through the perldocs and 
> the Perl Cookbook and found plenty dealing with capturing parameters passed 
> to the program and system interaction, but none quite touching on the 
> problem as I see it.
> 
> One solution I was mulling over was to try and get access to the bash 
> history (i.e. assume the last entry is our program being called) but the 
> problem is I don't know where or how bash history is stored, nor when the 
> last instruction is saved - i.e. if it is saved after the program executes 
> its of no use to the program.
> 
> Is there a simple way of doing this? Something like $^O (to get the os), 
> for example?
> 
> Thanks in advance for your help.
> 


-- 
Lucy Newman [EMAIL PROTECTED]

 



Can I tell how a program was called?

2001-05-28 Thread Tom Watson

Firstly, HI to everyone - and thanks to the gurus for all the good advice 
for us beginners :)

Now, the problem.

I was working on a project and realized that if I created a simple shell 
program I could make things easier for myself. However, when I started to 
code I found myself with a dilemma:

The program has to behave like two different programs depending on how it 
was called. i.e. it has to know what the instruction used to start it was - 
ignoring command-line parameters and such like. It would have two 
instructions for starting it, one the name of the program, the other a link 
to the same program but using a different name.

For example, from the command-line I could run the program by typing

[linux]# A -params  OR

[linux]# B -params

I want to be able to know if the program was started using program name A 
or program name B. In pseudo-code:

if (called by A){ do something }
elsif (called by B){ do a something else }

The program shares and stores the parameters for use with, (as it appears 
to the user), either A or B, but both parts of the program can access any 
of the parameters - they just act differently depending on the name used to 
start the program.

I know that I could write two separate programs but the idea of doing it as 
one just seemed less untidy.. plus now I'm not going to be happy until 
I find an answer!

I have searched, ok, glanced, you caught me ;), through the perldocs and 
the Perl Cookbook and found plenty dealing with capturing parameters passed 
to the program and system interaction, but none quite touching on the 
problem as I see it.

One solution I was mulling over was to try and get access to the bash 
history (i.e. assume the last entry is our program being called) but the 
problem is I don't know where or how bash history is stored, nor when the 
last instruction is saved - i.e. if it is saved after the program executes 
its of no use to the program.

Is there a simple way of doing this? Something like $^O (to get the os), 
for example?

Thanks in advance for your help.




AI-Categorize module

2001-05-28 Thread Moore, Larry

I would like to install and test this module on an NT system but I am not
having good luck.  Any help would be appreciated.

LM



Fileposting

2001-05-28 Thread Bernhard

Hi! I'm using a html form, where you can enter a file (a picture) and upload it, but 
when i send the form the Perl script only gets the local Adress of the file, but not 
the Data (so the picture) of the file. How can i save the picture in a new file on my 
Disk?
I have programmed it so that the new file will be saved in a new Folder.



Re: run perl in Win 2000 ?

2001-05-28 Thread Me

> The #! operator does not work.

Yes, the #! operator doesn't help in getting perl
to execute (though you should still use it to set
execution options like -w etc.)

On Windows, you should use the usual Windows
ways of doing this sort of thing. I think the most
common Windows idiom is to give all perl scripts
a particular extension, say .pl, and then create a
file association from .pl to the perl interpreter.




Re: size of textarea linked to param?

2001-05-28 Thread Me

> when I push the submit button to process the data inside the textarea 
> nothing happen if the textarea has a size > 1.6K
> 
> Any suggestion?

Use method=put rather than method=get. The latter
often truncates the total form data to around 2k.

If this doesn't help, you should probably head over to
the beginners-cgi list.




run perl in Win 2000 ?

2001-05-28 Thread prachi shroff

Hi,

I have WIN 2000 installed and have just started programming perl. Can 
somebody tell me how to set the PATH for the bin folder for the PERL 
executable? The #! operator does not work.

Thanks,
Prachi
_
Get your FREE download of MSN Explorer at http://explorer.msn.com




size of textarea linked to param?

2001-05-28 Thread P lerenard

Hi,
I use HTML and PERL together.
I have param which is a textarea value, but even if the size accepted by the 
textarea should be 32K, the form don't accept it.
when I push the submit button to process the data inside the textarea 
nothing happen if the textarea has a size > 1.6K

Any suggestion?

Thanks

Pierre


_
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.




Re: Win32::API and Win32::GUI

2001-05-28 Thread Adam Turoff

On Sun, May 27, 2001 at 11:32:16PM -0700, Helio S. Junior wrote:
> Is there anyone using one of these modules?
> I would like to exchange information about 
> how to use them.

You're likely to find people using those modules on 
<[EMAIL PROTECTED]>.  For more information, see the
archives at:

http://aspn.ActiveState.com/ASPN/Mail/browse/perl-win32-users

Z.




Re: Regex problem

2001-05-28 Thread John S. J. Anderson

> On Mon, 28 May 2001 17:29:40 +0100, "Bornaz, Daniel" <[EMAIL PROTECTED]> 
>said:

Daniel> $stt="The food is under the bar in the barn in the river.";
Daniel> $stt=~/bar(.*?)river/; print "$&";

Daniel> The output is: bar in the barn in the river

Daniel> Instead of the expected: barn in the river

Daniel> guaranteed by the question mark that follows the star. 

You've misunderstood (I think) both the effect of the non-greedy match
modifier ('?') and the way the Perl regex engine works. Perl starts
looking for matches at the left-hand side of the string; once a match
is found, the regex matches. 

In other words, your regex isn't looking for the shortest possible
substring bracketed by 'bar' and 'river'; it's looking for the _first_
possible match bracketed by 'bar' and 'river' (starting at the
left-hand part of the string). Since you've used the non-greedy
operator, Perl tries to extend the match right-ward from the first
'bar' match. If you hadn't used the non-greedy operator, the match
would have back-tracked from the end of the string.

As you note, in this case, that works out to the same thing, but if
your string was 'the food is under the bar in the barn in the river,
down-river from the sandbar', the output _would_ depend on whether the
non-greedy operator was present. (Try it and see!)

AFAIK, the question you're trying to ask (shortest substring between
two other substrings) isn't amenable to regex-ing; I'd probably try to
do something with split(),like this:

--code--
#! /usr/bin/perl -w

use strict;

my $string  = 'The food is under the bar in the barn in the river.';
my $left_bound  = 'bar';
my $right_bound = 'river';
my @matches = ();

my @one = split /$left_bound/ , $string;
foreach my $one ( @one ) {
  my @two = split /$right_bound/ , $one;
  next if $two[0] eq $one;
  push @matches , $two[0]
}

my $answer = $matches[0];
foreach( 1 .. $#matches ) {
  $answer = $matches[$_] if length( $matches[$_] ) < length( $answer )
}

print "$left_bound$answer$right_bound\n";
--/code--

john.




Re: Regex problem

2001-05-28 Thread Me

> Can anyone explain [Eager / Greedy], please?

Perl's regex engine is both Eager (Leftmost start)
and Greedy (Rightmost end).

The Greedy aspect is subservient to the Eager one.

The ? stops it being Greedy but not Eager.

To get the rightmost match, you could try adding
a .* at the start of the regex to greedily match from
the beginning.

See the Cookbook for more on this.




Regex problem

2001-05-28 Thread Bornaz, Daniel

Dear all,

I am trying the following code using ActivePerl 5.6.1.626, in my quest to
find the minimal string between "bar" and "river":

$stt="The food is under the bar in the barn in the river.";
$stt=~/bar(.*?)river/;
print "$&";

The output is:
bar in the barn in the river

Instead of the expected: 
barn in the river

guaranteed by the question mark that follows the star. In fact, the question
mark does not affect the output at all.
It seems to me that the greediness of the search expresion is only valid if
the string that you want to match shrinks from left to right, like looking
for the minimal match between "food" and "in", like in the following code:

$stt="The food is under the bar in the barn in the river.";
$stt=~/food(.*?)in/;
print "$&";

Which prints correctly:
food is under the bar in


Can anyone explain this, please?

Best regards,

Daniel Bornaz
GBS Specialist
~~
 Compaq Computer Romania
   77 Emanoil Porumbaru St.
   Bucharest Romania
   Tel.: +401 222 23 24
   Fax : +401 223 40 10
~~~