AW: why does this code fail with stat?

2010-04-21 Thread Thomas Bätzler
Harry Putnam wrote: > I'm not finding a reference in perldoc File::Find showing how to set > that flag when using the popular notation like the script involved > here. Probably a case of not seeing the woods because of the trees ;-) To quote: NAME File::Find - Traverse a directory tree.

Re: UNIX permission bit calculator ... ???

2010-04-21 Thread Jeff Pang
from perldoc -f stat: use File::stat; $sb = stat($filename); printf "File is %s, size is %s, perm %04o, mtime %s\n", $filename, $sb->size, $sb->mode & 0, scalar localtime $sb->mtime; $sb->mo

UNIX permission bit calculator ... ???

2010-04-21 Thread newbie01 perl
Hi, Does anyone have a UNIX permission bit calculator script that I can use? Basically, am looking for one where I don't have to a ls -l to check the permission on a file or directory. Am looking for a script that will display the permission bits and then just display what those permission bit set

Re: Help on using << on *nix and Windows

2010-04-21 Thread newbie01 perl
Hi David, Not being dubious, really am a newbie ... as far as Perl+DBI is concern. I can look at Perl codes on the average but not if the whiz programmers start using a lot of shortcuts etc My daytime job is as an Oracle DBA. Most of the scripting I do is mainly UNIX scripting and very limited

Re: why does this code fail with stat?

2010-04-21 Thread Harry Putnam
Shawn H Corey writes: > File::Find changes the working directory to each subdirectory as it > processes it. To prevent this, set the no_chdir flag. See `perldoc > File::Find` for details. http://perldoc.perl.org/File/Find.html I'm not finding a reference in perldoc File::Find showing how to s

Re: why does this code fail with stat?

2010-04-21 Thread Harry Putnam
Shawn H Corey writes: > File::Find changes the working directory to each subdirectory as it > processes it. To prevent this, set the no_chdir flag. See `perldoc > File::Find` for details. http://perldoc.perl.org/File/Find.html Doggone it.., I think this is at least the 2nd time I got caught o

Re: why does this code fail with stat?

2010-04-21 Thread Shawn H Corey
Harry Putnam wrote: I've run into one of those things where I can't see why my code fails. ... and know it has to be something obvious. Why does the second usage of stat... fail in the find() funciton? #!/usr/local/bin/perl use strict; use warnings; use File::Find; my $dir2 = './dir2'; my $fn

why does this code fail with stat?

2010-04-21 Thread Harry Putnam
I've run into one of those things where I can't see why my code fails. ... and know it has to be something obvious. Why does the second usage of stat... fail in the find() funciton? #!/usr/local/bin/perl use strict; use warnings; use File::Find; my $dir2 = './dir2'; my $fname1 = shift; my ($las

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

2010-04-21 Thread Shawn H Corey
Mimi Cafe wrote: Yes all non-alphanumeric and non-whitespace. I have a database for people to search using a keyword or all alphanumerical words (including space) are valid, but no special characters. All the characters I am substituting below are invalid characters for the search. $string =~ s/

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

2010-04-21 Thread Mimi Cafe
>> Do you have a list of these special characters or do you mean all >> non-alphanumeric and non-whitespace: >> >> #!/usr/bin/perl >> >> use strict; >> use warnings; >> >> while( <> ){ >>if( /[^[:space:][:alnum:]]/ ){ >> print "invalid: $_"; >>} >> } >> Yes all non-alphanumeri

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

2010-04-21 Thread Akhthar Parvez K
On Thursday 22 Apr 2010, Mimi Cafe wrote: > I am trying to match words or complete phrase (excluding special characters) > like: > 1.Tom > 2.Tom and Jerry > 3.Audio A4 Quattro > > I need to ensure users cannot feed my program with special characters so I > tried this below, but i

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

2010-04-21 Thread Shawn H Corey
Mimi Cafe wrote: I am trying to match words or complete phrase (excluding special characters) like: Do you have a list of these special characters or do you mean all non-alphanumeric and non-whitespace: #!/usr/bin/perl use strict; use warnings; while( <> ){ if( /[^[:space:][:alnum:]]/ ){

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

2010-04-21 Thread Mimi Cafe
I am trying to match words or complete phrase (excluding special characters) like: 1. Tom 2. Tom and Jerry 3. Audio A4 Quattro I need to ensure users cannot feed my program with special characters so I tried this below, but it doesn't match correctly. $string =~ s/\

Re: Using backtick operator output and feeding it into array

2010-04-21 Thread Linux Expert
(@digOutput) = `dig -x $ipaddie +short`; The line shown above is replacing the entire @digOutput array on each assignment. Try this instead: push @digOutput,`dig -x $ipaddie +short`;

Re: Using backtick operator output and feeding it into array

2010-04-21 Thread Uri Guttman
> "LE" == Lonnie Ellis writes: LE> I'm pretty new to perl, and can't seem to get the following bit of code LE> to work. If I print the array while in the sub, it returns what I want LE> but outside of the sub it doesn't recognize it. Aren't all variable LE> global by default unless

Re: How to manage large Conditional Statement

2010-04-21 Thread Uri Guttman
> "OR" == Octavian Rasnita writes: OR> From: "Uri Guttman" >> >> it isn't religious. it is just no one is taught the right way >> anymore. it used to be always done this way (in the good very old >> day). with the onslaught of redmond and aol the unwashed masses didn't >> learn

Re: How to manage large Conditional Statement

2010-04-21 Thread Octavian Rasnita
From: "Uri Guttman" > MC> Uri: I think the quoting is much a religious issue as everyone has their > MC> preferred way, but I now know what you meant. :-) > > it isn't religious. it is just no one is taught the right way > anymore. it used to be always done this way (in the good very old > day)

Using backtick operator output and feeding it into array

2010-04-21 Thread Lonnie Ellis
I'm pretty new to perl, and can't seem to get the following bit of code to work. If I print the array while in the sub, it returns what I want but outside of the sub it doesn't recognize it. Aren't all variable global by default unless told otherwise with "my"? Here is code below, any help would

Re: while and eval

2010-04-21 Thread Shawn H Corey
Uri Guttman wrote: "JWK" == John W Krahn writes: >> Also, how does 'eval' work and when is it useful? What is the difference if >> we put a block inside eval like: eval ( }; JWK> eval interprets a string as Perl code and compiles and runs it. If JWK> you are using a block eval then

Re: while and eval

2010-04-21 Thread Uri Guttman
> "JWK" == John W Krahn writes: >> Also, how does 'eval' work and when is it useful? What is the difference if >> we put a block inside eval like: eval ( }; JWK> eval interprets a string as Perl code and compiles and runs it. If JWK> you are using a block eval then the block must b

Re: How to manage large Conditional Statement

2010-04-21 Thread Uri Guttman
> "MC" == Mimi Cafe writes: MC> Earlier I thought of using an eval or BEGIN block to evaluate the MC> SQL, but then I thought wait a minute, that wouldn't be the MC> correct way of using them. Now I see that doing as you guys MC> recommended is the right way forward. a BEGIN block ma

Re: while and eval

2010-04-21 Thread John W. Krahn
Arun P Menon wrote: Hello All, Hello, Could you tell me what does the following do? 1 while (<>); That reads through all the files listed on the command line, or if there are no files listed on the command line then it reads through STDIN, and does nothing with the lines read, but does se

while and eval

2010-04-21 Thread Arun P Menon
Hello All, Could you tell me what does the following do? 1 while (<>); Also, how does 'eval' work and when is it useful? What is the difference if we put a block inside eval like: eval ( }; -- Regards, Arun.P.Menon

RE: How to manage large Conditional Statement

2010-04-21 Thread Mimi Cafe
>> -Original Message- >> I'm talking for myself here, but the way I usually do this is that I wrap >> up each SQL query or set of related SQL queries in a subroutine. >> >> If the sub's going to be used as a predicate I make sure it returns >> true/false and pass all of the relevant data

Get XML content using XML::Twig

2010-04-21 Thread alwaysonnet
Hello all, I'm trying to parse the XML using XML::Twig Module as my XML could be very large to handle using XML::Simple. Please help me out of how to print the values based on the following... get the values of Sender, Receiver get the FileType. In this case possible values are InitTAP,FatalRAP

ExtUtils-Makemaker comilation problems.

2010-04-21 Thread Raheel Hassan
Hi, When i am trying to install ExtUtils i have these errors are coming. I am trying ti install it in Mandriva. Can any one can give be the clue. Thanks in advance. *[r...@localhost ExtUtils-MakeMaker-6.56]# perl Makefile.PL* Writing Makefile for ExtUtils::MakeMaker *[r...@localhost ExtUtils-Make

Re: list assignment

2010-04-21 Thread Shawn H Corey
srd wrote: What really needs an explanation is if the array contains n elements then (n-2) warnings are emitted. maybe i was not so clear about my question Paul Johnson wrote: > On Tue, Apr 20, 2010 at 09:38:48AM -0700, Jim Gibson wrote: >> Yes, but as srd has observed, you get one fewer warni

Re: list assignment

2010-04-21 Thread srd
What really needs an explanation is if the array contains n elements then (n-2) warnings are emitted. maybe i was not so clear about my question -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: list assignment

2010-04-21 Thread C.DeRykus
On Apr 20, 9:38 am, jimsgib...@gmail.com (Jim Gibson) wrote: > On 4/20/10 Tue  Apr 20, 2010  9:25 AM, "Shawn H Corey" > scribbled: > > > srd wrote: > >> #!/usr/bin/env perl > >> use warnings; > >> use strict; > >> my $x= (1,2,3); > >> print $x,"\n"; > >> exit(0); > >> *

serial port communication

2010-04-21 Thread axr0284
Hi, I am trying to figure out how to use the serial port in perl. I am using windows with ActivePerl. This is what I have so far: [CODE] $o_rs232Port = new Win32::SerialPort($ARGV[1]) || die "Can't open $ARGV[1]: $!"; $o_rs232Port->user_msg("ON"); $o_rs232Port->baudrate(115200) || die "Can't set 1

Re: can't locate loadable object for module PadWalker in @INC

2010-04-21 Thread Shlomi Fish
Hi Kenneth, On Wednesday 21 Apr 2010 08:19:25 CHAN, KENNETH 1 [AG/7721] wrote: > Thanks Fish. > "Fish" is my last name, so you should say "Thanks, Shlomi" or "Thanks, Mr. Fish" - not "Thanks, Fish". See what Joel Spolsky wrote about it here: http://www.joelonsoftware.com/articles/ResumeRead.ht

Re: Precision laser printing

2010-04-21 Thread Shlomi Fish
Hi Keith, On Wednesday 21 Apr 2010 06:10:34 keithvb wrote: > Hi, > > I need to create a grid, 24 cols, 16 rows on 4.5 cm centers > on an HP laser printer. Some of the cells will be filled, some empty. > Is there a way to do this in Perl? > Yes, there is. You can try generating a vector graphic

Re: Precision laser printing

2010-04-21 Thread Dermot
On 21 April 2010 04:10, keithvb wrote: > >  Hi, > > I need to create a grid, 24 cols, 16 rows on 4.5 cm centers > on an HP laser printer. Some of the cells will be filled, some empty. > Is there a way to do this in Perl? You going to have to break this project down. The actual document will need