Thoughts on comments

2007-05-14 Thread Mathew Snyder
Is it possible to use too many comments?  I'm looking at a script I wrote and
think I may have made it less clear by trying to make it more clear.

-- 
Keep up with me and what I'm up to: http://theillien.blogspot.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Thoughts on comments

2007-05-14 Thread Jeff Pang

Mathew Snyder 写道:

Is it possible to use too many comments?  I'm looking at a script I wrote and
think I may have made it less clear by trying to make it more clear.



If you look at Spamassassin's codes,you'll find its comments are more 
than codes.One thing I'm not satisfied with in perl is that why it 
does'nt support the multi-lines comments like /*...*/ in C.



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Thoughts on comments

2007-05-14 Thread Chas Owens

On 5/14/07, Mathew Snyder [EMAIL PROTECTED] wrote:

Is it possible to use too many comments?  I'm looking at a script I wrote and
think I may have made it less clear by trying to make it more clear.


Yes, it is very easy to have too many comments, especially if you are
using them in the wrong way.  The purpose of comments is to tell the
story of why something is the way it is is, not to tell people what
the code does.  The variable and subroutine names should tell that
story.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Thoughts on comments

2007-05-14 Thread Dr.Ruud
Jeff Pang schreef:

 One thing I'm not satisfied with in perl is that why it
 does'nt support the multi-lines comments like /*...*/ in C.

The / is taken, but there are many other ways to do multiline comments.
For one, see perldoc perlpod.

-- 
Affijn, Ruud

Gewoon is een tijger.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: decode function equal to Java's

2007-05-14 Thread Jen mlists

2007/5/11, Dr.Ruud [EMAIL PROTECTED]:

Jen mlists schreef:

 I'm faint I MUST take the time to work with double-character
 handling though I'm not familiar with it.
 What's the function in perl which is equal to Java's this call:
 java.net.URLDecoder.decode(s, UTF-8)



Hello all,

I need to translate this string,

Perl%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%28%EF%BF%BD%EF%BF%BD%EF%BF%BD%C4%B0%EF%BF%BD%29.pdf

This was a string appeared in our web logs.

I tried this way,

use strict;
use Encode;
use URI::Escape;
my $str = 
'Perl%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%28%EF%BF%BD%EF%BF%BD%EF%BF%BD%C4%B0%EF%BF%BD%29.pdf';

my $tr;
$tr = encode(gb2312,decode(utf8,$str));  # It was 'gb2312' format
originally.
$tr = uri_unescape($tr);
print $tr;

__END__

But it couldn't work.Please help,thank you.

--Jen

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Can't sort error out; strict refs

2007-05-14 Thread Mathew Snyder
I'm passing two hash references into a subroutine.  One hash is in the format of
$dept{$env}{$user}.  This contains an amount of time spent by each user on a
customer ($env).  The second hash is in the format of
$ticCount{$env}{$user}{$ticID}.  This contains a running count of how many times
a user worked on ticket '$ticID' which belongs to customer '$env'.  I won't be
using that number though.  What I need is the number of tickets worked on so I
simply use 'scalar keys' on this hash.

The problem I'm encountering though, is that I'm passing the hashes into my
subroutine as references.  When I get to the statement that gets the key count I
get an error: Can't use string (2) as a HASH ref while strict refs in use
at user_timesheet.pl line 63.  Presumably, 2 is the number of keys at
$ticCount{$env}{$user}{$ticID}.

sub average {
my ($users, $count) = @_;
my %userAvg;
foreach my $env (keys %$count) {
foreach my $user (keys %{ $count-{$env} }) {
foreach my $ticID (keys %{ $count-{$env}-{$user} }) {
my $ticCount = scalar keys %{
$count-{$env}-{$user}-{$ticID}};
my @meantemp;
my @meantime;
my @endtime;
my $temp = $users-{$env}-{$user};
@meantemp= split /\./, ($temp / $ticCount);
# If the time divided by the number of tickets
has a decimal
# value round up if that value is greater than
# 0.5.  This will give an even number of minutes
to figure
# out the mean time with.
if ($meantemp[1]) {
if ($meantemp[1] = 5) {
$meantemp[0]++;
}
}
@meantime  = split /\./, ($meantemp[0] / 60);
$endtime[0]  = $meantime[0];
$endtime[1]  = $meantemp[0] % 60;
$userAvg{$env}{$user} = sprintf '%d:%02d',
@endtime[0,1];
}
}
}
return %userAvg;
}

I've run this in the debugger and when I get to the line which assigns $ticCount
I try to print it out and it's just blank.  If I keep hitting enter it just
returns to a blank line.  I get the error when I continue to the next line with 
'c'.

Mathew
-- 
Keep up with me and what I'm up to: http://theillien.blogspot.com

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Variables not replaced

2007-05-14 Thread tannhauser
Hello,
to prepare a (non-technical or -mathematical) txt-file for use with tex, i have
to replace a few things: umlauts, underscores, special characters and so on. 

My problem:
I also want to replace quotions, depending whether they are at the beginning or
the end of a word. For example tick should become ``tick''. Annoyingly, my 
script just
gives me ``$1ic$1''. Any ideas?

regards
tannhauser


use strict;
use warnings;

my $t =  \tick\ ; 
#all replacements are in %h, 
#i took out the working ones.
my %h = ( '(\w)\s+?' = '$1\'\'',  
   '\s+?(\w)' = '``$1' ); 
   
while ((my $old, my $new) = each (%h)) {
$t =~ s/$old/$new/g;
}  
print $t;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Variables not replaced

2007-05-14 Thread tannhauser

Please don't care that the replacement right now is deleting the
whitespace (yes, that's not wanted). i copied the wrong version. but
that doesn't affect the problem i described.

thanks
tannhauser.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Can't sort error out; strict refs

2007-05-14 Thread Rob Dixon

Mathew Snyder wrote:


I'm passing two hash references into a subroutine.  One hash is in the format of
$dept{$env}{$user}.  This contains an amount of time spent by each user on a
customer ($env).  The second hash is in the format of
$ticCount{$env}{$user}{$ticID}.  This contains a running count of how many times
a user worked on ticket '$ticID' which belongs to customer '$env'.  I won't be
using that number though.  What I need is the number of tickets worked on so I
simply use 'scalar keys' on this hash.

The problem I'm encountering though, is that I'm passing the hashes into my
subroutine as references.  When I get to the statement that gets the key count I
get an error: Can't use string (2) as a HASH ref while strict refs in use
at user_timesheet.pl line 63.  Presumably, 2 is the number of keys at
$ticCount{$env}{$user}{$ticID}.

sub average {

  my ($users, $count) = @_;
  my %userAvg;

  foreach my $env (keys %$count) {
foreach my $user (keys %{ $count-{$env} }) {
  foreach my $ticID (keys %{ $count-{$env}-{$user} }) {

my $ticCount = scalar keys %{$count-{$env}-{$user}-{$ticID}};

my @meantemp;
my @meantime;
my @endtime;

my $temp = $users-{$env}-{$user};
@meantemp= split /\./, ($temp / $ticCount);

# If the time divided by the number of tickets has a decimal
# value round up if that value is greater than
# 0.5.  This will give an even number of minutes to figure
# out the mean time with.
if ($meantemp[1]) {
  if ($meantemp[1] = 5) {
$meantemp[0]++;
  }
}
@meantime  = split /\./, ($meantemp[0] / 60);
$endtime[0]  = $meantime[0];
$endtime[1]  = $meantemp[0] % 60;
$userAvg{$env}{$user} = sprintf '%d:%02d', @endtime[0,1];
  }
}
  }

  return %userAvg;
}

I've run this in the debugger and when I get to the line which assigns $ticCount
I try to print it out and it's just blank.  If I keep hitting enter it just
returns to a blank line.  I get the error when I continue to the next line with 
'c'.


Hi Mathew

First of all, you can replace

 $count-{$env}-{$user}-{$ticID}

with

 $count-{$env}{$user}{$ticID}

and Perl will infer the indirection. It makes for neater code.

The reason for your problem is that you've gone too far down in the hash 
structure. You
said that $count-{$env}{$user}{$ticID} is a count of how many times a user 
worked on
[a] ticket, in this case 2. so you're then trying to do

 my $ticCount = scalar keys %{2};

which is failing.

Finally, you can round more efficiently by using int(x + 0.5). I suggest 
something
like this (untested):

 sub average {

   my ($users, $count) = @_;
   my %userAvg;

   foreach my $env (keys %$count) {
 foreach my $user (keys %{ $count-{$env} }) {

 my $ticCount = scalar keys %{$count-{$env}{$user}};

 my $time = $users-{$env}{$user};
 my $meantime = int($time / $ticCount + 0.5);

 $userAvg{$env}{$user} = sprintf '%d:%02d',
 int($meantime / 60), $meantime % 60;
 }
   }

   return %userAvg;
 }

HTH,

Rob

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Break up names

2007-05-14 Thread Jay Savage

On 5/11/07, Chas Owens [EMAIL PROTECTED] wrote:

On 5/11/07, Tony Heal [EMAIL PROTECTED] wrote:
 I have a list of names that I need to break up and reassemble.

 The list consists of the first name and last name combined as a single word 
in wiki format. i.e.JoeBlow

 I need to break this up and recreate the list as

 | FirstName | LastName | Email | WikiName |

 i.e.

 | Joe | Blow | [EMAIL PROTECTED] | JoeBlow |

 I can do all of this except break the original word apart.

 Tony

Assuming that JoeMcCarthey should be Joe McCarthy, I would do this

my ($first, $Last) = $wikiname =~ /([A-Z]\w*?)([A-Z]\w*)/;



But what about JoAnnConnors? JKRowling? HunterSThompson? Parsing
wikinames effectively is a tricky business. Unless the rules governing
name creation were very strict--only allowing a certain number of
capitals--or only allowing capitals in certain places, which was the
original intention, but most wikis don't actually force users to take
names like JrrTolkien--you'll probably want to pass anything with
three or more caps to a human for processing, or at least to a more
sophisticated routine:

   my ($fisrt, $last)
   my @name = $wikiname = /([A-Z][a-z]*)/g;
   if (@name = 2) {
   ($first, $last) = @name;
   else {
   figure_it_out(@name);
   }

figure_it_out could either just email the name to person for
clarification, or apply a little logic. Maybe match list elements
against common name parts:

   if (@name[-2] =~ /^Ma?c/) {
   $first = join ' ', @name[0..-3];
   $last = @name[-2] . @name[-1];

etc.

HTH,

-- jay
--
This email and attachment(s): [  ] blogable; [ x ] ask first; [  ]
private and confidential

daggerquill [at] gmail [dot] com
http://www.tuaw.com  http://www.downloadsquad.com  http://www.engatiki.org

values of β will give rise to dom!


Re: Variables not replaced

2007-05-14 Thread Chas Owens

On 5/14/07, tannhauser [EMAIL PROTECTED] wrote:
snip

My problem:
I also want to replace quotions, depending whether they are at the beginning or
the end of a word. For example tick should become ``tick''. Annoyingly, my 
script just
gives me ``$1ic$1''. Any ideas?

snip

The problem here is that the replace part of s/// is for all effective
purposes a double quoted string.  Double quoted strings do allow
interpolation when they are seen as literals, but not on each use.
And this is a good thing (tm), can you imagine how confusing it would
be if you had to deal with a situtation like this:

my $doc = the unknown amount of dollars is represented by \$x;
print $doc, \n;

The interpreter would try to interpolate $x into $doc and since it
doesn't exist you would get an error.  You would have to do what the
poor shell programmers do and include as many backslashes as necessary
to get it to the right value when it was used.  But enough about what
isn't the case.

It also isn't as easy as tacking on an e option since that just brings
us full circle with the interpolated string problem, but tacking on an
e option and calling eval on the string does the trick; however, it
looks like you have over generalized the problem and are just making
work for yourself and the interpreter.  In addition, if you are
reading through the file line-by-line you will miss situations like
this

foo foo bar
bar baz baz

And of course you may need to deal with escaped quotes

foo \bar\ baz

I would suggest you de-generalize your code some and take a look at
Conway's Text::Balanced*.

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

my $search  = qr{([^]+?)};
my $replace = q(qq{``$1});

my $value = qq(foo bar baz);

print $value\n;
$value =~ s/$search/eval $replace/ge;
print $value\n;

* http://search.cpan.org/~dconway/Text-Balanced-v2.0.0/lib/Text/Balanced.pm

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: decode function equal to Java's

2007-05-14 Thread Chas Owens

On 5/14/07, Jen mlists [EMAIL PROTECTED] wrote:
snip

I need to translate this string,
Perl%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%28%EF%BF%BD%EF%BF%BD%EF%BF%BD%C4%B0%EF%BF%BD%29.pdf

This was a string appeared in our web logs.

snip

The following worked for me.  And by worked I mean printed out what to
my ignorant eye is one of the various logographic languages (maybe
Kanji?).

Perl锟斤拷锟斤拷锟斤拷锟斤拷(锟斤拷锟侥帮拷).pdf


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

use strict;
use Encode;
use URI::Escape;
my $str = 
'Perl%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%28%EF%BF%BD%EF%BF%BD%EF%BF%BD%C4%B0%EF%BF%BD%29.pdf';

my $tr = encode(utf8,decode(gb2312,uri_unescape($str)));
print $tr\n;


Attempting to update files blanks them instead

2007-05-14 Thread Kent Frazier

First off, this is my first post to this list, so hello everyone.  I am
pretty new to Perl, and to programming in general, but I hope I can be of
help to some of you in the future.  Right now, though, I am pretty confused
because one of my programs is not working the way I expect it to, and I
can't find the error.

I am using Learning Perl (the llama book) to familiarize myself with the
language, and I haven't had any problems up til now, but while doing the
exercises in chapter 9, I ran into a problem.  The fourth exercise asks you
to write a program that goes through all of your previous programs and adds
a copyright line after the #! line.  The original files are supposed to be
backed up in the process.  I wrote something that I thought would work, but
it backed up the file and then blanked the new file (or never put anything
in it, at any rate).  Frustrated, I looked in the back of the book and
tailored my code to match the example code given.  The program still behaves
the same way.  If it is relevant, I am using ActivePerl 5.8.8 Build 820 on
Windows XP SP2.  The source code is below.  Can someone with a more honed
eye for this code tell me what I am doing wrong?

#!perl -w
use strict;

$^I = .bak;
while () {
   if ( /^#!/ ) {
   $_ .= ## Copyright (C) 2007 by Kent Frazier.\n;
   }
   }

Hope this doesn't end up being something too newbish, and thanks in advance
for all your help.

Kent


call system command

2007-05-14 Thread Tatiana Lloret Iglesias

Hi all,

I have to execute this command from perl:

my $status = system(d:\\blast\\bin\\blastall -p blastn -i $file -d $patDB
-o $workdir\\blast_$blast_file_id.txt);


but the problem is that $workdir contains spaces  how can I make it
work?

Thanks!
Regards
T


Re: call system command

2007-05-14 Thread Xavier Noria

On May 14, 2007, at 3:44 PM, Tatiana Lloret Iglesias wrote:

Hi all,

I have to execute this command from perl:

my $status = system(d:\\blast\\bin\\blastall -p blastn -i $file -d  
$patDB

-o $workdir\\blast_$blast_file_id.txt);


but the problem is that $workdir contains spaces  how can I  
make it

work?


Break that into a list of arguments:

  system(d:\\blast\\bin\\blastall, -p, blastn, -i, $file, ...);

-- fxn






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: call system command

2007-05-14 Thread Tatiana Lloret Iglesias

Thank a lot!

Another related question,,, system command can be used also for linux?
Regards
T


On 5/14/07, Xavier Noria [EMAIL PROTECTED] wrote:


On May 14, 2007, at 3:44 PM, Tatiana Lloret Iglesias wrote:
 Hi all,

 I have to execute this command from perl:

 my $status = system(d:\\blast\\bin\\blastall -p blastn -i $file -d
 $patDB
 -o $workdir\\blast_$blast_file_id.txt);


 but the problem is that $workdir contains spaces  how can I
 make it
 work?

Break that into a list of arguments:

  system(d:\\blast\\bin\\blastall, -p, blastn, -i, $file, ...);

-- fxn






--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





cpan question

2007-05-14 Thread Robert Hicks
I am working on a Perl 5.6.0 project and went to use cpan at the 
command line and behold it was not there. I download the 5.6.1 tar file 
and behold cpan the command line program wasn't in there either.


Did it not come with 5.6.0/5.6.1?

I don't see where I can get it either...

Robert

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: call system command

2007-05-14 Thread Xavier Noria

On May 14, 2007, at 3:52 PM, Tatiana Lloret Iglesias wrote:


Thank a lot!

Another related question,,, system command can be used also for linux?


Sure. Of course it is unlikely that the arguments themselvels are  
portable in practice, I mean blastall won't probably be located at d: 
\\blast\\bin\\blastall on Linux, but you can certainly rely on  
having system().


-- fxn




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: cpan question

2007-05-14 Thread Xavier Noria

On May 14, 2007, at 3:50 PM, Robert Hicks wrote:

I am working on a Perl 5.6.0 project and went to use cpan at the  
command line and behold it was not there. I download the 5.6.1 tar  
file and behold cpan the command line program wasn't in there  
either.


Did it not come with 5.6.0/5.6.1?

I don't see where I can get it either...


Nope, cpan(1) was added in 5.8.1. You can use the traditional

  perl -MCPAN -e 'install Module'

with that Perl.

-- fxn


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Attempting to update files blanks them instead

2007-05-14 Thread Chas Owens

On 5/14/07, Kent Frazier [EMAIL PROTECTED] wrote:
snip

Can someone with a more honed eye for this code tell me what I am doing wrong?

snip

You are never printing anything.  Try

#!perl -w
use strict;

$^I = .bak;
while () {
   if ( /^#!/ ) {
   $_ .= ## Copyright (C) 2007 by Kent Frazier.\n;
   }
   print;
}

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: call system command

2007-05-14 Thread Chas Owens

On 5/14/07, Tatiana Lloret Iglesias [EMAIL PROTECTED] wrote:
snip

my $status = system(d:\\blast\\bin\\blastall -p blastn -i $file -d $patDB
-o $workdir\\blast_$blast_file_id.txt);

snip

Just an unrelated note to make your life a little easier, Perl
automagically uses the right directory separator if you say

system(d:/blast/bin/blastall, -p, blastn, -i, $file, ...);

That saves you from trying to make sure you have escaped all of the
backslashes escaped correctly.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: cpan question

2007-05-14 Thread Chas Owens

On 5/14/07, Xavier Noria [EMAIL PROTECTED] wrote:
snip

   perl -MCPAN -e 'install Module'

snip

or

perl -MCPAN -e shell

If you prefer and interactive version of CPAN.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: cpan question

2007-05-14 Thread Robert Hicks

Xavier Noria wrote:

On May 14, 2007, at 3:50 PM, Robert Hicks wrote:

I am working on a Perl 5.6.0 project and went to use cpan at the 
command line and behold it was not there. I download the 5.6.1 tar 
file and behold cpan the command line program wasn't in there either.


Did it not come with 5.6.0/5.6.1?

I don't see where I can get it either...


Nope, cpan(1) was added in 5.8.1. You can use the traditional

  perl -MCPAN -e 'install Module'

with that Perl.

-- fxn


Thank you very much!

Robert

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: decode function equal to Java's

2007-05-14 Thread Jen mlists

2007/5/14, Chas Owens [EMAIL PROTECTED]:


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

use strict;
use Encode;
use URI::Escape;
my $str = 
'Perl%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%28%EF%BF%BD%EF%BF%BD%EF%BF%BD%C4%B0%EF%BF%BD%29.pdf';

my $tr = encode(utf8,decode(gb2312,uri_unescape($str)));
print $tr\n;



Sorry Chas this would work still.
Anyway thanks.I'll try other ways.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: decode function equal to Java's

2007-05-14 Thread Chas Owens

On 5/14/07, Jen mlists [EMAIL PROTECTED] wrote:

2007/5/14, Chas Owens [EMAIL PROTECTED]:

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

 use strict;
 use Encode;
 use URI::Escape;
 my $str = 
'Perl%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%28%EF%BF%BD%EF%BF%BD%EF%BF%BD%C4%B0%EF%BF%BD%29.pdf';

 my $tr = encode(utf8,decode(gb2312,uri_unescape($str)));
 print $tr\n;


Sorry Chas this would work still.
Anyway thanks.I'll try other ways.



What exactly do you want as output and what is your environment (mine
is Ubuntu 7.04 using the default locale).

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Thoughts on comments

2007-05-14 Thread David Moreno Garza
Dr.Ruud wrote:
 The / is taken, but there are many other ways to do multiline comments.
 For one, see perldoc perlpod.

You mean using =begin, =end? They are not exactly multiline *comments*.

-- 
David Moreno Garza [EMAIL PROTECTED] | http://www.damog.net/
 URL:http://www.georgedillon.com/web/html_email_is_evil.shtml


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: Thoughts on comments

2007-05-14 Thread Chas Owens

On 5/14/07, David Moreno Garza [EMAIL PROTECTED] wrote:

Dr.Ruud wrote:
 The / is taken, but there are many other ways to do multiline comments.
 For one, see perldoc perlpod.

You mean using =begin, =end? They are not exactly multiline *comments*.

--
David Moreno Garza [EMAIL PROTECTED] | http://www.damog.net/
 URL:http://www.georgedillon.com/web/html_email_is_evil.shtml


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





Not that I use them myself, but the proper (for various values of
proper) way to use POD for multi-line comments is

=for comment
 Commented text
=cut

Yes it sucks, yes it will be fixed* in Perl 6* (or possible earlier if
the trend of adopting Perl 6 features in Perl 5 releases continues).
It will be a quote-like operator, so you will be able to say

#{
  This is
   a multi-line comment
}

#[
   so is this
   #[ and this one is nested ]
]

#{{{ multiple brackets must match on both sides }}}

* for various definitions of fixed, there are some caveats, the
biggest being that a # as the first character on a line is always
considered a single line comment even if the next character is a
bracketing character.  Don't ask me why.

* http://dev.perl.org/perl6/doc/design/syn/S02.html

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




File Handling. Reading and Writting.

2007-05-14 Thread Bruno Schroeder
Hello All.

I am trying to read and write in a file, I am using something like:

open (FILE, +teste_rw.txt) or die I couldn't open the file.;
for my $line (FILE) {
 print $line;
 if($line eq X\n)
 {
print FILE b\n
 } else
 {
print FILE c\n
 }
}
print FILE Y\n;
close FILE;

In the attached file, I whant to write inside the $modify_class, 
$modify_method and $modify_parameter tests.

   Thnak you.
Bruno


begin 666 checkTracev10.pl
M=7-E('-TFEC=#L-@T*(V-H96-K5')A8V4NP-B-,:7-T(')E8W5RVEV
M96QY(EN(5V97)Y('-U8F9O;1EB!O9B!A(EN:[EMAIL PROTECTED]ER96-T;W)Y
M+!A;[EMAIL PROTECTED]')A8V4M:[EMAIL 
PROTECTED]('1R86-E+6]U=!E'!R97-S:6]NR!T
M:%T(%R92!N;[EMAIL PROTECTED];W)D:6YG('1O('1H92!M971H;V0G[EMAIL PROTECTED]
M#0HC1VQA8F%L(%9AFEA8FQESH-FUY(1F:6QE7V-O=6YT(#T@,#L-FUY
M(1P86-K86=E(#T@(CQP86-K86=E/B([#0IM2 D8VQAW,@/2 B/-L87-S
M/B([#0IM2 D;65T:]D(#T@(CQM971H;V0^(CL-FUY($!P87)A;65T97)S
M(#T@(B([#0IM2 D8VQAW-?;6ES=%K95]C;W5N= ](# [#0IM2 D;65T
M:]D7VUIW1A:V5?8V]U;G0@/2 P.PT*;7D@)'!AF%M971EE]M:7-T86ME
M7V-O=6YT(#T@,#L-FUY(1V97)I9GE?8VQAW,@/2 B=')U92([#0IM2 D
M=F5R:69Y7VUE=AO9 ]()TG5E(CL-FUY(1V97)I9GE?%R86UE=5R
M(#T@(G1R=64B.PT*;7D@)UO9EF5]C;%SR ]()TG5E(CL-FUY(1M
M;V1I9GE?;65T:]D(#T@(G1R=64B.PT*;7D@)UO9EF5]P87)A;65T97(@
M/2 B=')U92([#0IM2 D=5M ](# [#0H-B-';[EMAIL PROTECTED]W1A;G1S
[EMAIL PROTECTED];7D@)EN:71I86Q?9ER96-T;W)Y(#T@(D,Z7%QBG%7'-R8UQ0E)6
M4([#0IM2 D9FEL95]E'!R97-S:6]N(#T@(BYJ879A(CL-FUY(1P86-K
M86=E7V5X')EW-I;VX@/2 B%C:V%G92!;7CM=*SLB.PT*;7D@)-L87-S
M7V5X')EW-I;VX@/2 B7G!U8FQI8R!C;%SR([#0HC;7D@)UE=AO9%]E
M'!R97-S:6]N(#T@(G!U8FQI8UQS*UQW*UQS*UQW*EPH(CL-FUY(1L;V=?
M95B=6=?97APF5SVEO;B ](),;V=-86YA9V5R7XH87!P1$%/3]G9V5R
M?%P$-O;G1R;VQL97),;V=G97(I7YD96)U9R([#0HC;7D@)'1R86-E7V5X
M')EW-I;VX@/2 B(CL-GL-@EPFEN=@B8VAE8VM4F%C92YP;%QN0V]N
MW1A;G1S.EQN(BD[#0H-@EPFEN=@)(FEN:71I86Q?9ER96-T;W)Y(#T@
M(BP@)EN:71I86Q?9ER96-T;W)Y+ B7XB+ T*0D)(F9I;5?97APF5S
MVEO;B ]((L(1F:6QE7V5X')EW-I;VXL();B(L#0H)0DB%C:V%G
M95]E'!R97-S:6]N(#T@(BP@)'!A8VMA9V5?97APF5SVEO;BP@(EQN(BP-
M@D)2)C;%SU]E'!R97-S:6]N(#T@(BP@)-L87-S7V5X')EW-I;VXL
M();B(L#0H)0DC(FUE=AO9%]E'!R97-S:6]N(#T@(BP@)UE=AO9%]E
M'!R97-S:6]N+ B7XB+ T*0D)(FQO9U]D96)U9U]E'!R97-S:6]N(#T@
M(BP@)QO9U]D96)U9U]E'!R97-S:6]N+ B7XB+ T*0D)(R)TF%C95]E
M'!R97-S:6]N(#T@(BP@)'1R86-E7V5X')EW-I;VXL();B(L#0H)0DB
M=F5R:69Y7V-L87-S(#T@(BP@)'9EFEF5]C;%SRP@(EQN(BP-@D)2)V
M97)I9GE?;65T:]D(#T@(BP@)'9EFEF5]M971H;V0L();B(L#0H)0DB
M=F5R:69Y7W!AF%M971EB ]((L(1V97)I9GE?%R86UE=5R+ B7XB
M+ T*0D)(FUO9EF5]C;%SR ]((L(1M;V1I9GE?8VQAW,L();B(L
M#0H)0DB;6]D:69Y7VUE=AO9 ]((L(1M;V1I9GE?;65T:]D+ B7XB
M+ T*0D)(FUO9EF5]P87)A;65T97(@/2 B+ D;6]D:69Y7W!AF%M971E
MBP@(EQN(BP-@D)2);B(L*3L-@T*6QIW1?F5C=7)C:79E;'DH)EN
M:71I86Q?9ER96-T;W)Y*3L-@EPFEN=@B1F]U;F0@(BP@)-L87-S7VUI
MW1A:V5?8V]U;G0L((@;6ES=%K97,@;[EMAIL PROTECTED]W,@;F%M92P@(BP@)UE
M=AO9%]M:7-T86ME7V-O=6YT+ B(UIW1A:V5S(]N(UE=AO9!M86UE
M+ B+ D%R86UE=5R7VUIW1A:V5?8V]U;G0L((@;6ES=%K97,@;VX@
M%R86UE=5R(YA;64N7XB*3L-@EPFEN=@B1F]U;F0@(BP@)-L87-S
M7VUIW1A:V5?8V]U;[EMAIL PROTECTED] D;65T:]D7VUIW1A:V5?8V]U;[EMAIL PROTECTED] 
D%R
M86UE=5R7VUIW1A:V5?8V]U;G0L((@;6ES=%K97,N7XB*3L-@EPFEN
M=@B5F5R:69I960@(BP@)9I;5?8V]U;G0L((@(BP@)9I;5?97APF5S
MVEO;BP@(B!F:6QERY;B(I.PT*?0T*#0IS=6(@;ES=%]R96-UF-I=F5L
M0T*PT*6]P96YD:7(H9ER96-T;W)Y+ D7ULP72D[#0H@( @;[EMAIL PROTECTED]1I
MF5C=]R5]F:6QER ](')E861D:7(H9ER96-T;W)Y*3L-B @(!F;W)E
M86-H(UY(1D:7)E8W1OGE?9FEL97,@*$!D:7)E8W1OGE?9FEL97,I('L-
MB @( @( @;7D@)9I;5N86UE(#T@)%];,[EMAIL PROTECTED] B7%PB(X@)1IF5C
M=]R5]F:6QESL-B @( @( @:[EMAIL PROTECTED]$H)1IF5C=]R5]F:6QER!E
M2 G+B@?'P@)1IF5C=]R5]F:6QER!E2 G+BXG*2D-@D)PT*0D)
M:[EMAIL PROTECTED]UD(1F:6QE;F%M92D-@D)7L-@D)0EL:7-T7W)E8W5R8VEV96QY
M*1F:6QE;F%M92D[#0H)0E](5L[EMAIL PROTECTED])0E[#0H)0D)=')E871?9FEL
[EMAIL PROTECTED];64I.PT*0D)?0T*0E]#0H@(!]#0H@( @8VQOV5D:7(H
M9ER96-T;W)Y*3L-GT-@T*W5B('1R96%T7V9I;4-GL-@EM2 D9FEL
M96YA;64@/2 D7ULP73L-@EI9B HW5BW1R*1F:6QE;F%M92P@;5N9W1H
M*1F:6QE;[EMAIL PROTECTED]@H)9I;5?97APF5SVEO;BDL(QE;F=T
M:@D9FEL96YA;64I*2!E2 D9FEL95]E'!R97-S:6]N*0T*7L-@D);W!E
M;BAF:6QE+ B*SPB+ D9FEL96YA;64I(]R('!R:6YT*)#86X@;F]T(]P
M96X@(B K(1F:6QE;F%M92 K();B(I.PT*0DD9FEL95]C;W5N=LK.PT*
M0EM2 D;EN95]N=6UB97(@/2 P.PT*0EF;W(@;7D@)QI;[EMAIL PROTECTED]:6QE
M/[EMAIL PROTECTED])7L-@D)21L:6YE7VYU;6)EBLK.PT*0D):68H)QI;F4@/7X@
M+R1P86-K86=E7V5X')EW-I;VXO*0T*0D)PT*0D)6UY($!T96UP(#T@
MW!L:70H+UQS*WP[+RP@)QI;F4I.PT*0D)21P86-K86=E([EMAIL PROTECTED]'1E;7!;
M,5T[#0H)0D)(W!R:6YT*)P86-K86=E(#T@(BP@)'!A8VMA9V4L();B(I
M.PT*0D)?0T*0D):68H)QI;F4@/[EMAIL PROTECTED];%SU]E'!R97-S:6]N+RD-
M@D)7L-@D)0EM2! =5M ]('-P;ET*]RLO+ D;EN92D[#0H)
M0D))-L87-S([EMAIL PROTECTED]'1E;7!;,ET[#0H)0D)(W!R:6YT*)C;%SR ]((L
M(1C;%SRP@(EQN(BD[#0H)0E]#0H)0EM2! W!L:71E9%]L:6YE(#T@
MW!L:70H+UQS*WQ*'Q*2\L(1L:6YE*3L-@D)6EF*1SQI=5D7VQI
M;F5;,[EMAIL PROTECTED]@(G!U8FQI8R(@)B DW!L:71E9%]L:6YE6R0CW!L:71E9%]L
M:6YE72!E2 B7'LB*0T*0D)PT*0D)21M971H;V0@/2 DW!L:71E9%]L
M:6YE6S-=.PT*0D)6UY(1P87)A;65T97)?:6YD97@@/2 Q.PT*0D)6UY
M(1I([EMAIL PROTECTED]@D)0EW:[EMAIL 
PROTECTED]1SQI=5D7VQI;F5;)E=(5Q()T
M:')O=W,B('P@)'-P;ET961?;EN95LD:[EMAIL 

LibXML help

2007-05-14 Thread Tony Heal
When I run this, I get 'No such file or directory at 
/usr/lib/perl5/XML/LibXML.pm line 518.

 at ./temp.pl line 16'. I have confirmed that the file exists and is readable. 
How do I T/S this?

 

 

Tony

 

#!/usr/bin/perl

 

use warnings;

use strict;

use XML::LibXSLT;

use XML::LibXML;

 

sub goforit

{

my $object = Development.ActivityObject;



my $parser = XML::LibXML-new();



my $xslt = XML::LibXSLT-new();

 

my $source = $parser-parse_file( 
'/usr/local/twikixconf/tmpxconf/epace/src/conf/epace.xconf' );

 

my $style_doc = $parser-parse_file( 
/usr/local/twikixconf/epace-to-twiki.xsl );

 

my $stylesheet = $xslt-parse_stylesheet( $style_doc );

 

my $results = $stylesheet-transform( $source, object = ' . $object 
. ' );

 

return $stylesheet-output_string( $results );

}

 

goforit;

my $stuff = goforit();

 

print $stuff\n;



Re: File Handling. Reading and Writting.

2007-05-14 Thread Tom Phoenix

On 5/14/07, Bruno Schroeder [EMAIL PROTECTED] wrote:


I am trying to read and write in a file, I am using something like:

open (FILE, +teste_rw.txt) or die I couldn't open the file.;


A little better is to include $! in the message, maybe like this:

 open FILE, +teste_rw.txt
   or die Can't open r/w 'teste_rw.txt': $!;


for my $line (FILE) {
 print $line;
 if($line eq X\n)
 {
print FILE b\n


Depending upon your I/O system, you may need to use seek() whenever
you switch from reading to writing, or from writing to reading.

It looks as if you're trying to edit a text file in place. Although
that's possible for some simple cases, it's generally easier to use
Perl's $^I functionality.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: LibXML help

2007-05-14 Thread Tony Heal
Oops. BTW line 16 is
my $source = $parser-parse_file( 
'/usr/local/twikixconf/tmpxconf/epace/src/conf/epace.xconf' );

Tony



 -Original Message-
 From: Tony Heal [mailto:[EMAIL PROTECTED]
 Sent: Monday, May 14, 2007 8:40 PM
 To: beginners@perl.org
 Subject: LibXML help
 
 When I run this, I get 'No such file or directory at 
 /usr/lib/perl5/XML/LibXML.pm line 518.
 
  at ./temp.pl line 16'. I have confirmed that the file exists and is 
 readable. How do I T/S this?
 
 
 
 
 
 Tony
 
 
 
 #!/usr/bin/perl
 
 
 
 use warnings;
 
 use strict;
 
 use XML::LibXSLT;
 
 use XML::LibXML;
 
 
 
 sub goforit
 
 {
 
 my $object = Development.ActivityObject;
 
 
 
 my $parser = XML::LibXML-new();
 
 
 
 my $xslt = XML::LibXSLT-new();
 
 
 
 my $source = $parser-parse_file(
 '/usr/local/twikixconf/tmpxconf/epace/src/conf/epace.xconf' );
 
 
 
 my $style_doc = $parser-parse_file( 
 /usr/local/twikixconf/epace-to-twiki.xsl );
 
 
 
 my $stylesheet = $xslt-parse_stylesheet( $style_doc );
 
 
 
 my $results = $stylesheet-transform( $source, object = ' . 
 $object . ' );
 
 
 
 return $stylesheet-output_string( $results );
 
 }
 
 
 
 goforit;
 
 my $stuff = goforit();
 
 
 
 print $stuff\n;



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: LibXML help

2007-05-14 Thread Chas Owens

On 5/14/07, Tony Heal [EMAIL PROTECTED] wrote:

When I run this, I get 'No such file or directory at 
/usr/lib/perl5/XML/LibXML.pm line 518.

 at ./temp.pl line 16'. I have confirmed that the file exists and is readable.

snip

If both the xml and xsl files exist and are readable to the user who
is running the Perl script then the next step I would take would be to
simplify the problem by moving the files to the current directory and
removing the paths like this:

my $source= $parser-parse_file('epace.xconf');
my $style_doc = $parser-parse_file(epace-to-twiki.xsl);

If the problem persisted then I would double check and triple check
the permissions.  If I was still convinced that I should be able to
read the files then I would write a quick Perl script to try to open
and read the first line out of each file.  If that worked, but the
parser code didn't, well, I don't know what I would do.  Maybe check
to see if there is some weird ACL stuff going on.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: LibXML help

2007-05-14 Thread Tom Phoenix

On 5/14/07, Tony Heal [EMAIL PROTECTED] wrote:


When I run this, I get 'No such file or directory at /usr/lib/perl5/XML/
LibXML.pm line 518.
 at ./temp.pl line 16'. I have confirmed that the file exists and is readable.


The file named there is not the one that doesn't exist; that's the
source code that was running when Perl died.


my $source = $parser-parse_file( '/usr/local/twikixconf/
tmpxconf/epace/src/conf/epace.xconf' );


Is that line 16? I'd suspect that that names the file that needs to be readable.

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




regex question

2007-05-14 Thread Tom Allison
How do I pull all the words from a line between the two words 'from' and 'by' 
when I have NO IDEA what's in there, but I know they are all in one line.


To make it more difficult.  'by' is optional...

Like this:

from..by..
or
from..

I want all the stuff inside.

Initially I'm thinking
/from (.+?) (?:by (.+?))?/

Anything better?

I can negate a character  with [^b] to mean not-'b'
but can I negate a word?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: LibXML help

2007-05-14 Thread Tony Heal
That is the file that I confirmed is readable.

In fact I swapped lines 16 and 18 and the error moved to line 18. I have also 
written a small script that opens both
files and reads the first 3 lines. That script completed successfully.

After swapping lines 16  18 I see that the error has moved, but that (I think) 
also tells me that the xls file gets
parsed and the xconf does not, so it may be that the xconf file is not in the 
proper format. But if swapping the lines
means what I think then the issue is inside the xconf file and not in the code.

Does that logic work?

Tony

P.S. Sorry for the mis-sent email Tom

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix
 Sent: Monday, May 14, 2007 9:15 PM
 To: [EMAIL PROTECTED]
 Cc: beginners@perl.org
 Subject: Re: LibXML help
 
 On 5/14/07, Tony Heal [EMAIL PROTECTED] wrote:
 
  When I run this, I get 'No such file or directory at /usr/lib/perl5/XML/
  LibXML.pm line 518.
   at ./temp.pl line 16'. I have confirmed that the file exists and is 
  readable.
 
 The file named there is not the one that doesn't exist; that's the
 source code that was running when Perl died.
 
  my $source = $parser-parse_file( '/usr/local/twikixconf/
  tmpxconf/epace/src/conf/epace.xconf' );
 
 Is that line 16? I'd suspect that that names the file that needs to be 
 readable.
 
 Hope this helps!
 
 --Tom Phoenix
 Stonehenge Perl Training


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regex question

2007-05-14 Thread yitzle

# Requires by:
$line = daffromHello Worldby;
$line =~ /from(.*)(by)/;
print $1;

Not sure about making it optional.
Can always check if you got  and then try without the by

On 5/14/07, Tom Allison [EMAIL PROTECTED] wrote:

How do I pull all the words from a line between the two words 'from' and 'by'
when I have NO IDEA what's in there, but I know they are all in one line.

To make it more difficult.  'by' is optional...

Like this:

from..by..
or
from..

I want all the stuff inside.

Initially I'm thinking
/from (.+?) (?:by (.+?))?/

Anything better?

I can negate a character  with [^b] to mean not-'b'
but can I negate a word?

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regex question

2007-05-14 Thread Tom Allison

yitzle wrote:

# Requires by:
$line = daffromHello Worldby;
$line =~ /from(.*)(by)/;
print $1;

Not sure about making it optional.
Can always check if you got  and then try without the by



the .* pulls in too much.

I'm going to have to back up and try this again.
But I think it's late.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regex question

2007-05-14 Thread John W. Krahn
Tom Allison wrote:
 How do I pull all the words from a line between the two words 'from' and
 'by' when I have NO IDEA what's in there, but I know they are all in one
 line.
 
 To make it more difficult.  'by' is optional...
 
 Like this:
 
 from..by..
 or
 from..
 
 I want all the stuff inside.
 
 Initially I'm thinking
 /from (.+?) (?:by (.+?))?/
 
 Anything better?

$ perl -le'
for ( abc from to the word by and the end, abc from to the end ) {
print $1 if /from(.*?(?=by)|.*)/;
}
'
 to the word
 to the end




John
-- 
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order.   -- Larry Wall

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regex question

2007-05-14 Thread Jeff Pang

John W. Krahn 写道:



$ perl -le'
for ( abc from to the word by and the end, abc from to the end ) {
print $1 if /from(.*?(?=by)|.*)/;
}
'



But this coundn't handle this case:
$string = abc from to the word byebye...;

Maybe a space following the by is needed? :)

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regex question

2007-05-14 Thread Igor Sutton Lopes

Hi,

On May 14, 2007, at 11:50 PM, Tom Allison wrote:


yitzle wrote:

# Requires by:
$line = daffromHello Worldby;
$line =~ /from(.*)(by)/;
print $1;
Not sure about making it optional.
Can always check if you got  and then try without the by


the .* pulls in too much.

I'm going to have to back up and try this again.
But I think it's late.


You can use '?' for the not greedy way

$line =~ m/
from
\s+
(.*?) # anything, non greedy
(?:
\s+
by
\s+
(.*)
)?
$/smx;

Good luck!

--
Igor Sutton
[EMAIL PROTECTED]





PGP.sig
Description: This is a digitally signed message part


Re: Attempting to update files blanks them instead

2007-05-14 Thread Chas Owens

On 5/14/07, Kent Frazier [EMAIL PROTECTED] wrote:

That did the trick.  I figured it had to be something simple.  To my credit,
the book had it wrong too.  Anyways, thanks for your help.

snip

Unfortunately errors creep into all printed works.  The following four
links are the errata pages for each version of the Llama so far.

1st edition: http://www.oreilly.com/catalog/lperl/errata/
2nd edition: http://www.oreilly.com/catalog/lperl2/errata/
3rd edition: http://www.oreilly.com/catalog/lperl3/errata/
4th edition: http://www.oreilly.com/catalog/learnperl4/errata/

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: regex question

2007-05-14 Thread Chas Owens

On 5/14/07, Jeff Pang [EMAIL PROTECTED] wrote:
snip

Maybe a space following the by is needed? :)

snip

This what the word boundary character class is for

perl -le'
for ( abc from to the word by and the end, abc from to the end,
abc from this byebye to this) {
  print $1 if /from(.*?(?=\bby\b)|.*)/;
  }
'

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Delete a particular line from file

2007-05-14 Thread sivasakthi
Hi,

I have used the file in perl, file contains like that,

1176369096.111468 172.16.2.80 TCP_MISS/200 9629 
1176378643.614458 172.16.2.80 TCP_MISS/200 9626 
1176378681.984662 172.16.2.75 TCP_MISS/200 9626 
1176436396.304   1142 172.16.2.80 TCP_MISS/200 13281 
1176436397.228916 172.16.2.99 TCP_REFRESH_HIT/200 7521 
1176436469.060   1470 172.16.2.80 TCP_MISS/200 5822 

I have need to split the each column in to separate hash value,before
that i need to delete the particular user details from the file.For
example if a line contains the user I/P  of 172.16.2.80 then i should
delete that whole line and then split in to separate column. For that
what should i do??


Thanks,
Siva


Re: Delete a particular line from file

2007-05-14 Thread Jeff Pang
sivasakthi 写道:
 Hi,
 
 I have used the file in perl, file contains like that,
 
 1176369096.111468 172.16.2.80 TCP_MISS/200 9629 
 1176378643.614458 172.16.2.80 TCP_MISS/200 9626 
 1176378681.984662 172.16.2.75 TCP_MISS/200 9626 
 1176436396.304   1142 172.16.2.80 TCP_MISS/200 13281 
 1176436397.228916 172.16.2.99 TCP_REFRESH_HIT/200 7521 
 1176436469.060   1470 172.16.2.80 TCP_MISS/200 5822 
 
 I have need to split the each column in to separate hash value,before
 that i need to delete the particular user details from the file.For
 example if a line contains the user I/P  of 172.16.2.80 then i should
 delete that whole line and then split in to separate column. For that
 what should i do??
 

while(FILE) {
my ($time,$lport,$ip,$stats,$rport) = split;
next if $ip eq '172.16.2.80';
# using those values above to create hash,based on what form of hash
you needed.
}


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/