Search Results

Search: Posts Made By: deindorfer
5,622
Posted By deindorfer
Could you be more specific, please?
Could you be more specific, please?
3,983
Posted By deindorfer
Useless use of cat!
:D



grep -v "^\(.\).*\(.\) -> \1.*\2$" data

In Perl:


perl -lne '!/^(.).*(.) -> \1.*\2$/ && print' data



both of these will ( errantly? ) not catch this data:



tigerr -> tiger
11,540
Posted By deindorfer
Unix - Windows FTP Transfer Perl
Some Suggestions.

1. Turn the "Debug" Param on: Debug => 12. Set it to "2" if that shows more output ( it does with Net::SSH::Perl ) e.g. Debug => 23. Check if you can login to the win machine...
7,636
Posted By deindorfer
Float Manipulation with Perl
This will multiply two floats and print the result. You can modify the precision and padding by changing the FORMAT in the printf() statement. perldoc -f sprintf
printf "%f\n", $f1 * $f2;Maybe that...
3,995
Posted By deindorfer
Net::Telnet::Cisco
http://search.cpan.org/~joshua/Net-Telnet-Cisco-1.10/Cisco.pm#Sending_multiple_lines_at_once (http://search.cpan.org/%7Ejoshua/Net-Telnet-Cisco-1.10/Cisco.pm#Sending_multiple_lines_at_once)
2,315
Posted By deindorfer
cpan prerequisites follow
In ~/.cpan/CPAN/ there is a file called MyConfig.pm. This is where your configuration is written when you type "o conf commit" at the cpan shell. You already have figured out the directive to set,...
12,524
Posted By deindorfer
Revised Perl Script Outputting Code Snippets to a text file
This seems like an odd thing to want to do, but here you go.



open ( F, "data.txt" ) || die;
open ( G, ">perlcode.txt" ) || die;

while (<F>) {

chomp;
my ($k, $v);
( $k, $v...
12,524
Posted By deindorfer
Simple Perl Script to Make a Hash Table out of incoming, comma separated record
This code assumes your data is in an external file ( which I called dat.txt ), and that the data has two fields which are comma separated.

I did not make any attempt to golf it ( make brief ),...
1,601
Posted By deindorfer
previous post changes the input order because of the ascii sort, not the hash
perl -ne 'if ( /(^\d+$)/ ) { $h{++$i} = $1 . ". " }; if ( /(^[a-z]+)$/ ) { $h{$j} = $h{++$j} . $1 }; END { print map "$h{$_}\n", sort { $a <=> $b } keys %h }' data



This does not change the...
10,518
Posted By deindorfer
Split Large file with 2
You are correct that the first line is redundant, i.e. you could simply do this:



bash> head -100000 | perl -e '....' > out.1




I use this idiom frequently, and I like starting the...
10,518
Posted By deindorfer
The algorithm in Array::Transpose is better than...
The algorithm in Array::Transpose is better than the one I was working together, I would suggest using that. The out of memory error is still there because there is still a single array holding all...
10,518
Posted By deindorfer
Array::Transpose Uses two Variables
if the first example I gave runs the box out of memory with only one array, using Array::Transpose should run the box out of memory twice as quickly, yes?

After a brief RTS A::T uses two named...
10,518
Posted By deindorfer
it could. there are many ways to find out if...
it could. there are many ways to find out if that is the case. Here is one way:



shell_prompt-> head -1 datafile



if that kicks back the whole file, there are no line endings
10,518
Posted By deindorfer
Convert Colums to Rows
perl -F, -lane 'for ( 0 .. $#F ) { $rows[$_] .= $F[$_] }; eof && print map "$_\n", @rows' data



if the file "data" contains CSV data, like this:



1,2,3,4,5,6,7
a,b,c,d,e,f,g



The...
1,601
Posted By deindorfer
One Liner That Scales
perl -ne 'if ( /(^\d+$)/ ) { $h{++$i} = $1 . ". " }; if ( /(^[a-z]+)$/ ) { $h{$j} = $h{++$j} . $1 }; eof && print map "$h{$_}\n", sort keys %h' data
Forum: Solaris 06-03-2010
4,034
Posted By deindorfer
Undeleteable files: Immutable Bit Set?
check out the man pages for the /usr/bin/lsattr and /usr/bin/chattr command ( by Remy Card ).

They can do some pretty interesting things to files and filesystems, including setting the immutable...
1,719
Posted By deindorfer
Right my mistake, I had incorrectly cited the...
Right my mistake, I had incorrectly cited the source material you did not cite as the source of your post, as being the 2nd Edition of the Perl Cookbook. It is indeed the First Edition where you got...
1,719
Posted By deindorfer
Cite Reference Material Please
I hope Tom and Nat answered your question.

--Tom Christiansen, Nathan Torkington, "The Perl Cookbook, 2nd Edition" O'Reilly & Associates, May 1999, Chapter 6, Section 15 ;););)
1,719
Posted By deindorfer
Probably misunderstanding you here, but what's...
Probably misunderstanding you here, but what's wrong with:



print $1 if $str=~/This.*(test).*$/;



That matches a "This", followed by zero-or-more of anything, followed by "test", followed...
14,594
Posted By deindorfer
Perl's Wonderful Versatility
UncleCameron: Yes. This is an excellent point, and you stated clearly. One of the great advantages of Perl is that it can go toe-to-toe with awk and sed for command-line work; toe-to-toe with...
14,594
Posted By deindorfer
Perl Complaints, No Substance
Write my Geohash Code in Python in Fewer lines and/or so that it executes more quickly. and post please. No copying. The XKCD Geohash is a well known exercise, by now. and we will see. Where's...
14,594
Posted By deindorfer
Perl: XKCD Geohash Generator
Ever Read XKCD? Check this out: xkcd: Geohashing (http://xkcd.com/426/)

here's a Perl Script that implements the algorithm in the comic:



#! /usr/bin/perl

use strict;
use warnings;
...
1,817
Posted By deindorfer
Perl One-Line Substitution
(my $a = 'a,b,c' ) =~ s/b\,//;
print $a



There you go :b:
2,682
Posted By deindorfer
Here's how to do the erase and create the backup...
Here's how to do the erase and create the backup file one-shot with Perl.



perl -pi.bak -e 's/PATTERN//g' /etc/vfstab

replace the string "PATTERN" in the above code with the one...
2,045
Posted By deindorfer
Perl: Unbuffered Keyboard Read to Exit Running Code
use Term::ReadKey;
ReadMode 4;

until ( ReadKey(-1) eq 'Q' ) {
... Your Program Here ...
}

ReadMode 0; # Reset tty before exiting
exit;



There you are, sir.
Showing results 1 to 25 of 63

 
All times are GMT -4. The time now is 08:44 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy