perl and java and html

2005-08-03 Thread Sonia
Hi,
I want to run PERL script which will combine several JAVA applications.
Furthermore, I need this script to run in the HTML page.
Is that possible?  Can I run this locally on my machine, without a server?

Thanks



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




perl and php and parseing

2002-12-15 Thread Jerry M . Howell II
Hello all,

   Not sure if any of you are familiar with the search tool called perlfect.
but if anyone is I'm useing it to index a site and have a problem, it doesn't
parse the .php files. Does anyone know if there is a way to make perl parse
php files? any modules out there for this?

-- 
Jerry M. Howell II

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




:: and ->

2006-02-16 Thread Ken Perl
what is the difference of :: and -> in this statements?

$authInstance = Operation::Auth::getInstance($session,$u->authMethod,$u->userId)

$authInstance = Operation::Auth->getInstance($session,$u->authMethod,$u->userId)

--
perl -e 'print unpack(u,"62V5N\"FME;G\!Ehttp://learn.perl.org/> <http://learn.perl.org/first-response>




$! and $@

2003-07-08 Thread jdavis
Hello,
  I think these catch errors somehow...

  $! and $@

  could someone explain this.

thanks,
-- 
jdavis <[EMAIL PROTECTED]>


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



$= and $~

2001-06-05 Thread Alan F. Larimer, Jr.

I am attempting to fo the following (pseudocode and realcode to
follow):

(nomal stuff with STDOUT)
$old = $=;
$~ = "HEADER";
$= = 25;  #cuz that's how many lines on the screen
(print some stuff with HEADER format)
$~ = "STDOUT";
$= = $old;
(more stuff with STDOUT)

I used a print statement to ensure that $= is being set properly, and
it is.  But when I print stuff with HEADER format, it seems to not
stick with that new $= = 25;  Yes, the output is still going to STDOUT
(screen), where I want it, but just not with the new
format_lines_per_page.

Thoughts, suggestions, concerns, complaints?

Thnx  --Alan


=
Alan F. Larimer, Jr.
http://www.geocities.com/lrng_lnx/

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



'' and ""

2001-09-11 Thread Matija Papec


Is there a reason why '' should be preferred over "" when using static
expressions? My guess is that "" takes a little longer at compile time for
perl to see if variables resides inside quotes, but don't know if this is
significant to bother with single quotes.

ps. I've always used "" but now my boss tells me that this is a bad thing :)


-- 
Matija

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




$_. and $_,

2004-10-13 Thread E.Horn
Hallo!
Stupid question, but i am a perlbeginner! :-(
What is the difference between $_. and $_, ??

Regards


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




& and >>

2007-09-04 Thread Dan Sopher
Regarding the following document:

 

http://perldoc.perl.org/functions/system.html

 

1.  What does ($? & 127) mean?
2.  What does $? >> 8  mean?

 

 

Example from the document:

 

if ($? == -1) {
 print   "failed to
execute: $!\n";
}
elsif ($? & 127) {
 printf   "child died
with signal %d, %s coredump\n",
 ($? & 127),  ($? & 128) ? 'with' : 'without';
}
else {
 printf   "child
exited with value %d\n", $? >> 8;

}

 

Thanks in advance,

 

Dan

 



Nested if and elsif and else

2010-04-13 Thread Mimi Cafe
I think this will work, but is it elegant.?

 

If (condition){

   if (nexted_condition){

  do this.

   }

   Elsif (nexted_condition){

  Do that... 

   }

  else{

Do something else.

  }

 

}

else{

   Do something else.. 

} 

 

 

Mimi



stat and chmod safety and prtability

2004-12-04 Thread JupiterHost.Net
Hello group:
In attempting to set $file2 to the same mode as $file1 I do this:
  my $mode = (stat($file1))[2];
  chmod $mode, $file2;
That code does the trick but I just want to make sure of:
1)
I see in perldoc -f chmod it talks about oct() but if I'm using stat's 
mode it should be safe not to use oct() correct?

2) $mode is really strange, ls -l shows a file as being 644 but $mode is 
 33188 or a directory as 755 but $mode is 16877

Why is that? What am I missing?
TIA
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 



Re: perl and java and html

2005-08-03 Thread Chris Devers
On Wed, 3 Aug 2005, Sonia wrote:

> I want to run PERL script which will combine several JAVA applications.

This is possible.

> Furthermore, I need this script to run in the HTML page.

This is not possible.

HTML is just a "markup language". It tells an application such as a web 
browser how to present the contents of the page text, but that's it. You 
can have HTML that includes or refers to Javascript (or *cough* *spit* 
VBScript) code, but the application interpreting the HTML handles it 
separately, if at all. 

If you want to mix HTML and Perl [note that it isn't capitalized; nor is 
Java for that matter], the common way to do it is with a CGI script. CGI 
scripts are programs that get run by a web server, accepting a request 
from that server, processing the result in some way -- such as by firing 
off Java programs in the background -- and then returning results back 
to the web client, typically in HTML format. 

You can run CGI scripts on your local computer IF you have a web server, 
but that's not necessarily a problem. Most versions of Unix will already 
include some version of the Apache web server, and there are many groups 
offering pre-packaged versions of Apache along with Perl, MySQL, and PHP 
for Windows. Once you have Apache installed, there's not much overhead 
to running things this way -- you just interact with things through a 
web browser on your computer using <http://localhost/myscript.pl> etc. 

If you want to do things this way, the beginners-cgi@perl.org list has 
been set up to help people get up and running with this sort of work.


-- 
Chris Devers

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




Re: perl and java and html

2005-08-03 Thread Tony Frasketi




Hello
I would appreciate it if you would steer me to one or more of those 
groups you mentioned that offer pre-packaged version of Apache with 
Perl, MySQL and PHP for windows  Can these packages run on the same 
machine that I have windows running? Do I access these packages from 
Windows or do i have to dedicate a windows machine just for Apache 
functionality? 
Thanks

Tony



You can run CGI scripts on your local computer IF you have a web server, 
but that's not necessarily a problem. Most versions of Unix will already 
include some version of the Apache web server, and there are many groups 
offering pre-packaged versions of Apache along with Perl, MySQL, and PHP 
for Windows. Once you have Apache installed, there's not much overhead 
to running things this way -- you just interact with things through a 
web browser on your computer using <http://localhost/myscript.pl> etc. 
 



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




Re: perl and java and html

2005-08-03 Thread Chris Devers
On Wed, 3 Aug 2005, Tony Frasketi wrote:

> I would appreciate it if you would steer me to one or more of those 
> groups you mentioned that offer pre-packaged version of Apache with 
> Perl, MySQL and PHP for windows 

A quick Google search turns up several:

http://www.google.com/search?q=windows+Apache+Perl+MySQL+PHP

Look through them and find one you like.

> Can these packages run on the same machine that I have windows 
> running? Do I access these packages from Windows or do i have to 
> dedicate a windows machine just for Apache functionality?

Yes. That's rather the point :-)

You can deploy things using these packages, but IMO that isn't really 
what they're most suitable for. All this software works fine on Windows 
now, but it really sings on Unix, and that's really the best way to put 
it into production. 

These kits are useful for developers to set up things on their Windows 
workstations (or laptops) and do all the work there, developing and 
testing sites all from one computer that isn't even necessarily attached 
to a network -- think of commuting on a train, etc. Once you're happy 
with how it works here, you can upload your work to whatever the server 
may be (or serverS, for that matter, if things are broken up that way), 
and everything should work the same way there that it did originally. 

These kits make things very easy, too. I've seen them set up on laptops 
for non-technical managers and salespeople so that they could do onsite 
demos of complex Apache / Perl / PHP / MySQL / Flash / Actionscript web
sites. Even if there wouldn't be a network connection available for the 
demo, no problem, just click the "Apache Start" icon in the Start menu, 
then open up http://localhost/demo/ in the web browser, and it seems as 
if the salesperson was connected back to the "real" site. Everything is 
going to work exactly the same way as the real site, even when it's all 
just running from a modest little Windows laptop.

I won't bother recommending a specific kit because every time I've 
looked in the past year or so, I turn up a whole different set of "top" 
ones according to Google rankings, and it isn't clear to me which, among 
the ones that come and go, has the best reputation. 

I knew a guy that really liked UniServer, to name just one, but I didn't 
like that one because the directory layout was really eccentric and it 
promoted bad habits like putting half the web server config in a bunch 
of scattered and hidden .htaccess files rather than one central 
httpd.conf, which made it really annoying to figure out some of the 
behavior it did. It mostly worked, but was hard to tinker with. 

I found another one that seemed to be much more sane than UniServer, but 
it was mostly in French & so was not really useful to a typical American 
development group. In any case, I forget what it was called.

So, like I say, search for yourself and decide for yourself which suite 
looks most useful to you. There's lots of options... :-)


-- 
Chris Devers

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




Re: perl and java and html

2005-08-03 Thread Tony Frasketi
Thanks very much Chris for the clear explanation. Sounds like just what 
I need - A way to completely build and check out a web site on my own 
compter and then be able to migrate it to a hosting service when I'm 
ready. Sure beats the local editing and back and forth trips from my 
computer to the hosting service via FTP and SSH shell.


Tony


These kits are useful for developers to set up things on their Windows 
workstations (or laptops) and do all the work there, developing and 
testing sites all from one computer that isn't even necessarily attached 
to a network -- think of commuting on a train, etc. Once you're happy 
with how it works here, you can upload your work to whatever the server 
may be (or serverS, for that matter, if things are broken up that way), 
and everything should work the same way there that it did originally. 

These kits make things very easy, too. I've seen them set up on laptops 
for non-technical managers and salespeople so that they could do onsite 
demos of complex Apache / Perl / PHP / MySQL / Flash / Actionscript web
sites. Even if there wouldn't be a network connection available for the 
demo, no problem, just click the "Apache Start" icon in the Start menu, 
then open up http://localhost/demo/ in the web browser, and it seems as 
if the salesperson was connected back to the "real" site. Everything is 
going to work exactly the same way as the real site, even when it's all 
just running from a modest little Windows laptop.



 



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




Re: perl and java and html

2005-08-03 Thread Xavier Noria

On Aug 4, 2005, at 2:47, Chris Devers wrote:

You can run CGI scripts on your local computer IF you have a web  
server,
but that's not necessarily a problem. Most versions of Unix will  
already
include some version of the Apache web server, and there are many  
groups
offering pre-packaged versions of Apache along with Perl, MySQL,  
and PHP

for Windows. Once you have Apache installed, there's not much overhead
to running things this way -- you just interact with things through a
web browser on your computer using <http://localhost/myscript.pl> etc.


There are other fast and lightweight web servers that have less  
features but are a breeze to configure, for instance:


 lighttpd
 http://www.lighttpd.net/

 Thy
 http://bonehunter.rulez.org/software/thy/

-- fxn

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




Re: perl and java and html

2005-08-04 Thread Sonia

"Chris Devers" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
> On Wed, 3 Aug 2005, Sonia wrote:
>
>> I want to run PERL script which will combine several JAVA applications.
>
> This is possible.
>
>> Furthermore, I need this script to run in the HTML page.
>
> This is not possible.
>
> HTML is just a "markup language". It tells an application such as a web
> browser how to present the contents of the page text, but that's it. You
> can have HTML that includes or refers to Javascript (or *cough* *spit*
> VBScript) code, but the application interpreting the HTML handles it
> separately, if at all.
>
> If you want to mix HTML and Perl [note that it isn't capitalized; nor is
> Java for that matter], the common way to do it is with a CGI script. CGI
> scripts are programs that get run by a web server, accepting a request
> from that server, processing the result in some way -- such as by firing
> off Java programs in the background -- and then returning results back
> to the web client, typically in HTML format.
>
> You can run CGI scripts on your local computer IF you have a web server,
> but that's not necessarily a problem. Most versions of Unix will already
> include some version of the Apache web server, and there are many groups
> offering pre-packaged versions of Apache along with Perl, MySQL, and PHP
> for Windows. Once you have Apache installed, there's not much overhead
> to running things this way -- you just interact with things through a
> web browser on your computer using <http://localhost/myscript.pl> etc.
>
> If you want to do things this way, the beginners-cgi@perl.org list has
> been set up to help people get up and running with this sort of work.
>
>
> -- 
> Chris Devers

Chris,
Thanks for the response.  In fact that is exactly what I want to do.   And I 
know it can be done with a local web server.
Let me ask you this though.
Is there a way for me to utilize Javascript, or other script (such as PHP), 
in order to avoid using the web server?
Basically, like the original problem stated.. I will have several Java 
programs that will be linked via Perl script, and then I wish to present 
results back in HTML file.  So is there any way for me to do this without 
the web server?
Maybe Perl is not the way to go then? What do you think?
Thanks in advance,
Sonia



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




Re: perl and java and html

2005-08-04 Thread Alfred Vahau

Hello
Try xampp for Windows for development purposes. Has Apache, MySql and PHP.
Great for testing out CGI scripts using Perl on the same box.

http://www.xampp.org/

Alfred Vahau

Tony Frasketi wrote:





Hello
I would appreciate it if you would steer me to one or more of those 
groups you mentioned that offer pre-packaged version of Apache with 
Perl, MySQL and PHP for windows  Can these packages run on the 
same machine that I have windows running? Do I access these packages 
from Windows or do i have to dedicate a windows machine just for 
Apache functionality? Thanks

Tony



You can run CGI scripts on your local computer IF you have a web 
server, but that's not necessarily a problem. Most versions of Unix 
will already include some version of the Apache web server, and there 
are many groups offering pre-packaged versions of Apache along with 
Perl, MySQL, and PHP for Windows. Once you have Apache installed, 
there's not much overhead to running things this way -- you just 
interact with things through a web browser on your computer using 
<http://localhost/myscript.pl> etc.  





--
-
Alfred K. Vahau
Director (IT Services)
University of Papua New Guinea
PO Box 320 UPNG NCD 134
Papua New Guinea
Phone: (675) 3267 277 Fax: (675) 3267 187
Mobile: 688 8926 Email: [EMAIL PROTECTED]
-



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




RE: perl and java and html

2005-08-08 Thread Bliss, Kevin
 

Chris,
Thanks for the response.  In fact that is exactly what I want to do.
And I 
know it can be done with a local web server.
Let me ask you this though.
Is there a way for me to utilize Javascript, or other script (such as
PHP), 
in order to avoid using the web server?
Basically, like the original problem stated.. I will have several Java 
programs that will be linked via Perl script, and then I wish to present

results back in HTML file.  So is there any way for me to do this
without 
the web server?
Maybe Perl is not the way to go then? What do you think?
Thanks in advance,
Sonia



It sounds like you want to run a perl script on your client that will
make a connection to a server.  Once connected the application (written
in perl) will run some java programs, process the data, and return back
html files to the client.  If that is what you want, perl can handle
that (perldoc Socket).  The Perl Cookbook has some examples of socket
programs.


--

This email is confidential and may be legally privileged.

It is intended solely for the addressee. Access to this email by anyone else, 
unless expressly approved by the sender or an authorized addressee, is 
unauthorized.

If you are not the intended recipient, any disclosure, copying, distribution or 
any action omitted or taken in reliance on it, is prohibited and may be 
unlawful. If you believe that you have received this email in error, please 
contact the sender, delete this e-mail and destroy all copies.

==


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




Re: perl and java and html

2005-08-11 Thread Jan Eden
Sonia wrote on 03.08.2005:

>Hi, I want to run PERL script which will combine several JAVA
>applications. Furthermore, I need this script to run in the HTML
>page. Is that possible?  Can I run this locally on my machine,
>without a server?
>
>Thanks

Check out mod_perl (and Apache::SSI):

<http://perl.apache.org>

Cheers,

Jan
-- 
Hanlon's Razor: Never attribute to malice that which can be adequately 
explained by stupidity.

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




Perl and mySQL and character sets.

2002-09-22 Thread Shaun Bramley

Hello all,

I am currently using perl to import some information into a mysql db.  At
this point in time I have two issues:

1.  The text files that are being imported contain both english and french
text.  My text editor (textpad) gladly displays the text with all proper
hyphens and accentuated characters.  Now when I use perl to read the files,
the characters that are being displayed are not what I am expecting to see.
Apparently perl is reading the file as UTF8??  How do I get it to recognize
the file as using the ISO-8859-1 character set??  Now this leads to my
second question

2.  Does how perl is displaying the text really matter? will it store the
'proper' character or will it store the messed up character?

3. Does mysql by default use the ISO-8859-1 character set?

Any help is greatly appreciated.

Thanks Shaun

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




Difference between system() and exec() and ``

2008-06-17 Thread swaroop
As we know there are 3 ways a system shell command to be executed.

1.> $var = system("command");
2.> $var = exec("command");
3.> $var = `command`;

What is difference between these three?  I found that the first two
options are printing the output of the command.  And the third one
simply stores the output in the variable.


Regards
Swaroop


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




Date and Time and Function calls

2007-11-25 Thread AndrewMcHorney

Hello

 I am looking for a perl function or functions that will give me the 
date and time. I am going to use the results to create a unique file name.


Andrew


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




regular expressions and search and replace.

2001-11-26 Thread Kris Vermeulen

Hi everyone!

Many programming languages are taking over regular expressions.
But since it originated from Perl (am I correct?), I taught this
would be the ideal place to drop my beginner's question.

I already succeeded in replacing occurrences of some string in a
complete text, but is it also possible to replace a beginning piece
and an ending piece of string and just leave the text in between?
I'll give a quick example. 

If I have a string:
"some text [LINK='page.html']linkname[/LINK] some more text"

I want to replace every "[LINK='page.html']" with 
I just want to search for [LINK= and the matching ] and just leave
the text in between. Is this possible using just regular expressions?

You probably can guess now what the purpose will be for this. =)


Many thanks for helping me,
Kris



smime.p7s
Description: application/pkcs7-signature


Perl and tk, where and what?

2001-12-12 Thread Hal Johnson

Hello,

I am trying to create windows interfaces for perl programs, and I've
been told that the TK extension is what to get.  I searched the
internet and found tk800.023.tar.gz but I'm not sure if that will work
with Windows 2000. Also, it seems I need a Visual C++ compiler to get
it to work. I don't have acces to Visual C++, but I've heard that there
are some freeware compilers and I just can't find them.
I'd be gratefull for any information on installation or use problems
you've encountered, etc. with tk and perl.

Thanks,
Hal Johnson

__
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.yahoo.com

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




Re: Nested if and elsif and else

2010-04-13 Thread Jim Gibson
On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" 
scribbled:

> I think this will work, but is it elegant.?

Yes, it will work, and yes, it is elegant, as long as it encapsulates the
logic that is required by your program.

Be sure and watch your indenting, so you can mentally group the correct
branches together (you are a little off in your first 'else'). Also be sure
and put some comments for each conditional that explains what is happening
if it is not obvious (but don't just repeat what is in the condition).

Make sure the 'do this', 'do that', and 'do something else' are not too
long. If they are more than a few statements, use subroutines (with good
names).

> If (condition){
> 
>if (nexted_condition){
> 
>   do this.
> 
>}
> 
>Elsif (nexted_condition){
> 
>   Do that... 
> 
>}
> 
>   else{
> 
> Do something else.
> 
>   }
> 
>  
> 
> }
> 
> else{
> 
>Do something else..
> 
> } 



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




Re: Nested if and elsif and else

2010-04-13 Thread Uri Guttman
>>>>> "JG" == Jim Gibson  writes:

  JG> On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" 

  JG> scribbled:

  >> I think this will work, but is it elegant.?

  JG> Yes, it will work, and yes, it is elegant, as long as it encapsulates the
  JG> logic that is required by your program.

i disagree that it is elegant. too often if/else lists are not
needed. many can be replaced by dispatch tables. if one of the clauses
does just a return or next/last that can be replaced with a modifier or
shorter statement. without ANY serious work, i have over 10k lines of
perl code in one system with about 10 else's and maybe 3 elsif's. it
just is a matter of knowing how to manage flow control well and you
rarely need else's. 

uri

-- 
Uri Guttman  --  u...@stemsystems.com    http://www.sysarch.com --
-  Perl Code Review , Architecture, Development, Training, Support --
-  Gourmet Hot Cocoa Mix    http://bestfriendscocoa.com -

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




Re: Nested if and elsif and else

2010-04-13 Thread Kenneth Wolcott
Hi;

On Tue, Apr 13, 2010 at 19:54, Uri Guttman  wrote:
>>>>>> "JG" == Jim Gibson  writes:
>
>  JG> On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" 
> 
>  JG> scribbled:
>
>  >> I think this will work, but is it elegant.?
>
>  JG> Yes, it will work, and yes, it is elegant, as long as it encapsulates the
>  JG> logic that is required by your program.
>
> i disagree that it is elegant. too often if/else lists are not
> needed. many can be replaced by dispatch tables. if one of the clauses
> does just a return or next/last that can be replaced with a modifier or
> shorter statement. without ANY serious work, i have over 10k lines of
> perl code in one system with about 10 else's and maybe 3 elsif's. it
> just is a matter of knowing how to manage flow control well and you
> rarely need else's.
>
> uri

I really like the switch statement (native in Perl v5.10) over
anything more complicated than one if/else clause.

Ken Wolcott

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




Re: Nested if and elsif and else

2010-04-14 Thread Shlomi Fish
On Wednesday 14 Apr 2010 02:35:50 Mimi Cafe wrote:
> I think this will work, but is it elegant.?
> 
> 
> 
> If (condition){
> 
>if (nexted_condition){
> 
>   do this.
> 
>}
> 
>Elsif (nexted_condition){
> 
>   Do that...
> 
>}
> 
>   else{
> 
> Do something else.
> 
>   }
> 
> 
> 
> }
> 
> else{
> 
>Do something else..
> 
> }
> 

As other people noted, it will work - you can nest if/elsif/else's (and other 
flow-control constructs) arbitrarily. However, as Martin Fowler notes in his
book "Refactoring" ( http://www.refactoring.com/ ) long functions or methods 
are a code smell which indicates that one should extract one-or-more functions 
out of them. So if you have an inner conditional, consider extracting it into 
a function. Often after you have such a function, you can use 
<< return COND() ? TRUE_VAL() : FALSE_VAL() ; >> which can avoid further 
clutter. Or you can consider using a dispatch table like Uri suggested.

I admit I often write quick-and-dirty code that has some levels of nested 
constructs (primarily in mostly standalone scripts or programs) but it's 
better to refactor them into smaller subroutines for more serious stuff.

Regards,

Shlomi Fish

-- 
-
Shlomi Fish   http://www.shlomifish.org/
Why I Love Perl - http://shlom.in/joy-of-perl

Deletionists delete Wikipedia articles that they consider lame.
Chuck Norris deletes deletionists whom he considers lame.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

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




RE: Nested if and elsif and else

2010-04-14 Thread Mimi Cafe
Yes, the nested if and elsif and else makes the code difficult to read and I
often get stuck trying to make sense of it all. For now, I will look to see
if I can move some bit and pieces to subroutines to improve readability.

Thanks guys
Mimi

-Original Message-
From: Jim Gibson [mailto:jimsgib...@gmail.com] 
Sent: 14 April 2010 01:36
To: beginners@perl.org
Subject: Re: Nested if and elsif and else

On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" 
scribbled:

> I think this will work, but is it elegant.?

Yes, it will work, and yes, it is elegant, as long as it encapsulates the
logic that is required by your program.

Be sure and watch your indenting, so you can mentally group the correct
branches together (you are a little off in your first 'else'). Also be sure
and put some comments for each conditional that explains what is happening
if it is not obvious (but don't just repeat what is in the condition).

Make sure the 'do this', 'do that', and 'do something else' are not too
long. If they are more than a few statements, use subroutines (with good
names).

> If (condition){
> 
>if (nexted_condition){
> 
>   do this.
> 
>}
> 
>Elsif (nexted_condition){
> 
>   Do that... 
> 
>}
> 
>   else{
> 
> Do something else.
> 
>   }
> 
>  
> 
> }
> 
> else{
> 
>Do something else..
> 
> } 



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




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




Re: Nested if and elsif and else

2010-04-14 Thread Steve Bertrand
On 2010.04.13 23:17, Kenneth Wolcott wrote:
> Hi;
> 
> On Tue, Apr 13, 2010 at 19:54, Uri Guttman  wrote:
>>>>>>> "JG" == Jim Gibson  writes:
>>
>>  JG> On 4/13/10 Tue  Apr 13, 2010  4:35 PM, "Mimi Cafe" 
>> 
>>  JG> scribbled:
>>
>>  >> I think this will work, but is it elegant.?
>>
>>  JG> Yes, it will work, and yes, it is elegant, as long as it encapsulates 
>> the
>>  JG> logic that is required by your program.
>>
>> i disagree that it is elegant. too often if/else lists are not
>> needed. many can be replaced by dispatch tables. if one of the clauses
>> does just a return or next/last that can be replaced with a modifier or
>> shorter statement. without ANY serious work, i have over 10k lines of
>> perl code in one system with about 10 else's and maybe 3 elsif's. it
>> just is a matter of knowing how to manage flow control well and you
>> rarely need else's.
>>
>> uri
> 
> I really like the switch statement (native in Perl v5.10) over
> anything more complicated than one if/else clause.

I agree with Uri. Even switch statements can be cumbersome depending on
how many cases you have. I believe that (in the majority of cases)
dispatch tables are far more effective, easy to read (like a table of
contents) and maintainable (ie. very easy to add to without having to
worry about placement).

#!/usr/bin/perl

use warnings;
use strict;

my $dt = {
simple  => sub { print "Simple, anon sub inline\n" },
easy=> sub { my $num = 1; print $num*2 ."\n";}, 
complex => \&complex, # coderef to external sub,
};

sub complex {
my $num = shift;
# ... do a bunch of stuff
print "$num\n";
}

# call them

$dt->{ simple }();
$dt->{ easy }();
$dt->{ complex }( 5 );

Steve


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




Re: Nested if and elsif and else

2010-04-14 Thread Raymond Wan


Hi Mimi,


Mimi Cafe wrote:

I think this will work, but is it elegant.?

If (condition){

   if (nexted_condition){



As others have noted, it will work.  But as for elegance, this is a very subjective opinion and 
contrary to what recent comments have said, my take on it is that it depends on who intends to look 
at this code and what their background is.  Is it just you?  Or publicly available open source for 
potentially everyone?  Or just the members of your software engineering team?  Are they people with 
good Perl backgrounds or are their backgrounds varied and maybe might prefer if...else and switch, 
constructs that are available in other languages.


I personally prefer switch and if..else (in that order) since they are based on keywords which my 
syntax highlighter picks up easily and are even shown when I print the code out.  Also, I can grep 
for, if I need to.


Regardless of what you choose, you should also use comments before the block of code to explain what 
it is you're doing...


Ray


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




Re: Nested if and elsif and else

2010-04-15 Thread Harry Putnam
"Uri Guttman"  writes:

> i disagree that it is elegant. too often if/else lists are not
> needed. many can be replaced by dispatch tables. if one of the clauses
> does just a return or next/last that can be replaced with a modifier or
> shorter statement. without ANY serious work, i have over 10k lines of
> perl code in one system with about 10 else's and maybe 3 elsif's. it
> just is a matter of knowing how to manage flow control well and you
> rarely need else's. 

Can someone show an example of an if/elsif/else nested construct being
replaced by a dispatch table?


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




Re: Nested if and elsif and else

2010-04-15 Thread rkb
Harry Putnam wrote:
> "Uri Guttman"  writes:
>
>> i disagree that it is elegant. too often if/else lists
>> are not
>> needed. many can be replaced by dispatch tables. if one
>> of the clauses
>> does just a return or next/last that can be replaced
>> with a modifier or
>> shorter statement. without ANY serious work, i have over
>> 10k lines of
>> perl code in one system with about 10 else's and maybe 3
>> elsif's. it
>> just is a matter of knowing how to manage flow control
>> well and you
>> rarely need else's.
>
> Can someone show an example of an if/elsif/else nested
> construct being
> replaced by a dispatch table?
>
> --

Here's an example I gave in a similar question in another
forum.

my %dispatch = (
1 => \&getcpuinfo,
2 => \&osversion,
3 => \&loadaverages,
        4 => \&systemload_uptime,
5 => \&netinterfaceinfo,
6 => \&diskusage,
7 => \&ipaddress,
q => sub { print "Goodbye\n" and exit; },
error => sub { print "invalid selection\n" },
);

while(1)
{
print "press 1 to get CPU Info \n",
  "press 2 to get OS version \n",
  "press 3 to get CPU Load averages\n",
  "press 4 to get System Load & Uptime\n",
  "press 5 to get Net Interface info\n",
  "press 6 to get system disk usage info \n",
  "press 7 to get IP address info \n";
  "press q to Exit\n"

chomp(my $selection) = ;

my $code = $dispatch{$selection} || $dispatch{'error'} ;
$code->();
}


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




Re: Nested if and elsif and else

2010-04-15 Thread Harry Putnam
r...@i.frys.com writes:

> Here's an example I gave in a similar question in another
> forum.

Thanks... 

I'm sorry to ask more but if someone asked to be shown an
if/elsif/else construct being replaced by a dispatch table, I don't
really see how that answered there question.  It didn't for me.

Where is the comparable if/elsif/else construct that is being replaced
by the dispatch table?

Visualizing how it would go is a little beyond my grasp I guess.


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




Re: Nested if and elsif and else

2010-04-15 Thread Jim Gibson
On 4/15/10 Thu  Apr 15, 2010  9:21 AM, "Harry Putnam" 
scribbled:

> r...@i.frys.com writes:
> 
>> Here's an example I gave in a similar question in another
>> forum.
> 
> Thanks... 
> 
> I'm sorry to ask more but if someone asked to be shown an
> if/elsif/else construct being replaced by a dispatch table, I don't
> really see how that answered there question.  It didn't for me.
> 
> Where is the comparable if/elsif/else construct that is being replaced
> by the dispatch table?
> 
> Visualizing how it would go is a little beyond my grasp I guess.


Something like this:

  print "press 1 to get CPU Info \n",
"press 2 to get OS version \n",
"press 3 to get CPU Load averages\n",
"press 4 to get System Load & Uptime\n",
"press 5 to get Net Interface info\n",
"press 6 to get system disk usage info \n",
"press 7 to get IP address info \n";
"press q to Exit\n"

  chomp(my $selection) = ;
  if( $selection eq '1' ) {
getcpuinfo();
  }elsif( $selection eq '2' ) {
osversion();
  }elsif{ $selection eq '3' ) {
loadaverages();
  }elseif( $selection eq '4' ) {
systemload_uptime();
  ]elsif( 
...
  }else{
print "Dispatch error\n";
  );





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




Re: Nested if and elsif and else

2010-04-15 Thread Ron Bergin
On Apr 15, 9:21 am, rea...@newsguy.com (Harry Putnam) wrote:
> r...@i.frys.com writes:
> > Here's an example I gave in a similar question in another
> > forum.
>
> Thanks...
>
> I'm sorry to ask more but if someone asked to be shown an
> if/elsif/else construct being replaced by a dispatch table, I don't
> really see how that answered there question.  It didn't for me.
>
> Where is the comparable if/elsif/else construct that is being replaced
> by the dispatch table?
>
> Visualizing how it would go is a little beyond my grasp I guess.

Sorry for not posting the if/elsif/else block, but to me that part
appeared to be obvious, but I guess it wasn't.

I see that Jim has posted the if/elsif/else part, so I won't duplicate
it.


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




Re: Nested if and elsif and else

2010-04-15 Thread Harry Putnam
Ron Bergin  writes:

> Sorry for not posting the if/elsif/else block, but to me that part
> appeared to be obvious, but I guess it wasn't.

Probably would have been for all but the densist I guess.  Not the
first time I've been guilty of that.

> I see that Jim has posted the if/elsif/else part, so I won't duplicate
> it.

Yes, and thanks to both of you for making it clear even to me.

You fella's have lots of patience.


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




Re: stat and chmod safety and prtability

2004-12-04 Thread Lawrence Statton
> Hello group:
> 
> In attempting to set $file2 to the same mode as $file1 I do this:
> 
>my $mode = (stat($file1))[2];
>chmod $mode, $file2;
> 
> That code does the trick but I just want to make sure of:
> 
> 1)
> I see in perldoc -f chmod it talks about oct() but if I'm using stat's 
> mode it should be safe not to use oct() correct?
> 
> 2) $mode is really strange, ls -l shows a file as being 644 but $mode is 
>   33188 or a directory as 755 but $mode is 16877
> 

33188 is 0100644  
16877 is  040755

from perldoc -f stat:

     Because the mode contains both the file type and its
 permissions, you should mask off the file type
 portion and (s)printf using a "%o" if you want to
 see the real permissions.


Since chmod() cannot not change the *type* of the file, those bits
appear to be ignored.

..BEGIN PERL PROGRAM ...
#!/usr/bin/perl

use strict; 
use warnings; 

my $file = '/tmp/test.pl'; 
my $mode = (stat($file))[2];

print "Mode was; $mode or in octal (which makes more sense) ", sprintf("%o", 
$mode),"\n" ; 



... END PERL PROGRAM ...

-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
Lawrence Statton - [EMAIL PROTECTED] s/aba/c/g
Computer  software  consists of  only  two  components: ones  and
zeros, in roughly equal proportions.   All that is required is to
sort them into the correct order.

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




Re: stat and chmod safety and prtability

2004-12-04 Thread JupiterHost.Net

Lawrence Statton wrote:
Hello group:
In attempting to set $file2 to the same mode as $file1 I do this:
  my $mode = (stat($file1))[2];
  chmod $mode, $file2;
That code does the trick but I just want to make sure of:
1)
I see in perldoc -f chmod it talks about oct() but if I'm using stat's 
mode it should be safe not to use oct() correct?

2) $mode is really strange, ls -l shows a file as being 644 but $mode is 
 33188 or a directory as 755 but $mode is 16877


33188 is 0100644  
16877 is  040755

from perldoc -f stat:
 Because the mode contains both the file type and its
 permissions, you should mask off the file type
     portion and (s)printf using a "%o" if you want to
 see the real permissions.
Since chmod() cannot not change the *type* of the file, those bits
appear to be ignored.
..BEGIN PERL PROGRAM ...
#!/usr/bin/perl
use strict; 
use warnings; 

my $file = '/tmp/test.pl'; 
my $mode = (stat($file))[2];

print "Mode was; $mode or in octal (which makes more sense) ", sprintf("%o", $mode),"\n" ; 


... END PERL PROGRAM ...
Thanks Lawrence for the info, I understand much better now!
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



pack and unpack .. and 16 bit integers

2005-08-19 Thread zach
hi,

first, sorry for my english and i hope you understand.


Honestly im still confused with all defines like :
1. Unsigned Char value, is that 'invisible char'? like
we press 'spacebar key' or 'ctrl+f1' ?
2. In perlfunc pack i read something like this -> 'the
pack code for big endian is n for 16 bit and N for 32
bit integers', so i tried to explain to my self that
16 bit integers are "Numbers between 0-65536" ..
because 16 bit = 2^16, is it true?

3. what's big endian? isit just machine architecture?

4. have a look at my 4th question below :

here's the code :

$tcp_pseudo = pack('a4a4CCnnnNNH2B8nvn',
$tcp_len,$src_port,$dst_port,$syn,$ack,$tcp_head_reserved,$tcp_all,
$tcp_win,$null,$tcp_urg_ptr);
====
the full code is at :
http://www.perlmonks.org/index.pl?node_id=17576

and i tried to explain to myself like this :
1. a4 is for $tcp_len
2. a4 is for $src_port
3. C is for $dst_port
4. C is for $syn
5. n is for $ack
6. n is for $tcp_head_reserved
7. n is for $tcp_all
8. N is for $tcp_win
9. N is for $null
10. H2 is for $tcp_urg_ptr

is that true ?


im trying hard to explain my problem, and i hope u
understand, i know english's my biggest problem :[


cheers









Start your day with Yahoo! - make it your home page 
http://www.yahoo.com/r/hs 
 

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




Re: Difference between system() and exec() and ``

2008-06-17 Thread Jeff Peng
On Tue, Jun 17, 2008 at 1:47 PM, swaroop <[EMAIL PROTECTED]> wrote:
> As we know there are 3 ways a system shell command to be executed.
>
> 1.> $var = system("command");
> 2.> $var = exec("command");
> 3.> $var = `command`;
>
> What is difference between these three?  I found that the first two
> options are printing the output of the command.  And the third one
> simply stores the output in the variable.

`command` for capturing the command's output and assign it to a variable.
for what's the difference between system and exec, see 'perldoc -q "exec"'.


-- 
Jeff Peng - [EMAIL PROTECTED]
Professional Squid supports in China
http://www.ChinaSquid.com/

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




Re: Difference between system() and exec() and ``

2008-06-17 Thread Chas. Owens
On Tue, Jun 17, 2008 at 01:47, swaroop <[EMAIL PROTECTED]> wrote:
> As we know there are 3 ways a system shell command to be executed.
>
> 1.> $var = system("command");
> 2.> $var = exec("command");
> 3.> $var = `command`;
>
> What is difference between these three?  I found that the first two
> options are printing the output of the command.  And the third one
> simply stores the output in the variable.

The exec function* replaces the current process with the one specified
in the arguments, so exec("bash", "-l") would replace the perl process
with bash login shell running interactively.  This is most often not
what you want to do.  You want to run an external program and wait for
it to finish.  To do this you would need to fork the current process
into two processes (parent and child) and replace the child process
with an exec call to the external program while the parent process
waits for the child process to complete.  This is what the system
function** does.  It is implemented in terms of a fork***, an exec,
and a waitpid.  Due to the way fork works the file handles of the
parent are inherited by the child, so STDOUT and STDERR in the process
created by system are the same as in the Perl program.  This is why
output shows up when you use system or exec.

The qx// operator* (also known as ``) is very different.  It is
most likely implemented via the popen** function from
SUSv2***.  It captures the STDOUT (but not the STDERR) of an
external program and returns it as a list of lines (in list context)
or as string (in scalar context).

Other options for running (and capturing output/providing input)
include the open function (STDOUT or STDIN only),
IPC::Open2* (STDIN and STDOUT), and IPC::Open3**
(STDIN, STDOUT, and STDERR).

If you are not writing a quick and dirty program the open function is
preferable to the qx// operator because you have more control and the
output data shows up as soon as possible (rather than at the end of
the external program's run):

open my $output, "-|", "program_to_execute", "argument 1", "argument 2"
or die "could not run program: $!";

while (my $line = <$output>) {
#do something with a line printed by program_to_execute
#$line shows up here as soon as it is flushed
}

IPC::Open2 and IPC::Open3 provide even more control, and are useful
for puppet stringing other programs.

* http://perldoc.perl.org/functions/exec.html
** http://perldoc.perl.org/functions/system.html
*** http://perldoc.perl.org/functions/fork.html
 http://perldoc.perl.org/functions/waitpid.html
* http://perldoc.perl.org/perlop.html#qx/STRING/
** http://www.opengroup.org/onlinepubs/007908799/xsh/popen.html
*** Single UNIX Specification, the thing that replaced POSIX, see
http://en.wikipedia.org/wiki/Single_UNIX_Specification
 http://perldoc.perl.org/functions/open.html
* http://perldoc.perl.org/IPC/Open2.html
** http://perldoc.perl.org/IPC/Open3.html

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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




Re: Difference between system() and exec() and ``

2008-06-17 Thread Gunnar Hjalmarsson

swaroop wrote:

As we know there are 3 ways a system shell command to be executed.

1.> $var = system("command");
2.> $var = exec("command");
3.> $var = `command`;

What is difference between these three?


You should not have asked that question here; you should have looked up 
the answer in the docs. I think the best starting point is


perldoc -f system

Another thing would have been if you had made an attempt with the docs, 
and needed help to understand it. _That_ would have been a good reason 
to ask for help.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: Difference between system() and exec() and ``

2008-06-17 Thread Rob Dixon
Gunnar Hjalmarsson wrote:
> swaroop wrote:
>> As we know there are 3 ways a system shell command to be executed.
>>
>> 1.> $var = system("command");
>> 2.> $var = exec("command");
>> 3.> $var = `command`;
>>
>> What is difference between these three?
> 
> You should not have asked that question here; you should have looked up 
> the answer in the docs.

  Sheesh!

  This is the first thing I read on perl.beginners after time away.

  Are you really from the Cocos Islands, Gunnar?

  I think you should talk to the other abusive people who like to post here and
  form a separate group.

  Rob

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




Re: Difference between system() and exec() and ``

2008-06-17 Thread Gunnar Hjalmarsson

Rob Dixon wrote:

Gunnar Hjalmarsson wrote:

swaroop wrote:

As we know there are 3 ways a system shell command to be executed.

1.> $var = system("command");
2.> $var = exec("command");
3.> $var = `command`;

What is difference between these three?
You should not have asked that question here; you should have looked up 
the answer in the docs.


  Sheesh!

  This is the first thing I read on perl.beginners after time away.

  Are you really from the Cocos Islands, Gunnar?

  I think you should talk to the other abusive people who like to post here and
  form a separate group.


I take it that you don't agree.

The OP wondered about two built-in functions and the backticks operator. 
I can't think of a more natural first step to find out how they work 
than reading about them in the Perl documentation. Do you mean that I'm 
abusive by suggesting that people make it a habit to use the docs at 
first hand? If that's what you mean, I think you are plain stupid.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




Re: Difference between system() and exec() and ``

2008-06-18 Thread Rob Dixon
Gunnar Hjalmarsson wrote:
> Rob Dixon wrote:
>> Gunnar Hjalmarsson wrote:
>>> swaroop wrote:
>>>>
>>>> As we know there are 3 ways a system shell command to be executed.
>>>>
>>>> 1.> $var = system("command");
>>>> 2.> $var = exec("command");
>>>> 3.> $var = `command`;
>>>>
>>>> What is difference between these three?
>>>
>>> You should not have asked that question here; you should have looked up 
>>> the answer in the docs.
>>
>>   Sheesh!
>>
>>   This is the first thing I read on perl.beginners after time away.
>>
>>   Are you really from the Cocos Islands, Gunnar?
>>
>>   I think you should talk to the other abusive people who like to post here 
>> and
>>   form a separate group.
> 
> I take it that you don't agree.
> 
> The OP wondered about two built-in functions and the backticks operator. 
> I can't think of a more natural first step to find out how they work 
> than reading about them in the Perl documentation. Do you mean that I'm 
> abusive by suggesting that people make it a habit to use the docs at 
> first hand? If that's what you mean, I think you are plain stupid.

It has become popular in the last year or so to criticize people who ask
questions on this list essentially for not already knowing the answer. If you
have lost track of what sort of information a Perl beginner may not know then
you should not be trying to help them. It is entirely possible that the OP had
no knowledge of the built in documentation, or even that he had already read it,
failed to understand it and was looking for a summary from people who were more
familiar with the language. The pompous RTFM reply is precisely what Casey was
trying to put a stop to when he initiated this list.

And I wondered if you were really from the Cocos Islands because your email has
a .cc country code. I spent a couple of weeks there when I last finished working
in India.

Rob

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




Re: Difference between system() and exec() and ``

2008-06-18 Thread Dr.Ruud
Rob Dixon schreef:

> I think you should talk to the other abusive people who like to
> post here and form a separate group.

LOL 

Stop trying to find your way in like this! ;) 

-- 
Affijn, Ruud

"Gewoon is een tijger."

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




Re: Difference between system() and exec() and ``

2008-06-18 Thread Gunnar Hjalmarsson

Rob Dixon wrote:
It is entirely possible that the OP had no knowledge of the built in 
documentation,


True. But you can't seriously mean that we should accept that as a 
persistent state instead of calling his attention to it??



or even that he had already read it, failed to understand it


Yes, but considering the wording of the original post, that's highly 
unlikely, so the OP couldn't reasonably be offended by a request to make 
use of the docs.


The pompous RTFM reply is precisely what Casey was trying to put a 
stop to when he initiated this list.


RTFM is often _the_ adequate response to a question. It was in this case 
IMO. Trying to put a stop to requests to use the docs sounds just 
idiotic to me.


And I wondered if you were really from the Cocos Islands because your 
email has a .cc country code.


No, I'm from Sweden. But the .se TLD wasn't available to private persons 
when I registered my domain a few years ago.


--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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




RE: Difference between system() and exec() and ``

2008-06-18 Thread Richard.Copits


I mostly lurk, but just to offer a thought.this list seems to be
created
to help - not to chastise, so why put conditions on a request for help?
Why try to insure that the person is "worthy" of help?

A signature line on an email said in effect that the best skill a
programmer
can have is to be able to read. I differ. I think that the best skill a
programmer
can have is the ability to LISTEN. More bad programs and bad projects
won't
get done if you have that skill/ability.

Check out Matthew 7:9 and Luke 11:11 and no, I'm not religious but AM
someone who many times asks questions that are incredibly difficult for
me but incredibly easy if you have years of experience. Brain surgery is
easy once you know how.



-Original Message-
From: Gunnar Hjalmarsson [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 18, 2008 4:03 PM
To: beginners@perl.org
Subject: Re: Difference between system() and exec() and ``

Rob Dixon wrote:
> It is entirely possible that the OP had no knowledge of the built in 
> documentation,

True. But you can't seriously mean that we should accept that as a 
persistent state instead of calling his attention to it??

> or even that he had already read it, failed to understand it

Yes, but considering the wording of the original post, that's highly 
unlikely, so the OP couldn't reasonably be offended by a request to make

use of the docs.

> The pompous RTFM reply is precisely what Casey was trying to put a 
> stop to when he initiated this list.

RTFM is often _the_ adequate response to a question. It was in this case

IMO. Trying to put a stop to requests to use the docs sounds just 
idiotic to me.

> And I wondered if you were really from the Cocos Islands because your 
> email has a .cc country code.

No, I'm from Sweden. But the .se TLD wasn't available to private persons

when I registered my domain a few years ago.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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



Portions of this message may be confidential under an exemption to Ohio's 
public records law or under a legal privilege. If you have received this 
message in error or due to an unauthorized transmission or interception, please 
delete all copies from your system without disclosing, copying, or transmitting 
this message.

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




Re: Difference between system() and exec() and ``

2008-06-18 Thread Jenda Krynicky
Rob Dixon wrote:
> Gunnar Hjalmarsson wrote:
> > Rob Dixon wrote:
> >> Gunnar Hjalmarsson wrote:
> >>> swaroop wrote:
> >>>>
> >>>> As we know there are 3 ways a system shell command to be executed.
> >>>>
> >>>> 1.> $var = system("command");
> >>>> 2.> $var = exec("command");
> >>>> 3.> $var = `command`;
> >>>>
> >>>> What is difference between these three?
> >>>
> >>> You should not have asked that question here; you should have looked up 
> >>> the answer in the docs.
> >>
> >>   I think you should talk to the other abusive people who like to post 
> >> here and
> >>   form a separate group.
> > 
> > I take it that you don't agree.
> > 
> > The OP wondered about two built-in functions and the backticks operator. 
> > I can't think of a more natural first step to find out how they work 
> > than reading about them in the Perl documentation. Do you mean that I'm 
> > abusive by suggesting that people make it a habit to use the docs at 
> > first hand? If that's what you mean, I think you are plain stupid.
> 
> It has become popular in the last year or so to criticize people who ask
> questions on this list essentially for not already knowing the answer. If you
> have lost track of what sort of information a Perl beginner may not know then
> you should not be trying to help them. It is entirely possible that the OP had
> no knowledge of the built in documentation, or even that he had already read 
> it,
> failed to understand it and was looking for a summary from people who were 
> more
> familiar with the language. The pompous RTFM reply is precisely what Casey was
> trying to put a stop to when he initiated this list.

Spoonfeeding someone is not the best way to help him/her. He/she will 
only become dependent. 

If swaroop did not know where to find the docs, he/she should have 
asked where to find the docs.

If he/she could not understand the difference from the docs, he/she 
should have said he can't understand the docs and if possible say 
what does he find hard to understand.

There's nothing pompous about pointing someone at the source of the 
information he needs. It could, and probably should, be done better, 
telling swaroop to read the docs he obtains by running
  perldoc -f system
and
  perldoc -f exec
and
  perldoc perlop

And telling him that if he uses Windows and installed ActivePerl then 
in all likelyhood he has a shortcut to the complete Perl 
documentation in his start menu.

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]
http://learn.perl.org/




Re: Difference between system() and exec() and ``

2008-06-18 Thread Jay Savage
On Wed, Jun 18, 2008 at 4:40 AM, Rob Dixon <[EMAIL PROTECTED]> wrote:
> Gunnar Hjalmarsson wrote:
>> Rob Dixon wrote:
>>> Gunnar Hjalmarsson wrote:
>>>> swaroop wrote:
>>>>>
>>>>> As we know there are 3 ways a system shell command to be executed.
>>>>>
>>>>> 1.> $var = system("command");
>>>>> 2.> $var = exec("command");
>>>>> 3.> $var = `command`;
>>>>>
>>>>> What is difference between these three?
>>>>
>>>> You should not have asked that question here; you should have looked up
>>>> the answer in the docs.
>>>
>>>   Sheesh!
>>>
>>>   This is the first thing I read on perl.beginners after time away.
>>>
>>>   Are you really from the Cocos Islands, Gunnar?
>>>
>>>   I think you should talk to the other abusive people who like to post here 
>>> and
>>>   form a separate group.
>>
>> I take it that you don't agree.
>>
>> The OP wondered about two built-in functions and the backticks operator.
>> I can't think of a more natural first step to find out how they work
>> than reading about them in the Perl documentation. Do you mean that I'm
>> abusive by suggesting that people make it a habit to use the docs at
>> first hand? If that's what you mean, I think you are plain stupid.
>
> It has become popular in the last year or so to criticize people who ask
> questions on this list essentially for not already knowing the answer. If you
> have lost track of what sort of information a Perl beginner may not know then
> you should not be trying to help them. It is entirely possible that the OP had
> no knowledge of the built in documentation, or even that he had already read 
> it,
> failed to understand it and was looking for a summary from people who were 
> more
> familiar with the language. The pompous RTFM reply is precisely what Casey was
> trying to put a stop to when he initiated this list.
>

Hear, Hear!


--
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org

values of β will give rise to dom!


Re: Difference between system() and exec() and ``

2008-06-18 Thread Chas. Owens
On Wed, Jun 18, 2008 at 16:18,  <[EMAIL PROTECTED]> wrote:
snip
> A signature line on an email said in effect that the best skill a
> programmer
> can have is to be able to read. I differ. I think that the best skill a
> programmer
> can have is the ability to LISTEN. More bad programs and bad projects
> won't
> get done if you have that skill/ability.
snip

That would be my sig, and I stick to it.  Most of the time (in my
experience) a programmer won't get verbal instructions.  The ability
to read* (code, documentation, specs, etc) is a programmer's most
important skill.  Writing is the second most important skill.  Being
able to write clear, unambiguous prose is vital to the specification
and documentation process, and, of course, a programmer who can't code
is a programmer (although, there is a place for the analyst).

* and comprehend

-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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




Re: Difference between system() and exec() and ``

2008-06-18 Thread Chas. Owens
On Wed, Jun 18, 2008 at 16:41, Chas. Owens <[EMAIL PROTECTED]> wrote:
> On Wed, Jun 18, 2008 at 16:18,  <[EMAIL PROTECTED]> wrote:
> snip
>> A signature line on an email said in effect that the best skill a
>> programmer
>> can have is to be able to read. I differ. I think that the best skill a
>> programmer
>> can have is the ability to LISTEN. More bad programs and bad projects
>> won't
>> get done if you have that skill/ability.
> snip
>
> That would be my sig, and I stick to it.  Most of the time (in my
> experience) a programmer won't get verbal instructions.  The ability
> to read* (code, documentation, specs, etc) is a programmer's most
> important skill.  Writing is the second most important skill.  Being
> able to write clear, unambiguous prose is vital to the specification
> and documentation process, and, of course, a programmer who can't code
> is a programmer (although, there is a place for the analyst).

That should have been "is not".  Proofreading is the third most important skill.

>
> * and comprehend
>
> --
> Chas. Owens
> wonkden.net
> The most important skill a programmer can have is the ability to read.
>



-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.

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




Re: Difference between system() and exec() and ``

2008-06-18 Thread Jay Savage
On Wed, Jun 18, 2008 at 4:25 PM, Jenda Krynicky <[EMAIL PROTECTED]> wrote:
> Rob Dixon wrote:
>> Gunnar Hjalmarsson wrote:
>> > Rob Dixon wrote:
>> >> Gunnar Hjalmarsson wrote:
>> >>> swaroop wrote:
>> >>>>
>> >>>> As we know there are 3 ways a system shell command to be executed.
>> >>>>
>> >>>> 1.> $var = system("command");
>> >>>> 2.> $var = exec("command");
>> >>>> 3.> $var = `command`;
>> >>>>
>> >>>> What is difference between these three?
>> >>>
>> >>> You should not have asked that question here; you should have looked up
>> >>> the answer in the docs.
>> >>
>> >>   I think you should talk to the other abusive people who like to post 
>> >> here and
>> >>   form a separate group.
>> >
>> > I take it that you don't agree.
>> >
>> > The OP wondered about two built-in functions and the backticks operator.
>> > I can't think of a more natural first step to find out how they work
>> > than reading about them in the Perl documentation. Do you mean that I'm
>> > abusive by suggesting that people make it a habit to use the docs at
>> > first hand? If that's what you mean, I think you are plain stupid.
>>
>> It has become popular in the last year or so to criticize people who ask
>> questions on this list essentially for not already knowing the answer. If you
>> have lost track of what sort of information a Perl beginner may not know then
>> you should not be trying to help them. It is entirely possible that the OP 
>> had
>> no knowledge of the built in documentation, or even that he had already read 
>> it,
>> failed to understand it and was looking for a summary from people who were 
>> more
>> familiar with the language. The pompous RTFM reply is precisely what Casey 
>> was
>> trying to put a stop to when he initiated this list.
>
> Spoonfeeding someone is not the best way to help him/her. He/she will
> only become dependent.
>

There is a world of difference between spoonfeeding and simple
civility. I think all Rob is asking for is that we observe the social
graces. Perhaps "You might want to read X, it has a lot of useful
info," instead of "I can't believe you had the gall to ask that; go
away." If you gently suggest someone read the docs a few times,
they'll get the hint.

> If swaroop did not know where to find the docs, he/she should have
> asked where to find the docs.

That assumes OP knew what docs might exist. part of being a newbie is
learning your way around perldoc. It's not exactly an intuitive
system. Or to put it another way: people who kown how to use the docs
effectively don't ask many questions here.

Just approach this critically: this list takes time. No one who knew
where to look in the docs would waste time coming to this list. It
just doesn't make sense.

>
> If he/she could not understand the difference from the docs, he/she
> should have said he can't understand the docs and if possible say
> what does he find hard to understand.
>

In theory, this is nice. But in practice, if you know enough to know
what you don't understand, you can figure out the answer. One comes to
this list when one doesn't know where to look. Even though the
solution is obvious to the person who answers, it is, by definition,
not obvious to the person who asked. Hence the question. Making people
feel like idiots for asking questions isn't any more helpful than
"spoonfeeding."

> There's nothing pompous about pointing someone at the source of the
> information he needs. It could, and probably should, be done better,

There are more and less tactful ways to say anything. I think we
should all aim for rather more than less.

Cheers,

-- j
--
This email and attachment(s): [ ] blogable; [ x ] ask first; [ ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com http://www.downloadsquad.com http://www.engatiki.org

values of β will give rise to dom!


Installing and configuring DBI and DBD::Oracle

2001-06-08 Thread EOIN SHALLOO

> Hi,
> 
> I hope someone can help as I am new at Perl and configuring its setup.
> 
> Setup:NT Service Pack 5
>   Oracle iAS 1.0.2.1 (with Apache Apache/1.3.12 Server)
>   Oracle 8.1.7 Release3
>   Perl 5.00503
> 
> 
> I have downloaded the DBD-Oracle-1.07 module from CPAN and placed it in
> its own directory in lib (D:\oracle\ora81\Apache\perl\5.00503\lib).
> 
> When I try to load test.pl (which I have placed in
> D:\oracle\ora81\Apache\Apache\cgi-bin) I get the following errors in the
> Apache log file:
> [Thu Jun 07 12:16:02 2001] [error] [client 137.223.134.230] Premature end
> of script headers: d:/oracle/ora81/apache/apache/cgi-bin/test.pl
> [Thu Jun 07 12:16:02 2001] [error] [client 137.223.134.230] Can't locate
> loadable object for module DBI in @INC (@INC contains: blib/arch blib/lib
> D:\oracle\ora81\Apache\perl\5.00503\lib/MSWin32-x86
> D:\oracle\ora81\Apache\perl\5.00503\lib
> D:\oracle\ora81\Apache\perl\site\5.00503\lib/MSWin32-x86
> D:\oracle\ora81\Apache\perl\site\5.00503\lib .) at
> D:\oracle\ora81\Apache\perl\5.00503\lib/DBI.pm line 183
> [Thu Jun 07 12:16:02 2001] [error] [client 137.223.134.230] BEGIN
> failed--compilation aborted at
> D:\oracle\ora81\Apache\perl\5.00503\lib/DBI.pm line 183.
> [Thu Jun 07 12:16:02 2001] [error] [client 137.223.134.230] BEGIN
> failed--compilation aborted at
> D:\oracle\ora81\Apache\perl\5.00503\lib/Oraperl.pm line 25.
> [Thu Jun 07 12:16:02 2001] [error] [client 137.223.134.230] BEGIN
> failed--compilation aborted at (eval 1) line 1.
> 
> 
> I have checked the readme and see that I am being asked to compile the
> code using nmake and perl ing the makefile.pl: but when I do that I get
> the following error:
> Can't locate loadable object for module DBI in @INC
> 
> Can somebody point me an exact set of instructions for downloading and
> configuring the Oracle interface for Perl.
> 
> Many thanks for taking the time to read this.
> 
> Regards,
> Eoin
> 



IE and HTTP_REFERER; and a Perl test

2001-08-22 Thread Mike Breeze

Hi all,

My first question is a little off the beaten track. I'm writing some web
counter software at the moment. Basically I use Javascript to embed the
following into a html page:

  
<!--
  d = document;
  now = new Date();

  function pr() {
d.write( "<p>Page: " + d.URL, " Referrer: " + d.referrer +
"</p>");
d.write( "<img
src=\"<A  HREF="http://localhost/cgi-bin/Hit/bin/register.cgi?page="">http://localhost/cgi-bin/Hit/bin/register.cgi?page="</A>; + d.URL +
 "&refr=" + d.referrer + "&date=" + now + "\"
width=1 height=1>" );
  }

  pr();
//-->
  

My register.cgi instantiates a Hit object and then logs it for later
analysis, then returns a token image to satisfy the img tag:

# Register the Hit.
my $page = $q->param( "page" );
my $referrer = $q->param( "refr" );

if ( HitGlobals::DEBUG ) {
foreach my $name ( $q->param ) {
print FD "$name: \n";
foreach my $value ( $q->param( $name )) {
print FD "  $value\n";
}
}
}

if ( not $page eq "" ) {

my $hit = Hit->new();
$hit->page( $page );
$hit->referrer( $refr );
$hit->browser( $ENV{ "HTTP_USER_AGENT" } );
$hit->Print( \*FD );
$hit->register();
}


Anyway, it all works fine until I test with IE, which doesn't set the
HTTP_REFERER variable. Now depending on which side of Uncle Bill's fence
you sit on, this is either a very annoying bug, or an extra security
feature...

My CGI pages just access the HTTP_REFERER, REQUEST_URI and
HTTP_USER_AGENT directly so they are fine.

Without getting into any slinging matches, I'm wondering whether there
is any way to get around this without having to turn all my static html
pages into CGI.

My second question is whether anyone knows of any online Perl technical
tests? I've got Perl developer interview tomorrow which will involve a
written test and I'm just wondering what sort of curly questions might
be thrown at me.

Cheers

Mike


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




Re: Date and Time and Function calls

2007-11-25 Thread yitzle
time will give you the number of seconds since the epoch. This is good
so long as you don't expect to create two files in one second.
http://perldoc.perl.org/functions/time.html

"For measuring time in better granularity than one second, you may use
either the Time::HiRes module (from CPAN, and starting from Perl 5.8
part of the standard distribution)"
http://perldoc.perl.org/perlfaq8.html#How-can-I-measure-time-under-a-second%3f

An alternative might be to get a random number, and use that.

On Nov 24, 2007 11:44 AM, AndrewMcHorney <[EMAIL PROTECTED]> wrote:
> Hello
>
>   I am looking for a perl function or functions that will give me the
> date and time. I am going to use the results to create a unique file name.
>
> Andrew

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




Re: Date and Time and Function calls

2007-11-25 Thread Tom Phoenix
On 11/24/07, AndrewMcHorney <[EMAIL PROTECTED]> wrote:

>   I am looking for a perl function or functions that will give me the
> date and time.

Are you looking in the perlfunc manpage? Type 'perldoc perlfunc' at a
prompt (or into your favorite search engine) to get started.

> I am going to use the results to create a unique file name.

Even if you have the time to the second, there may be another process
active during the same second. One common and easy way to do what I
think you want is to include the process ID (PID) and some small
string (such as your program name), along with $^T as as the time.
Even though process IDs are eventually reused, the process ID is a
unique value while the program runs. If my program were named fred, I
might use something like this:

  my $unique_file_name = "fred.$^T.$$";

Perl's special variables, such as $$ and $^T, are documented in the
perlvar manpage.

Cheers!

--Tom Phoenix
Stonehenge Perl Training

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




Re: Date and Time and Function calls

2007-11-25 Thread rahed
AndrewMcHorney <[EMAIL PROTECTED]> writes:

> Hello
>
>  I am looking for a perl function or functions that will give me the
> date and time. I am going to use the results to create a unique file
> name.

There are many posibilities depending on uniqueness,
this is quite similar:

$randnum  = 1000 + int rand(9000);
$filename = time.'_'.$randnum;

-- 
Radek


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




Re: Date and Time and Function calls

2007-11-25 Thread Dr.Ruud
rahed schreef:
> AndrewMcHorney:

>>  I am looking for a perl function or functions that will give me the
>> date and time. I am going to use the results to create a unique file
>> name.
> 
> There are many posibilities depending on uniqueness,
> this is quite similar:
> 
> $randnum  = 1000 + int rand(9000);
> $filename = time.'_'.$randnum;

You could put that inside a "while (1) {}", 
that also contains a "-e $filename or last;",
but even then you would still risk a race condition. 

-- 
Affijn, Ruud

"Gewoon is een tijger."

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




Re: Date and Time and Function calls

2007-11-25 Thread Martin Barth
Hi Andrew,

I would suggest http://search.cpan.org/~tjenness/File-Temp-0.19/Temp.pm

HTH Martin

On Sat, 24 Nov 2007 08:44:18 -0800
AndrewMcHorney <[EMAIL PROTECTED]> wrote:

> Hello
> 
>   I am looking for a perl function or functions that will give me the 
> date and time. I am going to use the results to create a unique file name.
> 
> Andrew

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




RE: regular expressions and search and replace.

2001-11-26 Thread Bob Showalter

> -Original Message-
> From: Kris Vermeulen [mailto:[EMAIL PROTECTED]]
> Sent: Monday, November 26, 2001 11:26 AM
> To: [EMAIL PROTECTED]
> Subject: regular expressions and search and replace.
> 
> 
> Hi everyone!
> 
> Many programming languages are taking over regular expressions.
> But since it originated from Perl (am I correct?), I taught this
> would be the ideal place to drop my beginner's question.
> 
> I already succeeded in replacing occurrences of some string in a
> complete text, but is it also possible to replace a beginning piece
> and an ending piece of string and just leave the text in between?
> I'll give a quick example. 
> 
> If I have a string:
> "some text [LINK='page.html']linkname[/LINK] some more text"
> 
> I want to replace every "[LINK='page.html']" with 
> I just want to search for [LINK= and the matching ] and just leave
> the text in between. Is this possible using just regular expressions?

The general idea is to match text in capturing parens and then
refer to that text using $1, $2, etc. in the replacement expression:

   s/X(.*)X/Y$1Y/;# changes "Xfoo barX" to "Yfoo barY"

perldoc perlre (search for "backreference") for all the poop.

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




RE: regular expressions and search and replace.

2001-11-26 Thread Kris Vermeulen

Hi Bob and everyone else,

Many thanks for the tip and for pointing me into the correct direction!

Kris


> > I want to replace every "[LINK='page.html']" with 
> > I just want to search for [LINK= and the matching ] and just leave
> > the text in between. Is this possible using just regular
expressions?
> 
> The general idea is to match text in capturing parens and then
> refer to that text using $1, $2, etc. in the replacement expression:
> 
>s/X(.*)X/Y$1Y/;# changes "Xfoo barX" to "Yfoo barY"
> 
> perldoc perlre (search for "backreference") for all the poop.



smime.p7s
Description: application/pkcs7-signature


Re: Perl and tk, where and what?

2001-12-12 Thread Brett W. McCoy

On Wed, 12 Dec 2001, Hal Johnson wrote:

> I am trying to create windows interfaces for perl programs, and I've
> been told that the TK extension is what to get.  I searched the
> internet and found tk800.023.tar.gz but I'm not sure if that will work
> with Windows 2000. Also, it seems I need a Visual C++ compiler to get
> it to work. I don't have acces to Visual C++, but I've heard that there
> are some freeware compilers and I just can't find them.
> I'd be gratefull for any information on installation or use problems
> you've encountered, etc. with tk and perl.

ActiveState has Perl-Tk prebuilt as a PPM.  You should be able to get it
from their webstie or via the ppm command-line tool:

C:\>ppm
PPM interactive shell (2.1.2) - type 'help' for available commands.
PPM> install Tk
Install package 'Tk?' (y/N): y
Installing package 'Tk'...
 
Writing D:\Perl\site\lib\auto\Tk\.packlist
PPM>

When that's done, type 'pktsh' at the command-line, and you get a little
interactive shell to play with stuff.

Isn't Perl cool?

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

Ego sum ens omnipotens.


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




Re: Perl and tk, where and what?

2001-12-12 Thread Brett W. McCoy

On Wed, 12 Dec 2001, Brett W. McCoy wrote:

> When that's done, type 'pktsh' at the command-line, and you get a little
> interactive shell to play with stuff.

That's 'ptksh', rather.

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

Because we don't think about future generations, they will never forget us.
-- Henrik Tikkanen


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




RE: Perl and tk, where and what?

2001-12-12 Thread Gary Hawkins

> > When that's done, type 'pktsh' at the command-line, and you get a little
> > interactive shell to play with stuff.
> 
> That's 'ptksh', rather.

Type 'widget' for cool demos.  Text > Hypertext > 4. Arrows' for example.



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




& and subroutine

2012-04-16 Thread Paul.G
Hi All

Have a question, is it good coding practice to use a & when calling a 
subroutine, or it is not required, or it doesn't matter?


eg:

sub name {

some code here, returning a single value

return 0;

}

&name();

cheers


Re: :: and ->

2006-02-16 Thread Chas Owens
On 2/16/06, Ken Perl <[EMAIL PROTECTED]> wrote:
> what is the difference of :: and -> in this statements?
>
> $authInstance = 
> Operation::Auth::getInstance($session,$u->authMethod,$u->userId)
>
> $authInstance = 
> Operation::Auth->getInstance($session,$u->authMethod,$u->userId)
>
> --
> perl -e 'print unpack(u,"62V5N\"FME;G\!E ")'

What is passed to getInstance.  The -> syntax passes the class name as
the first argument.

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




Re: :: and ->

2006-02-17 Thread Hans Meier (John Doe)
Ken Perl am Freitag, 17. Februar 2006 02.34:
> what is the difference of :: and -> in this statements?
>
> $authInstance =
> Operation::Auth::getInstance($session,$u->authMethod,$u->userId)
>
> $authInstance =
> Operation::Auth->getInstance($session,$u->authMethod,$u->userId)

The first '::' is part of a package name, the package is

package Operation::Auth

The last '::' (in the first example) denotes a sub in this package and is a 
procedure invocation, the sub getting only the passed arguments.

The '->' is a method invocation, and the class name ('Operation::Auth' in this 
case) is implicitly passed to getInstance as first argument (as Chas already 
said).

The two notations are not interchangeable if the sub definition is for example

sub getInstance {
my ($class, $session, $meth, $uid)[EMAIL PROTECTED];
...
}

intended to be called as method.

The first invocation would leed to an error since the first argument 
getInstance receives is $session, and not a class name.


hth,
joe

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




Re: :: and ->

2006-02-18 Thread Ken Perl
This is really very clear.

On 2/17/06, Hans Meier (John Doe) <[EMAIL PROTECTED]> wrote:
> Ken Perl am Freitag, 17. Februar 2006 02.34:
> > what is the difference of :: and -> in this statements?
> >
> > $authInstance =
> > Operation::Auth::getInstance($session,$u->authMethod,$u->userId)
> >
> > $authInstance =
> > Operation::Auth->getInstance($session,$u->authMethod,$u->userId)
>
> The first '::' is part of a package name, the package is
>
>package Operation::Auth
>
> The last '::' (in the first example) denotes a sub in this package and is a
> procedure invocation, the sub getting only the passed arguments.
>
> The '->' is a method invocation, and the class name ('Operation::Auth' in this
> case) is implicitly passed to getInstance as first argument (as Chas already
> said).
>
> The two notations are not interchangeable if the sub definition is for example
>
> sub getInstance {
>my ($class, $session, $meth, $uid)[EMAIL PROTECTED];
>    ...
> }
>
> intended to be called as method.
>
> The first invocation would leed to an error since the first argument
> getInstance receives is $session, and not a class name.
>
>
> hth,
> joe
>
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>
>


--
perl -e 'print unpack(u,"62V5N\"FME;G\!Ehttp://learn.perl.org/> <http://learn.perl.org/first-response>




Re: :: and ->

2006-02-18 Thread Bob Showalter

Ken Perl wrote:

what is the difference of :: and -> in this statements?

$authInstance = Operation::Auth::getInstance($session,$u->authMethod,$u->userId)


This is a subroutine call, passing 3 arguments.



$authInstance = Operation::Auth->getInstance($session,$u->authMethod,$u->userId)


This is called a class method invocation. Perl will look for a 
getInstance sub in package Operation::Auth and its ancestors (via @ISA), 
and finally in package UNIVERSAL. If no sub is found, it will look for 
an AUTOLOAD sub using the same procedure and invoke it. Once a sub is 
found, it will be called with the string 'Operation::Auth' as the first 
argument, followed by the three remaining arguments.


--
Well I can't stop here all day...I'm on a cycling tour of North Cornwall!

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




$_ @_ and others

2002-12-03 Thread Duarte Cordeiro
Hi all,
 
 I'm following this mailing list for a while. Also, we had a small project inhouse 
that had some components made in perl.
 It was developped by 3 diferent guys, so we shared some code. In the end, I was the 
one who glued everything.
 
I don't know if is just us in here, but perl seems to "help" programmers make fuzzy 
and hard to understand scripts.
 
but why use $_ or even nothing ( because almost every function can  use $_ by 
default)?
if I have  a problem in a script, and I see a $_, I just have to backtrack and read 
the actual code just to see what that particular variable is supposed to hold. 
That's why they invented variable names, no? no use to have a var called $a or $xyz. 
Ins't a line like: s/$_[1]//; 
or even s/.+\w*?//; (assuming some things, its the same , no ? :)
more cryptic then: $fullname=~s/$lastname//; 
Eveybody can see that I want to take out the last name from the the var that holds the 
full name.
But in the first two cases, I just have to read the actual code to just understand 
what that line is supposed to do.
 
I don't want to be flamed :) I'm not saying its bad by itself... it's like having a 
goto in a language. It doens't harms anyone by itself.. but allow programmers to shoot 
themselfs in the foot.
 
Just my two cents,
 
 Duarte Cordeiro
 



RE: $! and $@

2003-07-08 Thread Gupta, Sharad
$! is the oserror.
$@ contains the exceptions thrown by eval.

Eg:


use strict;
my $out = get_list();
if($@) {
print "Could not get the list: $@";
}




sub get_list {
# If we die return the error set in [EMAIL PROTECTED]
eval {
# If we are unable to get the list, die with the
# error produced by my os.
my $out = qx("ls -l") or die "Error getting list: $!";
return $out;
}
}



perldoc perlvar
perldoc -f eval

-Sharad

-Original Message-
From: jdavis [mailto:[EMAIL PROTECTED]
Sent: Tuesday, July 08, 2003 1:39 PM
To: perl
Subject: $! and $@


Hello,
  I think these catch errors somehow...

  $! and $@

  could someone explain this.

thanks,
-- 
jdavis <[EMAIL PROTECTED]>


-- 
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: $! and $@

2003-07-08 Thread Janek Schleicher
Jdavis wrote at Tue, 08 Jul 2003 14:39:17 -0600:

>   I think these catch errors somehow...
> 
>   $! and $@
> 
>   could someone explain this.

Perl can explain it to you, just read:

perldoc perlvar


Greetings,
Janek


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



Re: $= and $~

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Alan F. Larimer, Jr. said:

>$old = $=;
>$~ = "HEADER";
>$= = 25;  #cuz that's how many lines on the screen
>(print some stuff with HEADER format)
>$~ = "STDOUT";
>$= = $old;
>
>I used a print statement to ensure that $= is being set properly, and
>it is.  But when I print stuff with HEADER format, it seems to not
>stick with that new $= = 25;  Yes, the output is still going to STDOUT
>(screen), where I want it, but just not with the new
>format_lines_per_page.

How do you know this, Alan?  Do you have a format_header set?  If not, I'm
afraid you won't be able to tell where one "page" ends and the next
begins.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
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
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: $= and $~

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Jeff 'japhy' Pinyan said:

>On Jun 5, Alan F. Larimer, Jr. said:
>
>>$old = $=;
>>$~ = "HEADER";
>>$= = 25;  #cuz that's how many lines on the screen
>>(print some stuff with HEADER format)
>>$~ = "STDOUT";
>>$= = $old;
>>
>>I used a print statement to ensure that $= is being set properly, and
>>it is.  But when I print stuff with HEADER format, it seems to not
>>stick with that new $= = 25;  Yes, the output is still going to STDOUT
>>(screen), where I want it, but just not with the new
>>format_lines_per_page.
>
>How do you know this, Alan?  Do you have a format_header set?  If not, I'm
>afraid you won't be able to tell where one "page" ends and the next
>begins.

Rather, format_top_name, set via the $^ variables.

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
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
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: $= and $~

2001-06-05 Thread Alan F. Larimer, Jr.

> >>$old = $=;
> >>$~ = "HEADER";
> >>$= = 25;  #cuz that's how many lines on the screen
> >>(print some stuff with HEADER format)
> >>$~ = "STDOUT";
> >>$= = $old;
> >>
> >>I used a print statement to ensure that $= is being set properly,
> and
> >>it is.  But when I print stuff with HEADER format, it seems to not
> >>stick with that new $= = 25;  Yes, the output is still going to
> STDOUT
> >>(screen), where I want it, but just not with the new
> >>format_lines_per_page.
> >
> >How do you know this, Alan?  Do you have a format_header set?  If
> not, I'm
> >afraid you won't be able to tell where one "page" ends and the next
> >begins.
> 
> Rather, format_top_name, set via the $^ variables.

Your first response did kinda confuse me, but now I see what you mean. 
Then my question becomes: Will the display wait for me to see the first
screen before jumping to the next?  Or do I need to implement that in
some other way?  (ie ; # like getch() in C)

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: $= and $~

2001-06-05 Thread Jeff 'japhy' Pinyan

On Jun 5, Alan F. Larimer, Jr. said:

>> >>$old = $=;
>> >>$~ = "HEADER";
>> >>$= = 25;  #cuz that's how many lines on the screen
>> >>(print some stuff with HEADER format)
>> >>$~ = "STDOUT";
>> >>$= = $old;
>> >>
>> >>I used a print statement to ensure that $= is being set properly,
>> and
>> >>it is.  But when I print stuff with HEADER format, it seems to not
>> >>stick with that new $= = 25;  Yes, the output is still going to
>> STDOUT
>> >>(screen), where I want it, but just not with the new
>> >>format_lines_per_page.
>> >
>> >How do you know this, Alan?  Do you have a format_header set?  If
>> not, I'm
>> >afraid you won't be able to tell where one "page" ends and the next
>> >begins.
>> 
>> Rather, format_top_name, set via the $^ variables.
>
>Your first response did kinda confuse me, but now I see what you mean. 
>Then my question becomes: Will the display wait for me to see the first
>screen before jumping to the next?  Or do I need to implement that in
>some other way?  (ie ; # like getch() in C)

No.  The FORMAT_LINES_PER_PAGE variable, $=, just holds how many lines get
printed per each header-content text.  You'll need to make some sort of
pager for your program.  In fact, $= isn't even needed, then.

  #!/usr/bin/perl -w

  use strict;

  sub pager {
my ($fh, $func, $pause, $lines) = @_;
local (*READ, *WRITE, *FH, *SAVE);

pipe READ, WRITE;
*FH = $fh;

open SAVE, ">&FH"; 
open FH, ">&WRITE";

my $old = select FH;

$func->();

close FH;
close WRITE;

open FH, ">&SAVE";   
close SAVE;   

while () {
  print;
  $pause->() if $. % $lines == 0;
}
 
close READ;

select $old;
  }

  pager(\*STDOUT, sub { print `ls -lag` }, sub {  }, 20);

If you need an explanation of this code, I'll gladly give one in the
morning.  Until then, I really need some sleep. ;)

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
Eruséro Marillion -- wielder of Ringril, known as Hesinaur, the Winter-Sun
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
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: $= and $~

2001-06-06 Thread Alan F. Larimer, Jr.

> You'll need to make some sort of
> pager for your program.  In fact, $= isn't even needed, then.
> 
>   #!/usr/bin/perl -w
> 
>   use strict;
> 
>   sub pager {
> my ($fh, $func, $pause, $lines) = @_;  # grab the args
> local (*READ, *WRITE, *FH, *SAVE);  # create local to use here
> 
>     pipe READ, WRITE;  # open the pipes for in and out
> *FH = $fh; # ??? Help me here, assigns reference
># of $fh ???
> open SAVE, ">&FH";  # output SAVE
> open FH, ">&WRITE"; # also output FH
>  #why two above?
> my $old = select FH; # save FH
> 
> $func->();  # ??? Help here also, does this call passed func?
> 
> close FH; # close FH
> close WRITE;  # close ouput
> 
> open FH, ">&SAVE";  # reopen FH, as output, why?
> close SAVE;  # close SAVE, which did what?
> 
> while () {
>   print;
>   $pause->() if $. % $lines == 0; # understand %, but
> } # confused by $pause->()
>  
> close READ;
> 
> select $old;  # seld old FH
>   }
> 
>   pager(\*STDOUT, sub { print `ls -lag` }, sub {  }, 20);
> 
> If you need an explanation of this code, I'll gladly give one in the
> morning.  Until then, I really need some sleep. ;)

I am a patient man and respect the need to sleep.  Besides, I didn't
check e-mail again until about 30 minutes ago, so there was no hurry.
:)

I added comments above to try to show what I can see and what I'm not
sure of.  Any explaniation would be usefull.  Thanx.

--Alan

__
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/



Re: $= and $~

2001-06-06 Thread Jeff 'japhy' Pinyan

On Jun 6, Alan F. Larimer, Jr. said:

>>   #!/usr/bin/perl -w
>> 
>>   use strict;
>> 
>>   sub pager {
>> my ($fh, $func, $pause, $lines) = @_;  # grab the args
>> local (*READ, *WRITE, *FH, *SAVE);  # create local to use here

These filehandles are only needed locally.

>>     pipe READ, WRITE;  # open the pipes for in and out

Create an output filehandle, *WRITE, and the input filehandle *READ that
reads from it.

>> *FH = $fh; # ??? Help me here, assigns reference
>># of $fh ???

We pass the filehandle to use as a reference to it (\*STDOUT), so here, we
assign it to another filehandle we can use.

>> open SAVE, ">&FH";  # output SAVE

We're copying the file-descriptor of FH to SAVE, so that SAVE goes where
FH does (and continues to, even after we change FH, below).

>> open FH, ">&WRITE"; # also output FH
>>  #why two above?

Now, we're redirecting FH to go to the WRITE filehandle.

We do this so that we can (temporarily) capture output to a
specific filehandle (the one we pass into the function), and then restore
the filehandle once that data has been gotten.

We're basically saying:

  1. save FH
  2. redirect FH to WRITE
  3. do something that writes to FH (and actually goes to WRITE)
  4. restore FH

We print to WRITE so that we can read from... READ.

>> my $old = select FH; # save FH

Default print() goes to FH, and we remember which filehandle was
select()ed before.

>> $func->();  # ??? Help here also, does this call passed func?

This calls the function reference (sub { ... } or \&foo) that we
passed.  This is the part that does some writing that we want to capture.

>> close FH; # close FH
>> close WRITE;  # close ouput
>> 
>>     open FH, ">&SAVE";  # reopen FH, as output, why?
>> close SAVE;  # close SAVE, which did what?

This is explained above -- we needed to temporarily redirect FH, and now
we need to restore it.

>> while () {
>>   print;
>>   $pause->() if $. % $lines == 0; # understand %, but
>> } # confused by $pause->()

The code reference in $pause is the thing that we use to pause the
scrolling, to act as the pager.  Here, I passed sub {  }, which
means "wait for input from STDIN".  You might use sub { sleep 1 }, or
something like that.

>>  
>> close READ;
>> 
>> select $old;  # seld old FH
>>   }
>> 
>>   pager(\*STDOUT, sub { print `ls -lag` }, sub {  }, 20);

-- 
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
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
**  Manning Publications, Co, is publishing my Perl Regex book  **




Re: '' and ""

2001-09-12 Thread Maxim Berlin

Hello Matija,

Tuesday, September 11, 2001, Matija Papec <[EMAIL PROTECTED]> wrote:


MP> Is there a reason why '' should be preferred over "" when using static
MP> expressions? My guess is that "" takes a little longer at compile time for
at run time. inside loop, for example.
MP> perl to see if variables resides inside quotes, but don't know if this is
MP> significant to bother with single quotes.

personally, i prefer '' in next case:
my $a = "\$\@\^";
my $a = '$@^';

MP> ps. I've always used "" but now my boss tells me that this is a bad thing :)

it depends :)

Best wishes,
 Maximmailto:[EMAIL PROTECTED]



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




and, or, &&, ||

2001-09-25 Thread Christine Lenda

Hello!

I remember someone mentioning that there may be a
precedence problem with "unexpected results" during a
mathematical conditional test, using the keywords
"and" and "or"...instead of the symbols (&& and ||). 
Is this true?  Can anyone give me an example?

Thanks much!
cl


__
Do You Yahoo!?
Get email alerts & NEW webcam video instant messaging with Yahoo! Messenger. 
http://im.yahoo.com

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




Re: $_. and $_,

2004-10-13 Thread Jose Alves de Castro
On Wed, 2004-10-13 at 10:48, E.Horn wrote:
> Hallo!

Hi.

> Stupid question, but i am a perlbeginner! :-(
> What is the difference between $_. and $_, ??

$_ is a variable (the context variable)
A single dot is the concatenation operator
A single comma is the list separator

So:

$_. isn't really "something", but two different things: a variable and
 an operator... and that will only be valid if something else would
 follow (so that the operator could have something to work on). Example:

$_ . "\n"

That would result in the concatenation of $_ with a string containing
 the new line character, "\n".

$_, would be valid code, but it would probably serve no other purpose
 than the one of $_ by itself.

Was that helpful?

If not, give an example and we'll try to put some light on it :-)

> Regards

Best regards,

jac

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


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




Re: & and >>

2007-09-04 Thread Chas Owens
On 9/4/07, Dan Sopher <[EMAIL PROTECTED]> wrote:
snip
> 1.  What does ($? & 127) mean?
snip

It means binary and $? with 127.  It is useful because the lower seven
bits of $? are set to the signal a child process received that caused
it to die.  Bit eight will be set if there was a core dump.

snip
> 2.  What does $? >> 8  mean?
snip

It means shift the bits of $? to the right eight places.  This is
useful because the exit code from a process is stored in bits 9
through 16 of $?.  We saw what the first eight bits held in the
previous question.  Normally we want to see the exit code as 0 through
255 and bit shifting $? eight places to the right causes this to
happen.

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




Re: & and >>

2007-09-04 Thread yitzle
http://perldoc.perl.org/perlvar.html
$?  - The status returned by the last pipe close, backtick (`` )
command, successful call to wait() or waitpid(), or from the system()
operator. This is just the 16-bit status word returned by the wait()
system call (or else is made up to look like it). Thus, the exit value
of the subprocess is really ($?>> 8 ), and $? & 127  gives which
signal, if any, the process died from, and $? & 128  reports whether
there was a core dump. (Mnemonic: similar to sh and ksh.).

wait() man page:
http://bama.ua.edu/cgi-bin/man-cgi?wait+2
o  If the child process stopped, the high order 8 bits of
status  will  contain  the  number  of the signal that
caused the process to stop and the low  order  8  bits
will be set equal to WSTOPFLG.
o  If the child process  terminated  due  to  an  _exit()
call, the low order 8 bits of status will be 0 and the
high order 8 bits will contain the low order 8 bits of
the argument that the child process passed to _exit();
see exit(2).
o  If the child process terminated due to a  signal,  the
high  order  8  bits  of  status will be 0 and the low
order 8 bits will contain the  number  of  the  signal
that caused the termination. In addition, if  WCOREFLG
is set, a "core image" will have been   produced;  see
signal(3HEAD) and wstat(3XFN).

> 1.  What does ($? & 127) mean?
127 in binary is 0111 . It is used as a mask. ($? & 127) returns a
number between 0 and 127, as any higher bits get zeroed out.
If the child terminated due to a signal, ($? & 127) will give you the
signal code that stopped it, because the signal code is stored in the
lower 8 (er, 7?) bits of the status as per the wait man page.
128 in binary is 1000 . ($? & 128) tells you if the 8th bit is 1
or 0, indicating coredump or not.

> 2.  What does $? >> 8  mean?
>> is a binary shift. >> 8 shifts the status 8 bits right, tossing out
the lower 8 bits and giving you the upper 8 bits. If you do (ABCD EFGH
IJKL MNOP >> 8) (where each letter represents a single 0/1 bit) you
get ABCD EFGH.
As explained in the wait man page, if the child terminated  due  to
an  _exit() call, the high order 8 bits of the status will contain the
low order 8 bits of the argument that the child process passed to
_exit(). So we shift the status 8 bits right to get the value the
child passed to _exit(); the exit code.

I'm sorry if this confuses you and would be glad to explain any part
you didn't understand.
This is sort of the type of stuff more commonly found in C.

On 9/4/07, Dan Sopher <[EMAIL PROTECTED]> wrote:
> Regarding the following document:
> http://perldoc.perl.org/functions/system.html
>
> 1.  What does ($? & 127) mean?
> 2.  What does $? >> 8  mean?
>
> if ($? == -1) {
>  print <http://perldoc.perl.org/functions/print.html>  "failed to
> execute: $!\n";
> }
> elsif ($? & 127) {
>  printf <http://perldoc.perl.org/functions/printf.html>  "child died
> with signal %d, %s coredump\n",
>  ($? & 127),  ($? & 128) ? 'with' : 'without';
> }
> else {
>  printf <http://perldoc.perl.org/functions/printf.html>  "child
> exited with value %d\n", $? >> 8;
>
> }
>
> Thanks in advance,
>
> Dan

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




Re: & and >>

2007-09-04 Thread yitzle
To address the subject, & is the bitwise AND operator and >> is the
bitwise shift.
& is used as a mask and >> is used to access higher bits.
Wikipedia explains bitwise operations. If you don't know about them,
you may want to read the article.
http://en.wikipedia.org/wiki/Bitwise_operation

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




Re: Installing and configuring DBI and DBD::Oracle

2001-06-08 Thread Ken

I am going to assume you installed the precompiled binaries from active
state.

Type in at a command prompt window:
perl -v

Look for the line that mentions which binary build it is...
Mine says: "Binary build 626 provided by ActiveState Tool Corp"

If yours says 6xx you want the following link:
http://www.activestate.com/PPMPackages/zips/6xx-builds-only/

If it says 5xx you want this:
http://www.activestate.com/PPMPackages/zips/5xx-builds-only/

Download the files and follow the instructions in the readme file.

- Original Message -
From: "EOIN SHALLOO" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 08, 2001 2:43 AM
Subject: Installing and configuring DBI and DBD::Oracle


> > Hi,
> >
> > I hope someone can help as I am new at Perl and configuring its setup.
> >
> > Setup: NT Service Pack 5
> > Oracle iAS 1.0.2.1 (with Apache Apache/1.3.12 Server)
> > Oracle 8.1.7 Release3
> > Perl 5.00503
> >
> >





RE: Installing and configuring DBI and DBD::Oracle

2001-06-08 Thread EOIN SHALLOO

Hi,

I've come a long way since that posting but have hit a new impasse.

Here are the steps taken so far:

I downloaded IndigoPerl and am using IndigoPerl Build 626.
http://www.indigostar.com/indigoperl.htm 

I downloaded a copy of nmake.exe from Microsoft
http://download.microsoft.com/download/vc15/Patch/1.52/W95/EN-US/Nmake15.exe

I then installed Microsoft Visual C++6.0 ( I couldn't get gcc from gnu to
work)

and did the following.

At the command line I went to the directory
D:\IndigoPerl\lib\DBI-1.18

I entered the following:
D:\IndigoPerl\lib\DBI-1.18>perl makefile.pl
D:\IndigoPerl\lib\DBI-1.18>nmake 

#
BTW no set of notes explains that nmake automatically takes a file by the
name makefile ;)I'm ashamed to say that predicting the result of this had me
stumped! Also until a unix guru colleague pointed out that nmake sits on top
of a C compiler as opposed to doing all the work itself (some job for such a
small file!) I was struggling with nmakes obscure error messages!
#


Then I entered
D:\IndigoPerl\lib\DBI-1.18>nmake test.

Everything seems fine from the output:
D:\IndigoPerl\lib test.pl
test.pl
DBI test application $Revision: 10.6 $
Using D:/IndigoPerl/lib/DBI-1.18/blib
Switch: DBI 1.18 by Tim Bunce, 1.18
Available Drivers: ADO, ExampleP, Multiplex, Proxy, mysql
dbi:ExampleP:: testing 5 sets of 20 connections:
Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Disconnecting...
Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Disconnecting...
Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Disconnecting...
Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Disconnecting...
Connecting... 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Disconnecting...
Made 100 connections in  0 wallclock secs ( 0.05 usr +  0.00 sys =  0.05
CPU)

Testing handle creation speed...
5000 NullP statement handles cycled in 1.3 cpu+sys seconds (3900 per sec)

test.pl done

 
Now I am wondering about how to get this compiled module into site\lib i.e.
install it into the Perl library on my machine. Then I can start on the
Oracle DBI and installing it!

Any help much appreciated again.

Thanks,

Eoin
 


-Original Message-
From: Ken [mailto:[EMAIL PROTECTED]]
Sent: Friday, June 08, 2001 4:08 PM
To: EOIN SHALLOO; [EMAIL PROTECTED]
Subject: Re: Installing and configuring DBI and DBD::Oracle


I am going to assume you installed the precompiled binaries from active
state.

Type in at a command prompt window:
perl -v

Look for the line that mentions which binary build it is...
Mine says: "Binary build 626 provided by ActiveState Tool Corp"

If yours says 6xx you want the following link:
http://www.activestate.com/PPMPackages/zips/6xx-builds-only/

If it says 5xx you want this:
http://www.activestate.com/PPMPackages/zips/5xx-builds-only/

Download the files and follow the instructions in the readme file.

- Original Message -
From: "EOIN SHALLOO" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, June 08, 2001 2:43 AM
Subject: Installing and configuring DBI and DBD::Oracle


> > Hi,
> >
> > I hope someone can help as I am new at Perl and configuring its setup.
> >
> > Setup: NT Service Pack 5
> > Oracle iAS 1.0.2.1 (with Apache Apache/1.3.12 Server)
> > Oracle 8.1.7 Release3
> > Perl 5.00503
> >
> >




Re: Extracting Directories and Sub Directories and Counting

2004-10-28 Thread Gunnar Hjalmarsson
[ replying to the list since that's where the discussion belongs ]
Ron Smith wrote (to me privately):
Thank you *very* much for furthering my 'Perl' knowlege. I've
never see a variable like '@{ $HoA{$dir} }' before.
Well, it's not a special variable type. $HoA{$dir} is a reference to an 
anonymous array, which you dereference with the @{ $HoA{$dir} } construct.

I'm just at the 'Llama' level. I think I understand what's going
on though.
Your solution:...
my %HoA;
for ( `dir /b/s` ) {
   push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.\d+\.\w+$/;
}
for my $dir (sort keys %HoA ) {
   print "$dir\n", join( "\n", @{ $HoA{$dir} } ), "\n\n";
}
...worked out fine. This one took some thought for me to wrap my
head around. Thank you so *very* much for showing me something
new and very useful.
I now realize that the small piece of code above combines three 
components of Perl that make it a really powerful programming language: 
Hashes, references and regular expressions.

I'm attempting to play around with this new tool to get it to do
different things, but I'm running into another problem. I can't
seem to pull the elements back out from the arrays properly. I'm
tring to count the basenames now. I get what looks like memory
addresses instead. I think these are the references to the actual
arrays that you were eluding to.
Sounds plausible. :)
I was using parts of the script you helped me out on before to do
the counting of the basenames:
#!/usr/bin/perl -w
use strict;
my @paths = `dir /b`;
my @basenames = &extract_names(@paths);
sub extract_names {
   my ($name, @names);
   for (@_) {
   if (/(\w+)\.\d+\.\w+$/) {
   $name = $1;
   $name =~ s/$/\n/;
Hmm.. It's usually practical to not add "\n" like that, but take care of 
linebreaks in connection with printing the variable. Without adding 
"\n", instead of saying

print @basenames;
you can say e.g.
print join("\n", @basenames), "\n";
   push @names, $name;
   }
   }
   @names;
}
my (%count, $frames);
for $frames (@basenames) {
   chomp ($frames);
   $count{$frames} += 1;
}
for $frames (sort keys %count) {
   # print "$frames\t1-$count{$frames}\n";
   printf "%20s\t%04d\n", $frames, $count{$frames};
}
One of the things I attempted was the following:
#!/usr/bin/perl -w
use strict;
 my %HoA;
for ( `dir /b/s` ) {
push @{ $HoA{$1} }, $2 if /(.+)\\(\w+)\.\d+\.\w+$/;
}
for my $dir (sort keys %HoA ) {
print "$dir\n";
for my $frames (@{ $HoA{$dir}}) {
my $count{frames} += 1;
print "$count{frames}\n";
}
}
But, I get the following error messages:
syntax error at solution line 13, near "$count{frames"
syntax error at solution line 13, near "+="
syntax error at solution line 16, near "}"
Execution of solution aborted due to compilation errors.
There's some concept I'm missing,
No, it's rather just because you didn't declare the %count hash properly 
(you also had 'frames' instead of '$frames' a couple of times). Instead of

for my $frames (@{ $HoA{$dir}}) {
my $count{frames} += 1;
print "$count{frames}\n";
}
you want
my %count;
for my $frames ( @{ $HoA{$dir} } ) {
$count{$frames} += 1;
print "$count{$frames}\n";
}
and I was hoping you'd
help me out one more time. I've spent a lot of time on this
trying to solve the problem myself, but I keep hitting a
brick wall no matter what I try. I'm trying to get:
C:\dir_name\dir_name\dir_name (Path) followed by
basename 0001-0005(file counts)
another_basename 0001-0010
These files have the same basename, but they're numbered like:
basename.0001.rgb, basename.0002.rgb ...etc.
Now when I've helped you with the syntax error, I believe you can figure 
out how to print the counts similar to what you did with the previous 
code version. If not, please feel free to post (to the list) again.

Also, If you can, could you point me in the dirrection of a book or a
site that explains the more advanced stuff like:
@{$HoA{$dir}}
I would really appreciate it.
References and data structures are indeed tricky in the beginning - I 
sure thought they were - but they are well documented at the same time. 
These are some applicable parts of the Perl docs:

perldoc perlreftut
perldoc perlref
perldoc perldsc
perldoc perllol
As regards books, others are better suited than me to give 
recommendations (the only Perl book I have is the "Camel").

Or, should I try to see if I can get a tutor?
Only you can tell.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: Extracting Directories and Sub Directories and Counting

2004-10-29 Thread Ron Smith
Well I've moved this along a little further, but it
looks like I'm stuck on one last thing.

I'm getting;

C:\Perl\scripts\dir\dir\dir

  basename  0001
  basename  0002
  basename  0003
  basename  0004
  basename  0005
  basename  0006
  basename  0007
  basename  0008
  basename  0009
  basename  0010
  another_basename  0001
  another_basename  0002
  another_basename  0003
  another_basename  0004
  another_basename  0005
  another_basename  0006
yet_another_name  0001
yet_another_name  0002
yet_another_name  0003
yet_another_name  0004
yet_another_name  0005

C:\Perl\scripts\dir\dir\dir\sub_directory

  basename  0001
  basename  0002
  basename  0003
  basename  0004
  basename  0005
  basename  0006
  basename  0007
  basename  0008
  basename  0009
  basename  0010

C:\Perl\scripts\dir\dir\dir\sub_directory\deeper_sub

basename  0001
basename  0002
basename  0003
basename  0004

The following is the re-worked script:

snip-

#!/usr/bin/perl -w

use strict;

my %HoA;
for ( `dir /b/s` ) {
push @{ $HoA{$1} }, $2 if
/(.+)\\(\w+)\.(\d+)\.(\w+)$/;
}

my %count;
for my $dir ( sort keys %HoA ) {
print "$dir\n";
my @basenames = @{ $HoA{$dir} };
for my $frames ( @basenames ) {
$count{$frames} += 1;
printf "%30s\t%04d\n", $frames,
$count{$frames};
}
}

snip-

I'm trying to get the following output:

C:\Perl\scripts\dir\dir\dir

 basename  0010
 another_basename  0006
 yet_another_basename  0005

C:\Perl\scripts\dir\dir\dir\sub_directory

  basename  0010

C:\Perl\scripts\dir\dir\dir\sub_directory\deeper_sub

basename  0004

I've gone through 'perldoc perlreftut', but can't see
the last step.
--- Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:

> [ replying to the list since that's where the
> discussion belongs ]
> 
> Ron Smith wrote (to me privately):
> > Thank you *very* much for furthering my 'Perl'
> knowlege. I've
> > never see a variable like '@{ $HoA{$dir} }'
> before.
> 
> Well, it's not a special variable type. $HoA{$dir}
> is a reference to an 
> anonymous array, which you dereference with the @{
> $HoA{$dir} } construct.
> 
> > I'm just at the 'Llama' level. I think I
> understand what's going
> > on though.
> > Your solution:...
> > 
> > my %HoA;
> > for ( `dir /b/s` ) {
> >push @{ $HoA{$1} }, $2 if
> /(.+)\\(\w+)\.\d+\.\w+$/;
> > }
> > 
> > for my $dir (sort keys %HoA ) {
> >print "$dir\n", join( "\n", @{ $HoA{$dir} }
> ), "\n\n";
> > }
> > 
> > ...worked out fine. This one took some thought for
> me to wrap my
> > head around. Thank you so *very* much for showing
> me something
> > new and very useful.
> 
> I now realize that the small piece of code above
> combines three 
> components of Perl that make it a really powerful
> programming language: 
> Hashes, references and regular expressions.
> 
> > I'm attempting to play around with this new tool
> to get it to do
> > different things, but I'm running into another
> problem. I can't
> > seem to pull the elements back out from the arrays
> properly. I'm
> > tring to count the basenames now. I get what looks
> like memory
> > addresses instead. I think these are the
> references to the actual
> > arrays that you were eluding to.
> 
> Sounds plausible. :)
> 
> > I was using parts of the script you helped me out
> on before to do
> > the counting of the basenames:
> > 
> > #!/usr/bin/perl -w
> > 
> > use strict;
> > 
> > my @paths = `dir /b`;
> > my @basenames = &extract_names(@paths);
> > 
> > sub extract_names {
> >my ($name, @names);
> >for (@_) {
> >if (/(\w+)\.\d+\.\w+$/) {
> >$name = $1;
> >$name =~ s/$/\n/;
> 
> Hmm.. It's usually practical to not add "\n" like
> that

Re: Extracting Directories and Sub Directories and Counting

2004-10-29 Thread Gunnar Hjalmarsson
Ron Smith wrote:
The following is the re-worked script:
snip-
#!/usr/bin/perl -w
use strict;
my %HoA;
for ( `dir /b/s` ) {
push @{ $HoA{$1} }, $2 if
/(.+)\\(\w+)\.(\d+)\.(\w+)$/;
}
The two last pairs of parentheses are redundant.
my %count;
for my $dir ( sort keys %HoA ) {
print "$dir\n";
my @basenames = @{ $HoA{$dir} };
for my $frames ( @basenames ) {
$count{$frames} += 1;
printf "%30s\t%04d\n", $frames,
$count{$frames};
}
}
Instead of that, you probably want:
for my $dir ( sort keys %HoA ) {
print "$dir\n";
my @basenames = @{ $HoA{$dir} };
my %count;
for my $frames ( @basenames ) {
$count{$frames} += 1;
}
for ( sort keys %count ) {
printf "%30s\t%04d\n", $_, $count{$_};
}
}
I made two changes:
- The %count hash is now declared within the outer loop, since I suppose 
you want to have it cleared before the program starts iterating over the 
basenames of a new directory.
- The printf() statement has been moved to a separate inner loop. The 
logic bids that %count is printed only after it has been populated.

HTH
--
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: Extracting Directories and Sub Directories and Counting

2004-10-29 Thread Gunnar Hjalmarsson
Gunnar Hjalmarsson wrote:
for my $dir ( sort keys %HoA ) {
print "$dir\n";
my @basenames = @{ $HoA{$dir} };
my %count;
for my $frames ( @basenames ) {
$count{$frames} += 1;
}
for ( sort keys %count ) {
printf "%30s\t%04d\n", $_, $count{$_};
}
}
Or with less typing:
for ( sort keys %HoA ) {
print "$_\n";
my %bn;
%bn = map { $_, ++$bn{$_} } @{ $HoA{$_} };
printf "%30s\t%04d\n", $_, $bn{$_} for sort keys %bn;
}
;-)
--
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: Extracting Directories and Sub Directories and Counting

2004-11-01 Thread Ron Smith
Hey Gunnar, and list,

---snip
print "\n";
my %HoA;
for ( `dir /b/s` ) {
push @{ $HoA{$1} }, $2 if
/(.+)\\(\w+)\.\d+\.\w+$/; 
}

for my $dir ( sort keys %HoA ) {
print join ( "\n", $dir ), "\n\n";
my @basenames = @{ $HoA{$dir} };
my %count;
for my $frames ( @basenames ) {
$count{$frames} += 1;
}

for ( sort keys %count ) {
printf "%30s\t%04d\n", $_, $count{$_};
}
print "\n";
}
---snip

gives me:

C:\scripts\dir\dir\dir

  basename  0010
  basename  0006
  basename  0005

C:\scripts\dir\dir\dir\sub_directory

  basename  0010

C:\scripts\dir\dir\dir\sub_directory\deeper_sub

basename0004

C:\scripts\dir\dir\dir\sub_directory\deeper_sub
even_deeper_sub

basename0011

This is what I was shooting for, file basenames and
counts. Thanks!

I've been reading 'perlreftut', 'perlrefdsc' and the
rest over the weekend and today. I've been playing
around with everything there. It's a lot, but I'm
plowing through. If I wanted to add more fields to my
output, which construct would I use to create more
fields; something like the following?

basenamecountextensionsize

...maybe 'HoH', or just expand on the 'HoA?


--- Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:

> Gunnar Hjalmarsson wrote:
> > 
> > for my $dir ( sort keys %HoA ) {
> > print "$dir\n";
> > my @basenames = @{ $HoA{$dir} };
> > my %count;
> > for my $frames ( @basenames ) {
> > $count{$frames} += 1;
> > }
> > for ( sort keys %count ) {
> > printf "%30s\t%04d\n", $_, $count{$_};
> > }
> > }
> 
> Or with less typing:
> 
>  for ( sort keys %HoA ) {
>  print "$_\n";
>  my %bn;
>  %bn = map { $_, ++$bn{$_} } @{ $HoA{$_} };
>  printf "%30s\t%04d\n", $_, $bn{$_} for sort
> keys %bn;
>  }
> 
> ;-)
> 
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
> 
> -- 
> To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED]
> <http://learn.perl.org/>
> <http://learn.perl.org/first-response>
> 
> 
> 




__ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.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: Extracting Directories and Sub Directories and Counting

2004-11-02 Thread Gunnar Hjalmarsson
Ron Smith wrote:
If I wanted to add more fields to my output, which construct would I
use to create more fields; something like the following?
basenamecountextensionsize
...maybe 'HoH', or just expand on the 'HoA?
I suppose that you are not really talking about the output now, but
rather about adding more info to the data structure. Anyway, it depends
on what you would like to use it for. I imagine that you might want a
HoAoH with each file being represented by a hash reference. Something
like:
my %HoAoH = (
dir1 => [
  {
basename => 'name1',
extension => 'html',
size => 1000,
  },
],
dir2 => [
  {
basename => 'name2',
extension => 'html',
size => 2000,
  },
  {
basename => 'name3',
extension => 'gif',
size => 1500,
  },
],
);
--
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: Extracting Directories and Sub Directories and Counting

2004-11-02 Thread Gunnar Hjalmarsson
Ron Smith wrote:
If I wanted to add more fields to my output, which construct would I
use to create more fields; something like the following?
basenamecountextensionsize
...maybe 'HoH', or just expand on the 'HoA?
You multi-posted basically the same question to comp.lang.perl.misc (see
below). Any comments on that, Ron?
 Original Message 
Subject: Re: Extracting Directories and Sub Directories and Counting
Date: Tue, 02 Nov 2004 13:40:21 +0100
From: Gunnar Hjalmarsson <[EMAIL PROTECTED]>
Newsgroups: comp.lang.perl.misc
References: <[EMAIL PROTECTED]>
Ron Smith wrote:

gives me:
file_base_name file_count
in two columns. How would I add additional columns like:
file_base_name file_countFile_extensionfile_size
Which construct would I use? Would it be a 'HoH', or simply expand on
a 'HoA', or is it another construct like 'AoA' or AoH?
I was very disappointed to see this post here, Ron. First of all, since
you posted basically the same question to [EMAIL PROTECTED] (where I
have answered it, btw), what you did is called multi-posting and is
considered rude. See why here:
http://www.uwasa.fi/~ts/http/crospost.html
Furthermore, your question was preceded by a long thread at
[EMAIL PROTECTED]:
http://www.mail-archive.com/beginners%40perl.org/msg63290.html
Do you really believe that you explained your problem properly to those
who have not read the previous posts?
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: Extracting Directories and Sub Directories and Counting

2004-11-02 Thread Ron Smith
Pardon me Gunnar, etal,
 
I'm new and thought that the 'comp.lang.perl.misc' post was entirely separate from 
'[EMAIL PROTECTED]', reaching an entirely different audience. I eanestly appologize to 
everyone on both lists. My bad!! I have spanked my own hand with a digital ruler. I'll 
do my best not to let that occur again.

 
I'm new, and some of the things I learn come the hard way. Again, my sincere 
appologies folks.
 
I'll be reading the 'crospost' page to get the rules. Is there anything other than 
that, that I can do to straighten things out?
 
Pardon the confusion.
Ron

Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:
Ron Smith wrote:
> If I wanted to add more fields to my output, which construct would I
> use to create more fields; something like the following?
> 
> basename count extension size
> 
> ...maybe 'HoH', or just expand on the 'HoA?

You multi-posted basically the same question to comp.lang.perl.misc (see
below). Any comments on that, Ron?


-------- Original Message 
Subject: Re: Extracting Directories and Sub Directories and Counting
Date: Tue, 02 Nov 2004 13:40:21 +0100
From: Gunnar Hjalmarsson 
Newsgroups: comp.lang.perl.misc
References: 

Ron Smith wrote:



> gives me:
> 
> file_base_name file_count
> 
> in two columns. How would I add additional columns like:
> 
> file_base_name file_count File_extension file_size
> 
> Which construct would I use? Would it be a 'HoH', or simply expand on
> a 'HoA', or is it another construct like 'AoA' or AoH?

I was very disappointed to see this post here, Ron. First of all, since
you posted basically the same question to [EMAIL PROTECTED] (where I
have answered it, btw), what you did is called multi-posting and is
considered rude. See why here:

http://www.uwasa.fi/~ts/http/crospost.html

Furthermore, your question was preceded by a long thread at
[EMAIL PROTECTED]:

http://www.mail-archive.com/beginners%40perl.org/msg63290.html

Do you really believe that you explained your problem properly to those
who have not read the previous posts?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

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






-
Do you Yahoo!?
 Check out the new Yahoo! Front Page.  www.yahoo.com/a

Re: Extracting Directories and Sub Directories and Counting

2004-11-02 Thread Chris Devers
On Tue, 2 Nov 2004, Ron Smith wrote:

> I'm new and thought that the 'comp.lang.perl.misc' post was entirely 
> separate from '[EMAIL PROTECTED]', reaching an entirely different 
> audience. I eanestly appologize to everyone on both lists.

It's a separate list, but a lot of the same people read both. 

It is generally considered rude to post the same question to multiple 
places at the same time. Even if the lists / newsgroups / web sites are 
separate, many people keep an eye on some or all of these places, so you 
end up effectively pestering the same group of people over and over.

> My bad!! I have spanked my own hand with a digital ruler. I'll do my 
> best not to let that occur again.

No worries :-)
  


-- 
Chris Devers

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




Re: Extracting Directories and Sub Directories and Counting

2004-11-02 Thread Gunnar Hjalmarsson
Ron Smith wrote:
Gunnar Hjalmarsson wrote:
You multi-posted basically the same question to comp.lang.perl.misc
(see below). Any comments on that, Ron?
Pardon me Gunnar, etal,
I'm new and thought that the 'comp.lang.perl.misc' post was entirely
separate from '[EMAIL PROTECTED]', reaching an entirely different
audience.
I admit that the document I pointed to is only talking about newsgroups,
while this is a mailing list. Nevertheless, this list and clpmisc are
forums with similar purposes, and they both support the Perl community,
so the banning of multi-posting applies (at least IMO).
Even if there are a few persons that follow both, that's not the main
point. The main point is to ensure that prospective helpers know about
the help provided by others, so they don't unnecessarily put efforts on
things that have been resolved.
I eanestly appologize to everyone on both lists. My bad!! I have
spanked my own hand with a digital ruler. I'll do my best not to let
that occur again.
I'm new, and some of the things I learn come the hard way. Again, my
sincere appologies folks.
I'll be reading the 'crospost' page to get the rules.
Great, thanks for understanding!
Is there anything other than that, that I can do to straighten things
out?
As a matter of fact, there is: Your quoting style. When replying to a
message, it's common practice to quote as much of the message you are
replying to that is needed to give context, but it's almost never
motivated to quote the whole message. Also, your comments should
preferrably be typed *below* the quoted part(s).
End of lesson. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: Extracting Directories and Sub Directories and Counting

2004-11-02 Thread Gunnar Hjalmarsson
Ron Smith wrote:
Gunnar Hjalmarsson wrote:
You multi-posted basically the same question to comp.lang.perl.misc
(see below). Any comments on that, Ron?
Pardon me Gunnar, etal,
I'm new and thought that the 'comp.lang.perl.misc' post was entirely
separate from '[EMAIL PROTECTED]', reaching an entirely different
audience.
I admit that the document I pointed to is only talking about newsgroups,
while this is a mailing list. Nevertheless, this list and clpmisc are
forums with similar purposes, and they both support the Perl community,
so the banning of multi-posting applies (at least IMO).
Even if there are a few persons that follow both, that's not the main
point. The main point is to ensure that prospective helpers know about
the help provided by others, so they don't unnecessarily put efforts on
things that have been resolved.
I eanestly appologize to everyone on both lists. My bad!! I have
spanked my own hand with a digital ruler. I'll do my best not to let
that occur again.
I'm new, and some of the things I learn come the hard way. Again, my
sincere appologies folks.
I'll be reading the 'crospost' page to get the rules.
Great, thanks for understanding!
Is there anything other than that, that I can do to straighten things
out?
As a matter of fact, there is: Your quoting style. When replying to a
message, it's common practice to quote as much of the message you are
replying to that is needed to give context, but it's almost never
motivated to quote the whole message. Also, your comments should
preferrably be typed *below* the quoted part(s).
End of lesson. :)
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>



Re: Extracting Directories and Sub Directories and Counting

2004-11-03 Thread Ron Smith
--- Gunnar Hjalmarsson <[EMAIL PROTECTED]> wrote:

> Ron Smith wrote:
> > If I wanted to add more fields to my output, which
> construct would I
> > use to create more fields; something like the
> following?
> > 
> > basenamecountextensionsize
> > 
> > ...maybe 'HoH', or just expand on the 'HoA?
> 
> I suppose that you are not really talking about the
> output now, but
> rather about adding more info to the data structure.
> Anyway, it depends
> on what you would like to use it for. I imagine that
> you might want a
> HoAoH with each file being represented by a hash
> reference. Something
> like:
> 
>  my %HoAoH = (
>  dir1 => [
>{
>  basename => 'name1',
>  extension => 'html',
>  size => 1000,
>},
>  ],
>  dir2 => [
>{
>  basename => 'name2',
>  extension => 'html',
>  size => 2000,
>},
>{
>  basename => 'name3',
>  extension => 'gif',
>  size => 1500,
>},
>  ],
>  );
> 
> -- 
> Gunnar Hjalmarsson
> Email: http://www.gunnar.cc/cgi-bin/contact.pl
> 

This looks closer to what I was refering to. But I
didn't even know you could do this. I've been away
from this thread a couple of days mulling over
'perlref' and 'perlreftut'.

I've also picked up a copy of "Learning Perl Objects,
References & Modules". Hey, I just recently discovered
this book was out there. I think I'd better go through
this material and what you've given me above, before I
proceed any futher with this thread.

Thanks, everybody, for your help; and especially
Gunnar. I'll be back with other questions regarding
references after I've done further homework. :)

Ron





__ 
Do you Yahoo!? 
Check out the new Yahoo! Front Page. 
www.yahoo.com 
 


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




  1   2   3   4   5   6   7   8   9   10   >