[22818] in Perl-Users-Digest
Perl-Users Digest, Issue: 5039 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 26 00:05:35 2003
Date: Sun, 25 May 2003 21:05:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sun, 25 May 2003 Volume: 10 Number: 5039
Today's topics:
Re: Crypt::CBC, Crypt::Rijndael - "almost" working <bwalton@rochester.rr.com>
Re: Error message with perl -MCPAN -e shell <mark_rogers@mac.com>
Re: How do I make a graph with this module? (James E Keenan)
Re: need explanation <uri@stemsystems.com>
Re: need explanation <johnsmith@yahoo.com>
Re: need explanation <sputnik@windows-sucks.com>
Re: need explanation <bwalton@rochester.rr.com>
Re: parsing text <no.spam@this.addy.ta>
Re: parsing text <no.spam@this.addy.ta>
Re: Perl Nightmare on OS X <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 26 May 2003 02:38:44 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Crypt::CBC, Crypt::Rijndael - "almost" working
Message-Id: <3ED17DA4.8010707@rochester.rr.com>
Frederic wrote:
...
> I wrote a script using Crypt::CBC to encrypt a file with Rijndael. The
> script is "almost" working. I can encrypt and decrypt, however, in the
> decrypted text, I always get two or three words "corrupted". You will find
> the script here under, and an example of a decrypted text, so that you can
> see what I mean by "corrupted" (the original plaintext contains lines of
> 0123456789).
...
> open(FH_plain,"./$plainfile");
> open(FH_crypted, ">$plainfile.cry");
binmode FH_crypted; #just a guess [untested]
> while (read(FH_plain,$buffer,1024)) {
> print FH_crypted $cipher->encrypt($buffer);
> }
...
--
Bob Walton
------------------------------
Date: Sun, 25 May 2003 23:03:22 -0500
From: Mark Rogers <mark_rogers@mac.com>
Subject: Re: Error message with perl -MCPAN -e shell
Message-Id: <xmgAa.21058$NC4.97580@news1.mts.net>
I get something very similar to this on
my A/UX box and have yet to determine
what it is. I too am using ncftp
as I can't get Bundle::libnet
Any help/suggestions would be appreciated.
Mark
Alan wrote:
> Hi Randy,
>
> This seemed to work pretty good. Now when I run the command perl -MCPAN -e
> shell get the message:
>
> Use of uninitialized value at (eval 3) line 16, <TERMCAP> chunk 1.
>
> cpan shell -- CPAN exploration and modules installation (v1.3901)
> ReadLine support available (try ``install Bundle::CPAN'')
>
> So I tried install Bundle::CPAN and got the message:
>
> Trying with "/usr/bin/ncftp -c" to get
> ftp://cpan.topend.com.au/pub/CPAN/authors/01mailrc.txt.gz
>
> And then the programme sits for ever doing nothing.
>
> I think I have messed up the configuration file. When I first ran
> per -MCPAN -e shell the programme asked me a lot of questions in order to
> write a config file. Would you know how I can get it to do this again, or
> alternatively what is the name of the file so I can edit it by hand? I
> believe I messed up the process as I deleted the directory
> /root/y/sources/MIRRORED.BY
>
> Thanks,
>
> Alan
>
>
> "Randy Kobes" <randy@theoryx5.uwinnipeg.ca> wrote in message
> news:UQ9ya.17178$NC4.76582@news1.mts.net...
>
>>"Alan" <waty-spam@powerup.com.au> wrote in message
>> news:mB%xa.504$po1.35400@nnrp1.ozemail.com.au...
>>
>>>"leeper" <sav_me_to_nospam@hotmail.com> wrote in message
>>>news:ba9qnm$qf$1@perki.connect.com.au...
>>
>>>>kill -9 1142 maybe?
>>
>>>Yes I tried kill -9 1142 it returned PID does not exist. I rebooted and
>>>retried perl -MCPAN -e shell. When the error appeared I ran
>>>ps aux
>>>This did not show a process id of 1142.
>>
>>Try looking in your CPAN.pm home directory (eg, /root/.cpan/,
>>or $HOME/.cpan/) for a file called .lock (with the leading period).
>>If it exists, remove it, and launch the CPAN shell again.
>>
>>best regards,
>>randy kobes
>>
>>
>>
>
>
>
>
>
------------------------------
Date: 25 May 2003 19:10:08 -0700
From: jkeen@concentric.net (James E Keenan)
Subject: Re: How do I make a graph with this module?
Message-Id: <b955da04.0305251810.211b85b0@posting.google.com>
email_entropy123@yahoo.com (entropy123) wrote in message news:<90cdce37.0305251252.16333c46@posting.google.com>...
> James,
>
> I guess I'm looking for some sort of sandbox so I can get used to
> inputting, outputting to this module....
>
> I read through the code and I see what it is doing, but have no idea
> how to actually take my data and produce a graph....
>
Hmm, having taken a closer look at that documentation, I get your
drift. The documentation is simply an ultra-terse description of the
methods.
If I were in your shoes at this point, I'd go back to search.cpan.org
and plug "Graph" into the search engine. The _next_ module that comes
up, Martin Viebruggen's GDGraph, looks more promising. There's even
an FAQ as part of the docs! (Note: I haven't tried any of these
myself.)
------------------------------
Date: Mon, 26 May 2003 02:04:22 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: need explanation
Message-Id: <x7wugesbtl.fsf@mail.sysarch.com>
>>>>> "A" == Anthony <johnsmith@yahoo.com> writes:
A> thanks for that,,,, what do the individual lines in purple mean????
i don't see purple lines. i only see pink elephants. try posting and
MARKING the lines you want explained. purple is not a good way to
describe code. and usenet is a plain text medium (as should be email :( ).
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Mon, 26 May 2003 02:26:47 GMT
From: "Anthony" <johnsmith@yahoo.com>
Subject: Re: need explanation
Message-Id: <3ed17b55$1@news.syd.ip.net.au>
sorry about that
will put an # besides the the rows that need explaning
Thanks again
my $num = 1;
my $filename = "ABCDEFF.TXT";
my $time = time();
my ($min, $hour, $day, $mon, $year) = (localtime($time))[1..5]; $mon++;
$year+=1900; #
$num = $num<10?"0$num":$num;
#
$min = $min<10?"0$min":$min;
#
my $h2 = $hour%10;
#
my $h1 = ($hour - $hour%10)/10;
#
$day = $day<10?"0$day":$day;
#
$mon = $mon<10?"0$mon":$mon;
#
$year = $year%1000;
#
my $stamp = "${num}${day}${mon}${year}${h1}.${h2}${min}";
#
rename($filename, $stamp) or die("RENAME: $!");
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x7wugesbtl.fsf@mail.sysarch.com...
> >>>>> "A" == Anthony <johnsmith@yahoo.com> writes:
>
> A> thanks for that,,,, what do the individual lines in purple mean????
>
> i don't see purple lines. i only see pink elephants. try posting and
> MARKING the lines you want explained. purple is not a good way to
> describe code. and usenet is a plain text medium (as should be email :( ).
>
> uri
>
> --
> Uri Guttman ------ uri@stemsystems.com --------
http://www.stemsystems.com
> --Perl Consulting, Stem Development, Systems Architecture, Design and
Coding-
> Search or Offer Perl Jobs ----------------------------
http://jobs.perl.org
------------------------------
Date: Mon, 26 May 2003 02:54:33 GMT
From: "Juan C. Muller" <sputnik@windows-sucks.com>
Subject: Re: need explanation
Message-Id: <pan.2003.05.26.02.54.32.28787@windows-sucks.com>
> $year+=1900; #
read $year=$year+1900;
> $num = $num<10?"0$num":$num;#
if $num<10 then add a "0" to $num, else leave it as it is
> $min = $min<10?"0$min":$min;
same
> my $h2 = $hour%10;
> my $h1 = ($hour - $hour%10)/10;
for example: $hour=23->$h1=2,$h2=3
$hour=4 ->$h1=0,$h2=4... get the idea?
> $day = $day<10?"0$day":$day;
> $mon = $mon<10?"0$mon":$mon;
above
> $year = $year%1000;
returns the last digit
2003 mod 1000=3
1995 mod 1000=995
>
> my $stamp = "${num}${day}${mon}${year}${h1}.${h2}${min}"; #
creates a string with all the values gotten before, and the second digit
of the hour and the minute are the extension for the file we are going to
rename in the next line.
> rename($filename, $stamp) or die("RENAME: $!");
this means, rename file $filename with $stamp or die.
HTH
------------------------------
Date: Mon, 26 May 2003 03:44:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: need explanation
Message-Id: <3ED18D20.50909@rochester.rr.com>
Anthony wrote:
...
> will put an # besides the the rows that need explaning
...
> my $num = 1;
> my $filename = "ABCDEFF.TXT";
> my $time = time();
> my ($min, $hour, $day, $mon, $year) = (localtime($time))[1..5]; $mon++;
> $year+=1900; #
This runs the localtime function on variable $time (which holds the
result of function time, which returns the 32-bit system time in seconds
since the epoch) in list context. This is enclosed in parens and
followed by an expression in brackets, which means we are taking an
array slice, returning the second (1) through sixth (5) elements of the
array localtime returns. That means minute, hour, day, month and year
of the current time. $mon++ increments the month, since localtime
returns 0 for January through 11 for December. $year+=1900 adds 1900 to
the year so we get the 4-digit year (localtime returns the number of
years since 1900).
> $num = $num<10?"0$num":$num;
If $num was less than 10, it prepends a leading zero to $num. Since
$num is 1, it does nothing.
> #
> $min = $min<10?"0$min":$min;
If needed, prepends leading 0 to $min to generate a 2-digit minute from
00 through 59.
> #
> my $h2 = $hour%10;
Computes the right-hand digit of the hour, 0 through 9.
> #
> my $h1 = ($hour - $hour%10)/10;
Computes the left-hand digit of the hour, 0 through 2.
> #
> $day = $day<10?"0$day":$day;
Generates a two-digit day, 00 through 31.
> #
> $mon = $mon<10?"0$mon":$mon;
Generates a two-digit month, 01 through 12.
> #
> $year = $year%1000;
> #
>
Generates a 1 through 3-digit year, 0 through 999. Probably a bug, as
I'm sure the intent was to generate a two-digit year. Also, the number
of digits in the year is not regulated, as I'm sure was the intent.
> my $stamp = "${num}${day}${mon}${year}${h1}.${h2}${min}";
Long way of sticking all the variables together in a string. It should
have probably been:
my $stamp = "$year$mon$day$h1$h2$min$num";
if the intent was to make filenames that will sort chronologically. All
the {} constructions are not needed.
The whole smash could have been done much easier with:
my @a=(localtime(time))[1..5];
$a[3]++;$a[4]+=1900;
my $stamp=sprintf '%04d%02d%02d%02d%02d',@a[4,3,2,1,0];
assuming a 4-digit year is wanted. Add
$a[4]%=100;
to the second line if a 2-digit year is required, and change the first
format specifier to %02d .
> #
>
> rename($filename, $stamp) or die("RENAME: $!");
>
--
Bob Walton
------------------------------
Date: Mon, 26 May 2003 02:07:52 +0100
From: "Brian H供" <no.spam@this.addy.ta>
Subject: Re: parsing text
Message-Id: <HNdAa.12639$sJ4.12153@newsfep4-winn.server.ntli.net>
w i l l said:
> On Sun, 25 May 2003 22:36:28 +0100, "Brian H供" <no.spam@this.addy.ta>
> wrote:
>
>> Following on from my counter query the other day.
>> I have created some more scripts that treat the list in various ways and
>> give me a final list containing just one word.
>> e.g. a text file "blahblah.txt" containing just the word "fred".
>> I would like to be able to parse/echo the word "fred" to a DOS edit command.
>> Can I call upon someone again to come to my rescue please?
>> I know that this may not require a perl script, and may only require a
>> couple of DOS commands, but the help section of my DOS book is about as
>> useless as boobs on a stallion.
>>
>> TIA (again)
>>
>> Brian
>>
>
>
> I'm not clear on what you are trying to do, but hopefully these hint
> will get you where you want to go.
>
> 1) opening and reading a file (assuming the word "fred" is on the
> first line of the .txt file)
>
> open(FILE,"<blah.txt") || die $!;
> my $firstLine = <FILE>;
> # so $firstLine contains the value
> # "fred\n"
>
> 2) using perl on Windows to call DOS commands
>
> system('copy file1 file2');
> #this would do a copy command
>
> system('echo this');
> #displays "this" to the screen
>
> system("echo $firstLine");
> #prints fred\n to screen
>
> w i l l
As part of a batch file, I wish to be able to have this line,
edit c:\folder\%1.txt
where %1 would become the word fred brought from the file blah.txt.
I know this is going to be something simple, and I will end up kicking myself,
but I just can't see the wood for the trees.
------------------------------
Date: Mon, 26 May 2003 03:12:43 +0100
From: "Brian H供" <no.spam@this.addy.ta>
Subject: Re: parsing text
Message-Id: <uKeAa.12653$sJ4.8647@newsfep4-winn.server.ntli.net>
Brian H供 said:
> w i l l said:
>
>> On Sun, 25 May 2003 22:36:28 +0100, "Brian H供" <no.spam@this.addy.ta>
>> wrote:
>>
>>> Following on from my counter query the other day.
>>> I have created some more scripts that treat the list in various ways and
>>> give me a final list containing just one word.
>>> e.g. a text file "blahblah.txt" containing just the word "fred".
>>> I would like to be able to parse/echo the word "fred" to a DOS edit command.
>>> Can I call upon someone again to come to my rescue please?
>>> I know that this may not require a perl script, and may only require a
>>> couple of DOS commands, but the help section of my DOS book is about as
>>> useless as boobs on a stallion.
>>>
>>> TIA (again)
>>>
>>> Brian
>>>
>>
>>
>> I'm not clear on what you are trying to do, but hopefully these hint
>> will get you where you want to go.
>>
>> 1) opening and reading a file (assuming the word "fred" is on the
>> first line of the .txt file)
>>
>> open(FILE,"<blah.txt") || die $!;
>> my $firstLine = <FILE>;
>> # so $firstLine contains the value
>> # "fred\n"
>>
>> 2) using perl on Windows to call DOS commands
>>
>> system('copy file1 file2');
>> #this would do a copy command
>>
>> system('echo this');
>> #displays "this" to the screen
>>
>> system("echo $firstLine");
>> #prints fred\n to screen
>>
>> w i l l
>
> As part of a batch file, I wish to be able to have this line,
> edit c:\folder\%1.txt
> where %1 would become the word fred brought from the file blah.txt.
>
> I know this is going to be something simple, and I will end up kicking myself,
> but I just can't see the wood for the trees.
OK, I'm using
open(FILE,"<image.txt") || die $!;
my $firstLine = <FILE>;
system("edit $firstLine.txt");
But instead of the file name showing in blue bar at the top, it just shows the
path to cmd.exe
I just need a way of getting a window to open that contains the name of the file
in $firstLine.txt in the blue bar.
:-(
------------------------------
Date: Mon, 26 May 2003 02:49:17 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: Perl Nightmare on OS X
Message-Id: <3ED1801C.6070507@rochester.rr.com>
Nick wrote:
> I believe I've found the answer. The problem lay in
> /sw/lib/perl5/darwin/Storable.pm. Moving that to /tmp and rebuilding
> via fink seems to have fixed the problem. One odd things, still --
> why to package variables have to be declared as belonging to a
> specific package, even if you want the to belong to main? For example,
> the following results in compilation errors:
>
> $foo = 'bar';
>
> while this works:
>
> $main::foo = bar;
Well, that's the whole point of packages. You want to be able to use
someone's package without having to worry about stomping on the variable
names the author chose to use in his/her package. Likewise, the package
author doesn't want to have to work around whatever variables you might
choose to use in your package main (as if he/she could ahead of time
anyway). So all user-defined Perl variables exist by default in a given
package. They can be accessed in other packages via constructions like
$package_name::variable_name, as you have demonstrated above. And/or
they can be exported. Package main is just another package -- about the
only thing special about it is that it is the package you are in if you
don't specify a package.
...
HTH.
--
Bob Walton
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V10 Issue 5039
***************************************