Re: [Fwd: fetchrow_arrayref()]

2005-07-13 Thread Jeff 'japhy' Pinyan
ithout making typos first. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -

Re: Regular Expressions

2005-07-13 Thread Jeff 'japhy' Pinyan
".g" part optional (so long as the word boundaries still match). The remaining problem is in the definition of a "word". What about "I got a grab-bag gift"? Should "grab-bag" match? It doesn't currently, because the '-' is not a vali

Re: rounding in perl?

2005-07-12 Thread Jeff 'japhy' Pinyan
gt; 100 round(123.456,-1) --> 120 round(123.456)--> 123 round(123.456,0) --> 123 round(123.456,1) --> 123.5 round(123.456,2) --> 123.46 It works with positive and negative numbers (both as the numbers BEING rounded and the places to round TO). -- Jeff "japhy" P

RE: Intelligent Sorting

2005-07-07 Thread Jeff 'japhy' Pinyan
ToNumber{lc($a->[2])} <=> $AlphaToNumber{lc($b->[2])} or $a->[3] <=> $b->[3] } map { [ $_, /^.(\d{4})(\w{3})(\d{2})/ ] } @user_links; Here, your @user_links array holds the data that Wags was reading from the DATA filehandle. We still execute the map() o

Re: FAQ

2005-07-07 Thread Jeff &#x27;japhy&#x27; Pinyan
rd) a line of output print $write "$x\n"; <$read>; # read (and discard) the next line of output print $write "$y\n"; chomp(my $z = <$read>); # read (and save) the next line of output close $read; close $write; -- Jeff "japhy&q

Re: Query on File::Find

2005-07-07 Thread Jeff &#x27;japhy&#x27; Pinyan
") }, no_chdir => 0, }, $spec_entry); Here, we create an anonymous function (sub { ... }) and use it. This anonymous function, when called, just calls the find_...(...) function. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Bro

Re: Intelligent Sorting

2005-07-06 Thread Jeff &#x27;japhy&#x27; Pinyan
, you could convert the month NAMES to numerical representations (Jan => 01, Dec => 12), and then after you've sorted them (ASCIIbetically will work here) you can change those numerical representations back to the month names. -- Jeff "japhy" Pinyan % How can w

RE: Emptying Arrays

2005-07-06 Thread Jeff &#x27;japhy&#x27; Pinyan
ing variable a lot (and it needs a descriptive name). -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %

Re: reg exp help

2005-06-28 Thread Jeff &#x27;japhy&#x27; Pinyan
. Identical. Use a flip-flop. It's easier. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %--

Re: Emptying Arrays

2005-06-28 Thread Jeff &#x27;japhy&#x27; Pinyan
ay and just use the return value from grep() in-place: for my $host (@hosts) { my %freq; $freq{$_}++ for grep /$host/i, @logfile; # open file for (sort keys %freq) { print "$_: $freq{$_}\n"; } # close file } Voila. -- Jeff "japhy" Pinyan

Re: reg exp help

2005-06-28 Thread Jeff &#x27;japhy&#x27; Pinyan
while () { # this is better-looking than 'for (;;)' if (/^-BEGIN/ .. /^-END/) { print; } } The flip-flop operator (..) is *false* UNTIL the left expression evaluates to true. THEN it STAYS *true* until the right expression evaluates to true. -- Jeff

Re: Run a subroutine, then replace subroutine and run again

2005-06-27 Thread Jeff &#x27;japhy&#x27; Pinyan
my %copy = %something; foo2(); Now you have %copy and %something. Is that the situation? -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been

Re: A file-handle query

2005-06-24 Thread Jeff &#x27;japhy&#x27; Pinyan
rewind it, you need to write seek(FILEHANDLE, 0, 0); to get back to the beginning. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago

Re: trying up date a hash

2005-06-21 Thread Jeff &#x27;japhy&#x27; Pinyan
x27;t need the quotes around the hash key 'bbookref' if it's a simple string (no whitespace or non-alphanumeric characters): $fullXmlHash{$xmlData{bbookref}} = \%xmlData; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734

Re: regex: working with parts of strings several times over..

2005-06-20 Thread Jeff &#x27;japhy&#x27; Pinyan
then > (.*?)# zero or more characters ($2) (?= <.+?> ) # look ahead for '<...>' (but don't actually match it) }{<$1>$2}xg; The /x modifier there allows me to embed that whitespace and comments in the regex half of the s///, and the /g modifier me

Re: hashes and loops

2005-06-14 Thread Jeff &#x27;japhy&#x27; Pinyan
hash, print it." so this is doing # the job of reading EACH line of EACH file, and ONLY printing those # lines which are not found in the %exclude hash. while (<>) { chomp; print "$_\n" unless $exclude{$_}; } } Presto! perldoc perlrun (for $^I

Re: ???UNSURE??? Re: need help with regular expression

2005-06-14 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jun 14, Praedor Atrebates said: On Tuesday 14 June 2005 17:34, Jeff 'japhy' Pinyan wrote: The [...] construct is a character class -- it represents a set of characters, any of which can match. Thus, [KRH] matches a 'K', an 'R', or an 'H'. But [A{3

Re: need help with regular expression

2005-06-14 Thread Jeff &#x27;japhy&#x27; Pinyan
ictive than I've started out with? Hrm, so the middle part must be NO LESS than 3 and NO MORE than 5, and is made up solely of L, V, I, F, Y, and A characters? $dnakmotif = qr/[KRH][LVIFYA]{3,5}[KRH]/; looks like it does the trick. -- Jeff "japhy" Pinyan % How can we ever

Re: Using Overload module

2005-06-13 Thread Jeff &#x27;japhy&#x27; Pinyan
nly eixsts inside those { } blocks of code. Do this instead: my $n; if ($a < 10) { $n = two_face->new("vii", 7) } else { $n = two_face->new("viii", 8) } -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734

Re: select case or switch statement

2005-06-11 Thread Jeff &#x27;japhy&#x27; Pinyan
7;m using Perl -v 5.8.0. The Switch.pm module isn't standard with Perl, but is a way to do it... ... but in your case, all you really need is a hash! my %day_of_week = ( mon => 0, tue => 1, wed => 2, thu => 3, fri => 4, sat => 5, sun =

Re: Change the format of $@

2005-06-11 Thread Jeff &#x27;japhy&#x27; Pinyan
e at the end of your argument to die(), there will be no file and line number information. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been over

RE: host id

2005-06-10 Thread Jeff &#x27;japhy&#x27; Pinyan
ply begins. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [

Re: question about appending spaces to each line of a file

2005-06-03 Thread Jeff &#x27;japhy&#x27; Pinyan
tsoever and from the second line onwards, the spaces are appended at the beginning of the line instead of the end. That doesn't sound right... you *are* chomp()ing the string, so the newline should disappear. Perhaps you also have \r (carriage return) at the end of each line too? -- Jeff

Re: Search Pattern for Roman Numerals?

2005-06-03 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jun 3, Jay Savage said: On 6/3/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote: s/\b(I|II|...)\b//g; This isn't going to get them all; it says to match (between word boundaries) "I" or "II" or any three non-newlines. So it will catch "I

Re: Search Pattern for Roman Numerals?

2005-06-02 Thread Jeff &#x27;japhy&#x27; Pinyan
aren't touching any word characters. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister

RE: Seaching for Words at the beginning of the line and end of line

2005-06-02 Thread Jeff &#x27;japhy&#x27; Pinyan
not a character. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-ma

Re: Seaching for Words at the beginning of the line and end of line

2005-06-02 Thread Jeff &#x27;japhy&#x27; Pinyan
roblems" and "abintern" won't match. ("Abintern" isn't a word, but I wanted to prove a point.) -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.

Re: invocant

2005-06-02 Thread Jeff &#x27;japhy&#x27; Pinyan
es PERL know not to put in another one? I don't have my Camel at hand. Is this an AUTOLOADing issue? -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have lon

Re: [Summary]: End of line character

2005-06-01 Thread Jeff &#x27;japhy&#x27; Pinyan
On Jun 1, Dermot Paikkos said: s/\s*$//; # delete all whitespace at the end of the string Except that it's awfully silly-looking. I'd *at least* do s/\s+$//; which is monumentally faster, although not perfect. -- Jeff "japhy" Pinyan % How can we ever be t

Re: Problem with replaceing

2005-06-01 Thread Jeff &#x27;japhy&#x27; Pinyan
t". So your regex would be s!\^AMATH\^D(\d{7}\.dat):(\d{1,2})\^B!math($1,$2)!eg; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been over

Re: is there a simple way get the current line number of processed file?

2005-05-26 Thread Jeff &#x27;japhy&#x27; Pinyan
able holds the current line number. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhar

Re: bold print to a FH

2005-05-26 Thread Jeff &#x27;japhy&#x27; Pinyan
e 45 main::mediausage() called at disk_cache-tape_slot-usage.pl line This means that Perl is interpreting your code as print MU color("bold", "Media Usage Key ..."); and the problem is that the color() function isn't expecting that "Media" string. Th

Re: open file failed

2005-05-25 Thread Jeff &#x27;japhy&#x27; Pinyan
'#!/usr/bin/perl\n' which means that Unix is looking for the program '/usr/bin/perl\r', and that file doesn't exist. Another question is what is the simplest way to replace "\r\n" with "\r" or "\n"? I think you'd just want to remove

Re: assigning printf statement to an array

2005-05-25 Thread Jeff &#x27;japhy&#x27; Pinyan
On May 25, John Doe said: Am Mittwoch, 25. Mai 2005 04.10 schrieb Jeff 'japhy' Pinyan: Jeff, thanks a lot for taking over. My explanation would not have been so understandable and with this fullness. Glad to be of service. -- Jeff "japhy" Pinyan % How can we ev

Re: while loop -> map

2005-05-25 Thread Jeff &#x27;japhy&#x27; Pinyan
On May 25, Jay Savage said: On 5/25/05, Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> wrote: On May 25, Jay Savage said: /e(?{push @bar, pos})/g; should work, but seems to ignore the /g. Because as you wrote it, the regex is in void context, which means it'll only match

Re: while loop -> map

2005-05-25 Thread Jeff &#x27;japhy&#x27; Pinyan
I'd do: /e(?{ push @bar, pos })(?!)/; If 'e' is more than one character, you'll need to use /(?>pattern)(?{ push @bar, pos })(?!)/; You could also use $-[0] instead of pos(). -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acac

Re: string, worlds

2005-05-25 Thread Jeff &#x27;japhy&#x27; Pinyan
\b (word boundary) anchor will fail, and the regex will backtrack until it reaches a point where there's a word character on one side and a non-word character on the other. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the

RE: Can't use subscript in angle brackets

2005-05-25 Thread Jeff &#x27;japhy&#x27; Pinyan
e using an array. In fact, you already HAVE the array (@files) since you're using the elements of the array both as paths to files AND as the filehandles themselves. It's a little unorthodox, but it's not a crime. I wouldn't do it, though, I'd create filehandles: my @

Re: Count special character

2005-05-24 Thread Jeff &#x27;japhy&#x27; Pinyan
in Perl, you have to use chr(8596) or a hex sequence like \x{2194}. Next, tr/// doesn't know what "\chr(29)" means. tr/// just takes normal characters, octal or hex escape sequences, and ranges (two characters with a - between them). my $count = ($a =~ tr/\x{2194}//); works

Re: assigning printf statement to an array

2005-05-24 Thread Jeff &#x27;japhy&#x27; Pinyan
for (@all_files) { push @files, $_ if $_ ne "." and $_ ne ".." } # lines 4-7 my @files_and_ages; for (@files) { push @files_and_ages, [ sprintf(...), $_ ]; } # line 3 my @old_files; for (@files_and_ages) { push @old_files, $_ if $_->[0] &g

Re: a question about print in array

2005-05-24 Thread Jeff &#x27;japhy&#x27; Pinyan
ot;this", "that", "those"), then "@array" is "this that those". However, if @array is ("this\n", "that\n", "those\n"), then "@array" is "this that those ". Don't put the array in quotes when

Re: efficiency of hash of hashes/lists

2005-05-22 Thread Jeff &#x27;japhy&#x27; Pinyan
; but this one is really slow from what i see. How have you seen this to be slow? -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been over

Re: Removing multiple spaces

2005-05-18 Thread Jeff &#x27;japhy&#x27; Pinyan
q is for strings, and you're trying to use character classes (or more generally, regexes). if (substr($line, 0, 1) =~ /[a-zA-Z]/) { ... } and if ($line =~ /^[\s\d]+$/) { ... } probably do what you want. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acaci

Re: One liner to process stdin/stdout similar "in place edit", grep, cut and awk ($5 PayPal reward for the best answer!)

2005-05-18 Thread Jeff &#x27;japhy&#x27; Pinyan
On May 18, Lance Murray said: perl -i -p -e "s/oldhostname/newhostname/g" /etc/hosts However, what is the syntax if I wanted to just process a text stream to stdout?, e.g.: cat /etc/hosts | perl "s/in_text/out_text/g" Simple: use the -p and -e switches, but not the -i sw

Re: $variables in a string

2005-05-16 Thread Jeff &#x27;japhy&#x27; Pinyan
On May 15, Paul D. Kraus said: Hello, my $image = Image::Magick->new; # trouble open(IMAGE, 'open(IMAGE, "That needs to be open(IMAGE, " That's because the variable name is 'sku', not 'sku_unprocessed'. -- Jeff "japhy" Pinyan % Ho

Re: modify PVA.pl (z/OS and perl-5.8.6)

2005-05-13 Thread Jeff &#x27;japhy&#x27; Pinyan
out when the hash gets re-optimized, etc. Second, do you know how this test is failing to recognize the 'ea' abbreviation? I might be able to help, but we'd have to see some sample code that demonstrates the problem. -- Jeff "japhy" Pinyan % How can we ever

RE: Perl One-liner de-compile?

2005-04-25 Thread Jeff &#x27;japhy&#x27; Pinyan
@F) = split(" ", $_, 0); print $f[4]; } -e syntax OK Perl will magically produce the @F array for you, as shown. It's up to YOU not to make the typo. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated,

Re: back to orininal question

2005-04-18 Thread Jeff &#x27;japhy&#x27; Pinyan
$self = shift; # my @loop = GetOfficers($self); my @loop = GetOfficers(); } You should be doing: my @loop = GetOfficers($self); -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.p

Re: passing database data to a sub

2005-04-17 Thread Jeff &#x27;japhy&#x27; Pinyan
ML_ProjectName => $row->{Name}, ); # put this row into the loop by reference push(@Officer, \%line); } return @Officer Instead, say return [EMAIL PROTECTED]; } -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the c

Re: Operation `eq': no method

2005-04-14 Thread Jeff &#x27;japhy&#x27; Pinyan
On Apr 14, Jeff 'japhy' Pinyan said: On Apr 13, Anish Kumar K said: The code gives strange error $subject = I get some value from the function Yes, and it's an object of class XML::LibXML::NodeList that doesn't have an 'eq' operator overloaded for it. Contact th

Re: Operation `eq': no method

2005-04-14 Thread Jeff &#x27;japhy&#x27; Pinyan
ot;. Any idea why? Because you used '...' to send the string to perl -e, that's why. Your internal quotes are the same as your external quotes. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we w

Re: Operation `eq': no method

2005-04-14 Thread Jeff &#x27;japhy&#x27; Pinyan
if ("$subject" eq '' or not defined $subject) { ... } And I would do those tests in the other order: if (not defined $subject or "$subject" eq '') { ... } Assuming the object CAN be string-ified, then putting it quotes will help you to work around the pr

Re: Attempting OO with Perl - New() method in subclass not working

2005-04-01 Thread Jeff &#x27;japhy&#x27; Pinyan
On Apr 1, Randal L. Schwartz said: "Jeff" == Jeff 'japhy' Pinyan <[EMAIL PROTECTED]> writes: Jeff>sub new { Jeff> my $that = shift; Jeff> my $class = ref($that) || $that; Jeff> my $self = $class->SUPER::new(); Jeff> $self-&

Re: Attempting OO with Perl - New() method in subclass not working

2005-03-31 Thread Jeff &#x27;japhy&#x27; Pinyan
) method is calling LogonDB's _init() method. To get around that, you'll have to do: package DBLogon; use Logon; @ISA = qw (Logon); use Carp; sub new { my $that = shift; my $class = ref($that) || $that; my $self = $class->SUPER::new(); $self->SUPER::_i

Re: quick regex question

2005-03-31 Thread Jeff &#x27;japhy&#x27; Pinyan
On Mar 31, Ramprasad A Padmanabhan said: $str = "[EMAIL PROTECTED]"; Should become [EMAIL PROTECTED] I'd use index() and substr(): if ((my $p = index($str, '@')) > -1) { substr($str, $p) =~ tr/_/./ } -- Jeff "japhy" Pinyan % How can we ever be the

Re: regexp help

2005-03-28 Thread Jeff &#x27;japhy&#x27; Pinyan
think of is: s/(\S+)(\s+)(\S+)/$3$2$1/g; That reverses every pair of fields, and retains the whitespace that was between them. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.pe

Re: Module questions (perhaps a module creation mini-tutorial)

2005-03-25 Thread Jeff &#x27;japhy&#x27; Pinyan
alue? If there is no explicit return value for a function, it returns the LAST thing it evaluated. As far as documentation goes, please read perldoc perlboot -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for ever

Re: inplace editing

2005-03-16 Thread Jeff &#x27;japhy&#x27; Pinyan
exmorf_ruisweg2.pl line 12." Windows doesn't let you do in-place editing without making a backup file. Therefore, $^I can't be "". Make it ".bak", and you'll be fine. -- Jeff "japhy" Pinyan % How can we ever be the sold short

Re: System o/p to a varaible

2005-03-15 Thread Jeff &#x27;japhy&#x27; Pinyan
On Mar 15, Chris Devers said: system($command) or die "Couldn't run command '$command': $!"; That needs to be system($command) == 0 or die ...; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734

Re: Reference name

2005-03-14 Thread Jeff &#x27;japhy&#x27; Pinyan
ch is the same as $foo{bar}->[2]->[5] which is the same as the ugly ${ ${ $foo{bar} }[2] }[5]. Read 'perlreftut' for more details. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every

Re: Reference name

2005-03-14 Thread Jeff &#x27;japhy&#x27; Pinyan
ect}}) { which looks very messy. It works, but it's got a lot of extra braces. I'd use one of the following: foreach my $key (keys %{ $$hashref{$object} }) { # or foreach my $key (keys %{ $hashref->{$object} }) { -- Jeff "japhy" Pinyan % How can we ever be the

Re: matching password problem

2005-03-14 Thread Jeff &#x27;japhy&#x27; Pinyan
am('pass'); # ... open PASSWORD, "< password.dat" or die "can't read password.dat: $!"; while (my $n = ) { my $p = ; chomp ($n, $p); if ($n eq $name) { if ($pass eq $p) { # the names match and the passwords match } else

Re: lost in multidimension

2005-03-12 Thread Jeff &#x27;japhy&#x27; Pinyan
On Mar 11, Peter Rabbitson said: _NASTY_SUB (\%{$batches{$current_batch}}); my %cards = %{clone (\%{$sources{${$batch_ref}{by_method}}{card_def}} )}; You've got two instances of \%{ thing_which_is_a_hashref } where you could just write thing_which_is_a_hashref -- Jeff "jap

Re: Dead-module etiquette

2005-03-10 Thread Jeff &#x27;japhy&#x27; Pinyan
hierarchy. Time::Period::Extended, for example. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- M

RE: Start reading from a specific line

2005-02-15 Thread Jeff &#x27;japhy&#x27; Pinyan
accessed. (Mnemonic: many programs use "." to mean the current line num- ber.) -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago

Re: Start reading from a specific line

2005-02-15 Thread Jeff &#x27;japhy&#x27; Pinyan
On Feb 15, Eduardo Vázquez Rodríguez said: open(INPUT, $file) or die "Can't read from file: $! $file"; # Where we "move" the pointer to line number 10 $. = 0; You don't need to initialize $. to 0. It's a magical variable that holds the right value. --

RE: Start reading from a specific line

2005-02-15 Thread Jeff &#x27;japhy&#x27; Pinyan
o use $.? That is, why create another variable which does the same thing? -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www

Re: IS there any way to get rthe content of the file

2005-02-10 Thread Jeff &#x27;japhy&#x27; Pinyan
On Feb 11, Anish Kumar K. said: open INPUT, "a.txt" | die "Cannot open the file"; That should be: open INPUT "a.txt" or die "cannot open a.txt: $!"; while () { $temp=$temp.$_; } You could write that as $temp .= $_; print "the entire file is

Re: Wild card substitution - Beginning of string to pattern, pattern to end of string.

2005-02-09 Thread Jeff &#x27;japhy&#x27; Pinyan
On Feb 9, Tham, Philip said: $var1 =~ s/^*.4160 //.; $var1 =~ s/\smodules*.$//; Your primary problem is that you're using "*." when you mean ".*" -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the che

Re: a question about the return value of a subroutine

2004-11-26 Thread Jeff &#x27;japhy&#x27; Pinyan
p over. Consider this: sub XYZ { my $z = 0; for (my $i = 0; $i < 10; $i++) { $z += $i } } The return value here is '', which is the result of '$i < 10' when $i is 10. 10 < 10 is false, and it returns ''. -- Jeff "japhy" Pinyan

RE: easy way to add element to array

2004-10-29 Thread Jeff &#x27;japhy&#x27; Pinyan
rray::Unique is a transparent solution -- that is, all you do is tie the array to T::A::U and things get done. Using hashes isn't all that hard, but T::A::U does that for you. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the

Re: Populating HASH from file

2004-10-25 Thread Jeff &#x27;japhy&#x27; Pinyan
f) = split /\s*=\s*/; Then you want to put that pair into the hash: $dict{$term} = $def; } Using the hash, and opening the file, I leave up to you. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every

Re: tie problem

2004-10-21 Thread Jeff &#x27;japhy&#x27; Pinyan
1]; s/./*/g; print; } That should work (I didn't test it, though). -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? h

RE: help - $line =~ tr/images\//..\/..\/images\//

2004-10-19 Thread Jeff &#x27;japhy&#x27; Pinyan
re literal, >should the '\' not be literal as well? The right-hand side is a double-quoted string. "." isn't special in a double-quoted string, but "\" is. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #

Re: substitute on \Z

2004-10-19 Thread Jeff &#x27;japhy&#x27; Pinyan
On Oct 19, Bryan Harris said: >Does anyone happen to know why this doesn't work as expected? > >perl -e '$_="1\n";s/\Z/2/g;print' > >Why does it print "2" twice? It works as *I* expect it to. \Z matches at the end of the string, OR before a NEWLINE at the end of the string. Therefore, in the st

Re: hash. removing duplicates

2004-10-18 Thread Jeff &#x27;japhy&#x27; Pinyan
t, and then include my %freq; you'll be ok. If not, just include: %freq = (); before the foreach loop below: > foreach $number (@numbers){ > $freq{$number}++; > print OUTFILE $number if $freq{$number}==1; >} > >} -- Jeff "japhy" Pinyan

Re: strict & getopt()

2004-10-15 Thread Jeff &#x27;japhy&#x27; Pinyan
>ignores my getopt(s) single-chars. Is this normal? What can I do to solve >this? > >I want to use perl with "-w" option and the "strict" pracma. Is this posible? If you're using Perl 5.6, don't use "-w" anymore, use the "warnings" pragma.

Re: IO::Socket - i can't get it to read the data

2004-10-15 Thread Jeff &#x27;japhy&#x27; Pinyan
In your case, apparently the IP address is longer than both the username and the password, so the IP is all you're seeing. ($user = <$client>) =~ s/\r?\n$//; ($pass = <$client>) =~ s/\r?\n$//; That should work for you. -- Jeff "japhy" Pinyan % How can we eve

Re: perl regex to array

2004-10-04 Thread Jeff &#x27;japhy&#x27; Pinyan
>How do I do it best ? I'd do: my @parts = split /{\d+}/, $string; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlm

Re: server is numb?

2004-09-28 Thread Jeff &#x27;japhy&#x27; Pinyan
On Sep 28, Christian Stalp said: >$socket-> send ( $data , $flags ) or die "could not send!\n"; To send data to the socket, just print() to it: print $socket "$data\n"; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Bro

Re: Delete all hash entries except for a specific list

2004-09-21 Thread Jeff &#x27;japhy&#x27; Pinyan
On Sep 21, Errin Larsen said: >On Tue, 21 Sep 2004 14:58:43 -0400 (EDT), Jeff 'japhy' Pinyan ><[EMAIL PROTECTED]> wrote: >> On Sep 21, Bob Showalter said: >> >> > my %hash = ( >> > foo => 1, >> > bar => 2, >>

Re: PROTO in sub NAME (PROTO) {

2004-09-21 Thread Jeff &#x27;japhy&#x27; Pinyan
thod of an object. See the documentation for prototypes. Chances are, you don't need them. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been ov

Re: Delete all hash entries except for a specific list

2004-09-21 Thread Jeff &#x27;japhy&#x27; Pinyan
which can vary at runtime. I know that >I only want to keep 'bar' and 'qux' however). >my @keys = qw(bar qux); You could do: my %keep_these_keys; @keep_these_keys{qw( bar qux )} = (); delete @hash{ grep !exists $keep_these_keys{$_}, keys %hash }; -- Jeff &

Re: truncate word

2004-09-20 Thread Jeff &#x27;japhy&#x27; Pinyan
G"; $phone_number =~ tr/A-Z/222333444555666888/; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %

Re: adding hash to a hash

2004-09-19 Thread Jeff &#x27;japhy&#x27; Pinyan
On Sep 20, Gunnar Hjalmarsson said: >Jeff 'japhy' Pinyan wrote: >> On Sep 19, JupiterHost.Net said: >>> >>>I want to add a hash to a hash, >>> >>>So how can I add %w to %q in that example? >> >> The general way is: >>

Re: adding hash to a hash

2004-09-19 Thread Jeff &#x27;japhy&#x27; Pinyan
On Sep 19, JupiterHost.Net said: >I want to add a hash to a hash, > >So how can I add %w to %q in that example? The general way is: # to add %w to %q @q{keys %w} = values %w; If there are overlapping keys, %w's values will be used. -- Jeff "japhy" Pinyan %

Re: interpolating the strings

2004-09-16 Thread Jeff &#x27;japhy&#x27; Pinyan
"; >print $str; > >produce "number one, number one" to the output. But what I must to do, that >output would be >"number one, number two" ?? You could use my DynScalar module from CPAN: use DynScalar; my $var; my $str = dynamic { "number $var,"

Re: can't use Scalar ref...

2004-09-15 Thread Jeff &#x27;japhy&#x27; Pinyan
rint $x . " "; >} You should use a hash instead of a set of variables. my %vars = ( foo => 'test', ); Then you do: for (@bar) { s/\[%([^%]+)%]/$vars{$1}/g; } -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia B

Re: String to integer

2004-09-09 Thread Jeff &#x27;japhy&#x27; Pinyan
gt; >Error Column "duration" is of type integer but expression is of type character >varying You neglected to show us the code that actually inserts the data into the table. Perhaps you've accidentally quoted the data? -- Jeff "japhy" Pinyan % How can w

Re: Leading zero in a string

2004-09-09 Thread Jeff &#x27;japhy&#x27; Pinyan
ng, I know I could easily: > >$option = "0".$option; I'd suggest sprintf(): my $two_digit_day = sprintf "%02d", $one_or_two_digit_day; To remove them, simply do: $date =~ s/^0+//; That will remove all leading zeroes from a string. -- Jeff "japhy"

Re: Splicing Hash problem - possible with "map"?

2004-09-06 Thread Jeff &#x27;japhy&#x27; Pinyan
/^1(?!\d)/, which reads "start of string, '1', NOT followed by a digit". -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overp

Re: Printing GET parameters

2004-09-04 Thread Jeff &#x27;japhy&#x27; Pinyan
es in the function definition: sub get_params { ... } -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.o

Re: Inserting short strings into longer strings -- strncpy in Perl?

2004-09-02 Thread Jeff &#x27;japhy&#x27; Pinyan
'CGTTAAagctgcgAAGTTCT'); Use substr($str, $pos, 0, $addition) to insert $addition into $str at position $pos. $a = "perl"; $b = "t ea"; substr($a, 2, 0, $b); print $a; # "pet earl" To get a random position, I'd use: subs

Re: substr complexities

2004-09-01 Thread Jeff &#x27;japhy&#x27; Pinyan
tured, and all the others remove all the $DIGIT variables. If you do: for (split /\n/, $EDM_nonactive_tapelist) { print "$1\n" if !/\*Orig/ and /st_9840_acs_0/ and /\((E\d+)/; } The problem you're having with substr() is that the third argument is the LENGTH of the substring

RE: delete all lines in a file save it come out

2004-08-31 Thread Jeff &#x27;japhy&#x27; Pinyan
ck (FILE, 2) or die "cannot flock $file: $!"; For safety's sake, use Fcntl's flock() constants. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ %

RE: delete all lines in a file save it come out

2004-08-31 Thread Jeff &#x27;japhy&#x27; Pinyan
o use && instead of ||: system("some system command") && die "system failed: $!"; or else system("some system command") == 0 || die "system failed: $!"; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI A

Re: delete all lines in a file save it come out

2004-08-31 Thread Jeff &#x27;japhy&#x27; Pinyan
FILE, 0, 0; # you need to go to the front first 1 while ; $lines = $.; seek FILE, 0, 0; truncate FILE, 0; print FILE "whatever\n"; close FILE; -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who

RE: Problems with a socket script

2004-08-20 Thread Jeff &#x27;japhy&#x27; Pinyan
st =gethostbyaddr($c_ip, AF_INET); > >Eww. You're using IO::Socket, so *use* it: What I meant was that you're using the IO::Socket module, but instead of using its easy and convenient object methods, you're using the klunky and awkward Socket module's functions. IO::Socket

Re: Problems with a socket script

2004-08-20 Thread Jeff &#x27;japhy&#x27; Pinyan
my ($port, $host) = ($client->peerport, $client->peerhost); # do whatever logging you want with those values... print $client tail(-75, "/var/log/radius.log"); close $client; # not strictly necessary, due to scoping } -- Jeff "japhy" Pinyan % How

Re: date calculations

2004-08-18 Thread Jeff &#x27;japhy&#x27; Pinyan
day, because there was an extra hour in the day. -- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Me

<    1   2   3   4   5   6   7   8   9   10   >