Re: How to use Text::Wrap correctly

2017-08-22 Thread Harry Putnam
rea...@newsguy.com (Harry Putnam) writes: > So trying to simplify things I'm running the script against 3 log > lines produced by sendmail. The 3 lines below are in a file named > `mail-loglines'. Instead of simplifying I made a mess of things... I left this line at the b

Re: How to use Text::Wrap correctly

2017-08-22 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: > There is an error in what I posted (sorry). The input is read into > the $line variable, but your regular expression is implicitly > testing the default variable $_. The loop should be: > > > while ( my $line = <> ) { > if ( $line =~ /$rgx/ ) { >

Re: How to use Text::Wrap correctly

2017-08-18 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: >> On Aug 13, 2017, at 6:02 PM, Harry Putnam wrote: >> >> My aim: >> >> Run certain kinds of log file lines thru a perl script that will: >> >> 1) Identify each line by regex that finds pattern at start of l

Re: How to use Text::Wrap correctly

2017-08-17 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: >> On Aug 13, 2017, at 6:02 PM, Harry Putnam wrote: >> >> My aim: >> [...] >> my @text; >> >> while (<>) { >> if (/$rgx/) { >> print "\n"; >> print wrap(","

How to use Text::Wrap correctly

2017-08-13 Thread Harry Putnam
My aim: Run certain kinds of log file lines thru a perl script that will: 1) Identify each line by regex that finds pattern at start of line 2) When such a line is found, print newline first then 3) wrap any lines longer than specified number of columns. I was not able to divine from `perldoc T

Re: File::Find .. still confused slightly

2017-07-05 Thread Harry Putnam
rea...@newsguy.com (Harry Putnam) writes: > What surprised me is the that when I ran them prefaced with the `time' > utility, I see the sloppy mess I wrote is nearly twice as fast. I may have found a reason. in the find sub {} part you did two returns return unless -f;

Re: File::Find .. still confused slightly

2017-07-05 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: > You have a logic error in your code somewhere. Your logic for counting > the files with a name matching a certain pattern is too complicated to > follow and point out where your error lies and how to fix it. The > basic problem is that your logic depends

File::Find .. still confused slightly

2017-07-05 Thread Harry Putnam
Working on script using File::Find to count the number of news posts in a semi-extensive hierarchy. As some may know, news posts are commonly stored in numeric named files, one file per posting. The following script tries to plow thru a hierarchy returning the directory name and file count for th

cancel <868tkby1y8....@local.lan>

2017-06-28 Thread Harry Putnam
I am canceling my own article. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: File::Find report file count per directory

2017-06-28 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: [...] > I don’t see how the code you have posted can possibly produce the > output you have reported. The code above looks like error checking > that the user of the program has entered one argument, and that > argument is the name of a directory. Egad,

Re: File::Find report file count per directory

2017-06-28 Thread Harry Putnam
jimsgib...@gmail.com (Jim Gibson) writes: [...] > I don’t see how the code you have posted can possibly produce the > output you have reported. The code above looks like error checking > that the user of the program has entered one argument, and that > argument is the name of a directory. Egad,

File::Find report file count per directory

2017-06-28 Thread Harry Putnam
1) I want to count numeric named files in each directory. 2) I want to capture the name of the directory those files are in 3) I want to print the directory name and the count (if any) for each directory. I know that all the information I want to extract is available in File::Find. Just havi

Re: Confused with File::Find

2017-06-25 Thread Harry Putnam
and...@geekuni.com (Andrew Solomon) writes: [...] > The way it works it that `find` is traversing through the directories and > `$File::Find::dir` is the directory it's *in* when it calls your subroutine > on `$File::Find::name` which is inside that directory. When it was sitting > in `/three` it

Re: Confused with File::Find

2017-06-24 Thread Harry Putnam
shlo...@shlomifish.org (Shlomi Fish) writes: > $File::Find::dir is the containing directory of the path item (= the > dirname in http://perldoc.perl.org/File/Basename.html ). Finally, > note that File::Find has OK, I guess I follow that. As you see in my reply to Andrew S, I kind of fumbled my w

Re: Confused with File::Find

2017-06-24 Thread Harry Putnam
and...@geekuni.com (Andrew Solomon) writes: > Hi Harry > > What do you want your code to do? > Devise a simple test script the counts the number of directories in a hierarchy (This is building toward a more complex script in the end). But taking small steps in an effort to really understand what

Confused with File::Find

2017-06-23 Thread Harry Putnam
Trying for a better understand of using File::Find, butI'm missing something pretty basic I think First: The directory structure in this test: ./one/tst.pl two/tst.pl three/tst.pl So each directory in the layering has the same type -f file in it. Or ls -R ./one ./one: tst.pl tw

Re: Debug when script WILL NOT RUN

2015-02-05 Thread Harry Putnam
Shawn H Corey writes: > On Mon, 02 Feb 2015 11:54:12 -0500 > Harry Putnam wrote: > >> Are we even talking about the same program... Perl::Critic/perlcritic? >> >> For me, it just blows up with piles of help information when I use >> `-c': > > Us

Re: Debug when script WILL NOT RUN

2015-02-02 Thread Harry Putnam
Shawn H Corey writes: > As Paul Johnson says, try it with the -c option first but note: > > -c causes Perl to check the syntax of the program and then exit > without executing it. Actually, it will execute and "BEGIN", > "UNITCHECK", or "CHECK" blocks and any "use" statements: these

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Harry Putnam
Shawn H Corey writes: > On Sun, 01 Feb 2015 11:12:46 -0500 > Harry Putnam wrote: > >> Shawn H Corey writes: >> >> > http://metacpan.org/pod/Perl::Critic >> >> Feeding my sorry script to the advertised webpage like by using the >> posted met

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Harry Putnam
Paul Johnson writes: > On Sun, Feb 01, 2015 at 09:56:39AM -0500, Harry Putnam wrote: >> Robert Wohlfarth writes: >> >> > On Sat, Jan 31, 2015 at 3:58 PM, Harry Putnam wrote: >> > >> > I have about 100 lines or so inside a File::Find: > > You w

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Harry Putnam
Shawn H Corey writes: > http://metacpan.org/pod/Perl::Critic Feeding my sorry script to the advertised webpage like by using the posted method of testing Perl::Critic with no installation. $> lwp-request -m POST http://perlcritic.com/perl/critic.pl < MyModule.pm $> wget -q -O - --post-file

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Harry Putnam
Charles DeRykus writes: [...] > One good sleuthing tool is perltidy (perltidy.sourceforge.net) which is good > at unraveling a rat's nest of errors to tease out the culprit: > > For instance, you'd run: perltidy badlywrittenscript.pl and might get > an error diagnostic file that'd say something

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Harry Putnam
Shawn H Corey writes: > On Sun, 1 Feb 2015 00:10:30 -0800 > Charles DeRykus wrote: > >> One good sleuthing tool is perltidy (perltidy.sourceforge.net) which >> is good at unraveling a rat's nest of errors to tease out the >> culprit: > > You can also download and install with `cpan`: [...] Lo

Re: Debug when script WILL NOT RUN

2015-02-01 Thread Harry Putnam
Robert Wohlfarth writes: > On Sat, Jan 31, 2015 at 3:58 PM, Harry Putnam wrote: > >> [snip...] > > I have about 100 lines or so inside a File::Find: >> >> find ( >> sub { >> }, $tdir; >>); &

Debug when script WILL NOT RUN

2015-01-31 Thread Harry Putnam
I've given myself a headache googling on how to debug a perl script that does not run. Maybe `debug' is the wrong word... I'd love to know if there is a more accurage one. I realize this post is quite a lot of yak, but hoping someone can lay out a few steps that will narrow down the problem. Man

Re: question of what can respond to die [...]

2015-01-28 Thread Harry Putnam
Brandon McCaig writes: [...] snipped excellent extrapolation > I hope that helps. Well, I could not have asked for a fuller answer... thanks. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: question of what can respond to die [...]

2015-01-28 Thread Harry Putnam
Shawn H Corey writes: > On Tue, 27 Jan 2015 09:37:15 -0500 > Harry Putnam wrote: > >> #!/usr/local/src/test/bin/perl >> >> use strict; >> use warnings; >> use Cwd 'abs_path'; >> >> my $tdir = shift; >> > > You can u

question of what can respond to die [...]

2015-01-27 Thread Harry Putnam
In the following code I hoped to use `use Cwd abs_path;' to not only produce the absolute path for a named directory but to die if it could not... thereby getting around having to test the named dir with -d ... to make sure it was really a directory in the fs. It does not have that effect when a

Re: should this old forumulation still work?

2015-01-21 Thread Harry Putnam
Andrew Solomon writes: > Hi Harry > > I was about to try to explain it but sometimes a picture is worth a > thousand words (even if it's a picture of code:) Yes, that did the job. I guess I was pretty confused about what `slurp' means... I was expecting the newlines to disappear. But of course

should this old forumulation still work?

2015-01-20 Thread Harry Putnam
I found this little snippet in a post (from 2000) by Randal L. Schwartz: http://www.perlmonks.org/?node_id=20235 The discussion was about: File::Slurp allows you read a filehandle into a scalar. However there is another way to do this without having to load an extra module at runtime. Th

Re: How does opendir/readdir process files

2015-01-15 Thread Harry Putnam
John SJ Anderson writes: > On Tue, Jan 13, 2015 at 7:40 PM, Brandon McCaig wrote: >> Harry: >> >> (Expect typographical errors in such a long post...) >> >> tl;dr? RTFM. > Please don't tell people that. It's not helpful, it's not a helpful > attitude, and it's really not welcome here. > > The

Re: How does opendir/readdir process files

2015-01-09 Thread Harry Putnam
Dermot writes: First, thanks for you helpful input and examples. I'm taxing peoples patience I suppose but being considerably thick of skull I cannot just look at this and see what it does. > my @files = map { $_->[0] } >sort { $a cmp $b } >map {[$_, (sta

How does opendir/readdir process files

2015-01-08 Thread Harry Putnam
Opening a directory and readdir with a grep in there to find specific filenames, how does that process collect the files? I mean will the generated @ar of files be oldest first or someother reliable order? Using an example paraphrased from perldoc -f readdir: (I changed the regex) opendir(my $

Get return value when running cmd like this

2015-01-05 Thread Harry Putnam
When running shell commands from perl script with an open() instead of system() or exec how is the return value snagged. I guess, if it doesn't die, it worked but how to snag that information and at what point? --- 8< snip -- 8< snip -- 8', "$log" or die "Can't open $log: $

Re: It works but is very messy

2014-12-08 Thread Harry Putnam
Harry Putnam writes: > sub usage{ ## It's been said that a HEREDOC would be better here. Probably >## true, but just curious why that would be the case >print " > Purpose: Find specific msgid's in procmail.log (including gzipped ones), > return &g

Re: why is if (! @ARGV) skipped

2014-12-06 Thread Harry Putnam
Brandon McCaig writes: > Hope that helps. Yes it does. Thanks for the continuing review and criticism much needed in my case... -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: why is if (! @ARGV) skipped

2014-11-19 Thread Harry Putnam
Harry Putnam writes: > Carl Inglis writes: > >> Interesting - in perl 5.10.1 on my system it works as expected. >> >> One point to note, your "$myscript" in your usage should be escaped >> otherwise you get an error. > > No. That changed in some p

Re: why is if (! @ARGV) skipped

2014-11-19 Thread Harry Putnam
e. [...] Kent Fredric writes: > On 19 November 2014 11:46, Harry Putnam wrote: > >> Only thing I did to debug was to make sure `use File::Find; comes >> after if (!@ARGV), but that seems not to matter. >> > > That will be because 'use' is processed during BE

why is if (! @ARGV) skipped

2014-11-18 Thread Harry Putnam
I'll probably be battered for general poor perlmanship but still risking posting my whole script (fairly brief). The problem I'm having with it, that I don't see how to debug is that it breaks out on code inside Find.pm instead of breaking out on the if clause designed to catch the advent of use

Re: (Possibly a terrible lamer) is `open' format wrong

2014-11-04 Thread Harry Putnam
Shlomi Fish writes: Accidentally left out of my previous resonse. > In addition to what Ken said: > >> cat tst: >> >> #!/usr/local/bin/perl >> >> use strict; >> use warnings; >> >> my $cmd = 'ls /'; >> >> open my $ch, '-|', "$cmd" or die "Can't open $cmd: $!"; >> > > 1. No need to wrap «$cm

Re: (Possibly a terrible lamer) is `open' format wrong

2014-11-04 Thread Harry Putnam
Ken Slater writes: (Note: somehow a post about like below didn't make it to the list when my other response did... this is paraphrasing) >> cat tst: >> >> #!/usr/local/bin/perl >> >> use strict; >> use warnings; >> >> my $cmd = 'ls /'; >> >> open my $ch, '-|', "$cmd" or die "Can't open $cmd: $!"

Re: (Possibly a terrible lamer) is `open' format wrong

2014-11-03 Thread Harry Putnam
Ken Slater writes: > > It is a good idea to avoid using $_ in production code: > > http://perl-begin.org/tutorials/bad-elements/#overuse_dollar_underscore > > So write it as: > > while (my $l = <$ch>) { > print $l; > } Again, easy enough to do. and no doubt it would be good. But why is

(Possibly a terrible lamer) is `open' format wrong

2014-11-02 Thread Harry Putnam
Intermittent programming can lead to brain bleed off. In the real script the command is something only found on solaris or any other zfs filesystem so I just used the first simple command I could think of. But the aim is to use the output of a command to perform a string match. I left that out t

About staying brushed up on perl

2014-07-19 Thread Harry Putnam
First my usage: Single user machines, home lan and basic networking. My specific perl usage is as often just something I want to do as it is some system oriented scripting. --- --- ---=--- --- --- I've been a perl user for several yrs, but never really stay

Re: about open with pipe '-|', '|-'

2014-05-09 Thread Harry Putnam
Kenneth Wolcott writes: > On Fri, May 9, 2014 at 1:41 PM, Harry Putnam wrote: >> I guess I need a mnemonic device to trick myself into remembering >> which way the pipe with dash symbol goes. > > Think of it as "producer" and "consumer". You could

about open with pipe '-|', '|-'

2014-05-09 Thread Harry Putnam
I guess I need a mnemonic device to trick myself into remembering which way the pipe with dash symbol goes. And I suppose I should apologize for the cry baby rant in advance: Even now I'm flopping around trying to remember... I've written scripts involving sending mail with sendmail from pe

[irc Q] how to extract info to disk

2014-05-07 Thread Harry Putnam
I am a complete and total novice to irc. Never used and never wanted to before. Rather than put my vast ignorance on display and annoy the heck out of others on the channel, I'd like to extract information from the irc servers and write it to disk. My most often used scripting language is perl s

Re: small puzzle

2014-04-27 Thread Harry Putnam
Shawn H Corey writes: > On Fri, 25 Apr 2014 12:39:21 -0700 > John SJ Anderson wrote: > >> Perl doesn't charge you by the lines of code you use, so doing this: >> >>my $re = shift; >>$re = qr/$re/; >> >> is just fine. > > This also works: > > my $re = qr/$ARGV[0]/; > shift @ARGV

Re: small puzzle

2014-04-27 Thread Harry Putnam
Uri Guttman writes: > On 04/25/2014 12:55 PM, Harry Putnam wrote: >> Uri Guttman writes: >> >>> why would you expect anything but 1 as the value? shift will return 1 >>> value or undef. that anon array will be dereferenced to an array with >>> 1 e

Re: small puzzle

2014-04-25 Thread Harry Putnam
John SJ Anderson writes: > In general, anywhere you're doing '@{[shift]}', unless you REALLY know > what's going on and why you'd want to do that ... instead just do > 'shift'. Thanks for the in depth answer. Very helpful. You've helped fill some tragic holes in my basic knowledge of perl. I'

Re: small puzzle

2014-04-25 Thread Harry Putnam
Uri Guttman writes: > why would you expect anything but 1 as the value? shift will return 1 > value or undef. that anon array will be dereferenced to an array with > 1 entry. the array is in scalar context which returns its > size. elementary! ^ my dear Watson. Thank you Mr U

small puzzle

2014-04-24 Thread Harry Putnam
Some simple code that is similar to other code I've written and used is returning something I don't understand. I've used the notation below for shifting off elements of AR many times but don't recall seeing this output. I think I know what is happening but I don't understand why. Is the second

Re: Not following the action here.

2013-10-04 Thread Harry Putnam
Jim Gibson writes: [...] >> >> So doesn't it mean that inside find() the program is changing dir >> right along with the search for executable files? That is, every time >> the search digs a directory deeper, `stat' is called inside that >> level. >> >> Isn't that the only way that '$_' would

Re: Not following the action here.

2013-10-03 Thread Harry Putnam
Jim Gibson writes: [...] > For debugging purposes, I usually declare a variable at the top of my program: > > my $debug = 1; > > Then I sprinkle print statements controlled by this variable throughout my > program: > > print "\$_=$_\n" if $debug; > > When my program is debugged and ready to

Re: Not following the action here.

2013-10-03 Thread Harry Putnam
Uri Guttman writes: [...] >> , >> | script.pl ./td >> | $eperm = (stat(./td/./td))[2] >> | $eperm = (stat(./td/./td/three))[2] >> | $eperm = (stat(./td/./td/one))[2] >> | $eperm = (stat(./td/./td/two))[2] >> ` >> >> That will be a non-working comparision > > in your original code and out

Re: Not following the action here.

2013-10-03 Thread Harry Putnam
"John W. Krahn" writes: First, thanks for the input. [...] >> my $exe = 33261; > > Or: > > my $exe = 0100755; Where does that come from? And it appears some kind of conversion must take place. If you print $exe right after assigning it 0100755, it still shows 33261. >> my $eperm; > > You do

Re: Not following the action here.

2013-10-03 Thread Harry Putnam
Uri Guttman writes: [...] >> find( sub { >> return unless -f; >> $eperm = (stat($File::Find::name))[2]; > > you don't have the dir there so the file isn't found by stat. > you need "$f/$File::Find::name" > [...] > >>print $File::Find::name . "\n"; > > that only prints the fil

Not following the action here.

2013-10-02 Thread Harry Putnam
Why is this script showing uninitialized variable warnings? - -----=----- - #!/usr/local/bin/perl use strict; use warnings; use File::Find; my $exe = 33261; my $eperm; my $f = shift; find( sub { return unless -f; $eperm = (stat($File::Find::name))[2];

Take input from user thru another application

2013-09-29 Thread Harry Putnam
I use emacs/gnus as my newsreader. In gnus you can select msgs and then run shell cmds on that selected content. I want to know how to take user input during that action. That is, I run a perl script against the selected content. When that script first starts to process the piped content I want

About variables passed to sub routines

2013-09-24 Thread Harry Putnam
Somehow I had it my mind that perl would recognize an incoming variable to a sub routine like: sub test($var) As $_ if there was only one element to @_, But I see from testing that, no, not true. These three methods below all work. Perhaps there are others. if ( -f "@_" ) (my $fname) =

Re: Make a sub routine return

2013-09-11 Thread Harry Putnam
Harry Putnam writes: Jesus... who wrote this illiterate crud? > Harry Putnam writes: > > Sorry to have dropped out on this. I called away and now have other ^ got > scripting to get done. > > But

Puzzled by ouput from this script

2013-09-11 Thread Harry Putnam
Posted below is a shortened down version of a larger script that tries to show the phenomena I'm seeing and don't understand. I'm running rsync from a perl script so I first thought the output was from rsync, but as I tinkered around I began to notice that as I changed things around a bit, the lin

Re: Puzzled by ouput from this script

2013-09-11 Thread Harry Putnam
Robert Wohlfarth writes: > On Wed, Sep 11, 2013 at 5:04 PM, Harry Putnam wrote: > > >> while(<$cmdh>) { >> print $fh; >> print; >> > > > I believe this code prints the file handle. Try this: > while(<$cmdh>){ > print $fh $

Re: Make a sub routine return

2013-09-11 Thread Harry Putnam
Harry Putnam writes: Sorry to have dropped out on this. I called away and now have other scripting to get done. But didn't want anyone to think I didn't appreciate the replies. The walk thru of my (poor) could is very helpful... Thanks -- To unsubscribe, e-mail: beginner

Re: Print to several logs

2013-08-28 Thread Harry Putnam
Shawn H Corey writes: > On Wed, 28 Aug 2013 10:42:30 -0400 > Harry Putnam wrote: > >> Thanks to all other posters.. lots of good input. > > It seems to me that recording the same information is many places is a > design flaw. If you have the same information in two or mo

Make a sub routine return

2013-08-28 Thread Harry Putnam
I know the format and scripting are probably pretty backwards but I seem to recall it being important to have a `return' line in a function. The code below was a script by itself but now I need to turn it into a function inside a larger script... I've done something that sort of works but fails o

Re: Print to several logs

2013-08-28 Thread Harry Putnam
Rob Dixon writes: > On 27/08/2013 23:06, John W. Krahn wrote: >> Harry Putnam wrote: [...] >>> (Simplified for discussion, from a longer script) >>> >>>my $rsync = 'rsync'; >>>my $tmplog = 'one.log'; >>>my $t

Print to several logs

2013-08-27 Thread Harry Putnam
I happen to be scripting something that needs to have two logs written to and was sort of taken by how awkward this construction looked: (Simplified for discussion, from a longer script) my $rsync = 'rsync'; my $tmplog = 'one.log'; my $tmplog2 = 'two.log'; open(LOG,">>$tmplog")or die "Ca

Re: Is this one line out of date (circa 2002)

2012-02-15 Thread Harry Putnam
Rob Dixon writes: >> And then (trying to print just the time column >> perl -i -n -a -e 'print @F[6];' ping.lst >> >> But there is no output at all. > > The -i option calls for in-place editing, where the output from Perl > replaces the input file. Take a look at ping.lst and you should find >

Is this one line out of date (circa 2002)

2012-02-13 Thread Harry Putnam
I found some one liners on this web page: http://www.techrepublic.com/article/use-command-line-perl-to-make-unix-administration-easier/1044668 This one appears not to work at all. Can anyone say why that is? Is it just too old? >From the cited page: , | The command provided using the -e op

Re: extracting exif information from images

2012-02-11 Thread Harry Putnam
"John W. Krahn" writes: >> #!/usr/local/bin/perl >> >> use strict; >> use warnings; > > Could it be that your editor is putting a BOM as the first two > characters of your program? It never has before but if so would that show up using the `l' (ell) operator in sed? Or could a BOM sneak right by

Re: extracting exif information from images

2012-02-11 Thread Harry Putnam
Ken Slater writes: Harry wrote: >>  use Image::ExifTool qw(:Public); >> >>  # Simple procedural usage >> >>  # Get hash of meta information tag names/values from an image >>  $info = ImageInfo('a.jpg'); >> >>  # Object-oriented usage >> >>  # Create a new Image::ExifTool objec

Re: Command line perl to stat a file

2012-02-11 Thread Harry Putnam
Kevin Spencer writes: > On Fri, Feb 10, 2012 at 10:52 AM, Harry Putnam wrote: >> >> But these command line attempts fail: >> >> (all on one line) >>  perl  -e 'my ($seven, $nine) = >>    (stat('./SweetwatterPk-016.jpg'))[7, 9]; >>    

Re: Command line perl to stat a file

2012-02-11 Thread Harry Putnam
Rob Dixon writes: > Something like this perhaps? > > perl -e "print join ' and ', (stat shift)[7,9]" ./SweetwaterPk-016.jpg Nice... yes Thanks > But I would think the modification time (stat 9) wouldn't be of much > use without formatting it. In this case it was just for a quick command lin

Command line perl to stat a file

2012-02-10 Thread Harry Putnam
This script: --- 8< snip -- 8< snip -- 8http://learn.perl.org/

extracting exif information from images

2012-02-06 Thread Harry Putnam
I've been looking around, googling for a way to extract exif info from images. There are many tools out there. But I wanted to fiddle with the information in very specific ways. I hit on the perl module: Image-ExifTool (Phil Harvey) on cpan. However I am apparently badly misunderstanding the usa

Re: Renaming with a specific spec

2011-02-04 Thread Harry Putnam
Jim Gibson writes: > On 2/4/11 Fri Feb 4, 2011 8:02 AM, "Harry Putnam" > scribbled: > >> >> One further question. In your formulation shown below: >> , >> | unless($filename =~ m(.+\.(bmp|gif|jpg|png|psd|tga|tif)$)) >> | { >&g

Re: Renaming with a specific spec

2011-02-04 Thread Harry Putnam
Brandon McCaig writes: > On Thu, Feb 3, 2011 at 4:59 PM, Harry Putnam wrote: >> May I ask how that formulation servers the purpose better?  Is it >> processed more easily or quicker in that formulation as against the >> one I posted? >> >> Or does mine leav

Re: Renaming with a specific spec

2011-02-03 Thread Harry Putnam
Jim Gibson writes: > This line assigns an upper-case letter to $d if $d has a value greater > than or equal to 10. A value of 10 is replaced by 'A', 11 by 'B', etc. > > $d = chr($d + ord('A') - 10) if $d >= 10; > > You can try changing that 'A' to 'a' and see what you get. I haven't > tried t

Re: Renaming with a specific spec

2011-02-03 Thread Harry Putnam
Brandon McCaig writes: > On Thu, Feb 3, 2011 at 10:47 AM, Harry Putnam wrote: >> I used this in my crude little starter program as one part of a >> foreach loop: >> >>  if ( !/^.*\.[bjgtp][gimnps][gfadp]$/) { >>    print "<$_> is not a properly

Re: Renaming with a specific spec

2011-02-03 Thread Harry Putnam
Rob Dixon writes: > Hey Harry > > As Jim says, there is very little chance that you will find an existing > module that conforms to such a tight specification, but such a facility > is trivial to write. Take a look at the program below and see if it > helps you with a solution. [...] Skipped nif

Re: Renaming with a specific spec

2011-02-01 Thread Harry Putnam
Jim Gibson writes: [...] "John W. Krahn" writes: [...] Rob Dixon writes: [...] I had roughed out something that worked (sort of) and so found some of the problems that come up (such as overwriting). With the excellent input provided from the above cited posts, I can now manage a pretty ni

Renaming with a specific spec

2011-01-31 Thread Harry Putnam
Looking for a renaming tool with certain capabilities, but when googling or searching cpan its quite hard to tell if the tool can or not satisfy them. So, I hope someone can tell me right off the top of their head if there is a renaming tool on cpan or anywhere else for that matter that can handle

reducing decimal ouput

2010-12-06 Thread Harry Putnam
Is there any way to reduce the amount of decimals math might be carried too short of printf? I always find printf to end up taking a fair bit of time, since I've forgotten most of what I ever knew about it each time I run into a need for it. I just wondered if there is any other kind of limiting

Re: A subroutine to find every occurrence of a substring in a string?

2010-06-12 Thread Harry Putnam
"Chas. Owens" writes: > A quick reference guide for operators: > http://github.com/cowens/perlopquick/blob/master/perlopquick.pod Is this just a typo, or am I not understanding what is presented at, I think, the 5th occurrence of the term `Example' on the above URL: Example my @a = qw/ a b

html stipper to use with regex search tool

2010-06-06 Thread Harry Putnam
There is such a clot of stuff on cpan... I'm hoping to get a little coaching here first. If my aim is to write a `home use' tool for searching thru code in html pages. (perl code I mean) there is always the problem of hits containing piles of html glop. Can anyone suggest a module that can help m

Re: script output => color highlight to stdout

2010-05-28 Thread Harry Putnam
trapd...@trapd00r.se writes: > And if you want to work with 256 colors (note that not all terminals support > this, and it should be avoided if it's not for your own use) you can do > something like this: > > > my @colors; > for(my $i=0;$i<256;$i++) { > push(@colors, "\033[38;5;$i".'m'); > } > p

Re: Which module ... ???

2010-05-27 Thread Harry Putnam
newbie01 perl writes: > Hi all, > > With multiple Perl install, there will be multiple versions of the same > modules. > > How can you change the order of where @INC look for the specific version of > the module that you want to use? Is this done by using use lib? > > use lib qw(/path/to/one/libr

script output => color highlight to stdout

2010-05-27 Thread Harry Putnam
I wondered if anyone could steer me to some information about making perl script output appear in color highlight on stdout. Something like what modern grep does on linux, where the searched term appears in some color (red) in the output to tty. -- To unsubscribe, e-mail: beginners-unsubscr...

Re: append to a hash?

2010-05-21 Thread Harry Putnam
Bryan R Harris writes: >> >>I have code that looks like this: >> >>** >>if ($props =~ /\S/) { >>%{$ptr[-1]->[-1]} = ($props =~ m/\s*([^=]+)="([^"]+)"/g); >> >> where is @ptr set? what are you using it for? > > Earlier, of course. Probabl

Re: Still pondering working with hashs

2010-05-11 Thread Harry Putnam
Shawn H Corey writes: Oh nice... thanks. Hope I can get to try this out later tonight... I have to go out for a while and can't get to it right now though. The main `for loop' near the end, and really, all of it, looks to be highly portable like the inversion code was I think that little in

Re: Still pondering working with hashs

2010-05-11 Thread Harry Putnam
Jim Gibson writes: Harry wrote: >> Shawn, hoping to pester you once more about this topic. Jim G responded: > It is not fair to single out Shawn for help. Just post your question > and hope for a response. Just a manner of speaking, but you're right it does appear to be a little off the wall.

Re: Still pondering working with hashs

2010-05-11 Thread Harry Putnam
Shawn H Corey writes: > Harry Putnam wrote: >> But, is there an easier way? > > Invert both hashes and find the keys in both inverses. Shawn, hoping to pester you once more about this topic. first: Hashes involved are built like this (Using File::Find nomenclature): (N

Re: how to arrange a default action in a dispatch table

2010-05-10 Thread Harry Putnam
"John W. Krahn" writes: > Because /\A\d+\z/ has less ambiguity then /^\d+$/. "Dr.Ruud" writes: > And /\A[0-9]+\z/ is probably what was really meant. Got it, and thank you both. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.or

Re: Inverting a hash

2010-05-09 Thread Harry Putnam
Jim Gibson writes: > my @original_keys = @{$inv_hash{$inverted_key}}; > > The element of the inverted hash is an array reference. The array is fetched > (copied into @original_keys) by de-referencing the reference. If there was > only key with the value $invereted_key, then the array @original_ke

Re: Inverting a hash

2010-05-09 Thread Harry Putnam
Harry Putnam writes: > [...] > > ARRAY(0x91af588) convol5.pnm > exits only in rh1 > --- --- --- > ARRAY(0x91aeb38) .arch-inventory > exits only in rh1 > > [...] > > How can I get the actual name represente

Re: Inverting a hash

2010-05-09 Thread Harry Putnam
Shawn H Corey writes: > my %inv_hash = invert( \%hash ); > print '%inv_hash: ', Dumper \%inv_hash; > > This will output: > > %inv_hash: $VAR1 = { > 'f2' => [ > './b/l/c/f2' > ], > 'fb' => [ > './b/fb', > './b/g/h/r/fb' > ], > 'fc' => [ > './b/g/f/r/fc' > ], > 'fd

Re: Inverting a hash

2010-05-09 Thread Harry Putnam
"Uri Guttman" writes: > as others have shown, that fails because of the dup value of 'fb'. but > in some cases where you know there are no dups, then reverse is a fine > solution. it all depends on the data and what you want to see when you > invert the hash. Well give the devil his due... you a

Re: Inverting a hash

2010-05-09 Thread Harry Putnam
Dermot writes: [...] > my %inverse_hash = invert( \%hash ); > > invert() is being passed a reference to the hash. References are a > useful and efficient way to pass data around [1]. You can create a > reference by putting a back-slash in front of your data. EG: [...] snipped more good info T

Re: Inverting a hash

2010-05-09 Thread Harry Putnam
Shawn H Corey writes: First, let me thank you for explaining every one of my questions simply and fully. Really nice to know there are people who seem to understand so much of this. [...] > my %inv_hash = invert( \%hash ); > print '%inv_hash: ', Dumper \%inv_hash; > > This will output: > >

  1   2   3   4   5   >