cpan message

2006-03-08 Thread Owen
This message pops up when a new CPAN.pm is available

There's a new CPAN.pm version (v1.87) available!
  [Current version is v1.83]
  You might want to try
install Bundle::CPAN
reload cpan
  without quitting the current session. It should be a seamless upgrade
  while we are running...


What I don't understand is how it is meant to be installed "while we are 
running"

I can't start another session as there is a lock file on the current session
so to me the message does not make sense

Installing the module as a separate task is no problem and that's what I do at
the conclusion of current tasks

Maybe I am reading something into it that isn't there


TIA



Owen

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




Parallel Port and Console Application

2006-03-08 Thread LinuxMurah . com
Hi GUYS,

I'm a beginner in PERL. After Python confusing me about installing
Parallel Port module, I decide to try Perl and hopefuly I have a
future with Perl. So I already download Parallel Port module
(http://search.cpan.org/CPAN/authors/id/S/SC/SCOTT/Device-ParallelPort-1.00.tar.gz)
then how this module can be load by Perl? should I copy to somewhere?

and next question is what kind of module do I need for console screen
programming? Like URWID, NCURSES, etc in Python. Specially the simple
one and has capability to communicate with parallel port.

Thanks GUYS!!

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




LinuxMurah.com wants to talk to you using Google Talk

2006-03-08 Thread LinuxMurah . com
---

LinuxMurah.com wants to talk to you for free using Google Talk.

If you already have Gmail or Google Talk, visit:
http://mail.google.com/mail/b-d09da123d2-c968a3e5b6-71df5c976a5f43bc
You'll need to click this link in order to add LinuxMurah.com to your
Friends list and talk with each other for free.

To try Google Talk (and get Gmail, a free Google email account with
over 2,500 megabytes of storage) visit:
http://mail.google.com/mail/a-d09da123d2-c968a3e5b6-2ecba1fa5c

Google Talk is a downloadable Windows* application that lets you send
instant messages to your friends and make free phone calls over an
internet connection. Google Talk offers excellent voice quality and
works with any computer speaker and microphone.

Gmail is Google's free email service, offering lots of free storage,
powerful spam protection, built-in search for finding your messages,
and a helpful way of organizing email into "conversations." And there
are no pop-up ads or untargeted banners -- just text ads and related
information that are relevant to the content of your messages.

Once you sign up, we'll notify LinuxMurah.com of your new Gmail address
and add you to each others' Friends lists so you can start talking right
away.

Gmail and Google Talk are still in beta. We're working hard to add new
features and make improvements, so we might also ask for your comments
and suggestions periodically. We appreciate your help in making our
products even better!

Thanks,

The Gmail and Google Talk Teams


To learn more about Gmail and Google Talk, visit:
http://mail.google.com/mail/help/benefits.html
http://www.google.com/talk/about.html

(If clicking the URLs in this message does not work, copy and paste
them into the address bar of your browser).

* Not a Windows user? No problem. You can also connect to the Google
Talk service from any platform using third-party clients
(http://www.google.com/talk/otherclients.html).

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




Re: linux doesn't like me

2006-03-08 Thread John W. Krahn
Kathryn E. Bushley wrote:
> Hello,

Hello,

> Maybe not a perl question but I'm trying to run my perl program below and
> am getting the following error which I'm fairly certain is from the linux
> system:
> 
>>(BC1G_02948.1) AMP 1/1 144 522
> sh: -c: line 0: syntax error near unexpected token `('
> sh: -c: line 0: `getseq.pl 56 374 (BC1G_03519.1) Botrytis_annotations'

perldoc -q "How do I tell the difference between errors from the shell and perl"


Also search for "syntax error" in perldiag.


> The first line of this message is what line 29 of the main program below
> is supposed to print out but then it is also supposed to print dna
> sequence data but instead prints the error.  If anyone has any
> suggestions, please help.
> 
> 
> The main program is:
> 
> #!/usr/bin/perl -w

use warnings;
use strict;

> $annotation_filename = $ARGV[0];
> my $protein_filename = "$ARGV[1]";

$ARGV[1] is already a string, why are you putting quotes around it?


> #input parameter;
> my $domain_param = "$ARGV[2]";

Again, why the quotes?

perldoc -q quoting


> print "domain_param->".$domain_param."\n";

Why concatenation instead of interpolation here?


> #open annotation file and assign file handle
> open(ANN,$annotation_filename)|| die "can't open annotation file: $!\n";
> 
> #initialize array and store data in the array
> my(@ANN);
> while (){
>   # split the line on spaces and put fields into array @ANN
>   @ANN = split(/\s+/);# print join(",", @ANN), "\n";
>   #get rid of carriage returns
>   chomp;

Why do you think that there is a carriage return to get rid of and why do you
think that chomp() will get rid of it?


>   my $proteinID = $ANN[0];
>   my $domain = $ANN[1];
>   my $start = $ANN[2];
>   my $stop = $ANN[3];

What is the point of using the @ANN array?

my ( $proteinID, $domain, $start, $stop ) = split;



John
-- 
use Perl;
program
fulfillment

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




Re: linux doesn't like me

2006-03-08 Thread Tom Phoenix
On 3/8/06, Kathryn E. Bushley <[EMAIL PROTECTED]> wrote:

> Maybe not a perl question but I'm trying to run my perl program below and
> am getting the following error which I'm fairly certain is from the linux
> system:
>
> >(BC1G_02948.1) AMP 1/1 144 522
> sh: -c: line 0: syntax error near unexpected token `('
> sh: -c: line 0: `getseq.pl 56 374 (BC1G_03519.1) Botrytis_annotations'

The prefix of those two lines is "sh:", leading me to believe that
this is a message from /bin/sh, the shell.

> #call up the getseq program
> $seq = `getseq.pl $start $stop $proteinID $protein_filename`;

It looks as if this is where the shell is getting involved. Backquoted
strings use shell command syntax, and parentheses are meaningful to
the shell.

One solution would be to try to fix up the command line: Use a little
programming to make a string that is a correct shell command, then
execute that.

Another solution would be to see whether getseq.pl could be turned
into a library or module. Better yet, see whether it's already been
done. Have you looked on CPAN? There's probably a module to do what
you're doing in backticks, and I'd imagine it to have roughly a tenth
of the overhead of running a command in backticks and parsing the
output. That could save you a lot of runtime if you would otherwise be
running that command in backticks hundreds of times.

http://search.cpan.org/search?query=getseq&mode=all

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




RE: FW: Reading a Unicode text file

2006-03-08 Thread Baskaran Sankaran
Hi group,

 

Finally I made Perl to understand my file (the context is the mail quoted 
below). The problems is with how the file is saved in Unicode. I saved the file 
this time as utf8 (in notepad) and the same code works now (earlier I saved as 
Unicode text file) including regular expression features. But, I think Perl 
doesn’t allow us to I/O with Unicode as encoding in the handle (instead of 
utf8).

 

Thanks to those who answered earlier.

Baskaran

 

 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix
Sent: 20 February 2006 11:56
To: Baskaran Sankaran
Cc: beginners@perl.org
Subject: Re: FW: Reading a Unicode text file

 

On 2/17/06, Baskaran Sankaran <[EMAIL PROTECTED]> wrote:

 

> File: Sample_Hin.txt

> 

> दूसरे राज्य पुनर्गठन आयोग के गठन का यही सही वक्त है।

 

> The sample files were created in Windows in Unicode (both English & Hindi)

> and I am able to open then in notepad and wordpad. But, the output as you

> see is garbage and somehow it misses the utf8. This apart, a blank space is

> added for every character in both English and Hindi.

 

I've done a little experimenting, and I think you're right and Perl is

wrong here. At least, Perl seemingly disagrees with some common tools

about what a utf8 file is. I confess that I don't know enough about

utf8 to be certain.

 

If you don't get any better responses soon, you could use perlbug to

file a bug report. It is best if you can include a (small) utf8 file,

such as the first few lines of your Sample_Hin.txt file. But it's

important that the exact file contents be part of the bug report, not

just the text. One way would be if you can include a URL where the

files could be downloaded. But if the files are small enough, you can

convert them to a textual form (such as a hex dump) and include them

with your bug report.

 

Good luck with it!

 

--Tom Phoenix

Stonehenge Perl Training



Re: linux doesn't like me

2006-03-08 Thread Jeff Pang

>>(BC1G_02948.1) AMP 1/1 144 522
>sh: -c: line 0: syntax error near unexpected token `('
>sh: -c: line 0: `getseq.pl 56 374 (BC1G_03519.1) Botrytis_annotations'
>

How do you run your script? It seems that you run it as 'sh script.pl'.
For correctly,you should run it as 'perl script.pl' or 'chmod +x script.pl; 
./script.pl' please.

--
Jeff Pang
NetEase AntiSpam Team
http://corp.netease.com

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




linux doesn't like me

2006-03-08 Thread Kathryn E. Bushley
Hello,

Maybe not a perl question but I'm trying to run my perl program below and
am getting the following error which I'm fairly certain is from the linux
system:

>(BC1G_02948.1) AMP 1/1 144 522
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `getseq.pl 56 374 (BC1G_03519.1) Botrytis_annotations'


The first line of this message is what line 29 of the main program below
is supposed to print out but then it is also supposed to print dna
sequence data but instead prints the error.  If anyone has any
suggestions, please help.


The main program is:

#!/usr/bin/perl -w


$annotation_filename = $ARGV[0];
my $protein_filename = "$ARGV[1]";

#input parameter;
my $domain_param = "$ARGV[2]";
print "domain_param->".$domain_param."\n";

#open annotation file and assign file handle
open(ANN,$annotation_filename)|| die "can't open annotation file: $!\n";

#initialize array and store data in the array
my(@ANN);
while (){
# split the line on spaces and put fields into array @ANN
@ANN = split(/\s+/);# print join(",", @ANN), "\n";
#get rid of carriage returns
chomp;
my $proteinID = $ANN[0];
my $domain = $ANN[1];
my $start = $ANN[2];
my $stop = $ANN[3];

#call up the getseq program
$seq = `getseq.pl $start $stop $proteinID $protein_filename`;
#print the identifier and then the sequence
print ">".$proteinID." ".$domain_param." ".$domain." ".$start."
".$stop."\n".$seq;
}

close(ANN);


and the getseq.pl program that gets pulled up by line 29 is:

>(BC1G_02948.1) AMP 1/1 144 522
sh: -c: line 0: syntax error near unexpected token `('
sh: -c: line 0: `getseq.pl 56 374 (BC1G_03519.1) Botrytis_annotations'




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




Re: counting scalar array elements question

2006-03-08 Thread John W. Krahn
Hans Meier (John Doe) wrote:
>>>From: Graeme McLaren [mailto:[EMAIL PROTECTED]
>>>
>>> If I have a variable, $var, and it contains an array how would I be
>>> able to easily count the number of elements in the array?  I've tried
>>> creating a new array and pushing the original array on to it but that
>>> creates an array of arrays.
>>>
>>> Basically I have:
> 
> use strict;
> use warnings;
> 
>>> my $var = [
>>> 'a',
>>> 'b',
>>> 'c'
>>>   ]
> 
> # shorter: 
> 
> my $var=[ qw/ a b c / ];
> 
>>> and I tried:
> 
> my @array;
> #or:
> my @array=();
> 
> (sidenote: the second form must be used in contexts where the code is 
> persistent/preloaded and used several times, to ensure that @array is always 
> empty when the next execution hits the code again. Of course only *if* it 
> should start empty and not accumulate between executions)

Are you sure about that?  Do you really understand what my() does?


>>> push @array, $var;
>>>
>>>
>>> and got:
>>>
>>> @array=[
>>>[
>>>   'a',
>>>   'b',
>>>   'c'
>>>]
>>>  ]
> 
> You probably got this AoA (array of arrays) by using 

You mean AoAoA (Array of Arrays of Arrays.)



John
-- 
use Perl;
program
fulfillment

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




Re: counting scalar array elements question

2006-03-08 Thread Hans Meier (John Doe)
> > From: Graeme McLaren [mailto:[EMAIL PROTECTED]
> > Sent: Wednesday, March 08, 2006 3:57 PM
> > To: beginners@perl.org
> > Subject: counting scalar array elements question
> >
> > Hi all, I have an array question:
> >
> > If I have a variable, $var, and it contains an array how would I be able
> > to
> > easily count the number of elements in the array?  I've tried creating a
> > new
> > array and pushing the original array on to it but that creates an array
> > of
> > arrays.
> >
> > Basically I have:

use strict;
use warnings;

> > my $var = [
> >  'a',
> >  'b',
> >  'c'
> >]

# shorter: 

my $var=[ qw/ a b c / ];

> > and I tried:

my @array;
#or:
my @array=();

(sidenote: the second form must be used in contexts where the code is 
persistent/preloaded and used several times, to ensure that @array is always 
empty when the next execution hits the code again. Of course only *if* it 
should start empty and not accumulate between executions)

> > push @array, $var;
> >
> >
> > and got:
> >
> > @array=[
> > [
> >'a',
> >'b',
> >'c'
> > ]
> >   ]

You probably got this AoA (array of arrays) by using 

use Data::Dumper;
Dumper [EMAIL PROTECTED];

The outer [] stems from the \ after Dumper.

The data structure of @array itself is only, formulated as list:
@array=( ['a','b','c'] )

An arrayref is a scalar (holding a reference to an array), so after pushing it 
to an empty array, you just get an array with one element, the pushed scalar.

> > Using my original array which is assigned to scaler, what I need is:
> >
> > @array = [
> > 'a',
> > 'b',
> > 'c'
> > ]
> >
> >
> > So I can do:
> >
> > my [EMAIL PROTECTED];
> >
> >
> > Can anyone shed any light on this or suggest a better way of doing this?
>
>Timothy Johnson am Donnerstag, 9. März 2006 01.06:
> You need to dereference your array ref.
>
> my $count = @{$var};

the same, shorter, but more hiding what's going on:

my [EMAIL PROTECTED];

> Or in some circumstances it might make more sense to explicitly use
> scalar context:
>
> my $count = scalar @{$var};

One of these circumstances would be for example, since print provides list 
context:

print scalar @$var;

Hans

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




RE: counting scalar array elements question

2006-03-08 Thread Timothy Johnson
You need to dereference your array ref.

my $count = @{$var};

Or in some circumstances it might make more sense to explicitly use
scalar context:

my $count = scalar @{$var};







-Original Message-
From: Graeme McLaren [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, March 08, 2006 3:57 PM
To: beginners@perl.org
Subject: counting scalar array elements question

Hi all, I have an array question:

If I have a variable, $var, and it contains an array how would I be able
to 
easily count the number of elements in the array?  I've tried creating a
new 
array and pushing the original array on to it but that creates an array
of 
arrays.

Basically I have:

my $var = [
 'a',
 'b',
 'c'
   ]


and I tried:

push @array, $var;


and got:

@array=[

[
   'a',
   'b',
   'c'
]

  ]

Using my original array which is assigned to scaler, what I need is:

@array = [
'a',
'b',
'c'
]


So I can do:

my [EMAIL PROTECTED];


Can anyone shed any light on this or suggest a better way of doing this?



Cheers,

G :)


Public Sub House()

On Error Resume drink

 If Pint.empty = True Then
 Pint.refill
   Else
 Pint.drink
 End if

stomach.add Pint

MsgBox " I've had  " & stomach.count & " Pints"
MsgBox "VERY DRUNK"

End Sub



-- 
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]
 




counting scalar array elements question

2006-03-08 Thread Graeme McLaren

Hi all, I have an array question:

If I have a variable, $var, and it contains an array how would I be able to 
easily count the number of elements in the array?  I've tried creating a new 
array and pushing the original array on to it but that creates an array of 
arrays.


Basically I have:

my $var = [
'a',
'b',
'c'
  ]


and I tried:

push @array, $var;


and got:

@array=[

   [
  'a',
  'b',
  'c'
   ]

 ]

Using my original array which is assigned to scaler, what I need is:

@array = [
   'a',
   'b',
   'c'
]


So I can do:

my [EMAIL PROTECTED];


Can anyone shed any light on this or suggest a better way of doing this?



Cheers,

G :)


Public Sub House()

On Error Resume drink

If Pint.empty = True Then
Pint.refill
  Else
Pint.drink
End if

stomach.add Pint

MsgBox " I've had  " & stomach.count & " Pints"
MsgBox "VERY DRUNK"

End Sub



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




Re: problems with Class::Std and Vstrings

2006-03-08 Thread Tom Phoenix
On 3/8/06, Angus <[EMAIL PROTECTED]> wrote:

> Error:   Vstrings are not implemented in the version of perl at
> /../../../5.8.7/version/vpp.pm

> Is this is a know bug or should I just try to re-install Class::Std and it's
> dependencies?

It's a known feature. :-)   As seen at http://perldoc.perl.org/perldata.html :

Version Strings (v-strings) have been deprecated. They will not be
available after Perl 5.8. The marginal benefits of v-strings were greatly
outweighed by the potential for Surprise and Confusion.

It's another one of those things that seemed like a good idea at the
time, until the Surprise and Confusion.

You may have some modules installed which use v-strings; if so you can
check whether an upgrade is available on CPAN. (I don't know about
Class::Std in particular.) Else you could try to fix the source
yourself, by changing the v-string syntax to ordinary string syntax.
But if you do that, be sure to send the patch to whoever maintains
that code; they'll appreciate it.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




Re: how to work with ^@ ^M ^D etc. ?

2006-03-08 Thread Rafael Morales
It seems like if you were creating/editing files in windows and re-editing in 
unix later.
When I have that symbols I do this in my console.

> dos2unix original_file.txt newfile.txt

Use it maybe it helps you.

> - Original Message -
> From: "Tom Phoenix" <[EMAIL PROTECTED]>
> To: "Eugeny Altshuler" <[EMAIL PROTECTED]>
> Subject: Re: how to work with ^@ ^M ^D etc. ?
> Date: Wed, 8 Mar 2006 09:20:10 -0800
> 
> 
> On 3/8/06, Eugeny Altshuler <[EMAIL PROTECTED]> wrote:
> 
> > How to replace character which looks in vim like ^@ ^M ^D ?
> 
> It looks as if you're talking about "control characters". In Perl's
> double-quoted strings, and similar places, you may use "\cX" to denote
> "control-X". So you could write code like this, perhaps, if you wished
> to replace every control-M with three #-signs.
> 
>  s/\cM/###/g;
> 
> There are other odd characters than control characters. You can see
> how to specify them in Perl in the perlop manpage. Hope this helps!
> 
> --Tom Phoenix
> Stonehenge Perl Training
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>  

>


-- 
___
Get your free email from http://mymail.bsdmail.com

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




Re: how to work with ^@ ^M ^D etc. ?

2006-03-08 Thread Tom Phoenix
On 3/8/06, Eugeny Altshuler <[EMAIL PROTECTED]> wrote:

> How to replace character which looks in vim like ^@ ^M ^D ?

It looks as if you're talking about "control characters". In Perl's
double-quoted strings, and similar places, you may use "\cX" to denote
"control-X". So you could write code like this, perhaps, if you wished
to replace every control-M with three #-signs.

s/\cM/###/g;

There are other odd characters than control characters. You can see
how to specify them in Perl in the perlop manpage. Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

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




how to work with ^@ ^M ^D etc. ?

2006-03-08 Thread Eugeny Altshuler
How to replace character which looks in vim like ^@ ^M ^D ?

I try to parse file generated by soft to my mobile for comfort reading.

Thanks,
Altshuler Eugeny

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




Re: multistring replacement

2006-03-08 Thread Bob Showalter

Chas Owens wrote:

On 3/8/06, Eugeny Altshuler <[EMAIL PROTECTED]> wrote:
snip


local $/; # to slurp the file at once
my $joined=<>;

...
Be careful with the setting of $/.  In small scripts like this one it
is not very dangerous, but in larger scripts in can cause all manner
of bugs if not properly localized:

my $joined;
{
local $/ = undef;
$joined = <>;
}


I like to write this like:

  my $joined = do { local $/; <> };

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




Re: multistring replacement

2006-03-08 Thread Chas Owens
On 3/8/06, Eugeny Altshuler <[EMAIL PROTECTED]> wrote:
snip
> local $/; # to slurp the file at once
> my $joined=<>;
snip
>  What '\s*=\s*(["']).*?\1' mean?

Be careful with the setting of $/.  In small scripts like this one it
is not very dangerous, but in larger scripts in can cause all manner
of bugs if not properly localized:

my $joined;
{
local $/ = undef;
$joined = <>;
}

or better yet, don't use slurp mode at all:

my $joined = join '', <>;

s,STYLE\s*=\s*([" ']).*?\1,,igs; means

replace in the entire string ignoring newlines as many times as it
appears in a case insensitive manner "STYLE" followed by zero or more
whitespace characters followed by  "=" followed by zero or more
whitespace characters followed by either ' or " followed by zero or
more characters (non-greedy) followed by the matching ' or " with
nothing

I would have written it like this

s{ #replace
STYLE #the word "style" (case insensitive)
\s*   #followed by zero or more whitespace characters
= #followed by the equal sign
\s*   #followed by  zero or more whitespace characters
("|') #followed by a quote (either " or ', remember the type)
.*?   #followed by the shortest number of characters
\1#followed by the match quote from above
}{ #with
  #nothing
}igsx;

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




Re: multistring replacement

2006-03-08 Thread Eugeny Altshuler
> That's one way to pass the file content to a script via the STDIN filehandle.
> A shorter way is to pass the filename to the script:
>
> $ ./myscript file.html
>
> Try out this code:
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> open my $fh, $ARGV[0] or die "can't open passed file '$ARGV[0]': $!";
>
> local $/; # to slurp the file at once
> my $joined=<$fh>;
>
> print $joined;
>
> # end of script
> Here is some untested code: may do the expected or not :-)
>
> ($joined)=~$joined=~m,(.*?),is or die "no body";
> $joined=~s,<(?:SPAN|FONT)[^>]*?>,,igs;
> $joined=~s,STYLE\s*=\s*(["']).*?\1,,igs;

thanks!!

slurp mode is great thing ;)

this works!

#!/usr/bin/perl

local $/; # to slurp the file at once
my $joined=<>;
$joined=~s/.*?]*?>//is;
$joined=~s/<\/BODY.*?>.*//is;
$joined=~s/<\/?(?:SPAN|FONT)[^>]*?>//igs;
$joined=~s/ (?:(STYLE|CLASS|LANG)\s*=\s*(["']).*?\1//igs;
print $joined;
-
 this is the way to convert doc to html: first, from doc to html by
OpenOffice (much better, than MS Word), then by this script -
beautiful html :)
PS
 What '\s*=\s*(["']).*?\1' mean?

Great thanks!
Altshuler Eugeny

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




Re: multistring replacement

2006-03-08 Thread Hans Meier (John Doe)
Eugeny Altshuler am Mittwoch, 8. März 2006 11.35:
> Hello!
>
> I have such problem, I need to make multistring replacement... How can
> I do this?
>
> I tried to make perl script which acquires file form STDIN and prints
> result into STDOUT
>
> cat file.html | ./myscript

That's one way to pass the file content to a script via the STDIN filehandle.
A shorter way is to pass the filename to the script:

$ ./myscript file.html

Try out this code:

#!/usr/bin/perl
use strict;
use warnings;

open my $fh, $ARGV[0] or die "can't open passed file '$ARGV[0]': $!";

local $/; # to slurp the file at once
my $joined=<$fh>;

print $joined;

# end of script

See:
perldoc perlvar (for @ARGV and $/)
perldoc open

> I work with html-files and I want to convert them into necessory format.
> I want to delete all stuff before  and after ... Also I
> want to delete  tags that can be splitted to few strings...
>
> $joined = join("", <>);
> $joined =~ s/.*//ig;
> $joined =~ s/]*>//ig;
> $joined =~ s/<\/SPAN>//ig;
> $joined =~ s/]*>//ig;
> $joined =~ s/<\/FONT>//ig;
> $joined =~ s/]*>//ig;
> $joined =~ s/<\/BODY.*>//ig;
> $joined =~ s/STYLE="[^"]*"//ig;

Without testing, the main problems here are:
- the missing /s modifier: Your html has more than one line!
- use of .* (greedy) instad of .*? (non greedy)

Studying the regexp man pages will help you getting the right regexps. 
See perldoc perlre and others.

Here is some untested code: may do the expected or not :-)

($joined)=~$joined=~m,(.*?),is or die "no body";
$joined=~s,<(?:SPAN|FONT)[^>]*?>,,igs;
$joined=~s,STYLE\s*=\s*(["']).*?\1,,igs;

This code is just a "hack" and assumes correct html syntax as well as no '>' 
and '<' in tag attribues. Correct regexpes would be longer.

A more structured way to do such things is the usage of one of the html 
parsers on search.cpan.org. Some of them can deal with erroneos html, others 
can not.


hth,
Hans

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




multistring replacement

2006-03-08 Thread Eugeny Altshuler
Hello!

I have such problem, I need to make multistring replacement... How can
I do this?

I tried to make perl script which acquires file form STDIN and prints
result into STDOUT

cat file.html | ./myscript

I work with html-files and I want to convert them into necessory format.
I want to delete all stuff before  and after ... Also I
want to delete  tags that can be splitted to few strings...

$joined = join("", <>);
$joined =~ s/.*//ig;
$joined =~ s/]*>//ig;
$joined =~ s/<\/SPAN>//ig;
$joined =~ s/]*>//ig;
$joined =~ s/<\/FONT>//ig;
$joined =~ s/]*>//ig;
$joined =~ s/<\/BODY.*>//ig;
$joined =~ s/STYLE="[^"]*"//ig;

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




problems with Class::Std and Vstrings

2006-03-08 Thread Angus
Hi,

 

I am trying to write some perl objects using Class::Std but when I run tests
against my module it says

 

Error:   Vstrings are not implemented in the version of perl at
/../../../5.8.7/version/vpp.pm

 

Is this is a know bug or should I just try to re-install Class::Std and it's
dependencies?

 

Thanks,

 

-angus



[OT] sanitize/sanitise ? [was: [regexp] Speaking of the /s modifier...]

2006-03-08 Thread Hans Meier (John Doe)
Adam W am Mittwoch, 8. März 2006 02.10:
> Hans Meier (John Doe) wrote:
> > Adam W am Mittwoch, 8. März 2006 00.49:
> >>Sorry, I'm relatively new to programming in general (perl is my first
> >>programming language), so I'm not sure what you mean by "sanitizing."
> >
> > Could also be "sanitising", saw both :-)
>
> I've seen it both ways, as well (I think it's a British vs. American
> distinction).  I did not mean to correct your spelling.  

Oh, I realize this interpretation only now!

> What I meant 
> was that I didn't understand the concept of "sanitizing" in a
> programming context.

Yes I read it this way, no problem! 

I was just wondering myself... and finally consulted the "Pons" dictionnary 
that only mentions "sanitize" but says it covers british / northamerican / 
australian vocabulary. 

But the british/american distinction seems plausible, since I also read 
"sanitise" from native english speakers (and in advisories from big companies 
if I remember correctly). 
Hm... anybody has the definitive answer (to this detail)? 

Wish you much fun programming!

Hans

[...]

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