@INC search path

2004-09-25 Thread Owen

I just installed the latest File::Slurp and now I have two of them

/usr/lib/perl5/site_perl/5.8.3/File/Slurp.pm
/usr/lib/perl5/vendor_perl/5.8.1/File/Slurp.pm

a perldoc File::Slurp gives me the site_perl version(the latest)

Printing @INC gives me
.
.
/usr/lib/perl5/site_perl/5.8.3
.
.
/usr/lib/perl5/vendor_perl/5.8.1


perldoc -q @INC does not answer my query, so can I ask

Is the print out sequence of @INC consistent and  the same as the search path?

I am very wary of deleting duplicate modules as it seems that those installed in the 
"vendor" (Mandrake) directory are necessary for much of Mandrake's operation.


TIA



-- 
Owen



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




Re: UNIX Process List (U)

2004-09-29 Thread Owen
On Wed, 29 Sep 2004 07:52:53 -0400
"Meidling, Keith, CTR, ISD" <[EMAIL PROTECTED]> wrote:

> Is there a module to get a list of processes on a UNIX/Linux machine, or
> would I just do a `ps` and save it to an array?





There is a program in the Perl Cookbook called 'psgrep' which may meet your need.



-- 
Owen



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




Regular expression help

2004-10-21 Thread Owen

This program 


#!/usr/bin/perl -w

use strict;
while () {

chomp;
my $line = $_;

my @y =split (/\b[\w]+:/,$line);

#print scalar(@y);
print $line;
print "\n\$y[0] $y[0]\n\$y[1] $y[1]\n\$y[2] $y[2]\n\$y[3] $y[3]\n\$y[4] $y[4]\n\$y[5] 
$y[5]\n";
} 

__DATA__
M:356 358 386 R:#132 W1:319 NRT:32 R:#132



produces 

[EMAIL PROTECTED] PerlScripts]$ perl  split.test
M:356 358 386 R:#132 W1:319 NRT:32 R:#132
$y[0]
$y[1] 356 358 386
$y[2] #132
$y[3] 319
$y[4] 32
$y[5] #132



but I would really like it to capture the first part of the element so that the result 
would be;

M:356 358 386 R:#132 W1:319 NRT:32 R:#132
$y[0]
$y[1] M 356 358 386
$y[2] R #132
$y[3] W1 319
$y[4] NRT 32
$y[5] R #132


Also, why is $y[0] undefined or null, scalar (@y) is 6.


TIA for any clues



-- 
Owen



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




Re: zcat

2004-10-22 Thread Owen
On Fri, 22 Oct 2004 01:27:22 -0400
[EMAIL PROTECTED] wrote:


> I have a gunzip file which I have to decompress through a perl script 
> and copy the uncompressed file to another file.
> I used this
> 
> system('zcat -c $filename > out');
> where the filename is stored in $filename.
> 
> zcat gave me an error message that the output is not read from a 
> terminal. Could you please give me an option for zcat which I can use 
> for this.


zcat [ -fhLV ] [ name ...  ]


man zcat suggests -c is not an option.

-f --force
-h --help
-L --license
-V --version

what happens when you try it without the -c option?




Owen

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




Re: Error: Line too long

2004-10-22 Thread Owen
On Fri, 22 Oct 2004 02:05:33 -0700 (PDT)
Melis Mutlu <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I would like to write a whole string into a file with
> the following code: 
> 
> open(NEW, "new.txt") or die "cannot open new_acl.txt";
> open(OUT, ">test");
> while(my $line=) {
> chop $line;
> $string=$string.$line;
> print OUT $string}
> 

what happens if you try

while() {
  chomp;
  print OUT "$_ "}#presuming you want a space between them



Owen
 

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




Re: cancatenate lists

2004-10-22 Thread Owen
On Fri, 22 Oct 2004 12:40:11 +0200 (CEST)
c r <[EMAIL PROTECTED]> wrote:


> How can I easily cancatenate two lists?
>  
> i.e. 
>  
> @list1 = qw(1 2 3);
>  
> @list2 = qw(4 5 6);


untested

push(@list1,@list2);


Owen

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




Re: problem printf

2004-10-25 Thread Owen
On Mon, 25 Oct 2004 05:17 pm, deny wrote:
> foreach $name ( sort @files) {
>     ($uid,$gid) = (stat $nane)[4,5];

stat $nane or $name?

Owen

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




Re: Determine the Binary format of a file

2004-10-27 Thread Owen
On Wed, 27 Oct 2004 17:59:39 -0400
"Jim" <[EMAIL PROTECTED]> wrote:

> 
> > Any ideas where to start?  Generally I try and determine 
> > record size and delimiter first.  Are they fixed length 
> > records?  newline or null delimited? CSV ??
> > 
> > more input.
> > 
> 
> I have no idea. It does not seem to be newline delimited (. Is there some
> trick to try to determine the record size and delimeter?


Does "strings file" give you any clues?


Owen

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




Interpreting Benchmark test

2004-10-29 Thread Owen
My first foray into Benchmark with the code below produced these results; 

The file is 22000 lines, and there are 2 matches in the file.

[EMAIL PROTECTED] PerlScripts]$ perl benchmark.pl

Regex with modifer
YES
YES
timethis 100:  5 wallclock secs ( 4.84 usr +  0.50 sys =  5.34 CPU) @ 187265.92/s 
(n=100)

Regex without  modifer
YES
YES
timethis 100:  7 wallclock secs ( 4.75 usr +  0.57 sys =  5.32 CPU) @ 187969.92/s 
(n=100)

It would seem to me that the /o modifier makes little difference, or is it that I am 
using the modifer incorrectly or even using Benchmark incorrectly?


TIA


Owen





#!/usr/bin/perl -w

   use Benchmark qw(:all) ;
   use strict;
   
   my $count = 100;
   my $name = "STILL";
   my $file = "test.data";
   my $line;
   open (FH,"$file") || die "Can't open $file $!\n";
   print "\nRegex with modifer\n";
   
   timethis ($count, 
sub{
while(){
chomp;$line=$_;
if ($line=~/$name/o){print "YES\n"}
}});
close FH;

   open (FH,"$file") || die "Can't open $file $!\n";
   print "\nRegex without  modifer\n";

timethis ($count, 
sub{
while(){
chomp;$line=$_;
if ($line=~/$name/){print "YES\n"}
}}); 

__END__

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




Re: GD isn't outputting image data

2005-01-08 Thread Owen
On Sat, 08 Jan 2005 14:36:57 -0600
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:

> 
> I've added it to my test script and did the othe types as well and 
> removed the content type header so that doesn't confuse the issue.
> 
> 
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use GD;
> 
> my $image = GD::Image->new(100,50);
> my $white = $image->colorAllocate(255,255,255);
> $image->transparent($white);
> 
> my $fontcolor = $image->colorAllocate(0,0,0);
> my $font = GD::Font->Small();
> 
> $image->string($font,2,10,'hello world',$fontcolor);

--insert---
open (OUT,">GD.png");

my $img = $image->png;
print OUT "$img";
--end insert---
> binmode STDOUT;
> 
> print "PNG\n";
> print $image->png;
> 
> 
> print "\nGIF\n";
> print $image->gif;
> 
> 
> print "\nJPEG\n";
> print $image->jpeg;


It worked for me, try modifying the script a la above and see if it produces a 
GD.png file



-- 

Owen


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




Re: GD isn't outputting image data

2005-01-08 Thread Owen
On Sat, 08 Jan 2005 20:19:26 -0600
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:

> 
> 
> Owen wrote:

> > --insert---
> > open (OUT,">GD.png");
> > 
> > my $img = $image->png;
> > print OUT "$img";
> 
> 
> $ cat GD.png
> $
> 
> Very weird, still nothing :)
> 
> GD just isn't returning anything in any format, scalar or array context...


Well all a bit of a mystery. 

su to root and do all that stuff again, maybe there is a permission problem on 
the files or on the directory.


-- 

Owen


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




Re: GD isn't outputting image data

2005-01-09 Thread Owen
On Sun, 09 Jan 2005 14:19:10 -0600
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:

> In this case there is no other sensible error message so why is die 
> "$!"; what I mean when I mean die $!; ? Why no t die "Sensible error 
> message $!"; ?



Well perhaps for a single debugging line, it doesn't matter too much, but 
consider a program where endless things can and do go wrong. Peppering your 
script with

or die "Can't open the file Data1 $!\n";
or die "Can't open the file Data2 $!\n";
or die "Can't open the file Data3 $!\n";
etc


really helps track down where to look


The rule is to always check the return value

-- 

Owen


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




Re: Logfile name

2005-01-24 Thread Owen
On Mon, 24 Jan 2005 14:31:53 +0100
Jan Eden <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I create monthly log files with names like statistics_01_2005.log. Now I have 
> a function which returns the logfile name for the current month:
> 
> sub statfile {
> my @date = localtime(time);
> my ($month, $year) = @date[4,5];
> $year += 1900;
> $month = sprintf ("%02d", $month+1);
> return my $statfile = qq{statistics_${month}_${year}.log};
> }
> 
> In some cases I need the name of last month's logfile. To achieve this, I 
> modified the subroutine like this:
> 
> sub statfile {
> my $mode = shift;
> my @date = localtime(time);
> my ($month, $year) = @date[4,5];
> $year += 1900;
> if ($mode) {
> $month = sprintf ("%02d", $month);
> $month = 12 if $month == 0;
> $year = $year - 1;
> }
> else {
> $month = sprintf ("%02d", $month+1);
> }
> return my $statfile = qq{statistics_${month}_${year}.log};
> }


I just get all the file names and sort them, last months is the second last (or 
first) 



opendir(DIR,$wherever) or die "Can't open DIR $!\n";
while (defined($file = readdir(DIR))) {
next unless($file =~ /\.log/); #just take out the .log files
push (@filenames,$file);
}
closedir(DIR);

# Now I get a sorted list for inclusion in a drop down menu

@filenames = sort{$a cmp [EMAIL PROTECTED];




Owen

-- 
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 error --> Global symbol requires...

2005-02-25 Thread Owen
On Fri, 25 Feb 2005 15:55:21 -0700
"Bret Goodfellow" <[EMAIL PROTECTED]> wrote:

> # while1.pl
> use strict ;
> use warnings ;
>  
> $i = 1;
>  
> while ($i < 10) {
>  print "I am at $i\n";
>  i++;
> }
> # while1.pl
>  
>  
>  
> Global symbol "$i" requires explicit package name at


Try removing the 'use strict;' statement. See what happens

You also have another problem with that script, perhaps i++ was a typo?



Owen

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




Re: Program to write code

2004-01-22 Thread Owen
On Wed, 21 Jan 2004 19:32:56 -0300
"Marcelo" <[EMAIL PROTECTED]> wrote:

> Hi, could anyone recommend a good program to write code, currently using notepad.

If you are using Windows, there are a number of "Notepad" improved editors. Google for 
"windows text editors" and you will get them all I guess. Some of these like 
NoteTabPro have libraries to assist in programming, some better than others.

There is also windows versions of Emacs or Vim which are unix originated editors. 


-- 
Owen


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




Re: Covert Date to week number

2004-01-23 Thread Owen
On Thu, 22 Jan 2004 19:28:24 +
[EMAIL PROTECTED] wrote:

> Is their a way in PERL to covert a date to a week number
> 

Try this;


#!/usr/bin/perl
use Date::Calc qw(Week_Number Week_of_Year);

@t=localtime;

$week = Week_Number($t[5]+1900,$t[4]+1,$t[3]);   #Deprecated
print " From Date::Calc Week Number is  $week \n";

($week,$year) = Week_of_Year($t[5]+1900,$t[4]+1,$t[3]);  #Preferred
print " From Date::Calc Week of Year is  $week \n";







> Cheers
> 
> Neill
> 
> 
> 
> 
> 
> 
> IMPORTANT NOTICE  This email (including any attachments) is meant only for the 
> intended recipient. It may also contain confidential and privileged information.  If 
> you are not the intended recipient, any reliance on, use, disclosure, distribution 
> or copying of this email or attachments is strictly prohibited. Please notify the 
> sender immediately by email if you have received this message by mistake and delete 
> the email and all attachments. 
> 
> Any views or opinions in this email are solely those of the author and do not 
> necessarily represent those of Trinity Mirror PLC or its associated group companies 
> (hereinafter referred to as "TM Group"). TM Group accept no liability for the 
> content of this email, or for the consequences of any actions taken on the basis of 
> the information provided, unless that information is subsequently confirmed in 
> writing. Although every reasonable effort is made to keep its network free from 
> viruses, TM Group accept no liability for any virus transmitted by this email or any 
> attachments and the recipient should use up-to-date virus checking software. Email 
> to or from this address may be subject to interception or monitoring for operational 
> reasons or for lawful business practices. 
> 
> Trinity Mirror PLC is the parent  company of the Trinity Mirror group of companies 
> and is registered in England No 82548, with its address at One Canada Square, Canary 
> Wharf, London E14 5AP. 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
> 
> 


-- 
Owen


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




Re: Date and Time

2004-01-23 Thread Owen
On Thu, 22 Jan 2004 17:06:58 -0800
"Larry Guest" <[EMAIL PROTECTED]> wrote:


> 
> But rsync does not know how to handle this string, I think when its
> passed to rsync its not text as I see it on the screen.  It cant make
> the dir and pukes.
> 
> I have seen a bunch of stuff out there for sprintf, etc  but no clear
> small little script to do this.
> 
> Thanks
> 


This will give you and answer like MMDDhhmmss for your directory name. Maybe watch 
line wrap

--

#!/usr/bin/perl

$dirname = dirname();
print "$dirname\n";

sub dirname{

my @t=localtime;
my $mon = $t[4]+1;my $yr = $t[5]+1900;
return (sprintf("%04d%02d%02d%02d%02d%02d",$t[5] +1900,$t[4]
+1,$t[3],$t[2],$t[1],$t[0]));

}





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


-- 
Owen


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




Re: Reading tab delimited File & sort everything according item 5 of every line

2004-01-23 Thread Owen
On Fri, 23 Jan 2004 09:36:00 +0100
Bjorn Van Blanckenberg <[EMAIL PROTECTED]> wrote:

> let say that the file contains these items (every item is seperated 
> with a tab)
> 
> one  title   state   name   code1   number
> two  title2   state2   name2   code2   number2
> one  title3   state3   name3   code3   number3
> four  title4   state4   name4   code4   number4
> six  title5   state5   name5   code1   number5
> dip  title6   state6   name6   code1   number6
> fun  title7   state7   name7   code2   number7
> 
> the thing i'am looking for is that it is sorted by item 5 and writes 
> back to the file
> with an extra line if item 5 is different
> 
> so I would come up with:
> 
> one  title   state   name   code1   number
> six  title5   state5   name5   code1   number5
> dip  title6   state6   name6   code1   number6
> 
> two  title2   state2   name2   code2   number2
> fun  title7   state7   name7   code2   number7
> 
> one  title3   state3   name3   code3   number3
> 
> four  title4   state4   name4   code4   number4


Well you can try;
-



#!/usr/bin/perl -w

chomp(@fields = ); # slurp in the file
$lastbit=1;

 @sorted =
 map { $_->[0] }
 sort { $a->[5] cmp $b->[5] }
 map { [ $_ , (split /\t/) ] } @fields;#tab separated fields

foreach (@sorted){
@bits = split;
print "\n" if ($bits[4] ne $lastbit);
print "$_\n";
$lastbit=$bits[4];
}

__DATA__
one title   state   namecode1   10
two title2  state2  name2   code2   21
one title3  state3  name3   code3   13
fourtitle4  state4  name4   code4   14
six title5  state5  name5   code1   number5
dip title6  state6  name6   code1   number6
fun title7  state7  name7   code2   number7

--
and it produces 


21:42:56 [~/perltest]#perl sortdata1.pl

one title   state   namecode1   10
six title5  state5  name5   code1   number5
dip title6  state6  name6   code1   number6

two title2  state2  name2   code2   21
fun title7  state7  name7   code2   number7

one title3  state3  name3   code3   13

fourtitle4  state4  name4   code4   14



 --
Owen

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




Re: Usage of Net:Telnet

2004-01-23 Thread Owen
On Fri, 23 Jan 2004 11:45:08 -
"Singh, Ajit p" <[EMAIL PROTECTED]> wrote:

>Timeout => $secs),
>   Prompt => 'W9-BAS-01');

What is the ) doing on line 17?

-- 
Owen


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




Re: Usage of Net:Telnet

2004-01-23 Thread Owen
On Fri, 23 Jan 2004 13:24:24 -
"Singh, Ajit p" <[EMAIL PROTECTED]> wrote:

> Thanks Owen for your reply.
> 
> that was a typo, however i m getting the below error message now..
> 
> $t = new Net::Telnet (Timeout => 10,
> Input_log => $inlogfileg,
> Output_log => $outlogfile,
> Telnetmode => 1,
> dump_log => $dmplog,
> Timeout => $secs,
>  Prompt => 'W9-BAS-01');
>  #Prompt => '/bash\$ $/');
> $t->open("hostname");
> 
> Error message:
> ignoring bad Prompt argument "W9-BAS-01": missing opening delimiter of match
> operator at Bastelnet.pl line 12

Please don't reply to me personally, reply to the list.

Try something like this

my $t = Net::Telnet->new(Host=>"hostname",
Timeout=>$secs;
Dump_log=>$dump_log); # assign $dump_log

$t->waitfor('/W9-BAS-01/') || die "bad $1";
$t->print ("$whatever");


Read perdoc Net::Telnet

Read the dumplog, it often contains clues as to what is happening




-- 
Owen


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




Re: how to construct 2 consecutive if conditions?

2004-01-24 Thread Owen
On Sat, 24 Jan 2004 17:41:13 -0700
danield <[EMAIL PROTECTED]> wrote:

>
> I do have file where is:
> 
>  Summary Log (generated: Tue Apr  1 22:02:29 MST 2003)
> 
> And I do have a script which goes through this file line by line. The
> first 'if' condition checks whether I have found the line I am
> interested in (Summary log...) The second 'if' then should check whether
> the month is "Apr" and the year is "2003". The script as it is now is
> not correct, since it evaluates the first condition and splits line into
> variables and then skips the second if.
> 
> The script looks like:


I think I understand your request.

Just try this. It reads line by line and has the three "if" conditions for a print. 
See if you can adapt that to your script. Also, chomp is preferred to chop.
-
#!/usr/bin/perl

#use strict, etc as required as per your original script

while(){
print if((/Summary Log/) and (/Apr/) and (/2003/))
}


__DATA__
Summary Log (generated: The Apr  1 22:02:29 MST 2003)
Summary Log (generated: Tue May  1 22:02:29 MST 2003)
Summary Log (generated: Tue Jun  1 22:02:29 MST 2003)
Summary Log (generated: Tue Apr  1 22:02:29 MST 2004)
Summary Log (generated: Tue Apr  1 22:02:29 MST 2004)
Summary Log (generated: The Apr  1 22:02:29 MST 2003)
-- 
Owen


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

2004-01-26 Thread Owen
On Sun, 25 Jan 2004 22:48:55 -0800 (PST)
Joe Echavarria <[EMAIL PROTECTED]> wrote:


>Where can i find a perl code that translate numbers
> to words ?, like 100.00 for "one hundred ..."
>I need it to glue it with some other code.


You might want to look at;

Lingua::EN::Numericalize 
(Replaces English descriptions of numbers with numerals)

Lingua::EN::Numbers 
Converts numeric values into their English string equivalents


-- 
Owen


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




Re: Time::Format

2004-01-26 Thread Owen
On Mon, 26 Jan 2004 14:57:35 -0500
"Paul Kraus" <[EMAIL PROTECTED]> wrote:

> Since I added use Time::Format qw( %time } I get this error on any die
> statement or end of program.
> 
> Everything runs fine and the program works fine it just dumps this at the
> end.
> 
> Can't locate I18N/Langinfo.pm in @INC (@INC contains: C:/Perl/lib
> C:/Perl/site/lib .) at (eval 1) line 30,  line 1.
>   ...propagated at C:\Documents and Settings\pdk\My Documents\perl
> code\customertracking\tracking.pl line 35,  line 45.


>From perldoc Time::Format

If the I18N::Langinfo module is available, Time::Format will return
weekday and month names in the language appropriate for the current locale.  If not, 
English names will be used


So guess you dont have I18N::Langinfo installed



-- 
Owen


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

2004-01-26 Thread Owen
On Mon, 26 Jan 2004 12:13:14 -0800 (PST)
Joe Echavarria <[EMAIL PROTECTED]> wrote:

> What about translating the numbers to spanish string
> equivalent ?

Well try searching CPAN, www.cpan.org
They have modules for Klingon, so they are bound to have spanish modules

Here's one

Lingua::ES::Numeros 
Convierte números a texto en Español (Castellano) 
 


-- 
Owen


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




Re: Zip using Perl

2004-01-28 Thread Owen
On Wed, 28 Jan 2004 15:37:12 -0500
"RL" <[EMAIL PROTECTED]> wrote:

> I would like to "zip" a file using perl script. I used following command:-
> 
> system ("zip  ");
> 
> However this command fails when the filename is more than 8 characters.



I really have no idea.

have you tried 


system ("zip  ")

rename ("eightchr.zip","nine_or_more_characters.zip")


-- 
Owen


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




Different results Command Line/CGI

2004-02-01 Thread Owen

I have this script stolen and modified from somewhere 

#!/usr/bin/perl -w
use strict;
use File::Find;
print "Content-type: text/html\n\n";

my $u=shift;
my $sizes = 0;
# replace this with your absolute path
my $path = "/home/$u/";

find (sub {$sizes += -s ;}, $path);
print  "$sizes\n";


I am logged onto my machine as user owen and am root. From the command line I execute

perl  /var/www/cgi-bin/ff1.cgi owen with the result

--
Content-type: text/html

(warnings snipped)

504137000
---

with rcook as the user in /home the result is 988865

Now when I do 'links http://localhost/cgi-bin/ff1.cgi?owen'

the result is 350200607 (vs 504137000 ???) and 
for user rcook the result is 0 (vs 988865)

du gives me yet another set of answers as does other File::Find type programs I have 
found, but that is not the problem at the moment.

Why do I get  0 for rcook when I run it through the browser?
I suspect the difference is something to do with permissions of the cgi script when 
run as a cgi script but do not know.



Any advice/clues would be most welcome


TIA

-- 
Owen


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




Re: Help with files

2004-02-03 Thread Owen
On Tue, 3 Feb 2004 11:06:08 -0300
"Marcelo" <[EMAIL PROTECTED]> wrote:

> Hi everyone, need help with two things;
> 
> how do you find out if a line is duplicated in a file, and delete it if so.
> 
> how do you delete a line if it has more than x number of characters.


You probably need to define your problem a bit better

How large is the file
What order is it, and does it have to keep that order
Are the duplicate lines sequential or randomly placed


perldoc -q duplicates
perldoc -f length

is initial documentation to read.


The simple process for sequential duplicates is

open the file for reading
open a file for writing
read the file line by line
test if the line read is the same as the last line read
if it is, read the next line, otherwise write the line to file
test if the line has more than x characters
if it is go to the next line, otherwise write to the file
when finished, unlink the initial file
then rename your write file to your read file name.


here is a simple example, printing to stdout


#!/usr/bin/perl -w

while (){
  next if (length($_)>20);
  next if defined $previous and $previous eq $_;
  print;
  $previous = $_;
 }


__DATA__
This is a line
This is a line
This is a line
This is not a line
This is a line This is a line This is a line
This is a line also





-- 
Owen


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




Bouncing mails

2004-02-06 Thread Owen


Al Kaibala  DO YOU READ THIS?

List members,

As administrator of the Linux SIG List, I am getting bounces for mail addressed to 
[EMAIL PROTECTED]

I have sent Al a e-mail previously, but no response. If you look at the headers below, 
it appears to be coming from ta-1-28 which is Al's IP address.

So if anyone sees him, ask him to check out his machine.



Received: from supreme.pcug.org.au (localhost [127.0.0.1])  by pcug.org.au 
(8.12.9/8.12.9/TIP-2.36) with ESMTP id i16682c9013769for <[EMAIL PROTECTED]>; Fri, 
6 Feb 2004 17:08:02 +1100 (EST)
Received: from server.local (ta-1-28.tip.net.au [203.11.71.28]) by pcug.org.au 
(8.12.9/8.12.9/TIP-2.36) with ESMTP id i1667Ec9013610for <[EMAIL PROTECTED]>; Fri, 
6 Feb 2004 17:07:14 +1100 (EST)



-- 
Owen


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




Re: Bouncing mails

2004-02-06 Thread Owen
On Fri, 6 Feb 2004 18:59:13 +1100
Owen <[EMAIL PROTECTED]> wrote:

> 
> 
> Al Kaibala  DO YOU READ THIS?
> 
> List members,




My apologies, senility setting in.


-- 
Owen


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




Re: Newbie that needs some help

2004-02-21 Thread Owen
On Sat, 21 Feb 2004 21:23:13 -0600
Perl Mail User <[EMAIL PROTECTED]> wrote:

> Hello All,
> 
> I have a basic question, I am new to perl, and I would like to try 
> and get a basic question answered, if possible.  I have a file with 
> about 63 lines in it, I am running it through a basic perl program
> that reads every line and prints it to the screen.  I am trying to 
> get the output of each line into an @array, but all I am getting is
> the last line in the file. Any help would be great.
> 
> Script  Like I said it is basic.
> 
> __begin__
> 
> #!/usr/bin/perl
> 
> open(FILE, "file1.txt") || die "Can not open file.  $! \n";
> while ($line = ) {
> if ($line =~ /:58/) {
>   #print $line; ## For Debugging Only
> foreach ($line) {
> @lines = $line;
> }
> }
> }
> print "@lines";
> 
> __end__


I think you need to change 

> foreach ($line) {
> @lines = $line;

to

push(@lines,$line);

Your foreach loop is in the inner most loop, so your @lines is only going to be the 
last line, though the systax is improper.

-- 
Owen


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




Re: target practice -- lottery numbers

2004-02-26 Thread Owen
On 26 Feb 2004 16:54:12 -0500
Cy Kurtz <[EMAIL PROTECTED]> wrote:

> Hi all. I have a little program here that generates a lottery play slip
> for the mega-millions game. It selects 50 of the 52 numbers exactly once
> over 10 tickets of 5 numbers each. It then selects 10 super ball
> numbers, one for each ticket. It then prints it all out(duh).


The snippet below has been modified from an Abigail post and should provide 50/52 
unique numbers.


#!/usr/bin/perl

while (keys %hash < 52) {$hash {int((+rand)*52)+1} = 1}
@array = keys %hash;

#now just get 50 of them
foreach $n(1..50){
print "$array[$n]\n";
}





-- 
Owen


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




Re: trouble with writing to file

2004-03-01 Thread Owen
On Mon, 1 Mar 2004 18:08:08 +0100
incognito <[EMAIL PROTECTED]> wrote:

> open(FH, "> $pkg_filename") or die "could not create $pkg_filename";
> while ($input =~ m/.../) {
> print $1;
> FH->print("$1\n") or die "could not write to $pkg_filename";
> }

I would have thought that to get a $1 out of that you would have needed while ($input 
=~ m/(...)/) ie, brackets around what you wanted to capture.



-- 
Owen


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




Re: Man page for CGI::Request/CGI::Base

2004-03-22 Thread Owen
On Mon, 22 Mar 2004 22:54:13 -0800 (PST)
Mike Ni <[EMAIL PROTECTED]> wrote:


> > If perldoc CGI::Request or perldoc CGI::Base
> > doesnt tell you anything the only place left
> > is the source code of each.

Not having either of those modules I tried an install from cpan

Going to read /root/.cpan/Metadata
  Database was generated on Mon, 22 Mar 2004 05:50:15 GMT
Running install for module CGI::Base

  The module CGI::Base isn't available on CPAN.

  Either the module has not yet been uploaded to CPAN, or it is
  temporary unavailable. Please contact the author to find out
  more about the status. Try 'i CGI::Base'.

cpan> i /CGI::Base/
Module  CGI::Base   (Contact Author The CGI-Perl Developers mailing list 
)
Module  CGI::BasePlus   (Contact Author The CGI-Perl Developers mailing list 
)
2 items found


Now I am curious!

-- 
Owen


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




How to write a Perl module

2004-05-06 Thread Owen

As an exercise in making an LDP How-To as well as confirming my own limited knowledge 
of making a Perl module I wrote.

 http://www.pcug.org.au/~rcook/PerlModule_HOWTO.html

It is for beginners, just "do this" and it should work without any explanation.




-- 
Owen

  
   __0 http://www.pcug.org.au/~rcook/rr.html for rides 
 _ \<,_
(_)./(_)   http://weather.smh.com.au/weather/canberra.html
---
 


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




Re: s/// Vs tr///

2004-04-27 Thread Owen
On Wed, 28 Apr 2004 10:42:01 +0530
"Sumanth Sharma" <[EMAIL PROTECTED]> wrote:

> Can you help me figure out why need tr/// when you have s/// and
> Vice versa ( NO, s/// is more powerful?).

Well I would say that the way they operate is different.

tr/// looks at each character and replaces it

eg, tr/aeiou/-/ replaces all vowels with a -

s/// looks for a pattern and replaces that pattern

eg s/aeiou/-/ replace any pattern of aeiou with a -

Try this

#!/usr/bin/perl -w
use strict;

my $word='aeiou';
$word =~tr/aeiou/-/;
print "translated word is $word\n";

$word='aeiou';
$word =~s/aeiou/-/;
print "substituted word is $word\n";

====
translated word is -
substituted word is -




Owen


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




Substitution/Regex problem

2004-04-29 Thread Owen
I would like to replace all instances of

 @non_space_characters[non_space_characters] with
 $non_space_characters[non_space_characters]

The program below gets the first one only. How do I get the others?

TIA

Owen
---
#!/usr/bin/perl -w
use strict;

my $line;
while (){
$line=$_;
#$line=~s/(@)(\S+)(\[\S+\])/\$$2$3/g;
$line=~s/(@)(\S+\[\S+\])/\$$2/g;

print "$line\n";

}
__DATA__
@[EMAIL PROTECTED]@banana[4];


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




Re: Newbie: regular expression

2004-05-03 Thread Owen
On Mon, 3 May 2004 15:00:20 +0530
"Durai" <[EMAIL PROTECTED]> wrote:

> Hello All,
> 
> I am having the following lines of code to remove "\n" from string.
> 
> $_="Hi. \n This is test string";
> s/
>  (\n)
>  /HI
> /xisg;
> 
> print;
> 
> I expected the output like:
> 
> Hi. HI This is test string
> 
> But I got:
> 
> Hi. HI
>  This is test string


What happens if you try s/\\n/HI/
(untested)

Owen




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




Re: RE : Module to validate credit cards

2004-05-18 Thread Owen
On Tue, 18 May 2004 22:07:16 +0200
"Jose Nyimi" <[EMAIL PROTECTED]> wrote:

> I discovered Business::CreditCard
> http://search.cpan.org/~ivan/Business-CreditCard-0.27/CreditCard.pm

That's a fine module, but you might want to have a separate list of dummy numbers that 
are valid but used for test purposes only. 
4111    is one that comes to mind. 



-- 
Owen

  
   __0 http://www.pcug.org.au/~rcook/rr.html for rides 
 _ \<,_
(_)./(_)   http://weather.smh.com.au/weather/canberra.html
---
 


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




Re: Regx for validating E-Mail addresses

2004-06-24 Thread Owen
On Thu, 24 Jun 2004 13:29:12 +0600
"LRMK" <[EMAIL PROTECTED]> wrote:

> I am using following code to validate e-mail addresses
> 
> if ($mail =~ m/^(\w+(\.|-))*\w+\@(\w+(\.|-)*)+\w+$/){
> valid
> }else{
> invalid
> }

A comprehensive regex for checking e-mail addresses may be found at;

http://www.foad.org/~abigail/Perl/url3.regex




-- 
Owen



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




Re: Regx for validating E-Mail addresses

2004-06-24 Thread Owen
On Thu, 24 Jun 2004 18:17:41 +1000
Owen <[EMAIL PROTECTED]> wrote:

> On Thu, 24 Jun 2004 13:29:12 +0600
> "LRMK" <[EMAIL PROTECTED]> wrote:
> 
> > I am using following code to validate e-mail addresses
> > 
> > if ($mail =~ m/^(\w+(\.|-))*\w+\@(\w+(\.|-)*)+\w+$/){
> > valid
> > }else{
> > invalid
> > }
> 
> A comprehensive regex for checking e-mail addresses may be found at;
> 
> http://www.foad.org/~abigail/Perl/url3.regex



Ooops, that was for URLs, now I can't find the posting to c.l.p.m


Sorry


Owen





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




Re: Pop up calendar

2004-07-12 Thread Owen
On Mon, 12 Jul 2004 00:29:52 -0700 (PDT)
Melis Mutlu <[EMAIL PROTECTED]> wrote:

 
> I have a form with a date field (created by
> CGI::Quickform). I would like to add a pop up calendar
> so I can pick dates easily. Does anybody know how I
> can do that? Is there any module I can use for that?


You might want to look at, and adapt


HTML::Calendar::Simple - A simple html calendar
DESCRIPTION
This is a simple module which will make an HTML representation of a
given month. You can add links to individual days, or in fact, any sort
of information you want.

but as it involves installing a module somewhere, it may not suit.

Randal Schwartz uses a similar module in
http://www.stonehenge.com/merlyn/WebTechniques/col66.html  and Bill Jones wrote 
http://backpan.cpan.org/authors/id/S/SN/SNEEX/cal.perl_v2A

I don't think you will get an off the shelf answer to your requirement. It's not too 
dificult to write your own.




-- 
Owen


  
__0 http://www.pcug.org.au/~rcook/rr.html for rides
  _ \<,_
 (_)./(_)   http://www.bom.gov.au/weather/act/forecasts.shtml
 --- 

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




Re: where does IO::File come from?

2004-07-20 Thread Owen
On Tue, 20 Jul 2004 15:24:03 -0500
"Christopher J. Bottaro" <[EMAIL PROTECTED]> wrote:

> i use IO::File all the time in my perl scripts.  i never installed any
> IO::File module from cpan.org and i don't see it anywhere in /usr/lib/perl. 
> also, its not listed in my book "programming perl" as a standard module.
> 
> so where does it come from and how am i able to use it?
> 
> thanks for the help.

If you are on a linux type system, try this

find `perl -e 'print "@INC"'` -name '*.pm' -print|grep IO

See what it prints out



-- 
Owen



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




Re: How to update perl5?

2004-08-07 Thread Owen
On Sat, 07 Aug 2004 17:29:34 +0800
Le Sandy Sun <[EMAIL PROTECTED]> wrote:

> Well,there are two perl5 in my solairs mechine.
> The defualt is perl5,v5.003 and another is perl5,v5.6.1
> My question is how can I change the defualt perl5 from v5.003 to v5.6.1?


You will probably find a symbolic link from /usr/bin/perl5-003 to /usr/bin/perl

Delete that and make a new link from /usr/bin/perl5.6.1 to /usr/bin/perl

Look around, may be it is in /usr/local/bin


-- 
Owen



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




Re: param help!

2004-08-14 Thread Owen
On Sat, 14 Aug 2004 16:37:18 +0530
Shillong Dotcom <[EMAIL PROTECTED]> wrote:

> Hi
> 
> I am very very new to perl. And after lots of work I did script a perl
> file to handle a online form (products order form). However, I am
> stuck at a point. I tried my best but could not get thru.
> 
> The form is located at: http://www.kevincoffey.com/order.htm
> 
> When I select a different shipping adrress, it shows not work!
> 
> Can someone plshelp me?


You are saying with this line


if ($query -> param ("Shipping_Preference") == "TRUE"){
print "SEND TO ABOVE ADDRESS\n";


"If a shipping address is ticked, then SEND TO ABOVE ADDRESS"

and then skip the printing of the alternate address


I think your logic is wrong, I think TRUE needs to be replaced with FALSE



-- 
Owen


  
__0 http://www.pcug.org.au/~rcook/rr.html for rides
  _ \<,_
 (_)./(_)   http://www.bom.gov.au/weather/act/forecasts.shtml
 --- 

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




Re: utility to install modules

2004-08-25 Thread Owen
On Wed, 25 Aug 2004 14:54:58 -0700 (PDT)
Joe Echavarria <[EMAIL PROTECTED]> wrote:

> hell there,
> 
>   I want to know if there is an utility that i could
> use to install the perl modules directly from CPAN on
> a sun solaris box.
>   It is something like ppm on windows activeperl.


yes, it is inperldoc CPAN



Owen


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




Re: Problem configuring MCPAN

2004-08-26 Thread Owen
On Thu, 26 Aug 2004 09:45:57 -0700 (PDT)
Joe Echavarria <[EMAIL PROTECTED]> wrote:

>When i try to configure the MCPAN i get this
> error..:

> Connecting to ftp.perl.org:21... 
> ftp.perl.org: Host not found
> Issuing "/usr/bin/ftp -n"
> ftp.perl.org: unknown host or invalid literal address
> Not connected.



I don't know but wonder what "Not connected" means. Seems like a good reason for 
failure.



-- 
Owen



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




Re: getting the IP address of a visitor to a site

2003-09-11 Thread Owen
On Thu, 11 Sep 2003 12:46:24 +
"Anadi Taylor" <[EMAIL PROTECTED]> wrote:

>
> I am writting a hit counter and would like to get the IP address of a 
> visitor to my site, can anyone point me in the right direction please. 
You might look at Enviroment variables, partcicularly

$ENV{REMOTE_ADDR} or maybe $ENV{REMOTE_HOST}



-- 
Owen

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



Re: Getting started in Perl for Windows

2003-09-25 Thread Owen
On Thu, 25 Sep 2003 13:05:28 +0100
"Dillon, John" <[EMAIL PROTECTED]> wrote:

> 'Can't locate Email/Find.pm in @INC <@INC contains: C:/Perl/lib
> C:/Perl/site/lib.> at F:\getemails.ph line 1'
> 
> Indeed line 1 does say:
> 
>   'use Email::Find;'
> 
> Hm.  It seems I haven't installed Email::Find, despite my efforts.
> 
> I suppose there might be some way to check this?

Something I found in this list or another, type this at the command promt, and you 
will get a list of all installed modules. (Note, it is all on one line)

perl -MExtUtils::Installed -le 'print for ExtUtils::Installed->new->modules;'




Owen


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



Re: easiest `cat` in perl

2003-10-02 Thread Owen
On Wed, 01 Oct 2003 23:14:00 -0700
Bryan Harris <[EMAIL PROTECTED]> wrote:

> 
> What I'm interested in is what's the easiest way to print the contents of a
> file?  For example, if I want to output my header file, "header.incl", how
> can I print the contents of that file the easiest (and most generally
> compatible)?

Firstly specify the file;

$file = "/location/of/header.incl";

Next open it for reading

open (FH, "$file") or die "Cannot open file $file $!";  


Lastly, go through the file line by line and print them


while(){
print "$_"; #$_ is the value of the current line
}

You may wish to change the print line to   print "$_\n";if you want a new line 
on your html for each new line in your file. 



Owen







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



Re: CPAN install failure...

2003-10-11 Thread Owen
On Fri, 10 Oct 2003 12:11:42 -0400
Rick Bragg <[EMAIL PROTECTED]> wrote:

> Hi,
> 
> I just tried to install HTML::Parser on my Redhat9 system
> and I got the following.
> 
> Should I just force it? if so how is that done...

I have just force installed a number of modules and they seem to work ok. All I can 
suggest is to try it, you have little to lose.


Owen

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



Re: Seeding a Random Number Generator

2003-12-07 Thread Owen
On Sun, 07 Dec 2003 03:29:02 -0800
"John W. Krahn" <[EMAIL PROTECTED]> wrote:


> I did a "grep -i -r 'seed' *.c" and the only hit I got was in pp.c.


FWIW

[EMAIL PROTECTED] perl-5.8.2]# grep -r seed

util.c:Perl_seed(pTHX)
util.c:* is enough real entropy to fill the seed. */
util.c:Perl_get_hash_seed(pTHX)
util.c: UV myseed = 0;
util.c:   myseed = (UV)Atoul(s);
util.c:   /* Compute a random seed */
util.c:   (void)seedDrand01((Rand_seed_t)seed());
util.c:   myseed = (UV)(Drand01() * (NV)UV_MAX);
util.c:   myseed +=
util.c:   if (myseed == 0) { /* Superparanoia. */
util.c:   myseed = (UV)(Drand01() * (NV)UV_MAX); /* One more chance. */
util.c:   if (myseed == 0)
util.c: PL_rehash_seed_set = TRUE;
util.c: return myseed;



 --
Owen



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




Re: stripping last field of a carriage return

2003-12-07 Thread Owen
On Sun, 07 Dec 2003 12:20:46 -0700
"Michael J. Golini" <[EMAIL PROTECTED]> wrote:

> I have tried to strip the carriage return of the last field 
> 
> $field[8] =~ s/\015//g;

You have to know how your original data was created. In Windows, each line is 
terminated by "\r\n" (carriage return followed by line feed). In Unix, lines end only 
in "\n". On old Mac systems, lines end only in"\r".
You might want to look at it in a hex editor.

Perl's record separator is $/ You can use this for portable programming. 
Unix is ASCII \012
Windows is ASCII \015\012
Mac is ASCII \015


chomp could be the way to go. See perldoc chomp



 --
Owen


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




Re: dbmopen problem

2003-12-10 Thread Owen
On Mon, 08 Dec 2003 01:06:04 -0500
Joel Newkirk <[EMAIL PROTECTED]> wrote:

> dbmopen (%PLRULES, "/var/szs/rules.dbm", undef) or die $!;
> I die, with "No such file or directory".

No idea but;

I would tend to beleive the "No such file or directory" statement.
you can do an ls -la /var/szs/rules.dbm ?

I would have written the "or die $!;" as or die "Can't dbmopen $!\n"; but then maybe 
you only have one die statement to worry about?

I have never seen "dbmopen (%PLRULES, "/var/szs/rules.dbm", undef)" normally I see 
dbmopen (%PLRULES, "/var/szs/rules.dbm", 0666) or die.
%PLRULES=();

The syntax for dbmopen is Arrayname DB_filename mode 
so I just wonder if undef is a mode?


-- 
Owen


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




Re: Use of uninitialized value in pattern match (m//) at ./getopt.pl line 14.

2003-12-14 Thread Owen
On Sat, 13 Dec 2003 18:12:17 +0100
Jerry Rocteur <[EMAIL PROTECTED]> wrote:

> I'm trying to be a good boy and use strict and warnings ..
> 
> The more I do, the more I feel I'm wasting so much time and should 
> become productive, my code looks full of 'my'


Because so many people in c.l.p.m said "use strict;" I decided to take the plunge and 
use it.

Until I worked out what was going on, I, like you, thought it was a waste of time.

That and warnings are a great pair in getting programs to run and I suppose "Use of 
unitialized..." is the most common warning. There is always a bit of pleasure in 
tracking down the reason for that one.

See http://perl.abigail.nl/Musings/coding_guidelines.html suggested perl coding 
practices
 
Hang on in there, it's worth it. 




-- 
Owen


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




Re: hash sorting

2003-12-14 Thread Owen
On Mon, 15 Dec 2003 00:17:17 -0800
"B. Rothstein" <[EMAIL PROTECTED]> wrote:

> I have a hash where each key is a first name linked to a last name, any
> suggestions on how to loop through the hash to sort the list by the last
> names? 


Something like this perhaps?

#!/usr/bin/perl -w

use strict;

my %h = (
 Jo => "Blow",
 Al => "Smith",
 Ok => "Corale"
 );

foreach my  $person(sort {$h{$a} cmp $h{$b} }
keys %h)

{
print "$person is $h{$person}\n";
}

__END__
Jo is Blow
Ok is Corale
Al is Smith


Straight from the Perl Cookbook

-- 
Owen


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




Re: Ending a compound statement

2003-12-18 Thread Owen
On Thu, 18 Dec 2003 13:35:17 -0600
Kenton Brede <[EMAIL PROTECTED]> wrote:

> Does a compound statement need to end with an "else" ?

Technically No. But what if you haven't covered all the options?


So I would suggest adding after the last elsif

} elsif ($string[0] =~ m/^\w/) { # limit search string
get_record($string[0]);
}


else {print "Mmmm something real odd here\n"}


-- 
Owen


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




Re: where to look for modules?

2003-12-20 Thread Owen
On Sat, 20 Dec 2003 04:33:24 -0600
christopher j bottaro <[EMAIL PROTECTED]> wrote:

> on my system, perl looks for modules in /usr/lib/perl5/5.8.0/.  how can i 
> specify an additional path to look for modules in?  say for 
> instance, /home/cjb/perlmodules/ in addition to the aforementioned path.


I think the easiest for you would be to;

use Modules;# as found in /usr/lib/perl5/5.8.0/

use lib '/home/cjb/perlmodules';   #followed by
use MyModule;   #and/or any other module you have there


-- 
Owen


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




Re: where to look for modules?

2003-12-21 Thread Owen
On Sun, 21 Dec 2003 13:49:59 -0600
christopher j bottaro <[EMAIL PROTECTED]> wrote:

> On Saturday 20 December 2003 05:05 am, Owen wrote:
> > I think the easiest for you would be to;
> >
> > use Modules;# as found in /usr/lib/perl5/5.8.0/
> >
> > use lib '/home/cjb/perlmodules';   #followed by
> > use MyModule;   #and/or any other module you have there
> 
> great, that worked perfectly...=)  i'm having a hard time finding 
> documentation for "use lib".  i looked at "use" in perlfunc and i also looked 
> at perlmodlib.


Like so many others, accessing information out of perldoc is still a bit of mystery to 
me. However in this case, something popped up with

perldoc  -q path

which might be a start


-- 
Owen


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




Re: Loading Modules

2003-12-22 Thread Owen
On Mon, 22 Dec 2003 22:06:33 +1300
Support <[EMAIL PROTECTED]> wrote:

>  I then then I get 
> a ' subroutine not defined '
> What am I doing wrong. 

Probably not defining a sub routine.

If your script is not too big, why not post it, and maybe we can help you find the 
error of your ways



-- 
Owen


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




Re: Loading Modules

2003-12-22 Thread Owen
On Tue, 23 Dec 2003 08:50:27 +1300
Support <[EMAIL PROTECTED]> wrote:

> The module is Pcalc.pm from CPAN. My website host does not have it in their 
> server and suggested I place it in the same directory as my original script 
> and just call it from there ??. I take then I do not have to go through all 
> the install carry-on like 'makefile', etc on to have install itself in the 
> correct place on the server. The module appears to be complete as it is. 
> Sorry people, I have read a bit about modules, but do not yet fully understand.


> >
> >If your script is not too big, why not post it, and maybe we can help you 
> >find the error of your ways


I don't know if Pcalc needs to be made or not, but assuming it doesn't, place it as 
suggested in your script directory, now, your program should look like this as 
modified for your OS and paths


#/usr/bin/perl -w

use lib '/path/to/module';
use Pcalc;

# rest of program


ps. I just checked
cpan> i /Pcalc/
DistributionS/ST/STBEY/Date-Pcalc-1.2.tar.gz
Module  Date::Pcalc (S/ST/STBEY/Date-Pcalc-1.2.tar.gz)
2 items found

So is that the module you are trying to use?
If so you might (because I don't know) need to make a directory "Date" in your working 
directory, place Pcalc in that Date directory and the use lines then becomes.

use lib '/path/to/working_directory';
use Date::Pcalc


Please corresspond to the list, not me personnally


-- 
Owen


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




Re: Loading Modules - More

2003-12-22 Thread Owen
On Tue, 23 Dec 2003 09:53:09 +1300
Support <[EMAIL PROTECTED]> wrote:

> use Pcalc qw(Delta_Days Add_Delta_Days Date_to_Days leap_year check_date);


See my previous message, you need to make a a directory "Date" in your working 
directory and place Pcalc in there

 use Date::Pcalc qw(Delta_Days Add_Delta_Days Date_to_Days leap_year check_date);


(just installed it, and looks like it searches for things in Date::Pcalc so if the 
Date directory isn't there you are in trouble)

 

-- 
Owen


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




Re: Problem with READDIR

2003-12-30 Thread Owen
On Tue, 30 Dec 2003 19:07:26 -0800
"Perl" <[EMAIL PROTECTED]> wrote:

> $iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1';
> opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS:  $!\n";
> 
> my @files = grep /\.log$/, readdir LOGS;
> @files = sort { -M $a <=> -M $b } @files;
> $active_log = $files[-1];  # this should be the newest file rather than
> a log in the local directory that the script is running from.



I was unable to duplicate your problem. Made 5 files 1.log .. 5.log  that order and in 
a faraway directory, and then 6.log in the working directory. 

"5.log" came up every time


-- 
Owen


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




Re: Problem with READDIR

2003-12-31 Thread Owen
On Tue, 30 Dec 2003 19:07:26 -0800
"Perl" <[EMAIL PROTECTED]> wrote:

> I have a problem with the following block of code. It works fine when
> there isn't a *.log file in the same directory as the script  but when
> there is, it always returns that log as the newest file and ignores the
> list of files it retrieves from the remote server. 
> 
> I debugged this and found that the READDIR is working but the last
> element in the list is the log file that is in the script directory. 
> 
> What can I do to make sure I get the list of *.log files on the remote
> machine regardless of what exists in my working local directory?

> $iisdir = '\\\server01\c$\winnt\system32\logfiles\W3SVC1';
> opendir LOGS, "$iisdir" or die "Directory error for IIS LOGS:  $!\n";
> 
> my @files = grep /\.log$/, readdir LOGS;
> @files = sort { -M $a <=> -M $b } @files;
> $active_log = $files[-1];  # this should be the newest file rather 

instead of the above three lines, try

@files = sort {-M $b <=> -M $a } grep -f,<$iisdir/*.log>;
#in windows that might have to be grep -f,<$iisdir\*.log>
$active_log = $files[-1];

That ensures you are reading the directory

Are you using the -w switch? if not do so as it will report warnings which should give 
you clues as to why it is not working.

You wont have to do the opendir bit then


--

Owen

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




Re: Help find info for CPAN update config questions

2004-01-03 Thread Owen
On Thu, 1 Jan 2004 05:18:00 -0800 (PST)
J Ingersoll <[EMAIL PROTECTED]> wrote:

> IS THERE a manual / document somewhere that explains in a little
> detail what is being asked in this config process?

perldoc CPAN

That will answer all your questions


-- 
Owen


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




Re: utc to local time

2004-01-07 Thread Owen
On Wed, 7 Jan 2004 15:43:05 -0500
"Paul Kraus" <[EMAIL PROTECTED]> wrote:

> How can I convert a utc time stamp to a perl standard time stamp for my
> timezone?


Can you show what *your* UTC timestamp looks like

Can you give an example of a perl standard time stamp format



-- 
Owen


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




Re: Day of the week by accepting date from User

2004-01-20 Thread Owen
On Tue, 20 Jan 2004 13:36:39 +0530
"Mallik" <[EMAIL PROTECTED]> wrote:

> Dear Friends,
> 
> How to calculate the Day of the week for a given date
> in PERL.
> 
> Please provide me any code available that doesn't require
> any other modules to be installed.

Try this


#!/usr/bin/perl -w

@t = localtime;
$y=$t[5]+1900; $m=sprintf("%0.2d",$t[4]+1); $d=sprintf("%0.2d",$t[3]);

print "Day of week is $t[6]\tMMDD is $y$m$d\n";

#--




-- 
Owen


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




Re: counters for lines

2004-01-20 Thread Owen
On Tue, 20 Jan 2004 13:39:44 -0500
"Anthony J Segelhorst" <[EMAIL PROTECTED]> wrote:

> I have the following output, and each value that is separated by comma is 
> a variable:
> 
> servera,serverb,109,aix4-r1,server
> servera,serverb,109,aix4-r1,server
> servera,serverb,109,aix4-r1,server
> servera,serverb,109,aix4-r1,server
> servera,serverb,109,aix4-r1,server
> servera,serverb,109,hpux10,server
> servera,serverb,109,solaris2,server
 
> 
> I am trying to set up a counter that would actually output the data to be:
> 
> servera,serverb,109,aix4-r1,server,5
> servera,serverb,109,hpux10,server,1
> servera,serverb,109,solaris2,server,10
> 
> Does anyone any suggestion on how to set up a counter to count the lines 
> until a different line shows up.  I already have the list sorted, so I 



system ("uniq $file_with_duplicates $file_sans_duplicates");

Then work on $file_sans_duplicates

-- 
Owen


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




Re: substitute math

2008-12-20 Thread Owen
> Hi,
>
> I have a variable for which I ultimately want to substitute w/ some
> math. Is there a way to get the result "6"?
>
> my $number=123;
> $number =~s/123/1+2+3/s; #This method results in "1+2+3", not the "6"
> I am looking for
> print "$number";


Run this program and see if you can see what is going on.


Owen

===


#!/usr/bin/perl -w

use strict;

my $number = 123;
my $total  = 0;
my @bits   = split //, $number;

print "$bits[0] $bits[1] $bits[2]\n";

my $added = $bits[0] + $bits[1] + $bits[2];

print "$added\n";

foreach my $nr (@bits) {
$total = $total + $nr;
}

print "$total\n";

===


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




Re: Perl garbage collector

2008-12-22 Thread Owen


> This is hardly a beginner question, and as such is a bit out of scope
> for this list. If you're really interested in Perl internals, you'll
> probably want to check out the alt.lang.perl.misc newsgroup.


comp.lang.perl.misc might be better. I think Randal S is the only one
to look at the alt group




Owen


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




Re: make command throws error "Perl script no found" C:/Program No such file or directory

2009-01-06 Thread Owen
> Hi,
>
> I have perl5.10.0 installed under C:/ and using bash prompt to run a
> make command.

How are you doing that?

>
> When I issue the make command it throws error
>
> "Perl Script not found" C:/Program no such file or directory

Where is the script that you are trying to run?

>
> Perl is not installed in Program files it under c:

It is not worried about perl, it is worried about the script

>
> Also I do understand it could be a spacing problem due to which it is
> not able to get Program Files.
> But Iam sure what it is trying to find in program files.
>
> I have C:/Perl/bin/perl5.10.0 added to my PATH variable.
>
> How do I sort out this issue.
> Or does program files contain some other requirement needed by the
> make file.
> Please let me know.



What is the make file? Note that 'make' is not a perl command.



Owen


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




Re: make command throws error "Perl script no found" C:/Program No such file or directory

2009-01-08 Thread Owen
> On Jan 6, 5:32 pm, rc...@pcug.org.au (Owen) wrote:
>> > Hi,
>>
>> > I have perl5.10.0 installed under C:/ and using bash prompt to run
>> a
>> >makecommand.
>>
>> How are you doing that?
>>
>>
>>
>> > When I issue themakecommandit throws error
>>
>> > "Perl Script not found" C:/Program no such file or directory
>>
>> Where is the script that you are trying to run?
>>
>>
>>
>> > Perl is not installed in Program files it under c:
>>
>> It is not worried about perl, it is worried about the script
>>
>>
>>
>> > Also I do understand it could be a spacing problem due to which it
>> is
>> > not able to get Program Files.
>> > But Iam sure what it is trying to find in program files.
>>
>> > I have C:/Perl/bin/perl5.10.0 added to my PATH variable.
>>
>> > How do I sort out this issue.
>> > Or does program files contain some other requirement needed by the
>> >makefile.
>> > Please let me know.
>>
>> What is themakefile? Note that 'make' is not a perlcommand.
>>
>> Owen
>
> Hi,
>
> Iam running a windows machine and using cgywin.I need to run a
> couple of bash commands in windows environment as it is the
> requirement of the installation kit.
> Basic requirements that is needed for instaaltion are
> cgywin
> VC++
> Perl
>
> Installed those and when I need to run a make command in one
> particular directory of the kit it throws me this error.




I do not think it is possible to help you.

There is not enough information on what you are doing

Is there a forum for the program you are trying to install?

Look for the perl script and try and locate where it is. Go to that
directory and then run the make command

Owen







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




Re: Floating point question

2009-01-13 Thread Owen
> Hi,
> I would like to divide a floating point number into its whole and
fractional
> parts.
> So,
> ($w, $f)= some_subroutine(12.735)
> assigns 12 to $w and 0.735 to $f.
>
> Any easy perlish way of doing this?


Someone no doubt will have a one liner, but here is a logical way of
achieving the result


#!/usr/bin/perl -w

use strict;

my $nr = "12.75";

my ( $whole, $part ) = ( int($nr), $nr - int($nr) );

print "$whole   $part\n ";




Owen





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




Re: how to insert records into table in oracle database.

2009-01-17 Thread Owen
>
> Hi,
>   Can some one help me how to insert records into oracle database
> tables using Perl script?
>



perldoc DBI is worth the read, then read the driver documentation for
Oracle (it would be something like DBD::Oracle)


Owen





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




Re: What does MakeFile do?

2009-01-18 Thread Owen
> Which is obviously a real beginner question. I have googled around,
> but all the info I have found assumes you have access to the server.
>
> My sites are shared hosting accounts located at Earthlink, Verio,
> GoDaddy, etc. I have used a number of scripts which I can use just by
> ftp uploading text files and changing permissions. Now I have a script
> (a module actually) I would like to use which arrives as a package
> that needs to be installed with a MakeFile.PL
>
> First, how can I install this module?
>
> Or should the .pm file located in the package work just by uploading?
>
> But more generally, what does make do?
>
> Is there a way to do it locally (on MacOSX) and then upload? Or is the
> installation server specific? (I did try it via Terminal, but it threw
> an error and did not complete.)


When you download a package, the first step is to unarchive it.

The second step is to read the INSTALL which will tell you what to do

What is the module?

The reason for this is that some modules are architecture dependant
and must be compiled against your 'server'

If you get an error message, keep it and if you don't understand it,
post it verbatim so others may help you

Owen


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




Re: Perl script modification

2009-01-22 Thread Owen
On Thu, 22 Jan 2009 06:21:32 -0800 (PST)
melbou...@gmail.com wrote:

> I have a Perl script that I run and the out come as showing below:
> 
>   Reading: server 1\08121100.mls
> Log chain 2:
>   Reading: server 2\08120700.mls
>   Reading: server 2\08120900.mls
>   Reading: server 2\08121100.mls
> Log chain 3:
>   Reading: server 3\08120700.mls
>   Reading: server 3\08120900.mls
>   Reading: server 3\08121100.mls
> 
> # Successful Syncs:2535
> # Failed Syncs:  34
> 
> Total: 2569
> 
> Average Sync Time:22.05 sec
> 
> However, it’s only on print screen and I would like to do the
> following:
> 1.Save it as an excel file
> 2.Access another file let’s call it Mark in the path
> (C:\Mark.xls) with error codes to show me the Failed Syncs errors.
> I’m very new on this Perl scripting please help on it






For starters you may wish to read the documentation for print

#  perldoc -f print

Next you might want to think about what you really want to do, perhaps
an output that can be opened by excel and then saved in excel format

Lastly, you will need to make a table of errors that can be looked up,
a hash table perhaps? 

# perldoc -q hash should prove informative reading

As you have not shown any code,  it maybe best for you to try
modifiying the script, and if you have any failures, report them when
seeking further help



Owen

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




Re: use vs require

2009-01-22 Thread Owen
> Hi Chas,
>
> Can you give me an example when one would be used over the other? So,
> is
> require used more for efficiency, so we load the module only if we
> need it?
> Thanks,
> -Ben


Bit of a conundrum there, if you don't need a module, why include it
in your program.

Anyway you might have your own local subroutines to suit your
environment and procedures and may or may not be used by your main
programs . Place them in a perl program and register the program with
a 'require' statement.

If you get real keen, you can make a private module out of your local
subroutines.

I have a general purpose perl program where I lump all my odd
requirements, the main one being 'trim' (a la php) for stripping
leading and trailing spaces and some odd date formatting for my own
use.

Owen



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




Re: Is there a way to un-install modules?

2009-01-23 Thread Owen
> I know this is going to sound odd, but I've installed some modules
> using
> the CPAN module and I now want to uninstall them or put them into a
> state where they are no longer detected.  Is there a way to do this?


Probably the easiest way is to find the module which will be called  
something.pm and remove it

For example if you installed File::Copy, you would find that in one of
your perl directories as  ../File/Copy.pm

The @INC search engine will never find it, but who else do you wish
not to find it?

chmod 000 would probably work as well though I haven't tried that



Owen


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




Re: a question related to file selection

2009-01-23 Thread Owen
On Thu, 22 Jan 2009 17:16:00 -0500
"Li, Aiguo (NIH/NCI) [E]"  wrote:

> Hi all,
> 
>  
> 
> I need copy files from a directory daily to a folder.  How can I
> select files based on dates that were created?

It will depend on the file naming format, for example, if the files are
named 20090123.blah.bz2, then you could collect all those files out of
the directory with something like;


opendir( DB_DIR, $db_dir ); # where $db_dir has been assigned earlier
my @files = grep { /\d{8}/ } readdir(DB_DIR);

You might then want to do the same for the receiving directory and then
read FAQ4.41 "How can I remove duplicate elements from a list or array'

and adapt with File::Copy to do the copy bit.

However I wouldn't bother with perl in this case, simply use rsync in
a cron job to update your copy directory.


Owen 

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




Re: Loading results of pattern match into an array - help please

2009-01-23 Thread Owen
> I am trying to split a very long fixed lenght record into its
> constituents, and then load them into an array. I have patterns like
> '^
> (.{3})(.{24})(.{6})...' which gets teh fields into $1, $2, $3 etc. I
> am stumped however as to how to get them into an array in a general
> way. With 'use strict' turned off I can force it with the ugly ${$i}
> construct in a loop, but I would prefer something that was 'strict'
> compatible. I havebasic. read the perodlc on @-, %-, %+, and none seem
> to do what I want - but that probably because I am missing something
>
> So, any help gratefully accepted



Perhaps if you gave an example of your fixed length record we could
help a bit better

So lets say your fixed length record is 80 characters in length

And let say you want it broken into 3, 24, 6, 7, 40 size elements.

Then use unpack ( see perldoc -f unpack )

You would do something like this


my $record = $_; # however you get the record

my ( $bit1, $bit2, $bit3, $bit4, $bit5 ) = unpack "A3 A24 A6 A7 A40",
$record;


If you wish to get it out by regular expression, then

my @array = ($1,$2, ... $5);

print "$array[0],$array[1], ... $array[4]\n";






Owen


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




Re: What does MakeFile do?

2009-01-28 Thread Owen
>>Which is obviously a real beginner question. I have googled around,
>> but all the info I have found assumes you have access to the server.
>>
>>My sites are shared hosting accounts located at Earthlink, Verio,
>> GoDaddy, etc. I have used a number of scripts which I can use just
by ftp uploading text files and changing permissions. Now I have a
script (a module actually) I would like to use which arrives as a
package that needs to be installed with a MakeFile.PL
>>
>>First, how can I install this module?
>>
>
> Well, I just copied the .pm files up to folders on the remote server
and changed permissions. Before I had the folder organization wrong.
In the calling file I used use lib '.'; to get the dependencies.
>
> So my question still stands: What does MakeFile do that just copying
the .pm files doesn't?



As I stated earlier, if the module is architecture dependent the make
builds against the architecture.


Also, you get the documentation with make, guess you cant do a
'perldoc module' with your installation. Of course, that may not
matter



Owen




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




Re: very basic questions

2009-01-28 Thread Owen
> i am completely new to perl, can you explain to me the following line
> of
> code in red.
>
> how does this line of code grab a time value and assign it to $ time,
>
> how does assigment happend in this conditiona statement.
>
>
>
> while (<>)
> {
>  chop;
>  # Grab the time
>  next unless ($time) = /(\d+:\d+:\d+\,\d+)/;
>



I don't see any line in red :-(


I presume time is written in a format such as :MM:DD,HH ( eg
2009:01:29,15 )

/(\d+:\d+:\d+\,\d+)/ is therefore the regular expression that looks
for digits separated by colons and finally a comma

\d+: is any number of digits followed by a :

/(\d+:\d+:\d+\,\d+)/ will match 2009:01:29,15 but not 2009:01:29:15

Once a match is made, an assignment is made, otherwise  $time would be
undefined or the value of the last match



Owen


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




RE: Query in Perl Programming

2009-01-30 Thread Owen
>
> Hi Rob,
>
> When I set the date to 30-Jan-2009 and run the code given below,
>
> Eg :
>
> When dates are set as :
>
> my $days1 = epoch_days('30-Jan-09');
> my $days2 = epoch_days('29-Feb-2009');
>
> I get the below error.
>
> hpcll402:/home/raji/perl>./date2.pl
> Day '30' out of range 1..28 at ./date2.pl line 35
>


Feb 2009 has 29 fays?


Owen


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




RE: Query in Perl Programming

2009-01-30 Thread Owen
>
> Get the same error, when the date is set to
>
> my $days1 = epoch_days('30-Jan-09');
> my $days2 = epoch_days('14-Feb-2009');
>
> Day '30' out of range 1..28 at ./date2.pl line 35
>
> -Rajini
>
>
>
>
>
>
>>-Original Message-
>>From: Owen [mailto:rc...@pcug.org.au]
>>Sent: Friday, January 30, 2009 4:09 PM
>>To: S, Rajini (STSD)
>>Cc: Perl Beginners
>>Subject: RE: Query in Perl Programming
>>
>>>
>>> Hi Rob,
>>>
>>> When I set the date to 30-Jan-2009 and run the code given below,
>>>
>>> Eg :
>>>
>>> When dates are set as :
>>>
>>> my $days1 = epoch_days('30-Jan-09');
>>> my $days2 = epoch_days('29-Feb-2009');
>>>
>>> I get the below error.
>>>
>>> hpcll402:/home/raji/perl>./date2.pl
>>> Day '30' out of range 1..28 at ./date2.pl line 35
>>>
>>
>>
>>Feb 2009 has 29 fays?
>

OK, well it looks like your program is thinking Jan is February.

Show us your program


Owen


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




Re: bash in perl

2009-02-07 Thread Owen
> Hello,
>
> I try to write the name of the current directory in $x:
>
> $x = system ("pwd");
>
> But it doesn't work. It also doesn't work in all these combinations:

> $x = 'system("pwd")';
> $x = system("`pwd`");
>
> Can You help me to write the result of 'pwd' in $x?


Where is 'pwd'?

You will find it in /usr/bin probably, just look

Then do your system("/usr/bin")

Generally though you might prefer to specify those commands earlier, eg,

my $pwd = '/bin/pwd';

and then do asystem ("$pwd");

I think the failure occurs because perls environment is not the same
as yours.



Owen





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




RE: Query in Perl Programming

2009-02-22 Thread Owen
>
> Hi Rob,
>
>  When I included the below code in my script, I
>  am getting below errors.
>
> Use of uninitialized value in integer ge (>=) at
> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 73.
> Use of uninitialized value in integer lt (<) at
> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 73.
> Use of uninitialized value in integer ge (>=) at
> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 73.
> Use of uninitialized value in integer gt (>) at
> /usr/local/lib/perl5/5.8.0/Time/Local.pm line 77.
>
> Any idea, why I am getting above errors ?


Yes

Because you are not passing the integers required by your module
Time::Local

You are doing something wrong with your parsing or date extraction.

Do you have a sample code snippet reproduces those errors and that you
can post here ?




Owen



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




RE: Query in Perl Programming

2009-02-22 Thread Owen
>
> Hi Owen,
>
> My code is as follows :
>
> use strict;
> use warnings;
> use Time::Local;
>
> $days1 = epoch_days('30-Jan-09');
> $days2 = epoch_days('16-Feb-09');
>
> $day = $days1 - $days2;
>
> print "Difference: @{[$days1 - $days2]} days\n";
>
> BEGIN {
>
>   my %month_num = do {
> my $n = 0;
> map(($_, $n++), qw/jan feb mar apr may jun jul aug sep oct nov
> dec/);
>   };
>
>   sub epoch_days {
>
> my @dmy = split /-/, shift;
> $dmy[1] = $month_num{lc $dmy[1]} || 0;
>   return timelocal(0, 0, 0, @dmy) / (24 * 60 * 60);
>   }
> }



I bet that is not your code!

Try # perl -c scriptname

and that will be the first fix


Owen


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




RE: Query in Perl Programming

2009-02-22 Thread Owen
>
> #perl -c 

RE: Query in Perl Programming

2009-02-22 Thread Owen
>
> Yeah, the script posted below is part of the code
> In my script.
>
> After including the below code, when I ran the script,
> I am getting the "uninitialized value" errors.



Nope


Do the following


Copy the code you posted to a new file

add #!/usr/bin/perl to the first line

then run perl -c


What is the result?


Owen


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




Re: Query in Perl Programming

2009-02-24 Thread Owen
On Tue, 24 Feb 2009 09:58:00 +
"S, Rajini (STSD)"  wrote:

> 
> My code in the program is : 

That all seems to work. If you ever have problems getting a program to
work, it is often advisable to add some debugging aids, and I have
added a few to your code below so you might get the idea.


uninitialized errors, I guess, are mainly caused by passing an undefined
value. You have to work back from the error line to then determine why
the value is unititialized. 


Owen


use strict;
use warnings;

use diagnostics;  # provides a more verbose explanation of errors

use Time::Local;

my $days1 = epoch_days('30-Jan-09');
my $days2 = epoch_days('16-Feb-09');

my $day = $days2 - $days1;

print "Difference: @{[$days2 - $days1]} days\n";

BEGIN {

  my %month_num = do {
my $n = 0;
map(($_, $n++), qw/jan feb mar apr may jun jul aug sep oct nov
dec/); };

  sub epoch_days {

my @dmy = split /-/, shift;
$dmy[1] = $month_num{lc $dmy[1]} || 0;

# put print statements every where to see what is happening
print "I am expecting to see $dmy[0] $dmy[1] $dmy[2]\n";

return timelocal(0, 0, 0, @dmy) / (24 * 60 *
60); }
}


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




Re: picking largest key by value..

2009-02-26 Thread Owen
On Thu, 26 Feb 2009 15:34:11 -0500
Rick  wrote:

> trying out getting lasrgest key(by value) but below is not working...
> 
> help please.
> 
> my %files=%{{"one" =>"1", "thiry" =>"30", "four" =>"4", "never"
> =>"997", "forever" =>"11", "five" =>"5"}};
> my $max;
> print join(" ",keys %files),"\n";
> 
> =pod
> grep($max=($files{$_} > $max )? $_ : $max,keys %files);
> =cut
> for my $jot (keys %files) {
> print "$jot $files{$jot}\n";
> }
> 
> for my $now (keys %files) {
>$max = $now if $now > $max;   
> }
> 
> 
> print "<$max>\n";
> 


What happens if you put this at the top of your program

use strict;
use warnings;
use diagnostics;


?



Owen

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




Re: perl script on remote server

2009-03-02 Thread Owen
> I have a perl script on remote server.
> I want to launch a expect script(none perl) from local server with
arguments and launch perl script on remote server.(arguments will be
feed into perl script)
> I don't know how long perl script will run but I want to scp(using
expect script from local) the file back to local as soon as perl
script
> is done on remote server.
>
> What is the best way for this?
>
> Only way I can think of is launching expect script every 30 sec to
see
> if remote server has output (say in /tmp/results.1) and if it does,
transfer back.
>
> Maybe this is not a perl question and perhaps it is more basic unix
quesiton(?) but just wondering if I can get some construtive
feedback
> on
> this.




Well I have scripts on the remote server which

a. checks for the existence of the file.
b. goes to sleep if not there
c. rsync it back if it is there, then exits

The whole process is initiated by a cron job, including the generation
of the file in the first place.


HTH


Owen





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




Re: Date::CalC

2009-03-06 Thread Owen
On Fri, 6 Mar 2009 14:42:48 -0800 (PST)
Bobby  wrote:

> 
> Hi, 
> 
> Could someone take a look at the code for me below and see if you can
> figure out what's wrong with it? I just want to evaluate
> $publish_date to see if it's with 21 days of the current date; if so
> then set $new_item=" True". Not sure why it's not doing that, I think
> the it's not evaluating the if statement. I do have Date::CalC
> installed. Thanks.  
> 
> "if (my ($year1,$month1,$day1) = Decode_Date_US($mmddyyy))". 
> 
> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> sub NewProducts
>   {
> 
>  use Time::localtime;
>  use Time::Local;
>  use Date::Calc qw(:all);
> 
>   # Create date property in format mmdd
>   # for input to Decode_Date_US() function below
>   my $publish_date = "01/02/2009 12:32:03 PM";
>   my $mmdd = substr($publish_date, 5, 2);
>   $mmdd .= substr($publish_date, 8, 2);
>   $mmdd .= substr($publish_date, 0, 4);
> if (my ($year1,$month1,$day1) = Decode_Date_US($mmdd))
> {
> my ($year2,$month2,$day2) = Today();
> my $delta = Delta_Days($year1, $month1, $day1,
> $year2, $month2, $day2); if($delta <= 21 && $delta >= 0)
> 
> {
>   my $new_item = "True";
>   
> }
> 
> }
>
>   } #End of sub
> 
> &NewProducts();
> 


I am not sure what you expected, but here is a rewrite which you could
look at and see how it works.


Owen

=

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

use Time::Local;
use Date::Calc qw(:all); # no need to use all, just Delta_Days

my ( $year2, $month2, $day2 ) = Today();

my $publish_date = "03/02/2009 12:32:03 PM"; # Be sure of this format

my ( $mm, $j1, $dd, $j2, $ ) = unpack( "A2 A1 A2 A1 A4",
$publish_date );

print "$ $mm $dd\t\t$year2 $month2 $day2\n";

my $delta = Delta_Days( $year2, $month2, $day2, $, $mm, $dd );
print "$delta\n";


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




Re: Can docx2txt Be Installed In Windows Strawberry Perl as a Module

2009-03-08 Thread Owen
On Sat, 7 Mar 2009 22:04:03 -0800 (PST)
socrtwo  wrote:

> 1. http://docx2txt.sourceforge.net/ - can this be installed in a
> Windows Strawberry Perl?
> 2. Why is there no Makefile.PL file?
> 3. Is 2. because it's a script not a module?
> 4. Do scripts need to be installed just like modules?  How do you
> manually install a script in Windows?



Thanks for bringing that script to my attention. Will save some future
heartache.


There is no Makefile.PL because that's the way the author has done it up

If you look at the Makefile, all it does is to take the .pl file and
install it and give it permissions


My guess is that for Windows, you need only take the .pl file and run
it like any other perl script

See the README for  details 



Owen

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




Re: I'd like to monitor a running script.

2009-03-08 Thread Owen
>
> I'd like to monitor a running script and if the script stops running,
> restart it and continue to monitor it. I need a little help from the
> community on the ins-and-outs of the details. But, basically I need
> someone to look at the following code/pseudo-code and give
> suggestions.
>
> 1) Check a script running.
> 2) If it's running, sleep for 30 seconds then check again.
> 3) If it's not running, restart it and continue to check after that.
>
> This is on a Red Hat box, so the first thing would be something like:
>
> While (1) {
> my $process = `ps -ef | grep  | grep -v grep`;
>
> if ($process) {
> sleep 30} else {
> exec (./) or print STDERR "couldn't exec
> : $!";
> }
> }


WARNING: Totally untested, but you will get the idea


 #!/usr/bin/perl -w

 use strict;

 my $program = "";
 my $status  = `/bin/ps cat | /bin/grep $program`;

 if ( length($status) > 0 ) {

 sleep 30;

 }
 else { exec "the_process" }# start program




owen


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




Re: Strange regular expression

2009-03-15 Thread Owen
> I'm trying to use the random_image.pl program from the nms-cgi project
> on sourceforge.net.
>
> This line has me baffled:
>
>   if ( $baseurl !~ m%/$% )
>
>
> I don't understand the function of the percent symbols.
> I hope someone can explain what it's doing.


you can define matching criteria by using  / ... / or | ... | or % ...
% and probably a couple of others.


In this case % has been used


Owen




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




Re: busy_handler in sqlite

2009-03-19 Thread Owen
> Hi all
>
> I'm a Perl programmer (not a complete beginer) using SQLite.
>
> I want to retry to execute every command automatically, until the DB
> is not locked. In C seems that I need to set the busy_handler.
>
> How do I do this with DBD in Perl?
>
> Thanks for any help



Hi,

You might want to also ask on the perl-dbi users mailing list, or in the
perl.dbi.users news group



Owen


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




Re: cpan Audio::File fails

2009-03-22 Thread Owen
> Hello
>
> I repeatedly run into problems when installing modules and I havent
> yet figured out a way to consistently resolve them.
>
> I want to install Audio::File but the tests fail
>
> Any help is greatly appreciated.
>
> david
>
> Running make test
> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
> "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
> t/Audio-File1/49 Ogg::Vorbis::Header::PurePerl: Didn't find an ogg
> header - invalid file?
> Ogg::Vorbis::Header::PurePerl: Didn't find an ogg header - invalid
> file?

>
> #   Failed test 'Audio::File::Ogg::AudioProperties::length()'


My guess is that you are missing a header file.

If you are using a distribution based system, look for something like
libogg-dev or/and libvorbis-dev



Owen




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




Re: cpan Audio::File fails

2009-03-23 Thread Owen
> On Sun, Mar 22, 2009 at 8:56 PM, Owen  wrote:
>>> Hello
>>>
>>> I repeatedly run into problems when installing modules and I havent
>>> yet figured out a way to consistently resolve them.
>>>
>>> I want to install Audio::File but the tests fail
>>>
>>> Any help is greatly appreciated.
>>>
>>> david
>>>
>>> Running make test
>>> PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e"
>>> "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
>>> t/Audio-File1/49 Ogg::Vorbis::Header::PurePerl: Didn't find an
>>> ogg
>>> header - invalid file?
>>> Ogg::Vorbis::Header::PurePerl: Didn't find an ogg header - invalid
>>> file?
>>
>>>
>>> #   Failed test 'Audio::File::Ogg::AudioProperties::length()'
>>
>>
>> My guess is that you are missing a header file.
>>
>> If you are using a distribution based system, look for something
>> like
>> libogg-dev or/and libvorbis-dev
>>
>
> Thank you for your reply,
> I did that already but without success.
>
> aptitude search libogg
> i A libogg-dev   - Ogg Bitstream Library
> Development
> p   libogg-ocaml - OCaml bindings for the
> Ogg bitstream library
> p   libogg-ocaml-dev - OCaml bindings for the
> Ogg bitstream library
> i   libogg-vorbis-decoder-perl   - An object-oriented Ogg
> Vorbis decoder
> i   libogg-vorbis-header-perl- perl interface to Ogg
> Vorbis information and commen
> i   libogg-vorbis-header-pureperl-perl   - A pure Perl interface
> to Ogg Vorbis information fie
> i   libogg-vorbis-perl   - Perl extension for Ogg
> Vorbis streams
> i   libogg0  - Ogg Bitstream Library
> v   liboggz-dev  -
> i   liboggz1 - convenience interface
> for Ogg stream I/O
> p   liboggz1-dbg - convenience interface
> for Ogg stream I/O debugging
> i   liboggz1-dev - convenience interface
> for Ogg stream I/O (developme
>
> In case you are not familiar with apt/debian, those packages with "i"
> in the first column are installed on my system.
>
> I just wonder why cpan cant tell me what libs are missing or give any
> other clue about whats going wrong.
>
> Anyway, Audio::File is still not working





Fair enough, just looking at this Ubuntu pakage system, I see there is
a liubaudio-file-perl

Perl audio file abstraction library
Audio::File abstracts a single audio file, independent of its format.
Using this module you can access a files meta-info like title, album,
etc. as well as the files audio-properties like its length and bitrate.


Might be better to just install the prepackaged program?



Owen



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




RE: Reg:Regular expression

2009-04-15 Thread Owen

>
> Hi .
>
>
>
> Please help me in resolving errors in the following script
>
>
>
> 1.open(INPUT,"
> 2.open(OUTPUT,">new.txt");
>
> 3.$temp = \/user\/gowri\/rem2;
>
> 4.while (  ) {
>
> 5.$_ =~ s{\\/user\\/cce\\/dbg_tool}{$temp};
>
> 6.print OUTPUT $_;
>
> 7.}
>
>
>
> Errors:
>
> Bareword found where operator expected at example1.pl line 5, near
> "$str
> =~ s{\\/user"
>
>   (Might be a runaway multi-line // string starting on line 3)
>
> (Missing operator before user?)
>
> Backslash found where operator expected at example1.pl line 5, near
> "user\"
>
> Bareword found where operator expected at example1.pl line 5, near
> "/iprcce\\/dbg_tool"
>
> (Missing operator before dbg_tool?)
>
> syntax error at example1.pl line 5, near "$str =~ s{\\/user"
>
> Unmatched right curly bracket at example1.pl line 5, at end of line
>
> Execution of example1.pl aborted due to compilation errors.






Looking at your numbered script above, I cannot find $str nor /iprcce/


Perhaps you need to copy and paste the program you were trying to run
rather than retype it in an unusable form?





-- 



Owen


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




RE: Reg:Regular expression

2009-04-15 Thread Owen

>
> Hi owen,
>
> Please help me in resolving errors in the following script
>
> open(INPUT," open(OUTPUT,">new.txt");
> $temp = \/user\/gowri\/remote2;
> while (  ) {
> $_ =~ s{\\/user\\/cce\\/g_tool}{$temp};
> print OUTPUT $_;
> }




Well, I can try.

But why don't you help me by sending a few lines of your Test.txt

There are a few things you might want to try first;

 a. place immediately under the #!/usr/bin/perl line

 use strict;
 use warnings;

 b. Change
 $temp = \/user\/gowri\/remote2; to
 my $temp = "\/user\/gowri\/remote2";

 (Note the inverted commas around the variable)

Now have another go
-- 



Owen


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




  1   2   3   4   >