RE: regex

2024-01-22 Thread Claude Brown via beginners
Jorge,

Expanding on Karl's answer (and somewhat labouring his point) consider these 
examples:

$a =~ /Jorge/
$a =~ /^Jorge/
$a =~ /Jorge$/
$a =~ /^Jorge$/

This shows that regex providing four different capabilities:
- detect "Jorge" anywhere in the string
- detect "Jorge" at the start of a string (by adding ^)
- detect "Jorge" at the end of a string (by adding $)
- detect that the string is exactly "Jorge" (both ^ and $)

Replace "Jorge" with your pattern, and the result is the same.

Cheers,

Claude.





--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: Using UNIX domain sockets

2024-01-15 Thread Claude Brown via beginners
The first difference I can see is that "echo" adds a newline, but your perl 
does not.  Try adding the newline:

my $cmd='{"command":["stop"]}' . "\n";

This is a wild guess!


-Original Message-
From: listas.correo via beginners 
Sent: Tuesday, January 16, 2024 6:26 AM
To: beginners@perl.org
Subject: Using UNIX domain sockets

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

Hi,

I am trying to control mpv player using unix sockets but it looks like
that perl is unable to send the string correctly.

I run the following command:
mpv --input-ipc-server=~/mpv.sock --idle=yes -v -v

If I sent the string using system commands:

$ echo '{"command":["stop"]}' | socat - ~/mpv.sock | jq
{
   "data": null,
   "request_id": 0,
   "error": "success"
}

It works as expected and is accepted by mpv:
[ipc_1] Client connected
[cplayer] Run command: stop, flags=64, args=[flags=""]
[ipc_1] Client disconnected


Now I run this perl code:

#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket::UNIX;

my $mpv_socket = IO::Socket::UNIX->new(
 Type=> SOCK_STREAM(),
 Peer=> "$ENV{HOME}/mpv.sock",
) or die "socket failed: ",$!,"\n";

my $cmd='{"command":["stop"]}';
$mpv_socket->send($cmd);

and it fails to send the correct text:
[ipc_2] Client connected
[ipc_2] Client disconnected
[ipc_2] Ignoring unterminated command on disconnect.

the message "Ignoring unterminated command on disconnect" is because the
text sent does not seem to be correct and is ignored by mpv.

For what reason could it be that the text sent does not end correctly?

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: Preference

2023-10-28 Thread Claude Brown via beginners
I’d go with Java, in order:


  *   Popularity – there is just more stuff being written in Java.  This would 
indicate the employment options are greater.
 *   https://www.tiobe.com/tiobe-index/
 *   Java currently rates 4th vs Perl at 27th


  *   Over the long arc, Java probably has a faster learning curve.  As much as 
I love Perl, it has some rather arcane syntax at times.

I’m sure you will get many opinions to the contrary on a Perl mailing list 

FWIW, I’d wildly guess the following for my coding time:

  *   90% using Perl
  *   9% using PHP/JavaScript for web-pages
  *   0.9% in, say, C++ or C
  *   0.09% in Java or C#

The rest of the time I slack off.

Cheers,

Claude.



From: William Torrez Corea 
Sent: Sunday, October 29, 2023 8:46 AM
To: Perl Beginners 
Subject: Preference


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.
What is preferable to learn?

Java or Perl

What is the learning curve of this language of programming?

--

With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄



RE: Using qr// with substitution and group-interpolation in the substitution part

2023-10-25 Thread Claude Brown via beginners
I should add that if the script reads values of $regex or $subst from an 
external source, then my use of eval is seriously flawed.  For example, that 
external source might provide this value for $subst:

/; system("do-bad-things"); qr/x/

The eval will execute the "do-bad-things" command on your system.  


-Original Message-
From: Claude Brown via beginners  
Sent: Thursday, October 26, 2023 8:07 AM
To: Levi Elias Nystad-Johansen ; Andrew Solomon 

Cc: Josef Wolf ; beginners@perl.org
Subject: RE: Using qr// with substitution and group-interpolation in the 
substitution part

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

Josef,

Inspired by Levi's “eval” idea, here is my solution:

sub substitute_lines {
my ($contents, $regex, $subst) = @_;
eval "\$contents =~ s/$regex/$subst/g";
return $contents;
}

$data = "foo whatever bar";
$data = _lines($data, qr/^foo (whatever) bar$/m, 'bar $1 baz');
print "$data\n";

The differences:
- escaped the "$" so the eval gets a literal "$contents"
- didn't escape "$" so the eval receives the value of $regex and $subst
- moved the "g" into the sub as it has no meaning for a qr//
- removed the "m" from the sub as it best left with the original qr//
- added "$data = ..." to get back the value from the subroutine

Cheers,

Claude.



RE: Using qr// with substitution and group-interpolation in the substitution part

2023-10-25 Thread Claude Brown via beginners
Josef,

Inspired by Levi's “eval” idea, here is my solution:

sub substitute_lines {
my ($contents, $regex, $subst) = @_;
eval "\$contents =~ s/$regex/$subst/g";
return $contents;
}

$data = "foo whatever bar";
$data = _lines($data, qr/^foo (whatever) bar$/m, 'bar $1 baz');
print "$data\n";

The differences:
- escaped the "$" so the eval gets a literal "$contents"
- didn't escape "$" so the eval receives the value of $regex and $subst
- moved the "g" into the sub as it has no meaning for a qr//
- removed the "m" from the sub as it best left with the original qr//
- added "$data = ..." to get back the value from the subroutine

Cheers,

Claude.



RE: Tool for develop in Perl

2023-10-22 Thread Claude Brown via beginners
I am 99% using “vi” and sometimes Notepad++.I do not like heavy-weight 
IDE’s – I find they get in the way.

I have colleagues using Visual Studio and they say it is great.  Yet, I’m more 
productive    I reckon they spend too much time messing around with the tool 
trying to make it do what they want!!




From: William Torrez Corea 
Sent: Saturday, October 21, 2023 3:49 PM
To: beginners@perl.org
Subject: Tool for develop in Perl


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.
What tool can I use for development in Perl?

I use VIM for coding and executing programs with the Perl Command Line from 
GNU/Linux. In addition I have installed Eclipse but the IDE is abandoned.

My theory: I can make full development from VIM but few developers use VIM for 
development. They use Eclipse, Netbeans, Visual Studio or some other code 
editor like Visual Studio Code, Sublime Text, Atom and Notepad++.

The IDE is complete but large files while the code editor is light.
--

With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄



RE: My progress in Perl

2023-08-07 Thread Claude Brown via beginners
Steve,

I agree.  Someone just starting out should go with Python.  It pains me to say 
it, but Perl isn’t a good skills investment.

My team and I program every day in Perl – we have 100’s of libraries and system 
integrations.  I love it and it is my first choice for backend work.Sadly, 
we are trying to figure out our path to Python.  We barely know Python, so it 
will be a difficult – but necessary – journey.
Cheers,

Claude.


From: Steve Park 
Sent: Tuesday, August 8, 2023 11:49 AM
To: Andy Bach 
Cc: William Torrez Corea ; beginners@perl.org
Subject: Re: My progress in Perl


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.
Honestly, my advise is if you are beginning to learn programming using perl in 
2023. Don't.
Pick up python and go from there.
If you already know some perl and want to advance, yes go right ahead.
2023, is perl dead? no. It's a tool and it's still a swiss army of programming 
language and lot can be done.
I would say writing concise and compact programming for regex related 
processing, it still is right up there with anything out there today.
But def if you are learning programming in 2023, you should start w/ python.
To be truly useful, you have to learn several language but python(or to lot of 
extend, javascript) should be the first language you should learn(until AI can 
take over the world).

Having said this, I still love my perl.


On Mon, Aug 7, 2023 at 12:31 PM Andy Bach 
mailto:afb...@gmail.com>> wrote:
Yeah, I learned Perl back in the V4 days; I was sort of new to linux admin 
though a programmer in school and after learning sed/awk/grep to handle 
digesting logs and munging data files I heard of Perl.  It was a bit like 
finding crack cocaine, all sorts of tasks became easy and I wrote scripts to 
handle everything.  Having a need was the motivation, not following the books, 
though I did have a copy of Programming Perl that had about 40 scotch tape tabs 
marking places for reference.  Other books, the Perl Monks site and finally a 
near-by Perl Mongers group really helped me find the Perl communtiy.

On Sun, Aug 6, 2023 at 12:24 PM William Torrez Corea 
mailto:willitc9...@gmail.com>> wrote:
I started testing some extensions of CPAN but I don't understand anything. I 
only execute and then proceed with a book. The name of the book is Beginning 
Perl of Curtis Ovid Poe.

I started with a lot of passion but then lost interest, the monotony conquered 
me. Actually I am learning references and Complex Data Structures in Perl.

I have a lot of doubts in my mind:

What is my purpose with this language?
In my country don't exist use of this language
I am boring and tired

I must be a success!

PD: Add your anecdote with this language.

--

With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄



--

a

Andy Bach,
afb...@gmail.com<mailto:afb...@gmail.com>
608 658-1890 cell
608 261-5738 wk


RE: configuring Net::SMTP

2023-07-08 Thread Claude Brown via beginners
Hi Rick,

We use Net::SMTP to send emails via SendGrid.  They require a user/pass 
authentication over SSL and I wonder if that is what is going wrong in your 
case.  The other thing worth doing is checking the return-value of each SMTP 
call as something may be going wrong silently.

Below is a fragment of our code that does (a) authentication and (b) checks 
each value.  I hope it assists.

Cheers,

Claude.

use strict;
use Carp;
use Net::SMTP;

use constant SMTP_HOST => 'smtp.sendgrid.net';
use constant SMTP_PORT => 465;
use constant SMTP_USER => 'the-username';
use constant SMTP_PASS => 'the-password';
use constant SMTP_TIMEOUT => 15;
use constant SMTP_DEBUG => 0;

my $smtp = Net::SMTP->new(
Host => SMTP_HOST,
Port => SMTP_PORT,
Timeout => SMTP_TIMEOUT,
SSL => 1,
Debug => SMTP_DEBUG);

my $fromAddr = 'whowe...@somehwere.com';
my $toAddr = 'whoe...@somewhere.com';
my $theBody = 'the mail headers and body of the email';

$smtp->auth(SMTP_USER, SMTP_PASS) or confess "SMTP auth: " . $smtp->message();
$smtp->mail($fromAddr)or confess "SMTP mail: " . $smtp->message();
$smtp->to($toAddr)or confess "SMTP to: " . $smtp->message();
$smtp->data() or confess "SMTP data: " . $smtp->message();
$smtp->datasend($theBody) or confess "SMTP datasend: " . 
$smtp->message();
$smtp->dataend()  or confess "SMTP dataend: " . 
$smtp->message();
$smtp->quit() or confess "SMTP quit: " . $smtp->message(); 
--
Claude.


-Original Message-
From: p...@reason.net  
Sent: Sunday, July 9, 2023 10:41 AM
To: Perl Beginners 
Subject: Re: configuring Net::SMTP

CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

Thanks, Andinus. This is useful information. — Rick

> On Jul 8, 2023, at 10:11 AM, Andinus  wrote:
>
>
> Hello Rick,
>
> Hostgator might be able to provide you more information regarding why
> the email delivery is failing. I'm not very familiar with mail stuff.
>
> You can also try NET::SMTP->new(Debug => 1) and send an email, it might
> provide useful info.
>
> Maybe this answer on stackoverflow might be helpful
> https://stackoverflow.com/a/10008814
>
> Have a good day!
>
> Rick T @ 2023-07-08 08:37 -07:
>
>> I have two subroutines (below) in a program that uses Net::SMTP. I’ve
>> recently moved my site from FutureQuest.net <http://futurequest.net/>
>> to Hostgator.com <http://hostgator.com/>, and this part of my program
>> has stopped working. The first routine sends an analysis of a test to
>> me at Reason.net <http://reason.net/>, and the second send a score to
>> several addresses associated with the student. On my new host at
>> Hostgator both fail to do this. (One of the “technicians” at Hostgator
>> said he found my email, so one or both likely arrived at
>> webmas...@hostgator.com <mailto:webmas...@hostgator.com>.)
>>
>> I am not trained in computer tech; I’m just a 78 year old high school
>> teacher who bought a few books on perl, so I don’t really understand
>> how to fill in the many variable assignments that make up most of
>> these two routines. Instead I took guesses and tried stuff to see
>> what would happen. If any of you have suggestions or corrections, I’d
>> be grateful!
>>
>> Rick Triplett
>>
>> FIRST SUBROUTINE:
>>
>> sub email_analysis {# to LibertyLearning for score posting and analysis
>>my $n_max = shift;
>>my @analysis = define_analysis($n_max);
>>
>>my $subject_line
>>= "$pf{percent_correct_final} $pf{name_full} $course_file\n";
>>
>># Send administration an email of statistical analysis
>>my $to= 'socra...@reason.net';
>>my $from  = 'webmas...@libertylearning.com';
>>my $site  = 'libertylearning.com';
>>my $smtp_host = 'mail.libertylearning.com';
>>
>>my $smtp  = Net::SMTP->new( $smtp_host, Hello => $site );
>>$smtp->mail($from);
>>$smtp->to($to);
>>$smtp->data();
>>$smtp->datasend("From: webmaster\@LibertyLearning.com\n");
>>$smtp->datasend("To: $to\n");
>>$smtp->datasend("Date: $pf{ date_ended }\n");
>>$smtp->datasend("Subject: $subject_line\n");
>>$smtp->datasend("\n");
>>$smtp->datasend("$student_id\n&q

RE: Communities or support

2023-06-14 Thread Claude Brown via beginners
I’m in Australia, and it is much the same story.  Perl is not mentioned 
anymore, and it is difficult to find resources.  You only need to look at the 
various “popularity” reviews to see Perl is out of favour.

In my company we use Perl for most everything. Plus a little PHP & Javascript 
for small web things.

We were a start-up and I was the only I.T. person.  I had to write all the 
integrations for every system we installed – it was Perl for speed, or not 
sleeping.  I’ve had to teach three new developers we hired and, to be fair, it 
isn’t the easiest language to learn.

I do worry about the future for us with staffing.  We won’t be able to attract 
talent unless they see a language they think will build out their CV.  I fear 
one day we will be moving to Python.


From: Mike 
Sent: Thursday, June 15, 2023 9:51 AM
To: beginners@perl.org
Cc: William Torrez Corea 
Subject: Re: Communities or support


CAUTION: This email originated from outside of the organization. Do not click 
links or open attachments unless you recognize the sender and know the content 
is safe.

Good question.  I know we are using it here in the USA.
I put in my time on Perl, and now I can whip up a
program mighty fast.  I do so quite often.  And I use it
every day - many times a day.


Mike

On 6/14/23 17:44, William Torrez Corea wrote:
Why don't existing communities, use or support the language of programming PERL 
in Central America?
What happened?
Why does nobody use this language of programming in this continent?

Only JavaScript, Java, .NET, Python and other frameworks are promoted and used 
in this continent.
--

With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄




RE: storage types for big file

2023-05-30 Thread Claude Brown via beginners
This is where you need to pad spaces.  So, for example:

- old: "I am young and fast\n" (20 bytes)

- new: "I am old and slow\n" (18 bytes)



The second version is shorter, so it will need two spaces before the newline:

- new: "I am old and slow__\n" (20 bytes; I put "_" instead of a space)



There is a problem here that I didn't consider.  If your line-length INCREASES, 
then this whole idea is, sadly, rubbish :(









-Original Message-
From: Tom Reed 
Sent: Wednesday, May 31, 2023 11:31 AM
To: Claude Brown 
Cc: beginners@perl.org
Subject: RE: storage types for big file





Hello



I am not sure,









what does this mean? not changing the line length?

but in most case I need to change the length of a line.



Thanks again.

Tom







> That sounds positive.  You should be able to avoid most of the overhead of

> writing the file.   The general idea is that you are "updating in place"

> rather than writing out the whole file.

>

> Something like below is what I was thinking, but it isn't tested!  Make

> sure you have a copy of your input file.  Oh, and I haven't thought about

> "wide" characters which may influence how some of this works.

>

> Cheers,

>

> Claude.

>

>

> open(my $fh, "+<", $theFileName) or die "open: $!";

>

> my $startOfLine = tell($fh) or die "tell: $!;

> while (defined(my $line = <$fh>))

> {

> if ($line has content that needs to change)

> {

>  doesn't change>

> seek($fh, $startOfLine, 0) or die "seek: $!";

> print $fh $line;

> }

>

> $startOfLine = tell($fh) or die "tell: $!;

> }

>

> close($fh);

>

>

> -Original Message-

> From: Tom Reed mailto:t...@dkinbox.com>>

> Sent: Wednesday, May 31, 2023 9:33 AM

> To: Claude Brown 
> mailto:claude.br...@gigacomm.net.au>>

> Cc: beginners@perl.org<mailto:beginners@perl.org>

> Subject: RE: storage types for big file

>

>

>

>> Do you have the option to "seek" to the correct place in the file to

>> make

>> your changes?  For example, perhaps:

>>

>> - Your changes are few compared to writing out the whole file

>> - Your changes do not change the size of the file (or you can pad

>> line-end

>> with spaces)

>>

>

> 1. each time just changes few lines, not the full file.

> 2. it has file size changed, but yes I can pad line-end with space.

>

> So what's the further?

>

> Thanks

>

>

> --

> Sent from https://dkinbox.com/

>

>

> --

> To unsubscribe, e-mail: 
> beginners-unsubscr...@perl.org<mailto:beginners-unsubscr...@perl.org>

> For additional commands, e-mail: 
> beginners-h...@perl.org<mailto:beginners-h...@perl.org>

> http://learn.perl.org/

>

>

>





--

Sent from https://dkinbox.com/





--

To unsubscribe, e-mail: 
beginners-unsubscr...@perl.org<mailto:beginners-unsubscr...@perl.org>

For additional commands, e-mail: 
beginners-h...@perl.org<mailto:beginners-h...@perl.org>

http://learn.perl.org/






RE: storage types for big file

2023-05-30 Thread Claude Brown via beginners
That sounds positive.  You should be able to avoid most of the overhead of 
writing the file.   The general idea is that you are "updating in place" rather 
than writing out the whole file.

Something like below is what I was thinking, but it isn't tested!  Make sure 
you have a copy of your input file.  Oh, and I haven't thought about "wide" 
characters which may influence how some of this works.

Cheers,

Claude.


open(my $fh, "+<", $theFileName) or die "open: $!";

my $startOfLine = tell($fh) or die "tell: $!;
while (defined(my $line = <$fh>))
{
if ($line has content that needs to change)
{

seek($fh, $startOfLine, 0) or die "seek: $!";
print $fh $line;
}

$startOfLine = tell($fh) or die "tell: $!;
}

close($fh);


-Original Message-----
From: Tom Reed  
Sent: Wednesday, May 31, 2023 9:33 AM
To: Claude Brown 
Cc: beginners@perl.org
Subject: RE: storage types for big file



> Do you have the option to "seek" to the correct place in the file to make
> your changes?  For example, perhaps:
>
> - Your changes are few compared to writing out the whole file
> - Your changes do not change the size of the file (or you can pad line-end
> with spaces)
>

1. each time just changes few lines, not the full file.
2. it has file size changed, but yes I can pad line-end with space.

So what's the further?

Thanks


-- 
Sent from https://dkinbox.com/


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: storage types for big file

2023-05-30 Thread Claude Brown via beginners
Do you have the option to "seek" to the correct place in the file to make your 
changes?  For example, perhaps:

- Your changes are few compared to writing out the whole file
- Your changes do not change the size of the file (or you can pad line-end with 
spaces)

It is an edge case, but just a thought.


-Original Message-
From: t...@dkinbox.com  
Sent: Tuesday, May 30, 2023 10:12 PM
To: beginners@perl.org
Subject: storage types for big file


Hello

I have a big file after making changes in ram I need to write it back to
disk.
I know for text file store it's written line by line.
But is there any better storage type for high performance read/writing?
maybe binary?

Thank you.


-- 
Sent from https://dkinbox.com/


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/




RE: GNU/Linux

2023-05-02 Thread Claude Brown via beginners
> Can develop a program in PERL for GNU/Linux without using BASH?

Yes.  But developing a script requires an editor of some sort.   Most often 
that will be launched from bash (or other shell), although I can imagine 
strange scenarios where it is not.

Executing a perl script definitely does not require bash, but it would be a 
common starting point.


> What is the difference between PERL and BASH?

That is a very open question!   Both are used to execute “scripts”, but the 
script content is different.  I would offer this subjective difference:


  *   Perl manages a broad range of datatypes and can be more object-oriented.  
The library, in general, executes efficiently within the same process as the 
caller of the library.
  *   Bash tends to focus on managing the order of execution of other programs, 
and their input/output streams.  It doesn’t have a vast “same process” library, 
and it has less datatypes.  It isn’t object oriented.

Cheers,

Claude.



From: William Torrez Corea 
Sent: Wednesday, May 3, 2023 2:53 PM
To: beginners@perl.org
Subject: GNU/Linux

Can develop a program in PERL for GNU/Linux without using BASH?
What is the difference between PERL and BASH?

--

With kindest regards, William.

⢀⣴⠾⠻⢶⣦⠀
⣾⠁⢠⠒⠀⣿⡁ Debian - The universal operating system
⢿⡄⠘⠷⠚⠋⠀ https://www.debian.org
⠈⠳⣄



Re: tail -f does not exit

2004-05-19 Thread Claude
 Rob == Rob Dixon [EMAIL PROTECTED] writes: 

I got your code running nicely, although I had to make a small change due to
an older Perl (5.004) I am using:

[...]
Rob You need to close and reopen the file if you want to check for a rename.
Rob Something like the program below.

Which actually emulates tail f- nicely, since it notices a filename
change and exits, on contrary of tail -f which has to be killed.

Rob use strict;
Rob use warnings;

Rob use IO::Handle;
Rob autoflush STDOUT;

Rob use Fcntl qw(:seek);
Removed line, as seek is not yet a tag in earlier Perl.

Rob my $file = 'junk.txt';
Rob my $pos;
Rob while (1) {
Rob   open LOG, $file or die Cannot open $file, $!;

Rob   seek LOG, $pos, SEEK_SET if defined $pos;
   seek LOG, $pos, 0 if defined $pos;

Rob   print while LOG;
Rob   $pos = tell LOG;
Rob   close LOG;
Rob   sleep 1;
Rob }

Tx a lot, Rob!
-- 
Claude

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




tail -f does not exit

2004-05-14 Thread Claude
I am reading continuously a file like this:

  open LOG, junk.txt or die Cannot open $file, $!\n;
  while ( my $line = LOG ) {
print $line;
  }

While appending lines to the file from a shell command line:

  $ echo this is a new line  junk.txt

Everything ok, except that I would like to find out from the Perl code
above when junk.txt has been deleted, or renamed. Unfortunately, tail
-f does not exit...

Any idea how to do that?
-- 
Claude

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




Re: tail -f does not exit

2004-05-14 Thread Claude
 Rob == Rob Dixon [EMAIL PROTECTED] writes:
[...]

Rob You need to close and reopen the file if you want to check for a
Rob rename. Something like the program below.
[...]

Tx, Rob, I'll give feedback soon here!
-- 
Claude

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




Re: Set $Log::TraceMessages::On at module file level

2004-04-26 Thread Claude
I'll try to re-phrase my question, as I didn't get any answer:

How can I set to local a globally defined variable, in order to get
file scope in a module file?
-- 
Claude

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




Set $Log::TraceMessages::On at module file level

2004-04-25 Thread Claude
I have the following problem:

The module variable $Log::TraceMessages::On tells all calls to
trace() to print an argument (1) or not to (0).

Now, I'd like to split my program between my own module and my own
file using it. I'd like as well to use trace() for different
purposes during the execution of my program: for example, from command
line, setting trace 'on' only in the scope of my component or in the
scope of other files or not setting it at all. Some kind of tracing
level implementation.

The Log::TraceMessages module pod says that making the variable
local would do it. Unfortunately, I failed to see how I can set the
local scope to a _whole_ _file_ instead of a block like the doc says:

  {   # ok but not file _scope_  
  local $Log::TraceMessages::On = 0;
  t 'this message will not be printed';
  }

  # this is what I'd like, but fail to do that in my module file
  local $Log::TraceMessages::On = $trace;

Any idea how to do tha?
-- 
Claude

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




Re: Perl parsing script

2004-04-23 Thread Claude
 Ron == Ron McKeever [EMAIL PROTECTED] writes:

Ron I am trying to figure out my Perl parsing script to dump the
Ron interesting part of my log files to another parsed file.
[...]

Ron But I get errors...

I am affraid You have to solve this issue in any case.

Ron Is there an easier way do to this? These log files get to around
Ron 500MB a day so the fastest way is hoped. Would a while  be
Ron better??

Maybe opening in follow mode (ie. calling tail -f) would help? You
launch your script in the morning when the log file is small and it
gathers new lines when they are written. It depends how the input log
file is written, and the syntax of the file, of course. New lines have
to be appended to it by your system.

  $infile = tail -fn +1 $file |;
  open LOG, $infile or die Cannot open log $file, $!\n;
  while ( $line = LOG ) {
  # parse one line, write the result
  }

Hope it helps.
-- 
Claude

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




Re: Test::Harness weird failure

2004-03-24 Thread Claude
 Claude == Claude  [EMAIL PROTECTED] writes:

 Paul == Paul Johnson [EMAIL PROTECTED] writes:
Paul Claude said:
 Hello,
 
 I tried to create a test suite file containing the following code:

[...]

Paul use Test::More tests = 1;

Claude Why would I need this separated module? I understood I can live
Claude without it. Am I wrong?

Actually, I got it wrong from the beginning: although there may be
ways go araound that, you _need_ the Test::More or Test::Simple from
the beginning. Test::Harness design is based on their use. I did not get
that right away.

Tx for your answer and your time, Paul!

[...]
-- 
Claude

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




Re: Test::Harness weird failure

2004-03-23 Thread Claude
 Paul == Paul Johnson [EMAIL PROTECTED] writes:

Paul Claude said:
 Hello,
 
 I tried to create a test suite file containing the following code:
 
 -- clip ---
 #! /usr/local/bin/perl
 
 use strict;
 use Test::Harness qw( runtests $verbose );
 $verbose=1;
 my @AoC = ( t/00.pl );
 my $len = @AoC;
 print 1..$len\n;

Paul This line should be in the test scripts rather than the harness.

 runtests( @AoC );
 -- clip ---
 
 The file t/00.pl contains the following lines:
 
 -- clip ---
 #! /usr/local/bin/perl
 
 print ok\n;

Paul Here you want something like:

Paul use Test::More tests = 1;

Why would I need this separated module? I understood I can live
without it. Am I wrong?

Paul my $x = qaz;
Paul is $x, qaz, qaz matches;

 What am I doing wrong?

Paul There is usually no need for your first file. 

Where would I run the runtest() from then?

Paul The standard way to set things up is to put the tests in the t
Paul directory, 

I did that. but I don't want to run all of them. I found the runtest()
call passed a array of test kind of handy for me.

Paul let MakeMaker do its magic, and then run make test.
Paul Unless you have specific requirements which preclude this, I
Paul would suggest that approach.

Magic? Sorry, I could not understand that. I am still stuck with the
way to handle Test::Harness.

Is there any newsgroup more appropriate that this one?

Tx for your answer and time.
-- 
Claude

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




Test::Harness weird failure

2004-03-17 Thread Claude
Hello,

I tried to create a test suite file containing the following code:

-- clip ---
#! /usr/local/bin/perl

use strict;
use Test::Harness qw( runtests $verbose );
$verbose=1;
my @AoC = ( t/00.pl );
my $len = @AoC;
print 1..$len\n;
runtests( @AoC );
-- clip ---

The file t/00.pl contains the following lines:

-- clip ---
#! /usr/local/bin/perl

print ok\n;
-- clip ---

Yet I got the following output when I run the suite file:

-- clip ---
test ./suite.pl
1..1
t/00.p..ok
FAILED before any test output arrived
FAILED--1 test script could be run, alas--no output ever seen
-- clip ---

Commenting out the $verbose=1 line does not change anything to the result:
-- clip ---
test ./suite.pl
1..1
t/00.p..FAILED before any test output arrived
FAILED--1 test script could be run, alas--no output ever seen
-- clip ---

What am I doing wrong?
-- 
Claude

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




Converting UNIX script to run under MIIS

2001-12-05 Thread Claude Jones

This is my first post, and I hope it's not too newbie even for a list with
this name. I'm just beginning to learn Perl and I have successfully got some
scripts working on our website to handle form submissions. We are in process
of bringing our site in house, where we will host on a MIIS server.
Currently our site is hosted on a Linux server. By changing some things, I
briefly got our forms to work on our new server, and didn't realize it, and
kept changing things. Now, I'm completely stumped and can't find the
problem. All the permissions are properly set. Perl has been mapped to run
with MIIS. I've installed a sendmail client for windows which works. If
someone is willing to take a look, the script is at the following:
www.crosseyes.biz\form_processor.txt I've changed the ending to .txt to
prevent any complications.

Claude Jones
WTVS, Leesburg, VA


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




Hotline Module

2001-11-29 Thread Trefois Jean-Claude

Hi,

I found a simple perl hotline bot, and when I try to launch it, it says
that the system command stty is not found!
I know it is a shell util under linux, but what is the equavalant system
utility under win2k?

Thanks for your answer

--
Christophe Tréfois ([EMAIL PROTECTED])
Web-Development



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