Problems matching filenames

2003-03-24 Thread papapep
I've made a small program that tries to get all the files from a 
directory that's full of files that they have the name format : 
pepe-1_DDMM.txt or pepe-2_DDMM.txt.
First, I am just trying to get them and print the array created. 
Afterwards, when this works I'll do more things with the data in them 
included, but for now I can't get though with the first objective :-/
When I execute the program it makes NOTHING!!! At least, that's what it 
seems...
I know its not a very good code, but it's my first one! :-D
Can anybody give some advice about where's the bug?
Thanks in advance.

#!perl
use strict;
use warnings;
my $program;
my @filenames;
opendir (FITXER,"c:/documents and settings/administrador/escritorio/pepes") or 
> die "no es pot llegir el directori: $!\n";
@noms = readdir (FITXER) or die "no es poden agafar els noms dels fitxers \n";
  foreach $program (@noms)
{
if ($program =~ m/^pepe-1_(\d[8])\.txt$/)
{
### do stuff, given a filename
  print "$program \n";
}
elsif( $program =~ m/^pepe-2_(\d[8])\.txt$/)
{
### do stuff, given a filename
print $program ;
}
};


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


Chopping strings

2003-02-19 Thread papapep
-BEGIN PGP SIGNED MESSAGE-
Hash: SHA1

How should I do to split a long string that the only thing I know is
that is a multiple of a previous defined number (for example 26).

A graphic example:

abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz

That's four times 26 (104) but I don't (I can't) count every string
because they are really long (They can be of thousands of charachters).

So what I should do, I think, is a loop that get the first 26
charachters and print them in a new file, after that evaluates if there
is more string to get, and so on, but I am not able to see how it
works... :-/

Give me some advice, please (the command I should use, or group of
commands, etc...)

Thanks in advance for your help and patience.

Josep Sànchez
~ [papapep]
-BEGIN PGP SIGNATURE-
Version: GnuPG v1.2.1 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+U2pP2vx52x0kyz4RArgbAKCwR88CWEfO0I8eePfRL42XsoTKxACgkm5d
hJTlHvX22x+LSCazIBDsruc=
=qw3e
-END PGP SIGNATURE-




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




Re: book for perl ???

2002-11-22 Thread papapep
Sunil Sonnad wrote:

Hi all,
 Which book would make the gr8 reference for PERL ???
  S.


1.- Programming Perl

2.- Learning Perl

Personally I prefer the second.

Take a look at amazon, for example.

Josep Sànchez
 [papapep]





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




Ultra-Newbie Reformatting a text file

2002-10-11 Thread papapep

First of all I beg your pardon for such a stupid question, but I'm new 
to programming and also to Perl.

The question is I've got one text message with a great amount of 
numbers, like this:

23845235900210848046801531651000151564186414812000441848415041848464143995

(There are a lot of lines like this)

First, I have to cut the line to, for example, 25 characters. After I 
would like to insert in certain places (in every line, of course), for 
example betwen the 12 an 13 character and between the 24 and 25, and so 
on, some characters to split the line in fields (really this data are a 
text exportation of a database).

Where should I begin with it??

Thanks in advance for your answer.

Josep Sànchez
  [papapep]





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