OT - Interesting Perl output; What is it?

2002-09-04 Thread nyec

This is off-topic, but I wasn't able to get an answer on a few math forums, 
so I thought I'd pass it by the diverse Perl community. By accident my Perl 
program produced some output - incorrect, but interesting. I was wondering if 
anyone recognizes the numerical pattern or what it is called? I couldn't find 
info on this during any of my searches.

The program took a number sequence. For example <10-100>, reversed the digits 
and calculated the difference of the original number. So the calculations 
look like this: <10-01=9; 11-11=0; 12-21=9; 13-31=18; etc.>. 

Two things were noticeable,  One, a pattern repeated (see output example 
below). Two, the separation between differences was always <9>. Patterns were 
present, albeit different, from <100-999>, and <1000->. 

Can someone tell me what this is called? 

## Example Output ##
10 - 01 = 9
11 - 11 = 0
12 - 21 = 9
13 - 31 = 18
14 - 41 = 27
15 - 51 = 36
16 - 61 = 45
17 - 71 = 54
18 - 81 = 63
19 - 91 = 72
20 - 02 = 18
21 - 12 = 9
22 - 22 = 0
23 - 32 = 9
24 - 42 = 18
25 - 52 = 27
26 - 62 = 36
27 - 72 = 45
28 - 82 = 54
29 - 92 = 63
30 - 03 = 27
31 - 13 = 18
## END Example Output ##

Thanks in advance for any information. This is driving me crazy. 

nyec

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




Re: how to approach this?

2002-09-08 Thread nyec

On Saturday 07 September 2002 05:37 pm, pelp wrote:
> I was given a job to manipulate MIF files and decided to do the job in
> PERL for it's powerful text manipulating capabilites. A MIF file is
> another method to represent a FrameMaker file which contains all these
> tags similar to html.
>
> What I need to do (and this is where I need help) is to delete any
> strike-through text in the file. Looking at the MIF file at hand, I
> noticed what tags I have to remove.
>
> For example, here are the MIF tags that represents something that is
> strike-through.
>
>
>
>
> 
> 
> 
>
>> # end of Font
>
>
>
> If you look at the MIF file in FrameMaker, there will be this string
> strike through:
>
> "There are at least two indications that the MM can re"
>
> If I delete the strike-throught text by hand in FrameMaker, the MIF
> representation would be
>
>
>
>
> 
> 
>
>> # end of Font
>
> Note that the above to MIF codes are the same part of the file where
> text appeared when strike-through and after when it was deleted.
>
> Okay my problem is how do I code the steps to delete any strike-through
> text. I've a good understand of condtions, functions, regular
> expressions and such.
>
> What I need to do is if the conditon CODE1 expample is found to delete
> all the tags that I did in CODE2. So is it legal to declare a varibales
> such as
>
>
>
> my($font) =<
>  
>  
>  
>
> > # end of Font
>
> 
> EOFONT
>
> And I'm stuck after that. So I would apprecitiate if someone could lead
> me a helping hand to help me solve the problem. And I apologies for my
> rambling and lack of English skills.
>
> THANKS !!!


How about something like this (from the command line):
 perl -p -i.bak -w -e 's///g' test.txt  

nyec

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




Re: how to approach this?

2002-09-08 Thread nyec

On Sunday 08 September 2002 09:11 am, nyec wrote:
> On Saturday 07 September 2002 05:37 pm, pelp wrote:
> > I was given a job to manipulate MIF files and decided to do the job in
> > PERL for it's powerful text manipulating capabilites. A MIF file is
> > another method to represent a FrameMaker file which contains all these
> > tags similar to html.
>
> How about something like this (from the command line):
>  perl -p -i.bak -w -e 's///g' test.txt
>
> nyec

Oops. That  solution example I gave leaves a blank line where "" 
was. Still early here. Try this:
perl -p -i.bak -w -e 's/\n//g' test.txt

nyec

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




Re: Regular expression

2002-09-12 Thread nyec

On Thursday 12 September 2002 08:11 pm, Javeed SAR wrote:
> I have a statement as follows;
> I need to split them into 3 parts;
>
> * test_merge1  \\blrk35ed\views\test_merge1.vws
>
>
> LIke this:
> $var1 should have *
> $var2 should have test_merge1
> $var3 should have  \\blrk35ed\views\test_merge1.vws
>
>
>
> TIA
>
> Jav

Here's what I came up with. I had a bit of trouble with the leading '\\' on 
the path. Using /\s+\ in 'split' causes the the first '\' to be dropped. It's 
acting like a special character escape. So, after the split I put the leading 
'\' back in. 
Perhaps someone has a more efficient method of keeping the double backslashes 
during the 'split'. Hope this helps.

nyec

# begin 
my $string = '* test_merge1 \\blrk35ed\views\test_merge1.vws';
my ($var1, $var2, $var3) = split/\s+/,$string;

$var3 =~ s/^\\//g;  #puts the double quote back in front

print "var1 is: $var1\n";
print "var2 is: $var2\n";
print "var3 is: $var3\n";

__END__

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




Re: Rename "File" to "File$date"

2002-09-13 Thread nyec

On Friday 13 September 2002 12:06 am, Kauffmann, Andreas wrote:
> Hy everybody in the List!
>
> I have a Problem writing a little perl application...
>
> Im a very newbie to programming and need your help :)
>
>
> The Problem is:
>
> I have a file "dev.txt" and I want to rename it once a day (with a cronjob)
> like "dev13092002.txt"
>
> So i need to rename it with a date variable.
>
> All I have at the moment is:
>
> #!/usr/bin/perl
> $d = `date`;
> $d = /pattern1(pattern2)/;
> sytem("cp test.txt test`$d`.txt");
>
>
> Does anyone of you know how to do that?

How about this? 

nyec

# BEGIN EXAMPLE
#STDERR = //Your syslog or log file//
# You may want/need to set the STDERR/STDOUT if
# this program is set as a cronjob depending on your system.
# Be sure to test logging and error output. 

#Date formatting
my ($day, $month, $year) = (localtime)[3,4,5];
$month++;
if ($month < 10) { 
  $month =~ s/^/0/;   # Keeps date format consistent(ddmm)
}
$year += 1900;
my $date = join($day,$month,$year);

my $oldfile = "dev.txt";

if (-e $oldfile) {
  my $datefile = $oldfile;
  $datefile =~ s/^dev/dev$date/;
  rename $oldfile, $datefile;   #Note-> Overwrites any existing file
  if (!-e $datefile) {
 die "'$datefile' was not created: $!";
  }
}  else { 
   die "Can not open '$oldfile': $!";
}

__END__

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




expenses

2002-12-10 Thread nyec
Here it is in CSV (comma separated values). it's not very much - $246
Date,Amount,Description,Location
10.08.02,100.52,"Business Cards - Mark, Me",Designyourowncard.com
10.22.02,50.26,Business Cards - Lorraine,Designyourowncard.com
10.22.02,31.28,Lunch - Mark & Lorraine,Claim Jumper
10.25.02,64.60,Wood for NOC base,Home Depot

TOTAL,$ 246.66

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


Re: Editors

2002-12-23 Thread nyec
On my FreeBSD box I use Xemacs and nedit . I enjoy nedit 
very much. Nedit is small, fast, and does a nice job of perl syntax 
highlighting. 

nyec

On Monday 23 December 2002 06:33 am, Joseph Ruffino wrote:
> Paul,
>
> I use Programmer's File Editor for Windows also.  I have found it
> very easy to use, and very helpful debugging my program visually. 
> I can see the typos better than with Notpad.
>
> Joseph Ruffino
> Automated Systems Assistant
> Gail Borden Public Library District

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




Re: Installing Crypt::IDEA

2003-01-03 Thread nyec
On Friday 03 January 2003 03:47 pm, Steve Rinehart wrote:
> Hello,
>
> I am experiencing some difficulties trying to install the module,
> Crypt::IDEA, which is required in order for me to use the Net::SSH
> module.
>
> When trying to install this module, I get the following error when
>
> attempting to do the "make":
> >perl Makefile.PL
>
> Checking if your kit is complete...
> Looks good
> Writing Makefile for Crypt::IDEA
>
> >make
>
> cp IDEA.pm blib/lib/Crypt/IDEA.pm
> cp IDEA.pod blib/lib/Crypt/IDEA.pod
> /usr/local/bin/perl /usr/local/lib/perl5/5.6.1/ExtUtils/xsubpp
> -typemap
>  /usr/local/lib/perl5/5.6.1/ExtUtils/typemap -typemap typemap  IDEA.xs
>
> > IDEA.xs
>
> c && mv IDEA.xsc IDEA.c
> Please specify prototyping behavior for IDEA.xs (see perlxs manual)
> cc -c-D_HPUX_SOURCE -Aa -I/usr/local/include -O
> -DVERSION=\"1.01\
> "  -DXS_VERSION=\"1.01\" +z
> "-I/usr/local/lib/perl5/5.6.1/PA-RISC2.0/CORE"   IDE
> A.c
> cc: "idea.h", line 5: error 1000: Unexpected symbol: "idea_cblock".
> cc: error 2017: Cannot recover from earlier errors, terminating.
> *** Error exit code 1
>
> Stop.
>
>
> Can anyone help me with this?
>
> Thank you.
>
> Steve Rinehart
> EDI P/A
> Utah Dept. of Health
Steve,

On my *BSD boxes most perl crypto modules already have a ported interface. On 
my FreeBSD machine the port for Crypt-IDEA is "p5-Crypt-IDEA". I always check 
the BSD ports before installing from CPAN. OS specific ported perl interface 
modules usually install with much less hassle. Check your OS ports for ported 
perl modules. 

I'm not sure about ported perl crypto interfaces for Windows. 

nyec

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




Re: Help with Hello world

2003-01-04 Thread nyec
On Saturday 04 January 2003 10:18 am, David Leathers wrote:
> #!/usr/bin/perl
>print"Hello World";

Are you sure it's not printing with your prompt immediately after "Hello 
World"? Try putting a new line after "World" and it may be noticeable.

print "Hello World\n";

nyec

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




Re: net::telnet and read eof error

2002-03-13 Thread nyec

On Wednesday 13 March 2002 10:30 am, Craig Williams wrote:
> In my first attempt at telneting into sun box from win98, i've been
> receiving the error message : pattern match read eof at scriptName.pl line
> xx--   where xx is the login line. Unable to resolve that error
> through the usual methods I tried executing the rainmaker sample in the
> documentation at the end of the net::telnet module and received the same
> error (this time at the "$t->waitfor('/continue:*$/);) line. I'm guessing
> it's a setup error on my machine but haven't a clue where to look.  Any
> ideas?
>
> (sample from the net::telnet documentation that i ran)
>
> #!perl -w
>
> my ($forecast, $t);
>
> use Net::Telnet ();
> $t = new Net::Telnet;
> $t->open("rainmaker.wunderground.com");
>
> ## Wait for first prompt and "hit return".
> $t->waitfor('/continue:.*$/');
> $t->print("");
>
> ## Wait for second prompt and respond with city code.
> $t->waitfor('/city code.*$/');
> $t->print("BRD");
>
> ## Read and print the first page of forecast.
> ($forecast) = $t->waitfor('/[ \t]+press return to continue/i');
> print $forecast;
>
> exit;

This may be a telnet client issue and not a perl problem. You might look at 
changing your Win98 telnet client to send a line feed instead of a carriage 
return. I'm not sure how to do this in win98 (also depends on the telnet 
client). 

>From my *BSD box I was able to run your provided sample code without a 
problem. Also, if you manually telnet to rainmaker.wunderground.com, you'll 
notice the following in the welcome message:

   **Note: If you cannot get past this opening screen, you must configure
   *   your telnet program to send a line feed instead of just a carriage
   *   return, or use a different telnet program that does so.

Hope this helps. 

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