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
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/ ) {
>
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
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(","
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
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;
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
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
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/
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,
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,
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
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
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
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
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
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
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
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
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
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
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
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
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;
>>);
&
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
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/
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
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
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
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
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
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
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 $
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: $
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
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/
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
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
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
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
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: $!"
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
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
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
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
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
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
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
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
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'
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
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
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
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
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
"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
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
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];
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
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) =
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
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
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 $
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
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
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
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
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
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
>
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
"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
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
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];
>>
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
This script:
--- 8< snip -- 8< snip -- 8http://learn.perl.org/
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
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
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
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
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
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
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
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
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
"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
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
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
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
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...
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
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
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.
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
"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
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
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
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
"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
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
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 - 100 of 478 matches
Mail list logo