Re: regular expression matching exact numbers

2001-09-25 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 25, Kredler Stefan said: I'd like to match numbers and add them to an array if the array does not contain the number. You'd want to use a hash, not an array. let's assume $part[1] can hold the values in consecutive order e.g. 5, 1005, 5, 2000 then next if (grep /$part[1]/,

Re: Array of Hashes?

2001-09-24 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 24, Pete Sergeant said: @hosts = sort { %{$a}-{'name'} = %{$b}-{'name'} } @hosts; That (%{$x}-{key}) works for an ugly reason. It's probably a bug. @hosts = sort { $a-{name} cmp $b-{name} } @hosts; -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI

Re: remove last n elements from array and return the rest

2001-09-24 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 25, birgit kellner said: Is there a simpler way than this to remove the last n elements of an array and to reassign same array to the remainder? You probably want to do: splice @array, 0, @array - 3; -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI

RE: checking for existence of a file.

2001-09-21 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 21, John Edwards said: do { $artikelID = newID; } until (! -e $ARTIKEL_DIR.$artikelID); That produces a race condition. Between the checking for the existence of the file, and the opening of the file itself, the file COULD be created. I suggest the use of the sysopen() function.

Re: system calls

2001-09-21 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 21, Jonathan Howe said: Is it possible when making a call to the system, using the system command our back ticks to have a script exit/finish with out hanging around for a return from the process handed to the system. You need to fork a new process. if ($pid = fork) { print child

Re: Any feature equivalent to Macros of C?

2001-09-20 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 20, G Lakshmi said: if (index($OSNAME,Win,0) -1) { use Win32::Process; } That will ALWAYS try to include the Win32::Process module, regardless of the rest of your program. 'use' statements are executed at compile-time, while the rest of the code is executed at run-time. You'll want to

Re: functions in arrays

2001-09-20 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 20, Geert Neuts said: for ($i = 0; $i @stuff; $i++) { print $stuff[$i][0] ($stuff[$i][1])\r\n; } $stuff[$i][1] is just a reference to the function. To actually call it, you'll need to use { $stuff[$i][1] } or $stuff[$i][1]-(); However, neither of those expands in a

Re: RegExp Problem...

2001-09-18 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 18, David Simcik said: sub isFacStaff { my $id = @_; This is the error: assignment of an array to a scalar returns the number of elements. You want want one of the following: my $id = shift; my ($id) = @_; my $id = $_[0]; if($id =~ m/^.+_.+$/i) You're doing too

Re: autovivification of typeglobs

2001-09-18 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 18, [EMAIL PROTECTED] said: open my $self, $from, @_ or croak can't open $from@_:$!; ... the my $self furnishes undefined scalar to open, which knows to autovivify it into a typeglob. and further mentions autovivifying a When you use an undefined value as a reference, Perl

Re: bless function

2001-09-17 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 17, baby lakshmi said: should we have to use the bless fuction in the constructor alone we can use the created object ($foo) to invoke the function. isnt it??? so whatz the real advandage of using bless function??? and why we need to bless that particular object to some specific

Re: help please.....array and coding problem

2001-09-17 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 17, Rahul Garg said: while( ($details_1 = shift(@lines) ) =~ /^$/ ) You have the logic backwards. Change the =~ to a !~ instead. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ **

Re: Removing duplicate PATH entries?

2001-09-17 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 17, Jason Tiller said: 2) Duplicate path entries must be removed from the *tail*, not the head of the path. Then reverse the string, screw around with it, and reverse it again. Any way to make Perl do the regexp's sdrawkcab? Well, you don't need to do any of the standard sexeger

Re: bless function

2001-09-14 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 14, baby lakshmi said: package Animal; sub named { my $class = shift; my $name = shift; bless \$name, $class; } sub eat{ my $class = shift; $class = ref($class) || $class; my $food = shift; print $class eats $food\n; } In this program i dont understand what is the

Re: removing spaces from a file

2001-09-14 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 14, John_Kennedy said: print oBOTH @UNLOCKED\n; How can I prevent the blank lines from the grep or how can I remove the blank lines from @UNLOCKED? This was a recently-added question to the FAQ (in perlfaq5, under the title Why do I get weird spaces when I print an array of lines?).

Re: chomp question

2001-09-14 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 14, siren jones said: $date = `/bin/date + %y%m%d`; There's really no need to be calling an external system command to get the date. Perl has its own function, localtime(), and you can use the POSIX::strftime() function to use date-like formatting instructions (the %y and %m stuff). $a

Re: Thanks on chomp on to localtime

2001-09-14 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 14, siren jones said: Where can I get more info on using localtime() function or POSIX::strftime? perldoc -f localtime For any built-in function, use perldoc -f NAME For the POSIX module, do perldoc POSIX It'll bring up the module's documentation. Search in there for

RE: Is there a better way to do this

2001-09-13 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 13, Bradshaw, Brian said: while (%result = $finalSet-fetchhash()) { push @arr_DBanswers, values %result; } That code looks fine. You might want to use 'my' on the %result hash, since you don't need it existing later. while (my %result = $finalSet-fetchhash()) { push

Re: OOPs concepts

2001-09-11 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 11, baby lakshmi said: I am learning OOPs concepts. Can anyone tell me what is the real use of UNIVERSAL class(in built)? The UNIVERSAL class offers three methods for every class: isa, can, and VERSION. It also provides a place for you to write methods available to every class. Also

Re: how to use $1

2001-09-11 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 11, lyf said: hi, I am a perl beginner, and I am confused by $1. what does $1 ($2,and so on) mean? and how to use them? The $DIGIT variables correspond to sets of ()'s in a regex. Here's an example: $pn = 1-800-555-1212; if ($pn =~ /^\d-(\d)\d{2}-(\d{3}-\d{4})$/) { print toll

Re:Seek issue

2001-09-11 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 11, Jorge Goncalvez said: Hi, I have this code: open FILE, $SYSLOG or die $!; seek FILE,10,2; I'm sorry. I meant -10, not 10. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/

Re:If always verified

2001-09-10 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 10, Jorge Goncalvez said: if(defined $lastline and $lastline =~ /$success/) The if statement is always verified even the last line don't end with success. You put the '$' in the wrong place. /success$/ -- Jeff japhy Pinyan [EMAIL PROTECTED]

Re:If always verified

2001-09-10 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 10, Jeff 'japhy/Marillion' Pinyan said: On Sep 10, Jorge Goncalvez said: if(defined $lastline and $lastline =~ /$success/) The if statement is always verified even the last line don't end with success. You put the '$' in the wrong place. /success

Re: array as an class attribute

2001-09-08 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 8, Gustavo A. Baratto said: Thanks for the help. I wasn't initializing the $self-{ARRAY} with []. But later in the code I need to do something like this: @self-{ARRAY} = @another_array; # of course this is giving me an error. @{ $self-{ARRAY } = @another_array; or $self-{ARRAY} =

Re: HELP - Stuck with a regex

2001-09-08 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 8, Gary Luther said: $line =~ s/\s{2,}(\w+(\s?\W?\w+)*).*?/$1/; I think you want to use something a bit simpler for the \w+... part: $line =~ s/\s{2,}(\S+(?:\s\S+)*).*/$1/; That gets non-whitespace (\S+) followed by any number of occurrences of a single whitespace followed by MORE

Re: ' meanning

2001-09-07 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 7, Paul Johnson said: what does extra' mean? or for example extra'itemstotalbe(scalar, @colwith) ' is the old (pre Perl 5) way of writing ::- it is obsolete Borrowed from Ada (regretably, I believe). -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/

Re: line number

2001-09-07 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 7, Roland Schoenbaechler said: In some cases I want to write the line-number of the script to STDERR (In analogy to the functions die or next). Does a variable exist indicating the line number of the currently executed step (or the last step)? The caller() function also gives you this

Re: general multipliers in a substitution regexp..

2001-09-07 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 7, Dan said: If I have a string with say a number of '' in it which may be variable in length and I wish to write a regexp to match and replace it with the equivalent number of ')'s [ie would become ] There's a very clever solution to this in Effective Perl Programming. It is

RE: general multipliers in a substitution regexp..

2001-09-07 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 7, [EMAIL PROTECTED] said: $somestring =~ s!!)!g; Then I would suggest tr//!/, which is a better way to write such substitutions, for certain values of better. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734

RE: general multipliers in a substitution regexp..

2001-09-07 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 7, Jeff 'japhy/Marillion' Pinyan said: On Sep 7, [EMAIL PROTECTED] said: $somestring =~ s!!)!g; Then I would suggest tr//!/, which is a better way to write such substitutions, for certain values of better. My bad. I really meant tr//)/. -- Jeff japhy Pinyan [EMAIL PROTECTED

Re: Reg exp into variable

2001-09-06 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 6, Paul Jasa said: How do I put something I am looking for, and find, with a reg expression INTO a variable? You want to capture the specific part of the regex with ( and ), and then set that equal to a variable. There are two ways of doing that: if (/(pattern)/) { $x = $1; # $1

RE: Reg exp into variable

2001-09-06 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 6, Paul Jasa said: /((?:\d{1,3}\.){3}\d{1,3})/ what is this part: (?:\d{1,3}\.) and this:{3}\d{1,3} Ok. (?: ... ) groups part of the regex. It just binds it together as one big clump. The {3} is a quantifier, like {1,3}. {1,3} means 1, 2, or 3 times. {3} means exactly 3 times.

Re: Use of uninitialized value in print after regexp

2001-09-05 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 5, Dan said: cDNA AK027199 cttaatgagt gagcagtaag tctgtgtaag aggctgaatg catgtc 50 agataagcca gtacactcct tgcttagcaa cagaacatca gggtgatgtg 100 [lots more like this] tttatttgga aggttacctg ctgttggatt taataaattt gtttacttga 2100 aa Genomic chr16 reverse strand: (my

Re: How to parse a string with ..{..}..{..}..

2001-09-05 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 5, Curtis Poe said: my $instr1 = 111{first first}222 333{second}444; $_ = $instr1; my @outstr = m/{([^}]+)}/g; Also, I stripped out your dot star and replaced it with a negated character class. See http://www.perlmonks.org/index.pl?node_id=24640 for why this is done.

Re: How to parse a string with ..{..}..{..}..

2001-09-05 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 5, Jeff 'japhy/Marillion' Pinyan said: On Sep 5, Curtis Poe said: my $instr1 = 111{first first}222 333{second}444; $_ = $instr1; my @outstr = m/{([^}]+)}/g; Also, I stripped out your dot star and replaced it with a negated character class. See http://www.perlmonks.org

Re: Validate the regex

2001-09-04 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 4, neeraj arora said: Is there anything using which i can validate that the regex i input is valid or not. The simplest way is to try and use it: eval { =~ $regex }; if ($@) { # bad regex } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/

Re: Finance::QuoteHist

2001-09-04 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 4, John Bollinger said: use Finance::QuoteHist; $q = Finance::QuoteHist-new ( symbols= [qw(LNUX MSFT IBM)], start_date = '01/01/2000', end_date = 'today', ); print Quotes:; foreach $row ($q-quotes()) { ($date, $open, $high, $low,

RE: why doesn't this work

2001-09-03 Thread Jeff 'japhy/Marillion' Pinyan
On Sep 3, John Edwards said: unless ( $status == (1 || 2) ) { print \nport status must be either up or down\n\n; exit; } else { system(/usr/bin/snmpset hostname password interfaces.ifTable.ifEntry.ifAdminStatus.$port i $status); } The above says unless status equals 1 or

Re: regular expresions

2001-08-31 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 31, agc said: so I would like to know wich woud be the reg exp for a case like that where are examples? fro a beguinner? can any one give me a hand with this? cheers There are several Perl documents on regexes: perlrequick perlretut perlre Looking at them in that order

Re: how to display a value

2001-08-29 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 29, Jerry Preston said: name = Jerry; You mean $name = Jerry; foreach $key ($query-param) { undef $check; $check = $1 if $key =~ name; (I think) you mean $check = $1 if $key =~ /($name)/; if( $check ) { print name key *$key* check $1 *BR; } } What

Re: combine commands

2001-08-29 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 29, Jeff 'japhy/Marillion' Pinyan said: You could do the remove whitespace regex all at once, and even include the lc() in there. I don't suggest it, though: ($scode = lc $ucscode) =~ s/\s*(\S*(?:\s+\S+)*)\s*/$1/; And if you don't want to use $scode, and just want $ucscode, you could

Re: Re[6]: Stripping line breaks

2001-08-28 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 28, Stephen P. Potter said: Lightning flashed, thunder crashed and Maxim Berlin [EMAIL PROTECTED] whispered: | | well, ${ unassigned now... | And must remain unassigned, otherwise there is no way to disambiguate: print $dayday and print ${day}day But you can use ${{} and ${}} to

Re: Help with Recursive script on Large Directory

2001-08-28 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 28, Kipp, James said: I have this script that recursed through a directory on a network drive and it's subdirs flagging files based on a couple of params. Firstly, I know this will be resource intensive. Is there a better way to do this that is maybe not even a Perl solution? You want

Re: Unix awk

2001-08-28 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 28, [EMAIL PROTECTED] said: Does any one out in Per Land have a Perl program that performs the same functions as Unix awk? If yes would you mind sharing it? Um. Perl's regular expression library does that. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/

RE: perl version

2001-08-23 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 23, HOLLAND-MORITZ,MARCUS (A-hsgGermany,ex1) said: | how could i know which perl version i am using : any command | on unix/linux perl -v Or, if you're sick like me, perl -version number, please -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI

Re: Regex help

2001-08-23 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 23, Michel Blanc said: sub unique_char_set { my ($str, $chars) = @_; return 0 if $str =~ /[^\Q$chars\E]/; return !($str =~ /(.).*?\1/s); } Thanks for your response guys. This is very useful. In fact, since I needed a one liner (I forgot to say that) for a

Re: a1.a2.a3.a4 - integer

2001-08-23 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 23, P lerenard said: I can transform an ip a1.a2.a3.a4 to an integer using b1=a1 24 b2=a2 16 b3=a3 8 int =b1+b2+b3+a4 now I want to do the opposite. how can I get a1.a2.a3.a4 from this integer? ok I get a1, but I start to have a headeach to get the rest Do: while ($x) { unshift

RE: a1.a2.a3.a4 - integer

2001-08-23 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 23, Gibbs Tanton - tgibbs said: $a4 = $x 0xFF; $a3 = ($x8) 0xFF; $a2 = ($x16) 0xFF; $a1 = ($x24) 0xFF; D'oh, I forgot -- is faster than %. while ($x) { unshift @parts, $x 256; $x = 8; } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/

Re: Looking for help with the Translate operator

2001-08-23 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 23, Carl W Rogers said: I don't know if this is possible... But I'm trying to replace the high-hex symbol for one-half (\xBD) with 1/2 No, you have to use a substitution (s///) for that. tr/// is for character-to-character translations. $variable =~ tr/[\xBD]/1/2/; #tr

Re: Reusing $1?

2001-08-23 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 23, Rob Waggoner said: while ($line = LOGFILE) { $line =~ /\[(.+)\] /; # get date time value between [] $ThisDateTime = $1; # should look like 19/Aug/2001:06:28:45 -0600 # this works #($ThisDate, $Junk) = split(/:/, $ThisDateTime); #

Re: Brand New!

2001-08-22 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 22, William A Fink said: Hello, I'm *BRAND NEW* to the list and have what may seem trivial to some of you - but (because of the pressure here at-the-office) I'd appreciate any help anyone could lend. Your subject should be related to your question, if you don't mind. What I'm running

Re: Regex help

2001-08-22 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 22, Michel Blanc said: Does anyone could help in mathing one of the following letters cCdeEfGhiI any number of times, but if a letter has already matched, it can repeat again in the string. cCdE : match cCcE : doesn't match I think you mean if a letter has already matched, it

Re: foreach() loop creates $aString-s that I modify , AND they modifythe Array Contents !?

2001-08-22 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 21, [EMAIL PROTECTED] said: I change the value of $aString but ... it turns out that I am **also** altering the values of the Strings held in the Array. A for-loop aliases a variable to each element of the list you're looping over. That's why you can't say: for (1, 2, 3, 4) {

Re: grep

2001-08-21 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 21, Janice Pickron said: What regular expression would you pass to the grep (1) program to search for all the #define statements in file? Remember that there can be spaces or tabs both before and after the # sign. This language sounds HIGHLY suspect of homework. -- Jeff japhy Pinyan

Re: FW: hash, key value

2001-08-21 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 21, Jennifer Pan said: $value1 -- @list1 $value2 -- @list2 %hash{key} = $value3 --@list3 $value4 -- @list4 $value5 -- @list5 Well, you want a reference to an anonymous array [ ... ] that holds references to other arrays

Re: How to count the number of whitespaces at the start of a line

2001-08-20 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 20, Darren Edgerton said: my $i = () = $str =~ /^\s/; print $i; Your regex doesn't match globally, which is what you assumed, methinks. You could do: my $leading = () = $str =~ /\G\s/g; but that's more effort than I think you should need. You can just use: my $leading = length(

Re: How to count the number of whitespaces at the start of a line

2001-08-20 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 20, Paul Johnson said: On Mon, Aug 20, 2001 at 08:27:41AM -0400, Jeff 'japhy/Marillion' Pinyan wrote: $str =~ /\s*/; my $leading = length $1; that would be $str =~ /(\s*)/; Err, yes. My mistake. ** Look for Regular Expressions in Perl published by Manning, in 2002

Re: How to count the number of whitespaces at the start of a line

2001-08-20 Thread Jeff 'japhy/Marillion' Pinyan
/me greets [Ovid] On Aug 20, Curtis Poe said: First, I added the caret to force matching from the beginning of the line so we don't accidentally match embedded whitespace. That may or may not matter, depending upon the structure of the data, but since I haven't seen the rest of the thread,

Re: calling between perl programs

2001-08-20 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 20, [EMAIL PROTECTED] said: I am confused about how perl provides for separate perl scripts to talk to each other. In k-shell I can load a function using . file_name.ksh. In the file I have defined a function function myfunction { I can execute that function from

Re: Turning off warnings causes scripts to fail

2001-08-20 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 20, Curtis Poe said: One of our scripts runs fine from the command line but wouldn't run through the browser. We'd type perl somescript.cgi and everthing would run fine. However, when we tried ./somescript.cgi we would get a No such file or directory error. The shebang line

Re: PERL IS NOT A HIGH LEVEL LANGUAGE

2001-08-17 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 17, Jon Acierto said: i have to agree with will's assessment. perl is not a high level language. it amounts to a scripting language. simply having 2 years of working with perl says nothing about whether he has worked on more complex problems or has developed the programming skills

Re: regular expressions and newline characters

2001-08-16 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 16, Michel Rodriguez said: On Thursday 16 August 2001 1:57 pm, Joe Bellifont wrote: the code you provided below produces an error at the foreach line. --syntax error at line 12 , near $field qw( FNAME SURNAME QDETAILS) ... use Data::Denter;# just to check what's read

Re: Passing Scalar Reference to Subroutine

2001-08-16 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 16, David Simcik said: Type of arg 1 to main::isPresent must be scalar (not single ref constructor) at C:\src\Orion\cgi-bin\share.pl line 45, near $user) A prototype of \$ means that Perl will add the \ for you automagically. sub isPresent(\$$); if(!isPresent(\$req, $user)) You don't

Re: What does this error actually mean?

2001-08-16 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 17, Daniel Falkenberg said: called too early to check prototype at /usr/lib/perl5/site_perl/5.6.0/GD/Graph/Map.pm line 366 All standard error messages can be explained by looking in the perldiag documentation, or by including 'use diagnostics' in your program, or by piping the error

Re: how does 1 while $scalar =~ s/(%A .*)\n%A /$1\;/g; work?

2001-08-13 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 13, ERIC Lawson - x52010 said: It does change every instance (except the first) of \n%A in the scalar into a semicolon, given a scalar containing, e.g., Basically, it scrunches %A this %A that %A those into %A this;that;those My concern is with how it works...not understanding how,

Re: how does 1 while $scalar =~ s/(%A .*)\n%A /$1\;/g; work?

2001-08-13 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 13, Jeff 'japhy/Marillion' Pinyan said: On Aug 13, ERIC Lawson - x52010 said: It does change every instance (except the first) of \n%A in the scalar into a semicolon, given a scalar containing, e.g., Basically, it scrunches %A this %A that %A those into %A this;that;those The logic

Re: how does 1 while $scalar =~ s/(%A .*)\n%A /$1\;/g; work?

2001-08-13 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 13, ERIC Lawson - x52010 said: Given that 1 while ... logic works for my needs here, though, is there a reason I should use the sexeger logic instead? Is the 1 while ... expression more costly? It seems, on the face of it, that the 1 while is more readily decypherable by another

Re: Split question

2001-08-13 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 13, Scott and Kristin Seitz said: $CharSep=\|; The double quoted string \| is still just |. Use single quotes or the quotemeta() function. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/

Re: finding a key in a hash with regexp

2001-08-12 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 13, Birgit Kellner said: Hm, what's the shortest way to do this: I have a hash where one, and only one, key begins with a number, I don't know its value and want to assign this value to a variable. Loop over the keys, using keys() or each(). for (keys %hash) { $wanted =

Re: Fw: changes visible when passing a list by value

2001-08-10 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 10, Rizwan Majeed said: It is known that passing a list by value to a function does not make visible to the calling function changes made to the list. But I dont understand how does the push() function works. Push takes the value of a list and still makes visible to the calling block of

Re: Translating an octet string...

2001-08-10 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 10, Hamish Whittal said: I have an octet string that I need to print. When I print it, I get some rubbish on the screen. I would therefore like to translate this to something printable. e.g I have 11011010110001001011 and I want to print this as 11011010 1000100 1011 You want to

Re: Translating an octet string...

2001-08-10 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 10, Jeff 'japhy/Marillion' Pinyan said: my $len = length $output; my $i = 0; while ($i $len) { print substr($output, 8 * $i++, 8), ; } Oops. The condition of the while loop should be: while ($i * 8 $len) { ... } -- Jeff japhy Pinyan [EMAIL PROTECTED] http

Re: number of elements in array is -1?

2001-08-10 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 10, Tyler Longren said: while (LOGFILE) { chomp; push (@array, $_) if m/ida/i; } while (LOGFILE) { push (@scans, $_) if m/$last_host/i; } Is there a reason you didn't put both of those into ONE while block? It would be far more efficient (and it would

Re: grep repetitive elements?

2001-08-10 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 10, Jennifer Pan said: I have two list, @list1 and @list2, each element @list1 is unique (could be a hash I suppose) I want to find out all the elements @list2 that is an element in list1 and have appeared two or more times I want to use GREP but I don't know how to grep certain

Re: grep repetitive elements?

2001-08-10 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 10, Jeff 'japhy/Marillion' Pinyan said: my %freq; $freq{$_}++ for @list2; # create a hash of key - frequency for (@list1) { print $freq{$_} if $freq{$_} 1; } Rather, print $_ if $freq{$_} 1; -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy

Re: string into an array

2001-08-08 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 8, Tyler Longren said: I'm grepping a file for a short string (dns3): my $command = cat $file | grep -i dns3; my $exec = `$command`; This will give me many lines for a result. If I did a print $exec; all of the data would be printed at once. How Do I get the results from the grep and

Re: Variable Recalculation

2001-08-07 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 7, Michael Kelly said: Is there any way to recalculate a certain variable when another variable's value changes? For instance if, $a = 5; $b = $a * 4; $a = 10; You can use my DynScalar module from CPAN. use DynScalar; $x = 5; $y = dynamic { $x * 4 }; print $x * 4 = $y\n; $x

Re: how to compare two references (pointers)?

2001-08-07 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 7, Qiang Qiang said: Who knows how to compare two references (pointers) in OOPerl? A reference is neither a numeric or a string, thus == and eq are useless. Of course, I can use what they point at (the objects) to compare, however, I want to know how to deal with references. Thanks

FMTYEWTKAW (far more than you ever wanted to know about whitespace)[was RE: Remove White Space]

2001-08-06 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 6, Mooney Christophe-CMOONEY1 said: That would do it. Without the 's' in front of the regex, it doesn't know you're trying to search and replace. The divide error is odd, and shouldn't be happening, but try this instead: s(\s*)()g The divide-by-zero error was because writing

RE: regular expression

2001-08-03 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 2, Messervy, Joe M said: Ok, I feel stupid the test should have been perl -p -i -e 's/\nmachine//g' myfile ... but it still doesnt work :( Well, $_ is only ONE LINE of the file. So it can't possibly start with a newline and then have other text. Perhaps you want s/^machine//; --

Re: Certification

2001-08-02 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 2, Paul said: That would be Merlyn (Randall Schwartz) co. at Stonehenge, if you want to call it that. But it isn't a certification, I don't think. Randall? chop(), if'n you don't mind. ;) -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother

Re: memory for implied array/list HANDLE read

2001-08-02 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 2, Michael Fowler said: You can only print a string. When print is given multiple arguments it joins them with $ before printing. This is documented in perldoc -f print. *Cough* $, not $. $ is used when you put an array (or array slice) in double quotes. WIZARDRY And, upon checking

Re: removing redundant entries in an array

2001-08-01 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 2, Charles Lu said: @list = (1,2,3,4,2,67,4,4,9); I want to remove all the redundant ones so the final list should contain (1,2,3,4,67,9). Although I have implemented my own way of doing it, I think this problem is quite common and therefore someone must have written a function for

Re: difference between and and ...

2001-07-31 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 31, Christiam Camacho said: Is the only difference between and and and or and || the precedence of the operators? has higher precedence (it binds more tightly) than 'and'. $x = 2 and 5; # ($x = 2) and 5; $x = 2 5' # $x = (2 5); -- Jeff japhy Pinyan [EMAIL

Re: is it possible?

2001-07-31 Thread Jeff 'japhy/Marillion' Pinyan
On Aug 1, Rahul Garg said: How can we disable the hyperlink? This is an HTML question, and not related to Perl at all. There are many ways of disabling a hyperlink. * remove the a tag * comment out the a tag * remove the href= attribute of the a tag -- Jeff japhy Pinyan [EMAIL

Re: Matching within the LHS of a regex...

2001-07-30 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 30, David Wood said: $str = qq( udb:person data_onesome data/data_one data_twosome more data/data_two /udb:person ); What I need to do is something like:- $str =~ s/udb:[^]+\n(.*?)\/udb:$1/$sub-($1,$2)/gs; Even if you change the $1 to a \1, it won't match, since you have

Re: arrays

2001-07-30 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 30, Matija Papec said: my $i; my (@datumi2) = (1..100); my (@temp, @data); # block for optimization for $i (0..$#datumi2) { push @temp, } push @data, \@temp; undef @temp; # end of block for optimization push @data, \@datumi2; You can use the length of an array with the x

Re: reference to a two dimensional array

2001-07-30 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 30, Robb Wagoner said: When I pass a reference to the array in a subroutine: some_sub(\@array); What is the proper way to dereference the array with in the subroutine? I do: some_sub([ [1,2,3], [4,5,6] ]); sub some_sub { my $aref = shift; print $aref-[0][0]; # 1

Re: my, strict, and function references

2001-07-28 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 28, Dan Grossman said: #!/usr/bin/perl -w use strict; my $funcRef = \otherDummyFunc; sub callTheReferredFunc { my $returnVal = $funcRef; return $returnVal; } I don't pass $funcRef to callTheReferredFunc, and yet -w doesn't generate a warning for an undefined reference. Are

Re: checking for an open filehandle?

2001-07-27 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 27, Barry Carroll said: Is this code good enough for doing that job? if (!(-e TEMPLATE)) No, use the fileno() function. if (defined fileno TEMPLATE) { # it was opened ok } -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ I am Marillion,

RE: $_ question

2001-07-27 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 27, Wagner-David said: ps I tried to remove the \n on STDIN and got an error: Can't modify HANDLE in chomp at d:\currwrka\00COMM~1\03AAPL~1\aapl210.pl line 2, near STDIN) and the code looked like: chomp(STDIN); Reading from a filehandle never automatically assigns to a

Re: regexp issues TR

2001-07-26 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Teresa Raymond said: I tried the following code to test for bad characters but keep getting my error msg though the values passed do not contain chars that are not A-Za-z0-9_@.- (I also reread my last post and found that my English articulation was very poor, I'm grateful that

Re: __TAGS__

2001-07-26 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 26, Mooney Christophe-CMOONEY1 said: Where can i find out more information about the __TAGS__ ? BTW what are they really called? Are they directives? These are documented in perlsyn: __END__ end of program __DATA__ end of program, but allow this to be accessed via

Re: pushing into a hash

2001-07-26 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 26, Mooney Christophe-CMOONEY1 said: @b=qw/-x 24 -y 25 -z 26/; Is there a nice way to merge the hash implied by @b into %a to get while (@b) { my ($k, $v) = splice @b, 0, 2; $a{$k} = $v; } You could write %a = (%a, @b); but that's potentially slow and ugly. -- Jeff

Re: regular expressions

2001-07-26 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 26, Dan Grossman said: On Fri, 27 Jul 2001, Akshay Arora wrote: $line =~ s/(\w)(\S*)/\u$1$2/g; Wow, I've never seen this \u before. I can't find it anywhere in the Perl documentation. Is there a list of interesting regexp modifiers like this somewhere that I've been missing? \u is

Re: Running Perl scripts...

2001-07-25 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Daniel Falkenberg said: I want to be able to check for errors on my Linux box before I run them in a browser. The problem is is tha when I do this all my HTML is dispalyed. I don't want to see this I want to be able to just check for any errors and display the errors only.

Re: Running Perl scripts...

2001-07-25 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Jeff 'japhy/Marillion' Pinyan said: On Jul 25, Daniel Falkenberg said: I want to be able to check for errors on my Linux box before I run them in a browser. The problem is is tha when I do this all my HTML is dispalyed. I don't want to see this I want to be able to just check

Re: typeglobs and references

2001-07-25 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Silvio Luis Leite Santana said: When I write *PI = 5; What am I really doing? Well, you can assign a string to a typeglob, and Perl will assume that you meant to assign a typeglob to a typeglob: *first = *1; japhy =~ /([aeiou])/; print $first\n; # prints 'a' -- Jeff japhy

Re: Another regex puzzle....

2001-07-25 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Hamish Whittal said: %CardType% .1.3.6.1.4.1.45.1.6.3.3.1.1.5 %CardSlotNum% =calc=CardType/3.([0-9]*).0/ if ( /^%([a-zA-Z]*)%[\s\t]*[\=calc\=([a-zA-Z]+)\/(.*)\/|(\.[0-9]*)]/ ) { I'm afraid you're trying to be a bit too specific. If you let yourself slip into

Re: typeglobs and references

2001-07-25 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Jeff 'japhy/Marillion' Pinyan said: On Jul 25, Silvio Luis Leite Santana said: When I write *PI = 5; What am I really doing? Well, you can assign a string to a typeglob, and Perl will assume that you meant to assign a typeglob to a typeglob: *first = *1; japhy =~ /([aeiou

Re: checking for true/false after a command has run

2001-07-25 Thread Jeff 'japhy/Marillion' Pinyan
On Jul 25, Stephanie Stiavetti said: open (REZFILE, $rezFile) or die ew! can't open $rezFile! $!\n; foreach (@allParams) { print $_\t; } print \n\n; close (REZFILE); I would check to see if the file could be closed properly. And maybe

  1   2   >