File::Basename problem

2011-03-04 Thread Téssio Fechine
Hello! I'm trying to use File::Basename, but it is not behaving well: tessio@pacman:~/tmp/ASAP$ ls book.div book.tex erotic.div erotic.tex erotyc.tex problem source.a source.c source.o tessio@pacman:~/tmp/ASAP$ cat problem use 5.010; use strict; use warnings; use File::Basename;

Re: File::Basename problem

2011-03-04 Thread Téssio Fechine
: Shawn H Corey shawnhco...@gmail.com Assunto: Re: File::Basename problem Para: beginners@perl.org Data: Sexta-feira, 4 de Março de 2011, 13:22 On 11-03-04 11:14 AM, Téssio Fechine wrote:     my ( $file, $dir, $sufix ) = fileparse( $item, %sufixTable ); I don't think fileparse takes a hash

-d test stops working

2011-02-18 Thread Téssio Fechine
Hello, I made a program that traverses a directory listing all the files in it and in it's sub directories.. root@pacman:/home# cat list_dir #!/usr/bin/perl -w use 5.010; use strict; sub list_dir { say Entring directory $_[0]; chdir $_[0] or die $_[0]: $!\n;

Re: -d test stops working

2011-02-18 Thread Téssio Fechine
I just found the bug.. -- #!/usr/bin/perl -w use 5.010; use strict; sub list_dir { my ($dir) = @_; chdir $dir or die $dir: $!\n; chomp(my $pwd = `pwd`); say $pwd/; foreach my $entry (glob *) { # if entry is a directory, call list_dir on

reference noob

2011-02-03 Thread Téssio Fechine
The program: -- #use strict; use warnings; my $field = shift @ARGV; my $regex = '(\w+)\s*' x $field; while (STDIN) { if (/$regex/) { print $$field\n; # refers to a match variable } } -- Example Usage: -- $ echo 'Strange New World!' | ./this_program 3 $

Re: Why can't print accept a comma between arguments ?

2010-11-29 Thread Téssio Fechine
But it accept! -- print Hello, , World!, \n; -- In your case you are just using the wrong syntax for optional file handle.. De: Manish Jain bourne.ident...@hotmail.com Assunto: Why can't print accept a comma between arguments ? Para: beginners@perl.org Data: Segunda-feira, 29 de

Re: Split function

2010-11-28 Thread Téssio Fechine
Take extra caution with the backslash-scapes.. --- use 5.010; use strict; use warnings; my $str1 = F:\test\test123\test1233; #Wrong! Backslash being expanded! my $str2 = 'F:\test\test123\test1233'; my @array1 = split(/\\/, $str1); my @array2 = split(/\\/, $str2); my $n1 = @array1; my $n2 =

smart match question

2010-11-27 Thread Téssio Fechine
Another day, another problem.. =/ -- tes...@krauzer:~/Perl/Ex/ch15$ cat smart use 5.010; use strict; use warnings; my @divisors = (1, 2); say It's divisible by 2! if @divisors ~~ 2; tes...@krauzer:~/Perl/Ex/ch15$ perl smart tes...@krauzer:~/Perl/Ex/ch15$ -- Why @divisors ~~ 2 is not

Re: Re: smart match question

2010-11-27 Thread Téssio Fechine
I'm running perl 5.10! -- perl -v This is perl, v5.10.1 (*) built for i486-linux-gnu-thread-multi -- A think it's no longer true then: The smart match operator is commutative, which you may remember from high school algebra as the fancy way to say that the order of the operands doesn’t

Re: smart match question

2010-11-27 Thread Téssio Fechine
Smart match operator was commutative the first time it was introduced. So @divisors ~~ 2 would search for 2 in the list of divisors.. For any reason smart match is not commutative anymore, so the right syntax now is 2 ~~ @divisors.. The problem is that the syntax has changed. De:

given-when problem

2010-11-26 Thread Téssio Fechine
I think this is a bug: tes...@krauzer:~/Perl/Ex/ch15$ cat when #!/usr/bin/perl -w use 5.010; use strict; given($ARGV[0]) { when(/fred/i) { say 'Name has fred in it'; continue } when(/^Fred/) { say 'Name starts with Fred'; continue } when('Fred') { say 'Name is Fred' }