Re: perl interview questions

2011-04-25 Thread Akhthar Parvez K
On Monday 25 Apr 2011, Shlomi Fish wrote: > On Sunday 24 Apr 2011 21:01:57 Shawn H Corey wrote: > > On 11-04-24 10:36 AM, Akhthar Parvez K wrote: [ snip ] > > I still think I have to disagree. Sometimes interviewers ask purposely > > obscure questions not to see if you know

Re: perl interview questions

2011-04-24 Thread Akhthar Parvez K
On Sunday 24 Apr 2011, Shawn H Corey wrote: > On 11-04-24 09:48 AM, Akhthar Parvez K wrote: > > #5 - Never give a wrong answer - If at all you receive a question that you > > don't know, do not panic, just be smart and divert the question so you can > > answer what y

Re: perl interview questions

2011-04-24 Thread Akhthar Parvez K
ould let you handle the interview in the best possible way. #5 - Never give a wrong answer - If at all you receive a question that you don't know, do not panic, just be smart and divert the question so you can answer what you know. #6 - Please your interviewer with well explained respon

Re: Assistance with regular expression

2011-02-16 Thread Akhthar Parvez K
; > # print "Found\n"; > } > } > } > > #read MSRT first @msrt = ; chomp(@msrt); #perform the check while reading Test_server while ($tom = ) { chomp($tom); my @result = grep { /\Q$tom\E/ } @msrt; print "$tom: @result\n" if @result; } #T

Re: Regular expression: Search a pattern but starting from the end of a string?

2010-11-02 Thread Akhthar Parvez K
ust the following simple regex would do, right? /.*(E)/ or did I miss another important criteria? If so, please excuse me for I'm probably not concentrating enough now. Might be because it's being late night over here. Good nite/day! -- Regards, Akhthar Parvez K http://www.sysad

Re: Subroutine question: Placement of subroutine definitions matter?

2010-11-02 Thread Akhthar Parvez K
red in perl4. > it shouldn't be used in perl5 calls unless you know why and it is a very > special case. Thanks for clarifying that. -- Regards, Akhthar Parvez K http://www.sysadminguide.com/ UNIX is basically a simple operating system, but you have to be a genius to understand

Re: Regular expression: Search a pattern but starting from the end of a string?

2010-11-02 Thread Akhthar Parvez K
signatures. > > like i just did to the whole email you quoted. > Well, I hope that was an aberration as I usually do bottom postings only. Apologize for any inconvenience brought to you. -- Regards, Akhthar Parvez K http://www.sysadminguide.com/ UNIX is basically a simple oper

Re: Subroutine question: Placement of subroutine definitions matter?

2010-11-02 Thread Akhthar Parvez K
outine I remember I'd read in the past that & should be used in such cases so that Perl can easily recognize I'm attempting to call a subroutine, correct and/or is that (only) required with older versions? -- Regards, Akhthar Parvez K http://www.sysadminguide.com/ UNIX is basically a

Re: Regular expression: Search a pattern but starting from the end of a string?

2010-11-02 Thread Akhthar Parvez K
Hi Henning, $catch = $1 if ($string =~ /.*(E)\d*\b/); you can use this to test it: $catch = $1 if ($string =~ /.*(E\d*)\b/); -- Regards, Akhthar Parvez K http://www.sysadminguide.com/ UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity

Re: A story

2010-05-30 Thread Akhthar Parvez K
> -stevieb > > ps: % perl -e 'print "Not Another Perl Hacker"' > > >subject: A story .. and a good one at that :-) -- Regards, Akhthar Parvez K http://tips.sysadminguide.com/ UNIX is basically a simple operating system, but you have to be a genius to understand t

Re: grep and regex

2010-05-25 Thread Akhthar Parvez K
they were two separate regex expressions. Sorry for that! my $rx1 = qr{ ab(cd) }mx; my $rx2 = qr{ (pq)rs }mx; So could you tell me how would you write the statement now? -- Regards, Akhthar Parvez K http://tips.sysadminguide.com/ UNIX is basically a simple operating system, but you have to b

Re: grep and regex

2010-05-22 Thread Akhthar Parvez K
On Saturday 22 May 2010, Jim Gibson wrote: > On 5/21/10 Fri May 21, 2010 12:13 PM, "Akhthar Parvez K" > scribbled: > > Shouldn't > > Perl be smart enough to understand that the outer most pair of paranthesis > > and > > | symbol were solely used f

Re: grep and regex

2010-05-21 Thread Akhthar Parvez K
nwanted delay if there are more strings to be matched, so I thought to get it done in a single statement, or a group of statements, without any loop. The above regex method worked for me, except it gave me some undefs as well. Is there any way I can get rid of them by using the same statement

Re: grep and regex

2010-05-21 Thread Akhthar Parvez K
On Friday 21 May 2010, Akhthar Parvez K wrote: > Look at this code: > > my @data = ( 'Twinkle twinkle little star > How I wonder what you are > Up above the world so high > Like a diamond in the sky. > 123 > Twinkle twinkle little star > How I wonder what you are&#

Re: grep and regex

2010-05-20 Thread Akhthar Parvez K
like it was not picked because some part of the string was already picked by another regex. How can I get the expression pick that as well so the output would be like below: result: $VAR1 = [ 'little starHow I wonder', 'what you areUp above the world'

grep and regex

2010-05-20 Thread Akhthar Parvez K
grep show only the matched string like Unix egrep -o or Perl regex? -- Regards, Akhthar Parvez K http://tips.sysadminguide.com/ UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennis Ritchie -- To unsubscribe, e-mail: beginners-uns

Re: Perl general questions

2010-05-13 Thread Akhthar Parvez K
On Thursday 13 May 2010, Akhthar Parvez K wrote: > On Thursday 13 May 2010, Shlomi Fish wrote: > > Then it is very likely that the memory allocated to the "mem" pointer will > > not > > be returned to the kernel due to the nature of malloc() and how it is

Re: Perl general questions

2010-05-13 Thread Akhthar Parvez K
am is forking that part of the program so that it will run as a child process and return all the memory used by it back to the system. Please correct me if I am wrong. -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to b

Re: Perl general questions

2010-05-13 Thread Akhthar Parvez K
l won't need to grow its size if it can > reuse lexical data that is reclaimed upon scope exit. > Doesn't Perl free up any memory that was used by it until the program exits? If that's how it goes, if a Perl program uses a lot of memory at the beginning and it takes

Perl general questions

2010-05-12 Thread Akhthar Parvez K
y that's used to allocate a variable defined with 'my' will be freed up once the current lexical scope is exited? -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicit

Re: AW: Hash with variable name

2010-05-12 Thread Akhthar Parvez K
   "vvw" => "\%vvw_dirs" ); Remove the quotes. When you put something around quotes, you're telling it's a string and a reference is not a string as you know. -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie

Re: AW: Hash with variable name

2010-05-12 Thread Akhthar Parvez K
31" => "dir32", "dir33" => "dir34" ); # PKV my %pkv_dirs=( "dir41" => "dir42", "dir43" => "dir44" ); # VVW my %vvw_dirs=( "dir51" => "dir52", "dir53" => "dir54" ); #

Re: about dispatch tables

2010-05-06 Thread Akhthar Parvez K
is not the argument list of another subroutine inside that. >>print N(@_#HERE) Why are you calling the subroutine N? Have you already defined a subroutine with the name N in your program? -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, b

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
ays if everything is OK (you may do occassionally), but if anything failed :-) -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: b

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
e explanation John. Could you give one or two real time examples where you used a list (instead of an array) except in loops such as: for ('a', 'b', 'c', 'd')? I wonder if I'm underusing lists in my Perl programs. -- Regards, Akhthar Parvez K htt

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
as RAID, it's important to have a live monitoring system such as nagios so that you'll never miss out on such things. At the end of day, it comes down to how you manage what you have got in your hands. -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simpl

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
- But what if the file is huge? 2. Opening filehandles again and again - would cause I/O overhead 3. any other method? -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
statement, loop is processed whilst the file is being read and hence it's more appropriate. So while would be a better choice, more so if the file size is higher and there's a scope of closing the file before it's read completely. That's what I understood. Please correct

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
production code - it's a very bad > idea.). Thanks Shlomi for the explanation. I was amazed with some of the Perl tricks, so wondering if it can go to that extent to blow me out completely. -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating sy

Re: Array, foreach problem

2010-05-05 Thread Akhthar Parvez K
ehandle and the scalar variable. Is Perl too intelligent to recognize both of them? -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-un

Re: Still pondering working with hashs

2010-05-04 Thread Akhthar Parvez K
program here, I think he should state clearly what he wants to do as it will help both parties (those who seek help and those who help) and eventually the resolution would be faster. -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but

Re: function return

2010-04-30 Thread Akhthar Parvez K
0]; Nice to see all these explanations coming in. Thanks Charles :-) -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-unsubscr...@perl.

Re: function return

2010-04-29 Thread Akhthar Parvez K
r functions inside it. Correct and thanks for clearing my misconception! Is there any way to catch only the second return value then? I am not so sure but I think I had done it in the past using the method that I mentioned earlier (or similar). -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.

Re: unless with AND

2010-04-29 Thread Akhthar Parvez K
On Thursday 29 Apr 2010, Shlomi Fish wrote: > On Thursday 29 Apr 2010 14:39:11 Akhthar Parvez K wrote: > > There was a typo in my original email. I missed the word "not" which was > > very crucial as always. > > > > Scenario: #1 > > unless ( (define

Re: unless with AND

2010-04-29 Thread Akhthar Parvez K
quot; a few years back, but haven't been into scripting except Shell for the past few years and may be due to that, lost on that completely. But with you guys' help, I have polished it back now. :-) -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple ope

Re: function return

2010-04-29 Thread Akhthar Parvez K
at) Anything wrong with this method? If so, what's the correct method then? -- Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: unless with AND

2010-04-29 Thread Akhthar Parvez K
On Thursday 29 Apr 2010, Shawn H Corey wrote: > !( A && B ) === !A || !B Thanks Shawn, had learnt it a few years back, but forgot that it seems and eventually got confused :-) Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you

Re: unless with AND

2010-04-29 Thread Akhthar Parvez K
ESS $test does not contain TEST), but not the scenario #1. Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie On Thursday 29 Apr 2010, Akhthar Parvez K wrote: > Hi,

function return

2010-04-29 Thread Akhthar Parvez K
well for me, but I'm getting the following warning: Scalar value @_[0] better written as $_[0] I hate warnings, but how can I fix that? As I said, $_[0] doesn't work. Can someone shed some light on this? Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simp

unless with AND

2010-04-29 Thread Akhthar Parvez K
SS $test does contain TEST), but not the scenario #1. Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For addi

Re: AW: Filehandle problem

2010-04-29 Thread Akhthar Parvez K
for the next one which produces the errors mentioned, only a few lines > later! So you have fixed those lines as well, good :) Btw, the messages you received were "warnings", not errors I guess. Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple

Re: How to make a hash in a subroutine accessible by all other subrountines?

2010-04-29 Thread Akhthar Parvez K
($fred != $href->{fred}) { print "fred failed.\n"; } } Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-unsubsc

Re: Filehandle problem

2010-04-29 Thread Akhthar Parvez K
ne 232. > > Could somebody please tell me why this doesn't work? Most probably you have used an undefined scalar in an expression. Would be good if you can mention the lines along with the line no. Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating

Re: How to make a hash in a subroutine accessible by all other subrountines?

2010-04-29 Thread Akhthar Parvez K
reference as an argument while calling the function. Do remember that you can't pass the hash to a function, but just the hash reference. Also minimize (or even avoid) the use of declaring with "our", use argument passing instead. Regards, Akhthar Parvez K http://Tips.SysAdminGUI

Re: Regex to match a word or phrase (no special character)

2010-04-21 Thread Akhthar Parvez K
t; tried this below, but it doesn't match correctly. if ($string =~ /^[\w\s]*$/) {print "$string\n";} else {print "Invalid Keyword. Please check and try again\n";} Audio A4 Quattro -> Audio A4 Quattro Tom & Jerry -> Invalid Keyword. Please check and try aga

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
uninitialized value in concatenation (.) or string at scripts/test/test2.pl line 14. extracted: But it worked for the OP (the above condition may not have been required for him) and that's what is important :-) Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a sim

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
Hi, > It works fine and I like it. My regex is not that good, but I can see what > is doing. I modified it a bit (to capture up till a full stop sign). Kewl. Good to hear that! Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you h

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
Hi Shawn, > $str =~ m{ \A ( .{15} .*? ) \s }msx; I don't think this would work if the value given in the match string (15 as per above eg.) is greater than the character count of the particular string. Right? Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically

Re: Extract substring from offset to space or full stop

2010-04-18 Thread Akhthar Parvez K
ints: The black cat climbed the green tree My knowledge in Perl is limited, so there may be a more apt solution in your case. Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Ric

Re: SCALAR ref

2010-04-13 Thread Akhthar Parvez K
Got that, thanks Shlomi! However, can this be done by referencing $1 directly with strict refs on? I definitely feel it can be done and would be nice to know how! Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to

SCALAR ref

2010-04-13 Thread Akhthar Parvez K
while "strict refs" in use at test.pl I tried to overcome this issue using scalar(), but didn't help. Could someone please let me know what is the workaround here. Thank you! Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, b

Re: encrypted file

2010-04-08 Thread Akhthar Parvez K
an alternative that would work in my case as well. Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie On Thursday 08 Apr 2010, Rob Coops wrote: > On Thu, Apr 8, 2010

encrypted file

2010-04-08 Thread Akhthar Parvez K
help me to set this up? Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginner

Re: Permission mode of a directory

2010-04-03 Thread Akhthar Parvez K
Excellent, John. Didn't know that Perl only deals with decimal numbers. Funny thing was I did think that it could be a hex, so converted it to binary and done an AND, but didn't get the desired result. Wonder why I didn't give a thought that it could be decimal! Regards, Akhtha

Permission mode of a directory

2010-04-03 Thread Akhthar Parvez K
e given directory is having 1777 perm mode? Regards, Akhthar Parvez K http://Tips.SysAdminGUIDE.COM UNIX is basically a simple operating system, but you have to be a genius to understand the simplicity - Dennie Richie -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/