Re: Using a variable in a =~ match??

2008-10-21 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi all, Hello, Serious noob here (one week into llama 5th ed.). I'm trying to write a script to pull a specific file from a directory and search that file for specific phrases. I am having a problem searching for the file in the directory. If I type in the actual fil

Re: last element during foreach loop

2008-10-21 Thread John W. Krahn
six24hourdays wrote: Hello, Hello, I would like to know how to test for the last element of a list during a foreach loop, e.g. foreach $element (@List) { if (this is the last element) { do something } } What would I use for the IF condition? You can't because a list does n

Re: two questions on my perl exam.

2008-10-21 Thread John W. Krahn
birdinforest wrote: I am a student and enrolled Unix programing this semester. There are two questions relating to perl I can not work out in the last exam ( Actually I have write out my code, however the exam system marked it as "wrong"). Please help me to point out the fault. Thanks. QUESTION

Re: using unix command issue...

2008-10-20 Thread John W. Krahn
Ariel Casas wrote: Hello all, Hello, Any time I run a unix command where I initiate a variable > use the variable as an arg in the unix command > pipe it to another unix command, I get an error. This is the error I get: --- ./test.1.pl Use of uninitialize

Re: Returning character from string

2008-10-20 Thread John W. Krahn
brian54321uk wrote: Hi, Hello, I'm stuck with what will probably turn out to be a simple solution, I've been scouring google for ages, and can't find anything close to what I'm looking for. Given that $fred = 10 $barney = abcdefghijklmn how do I get $wilma = j $ perl -le' my $fred = 10

Re: How to turn a user perl script in string format into actual perl commands that eval accepts in my script?

2008-10-19 Thread John W. Krahn
Zhao, Bingfeng wrote: Hello, Hello, I encounter following requirements: 1. accept customized perl sentences; 2. provide variables exchange between customized perl sentences and my routine. Here is a sample: [code] use strict; use warnings; # we use $_ to pass value in and out $_ = qw/foo/;

Re: if condition question

2008-10-16 Thread John W. Krahn
sanket vaidya wrote: Hi all, This is the exact same question you asked 16 days ago. Did you not like the answer you got then? (Which is the same as the answers you are getting now.) John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools

Re: translate IP mask

2008-10-16 Thread John W. Krahn
Sandy lone wrote: I need to translate an IP addr with its mask from this form: 192.168.1.30/255.255.255.0 to this one: 192.168.1.30/24 One way to do it: $ perl -le' use Socket; my $stuff = "192.168.1.30/255.255.255.0"; my ( $ip, $mask ) = split /\//, $stuff; print "$ip/" . unpack "%32b*

Re: array serach for partial value

2008-10-14 Thread John W. Krahn
Richard wrote: Hello, Hello, I have small Perl project and got stuck on following problem : There is a zip file with bunch of files in it. I need to search through it and find if every xxx.txt file has xxx.log pair and list all of those .txt without pairs. Use File::Basename to separate the

Re: Please help me w/ my sub

2008-10-14 Thread John W. Krahn
Richard Lee wrote: below sub works fine except the line where key is default. Instead of printing out PCMU only once, it's printing it out 40 times randomly.. Trying to figure out what I did wrong. Please leave me a feedback. thank you. 156 time(s) Codec(s) : unassigned_38 185 time(s) Cod

Re: printing array elements

2008-10-13 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Mon, 2008-10-13 at 14:04 +0100, Rob Dixon wrote: A program with arrays that are tied in one place and not in another has bigger problems than this anyway. But I don't see a problem with using $" with tied arrays, unless the tied class happens to overload stringificat

Re: Coverting string with commas to a number to add

2008-10-11 Thread John W. Krahn
AndrewMcHorney wrote: Hello Hello, I have a line of code that appears to not be returning what I am looking for. I am attemting to add a number which has commas in it. It represents the number of bytes of a file obtained for the dir command. At the end of the run the number of bytes does no

Re: Stripping the beginning of a line of spaces

2008-10-11 Thread John W. Krahn
AndrewMcHorney wrote: Hello Hello, I am working on a script that does a directory of a Windows drive. There are some lines returned where there are spaces before the 1st character. If it's the first character then by definition it can't have anything before it. This throws off the spli

Re: Concerning passing refs of anonyme Hash to subs...

2008-10-10 Thread John W. Krahn
Deviloper wrote: Hi there, Hello, have a look at this example: #!/usr/local/bin/perl use strict; use warnings; my $a_hash = { hund => "Dogge", katze => "Perser", obst => "Banane"

Re: writing to a .txt file issues

2008-10-09 Thread John W. Krahn
David wrote: My simple program works well in the terminal window: #!/usr/bin/perl -w use strict; my $answer; for ($a = 1; $a <= 100; $a++) { for ($b = 1; $b <= 100; $b++) { $answer = ($a-$b); print "$a - $b\t$answer\n"; } } Output: 1 - 1 0 1 - 2 -1 1

Re: printing array elements

2008-10-09 Thread John W. Krahn
Charlie Farinella wrote: I have a string of text that I want to split on the tabs: while () { my @array = split(/\t/, $_); ...manipulate them a little, and print them back out like so: print "$array[0],$array[1],$array[2]"; etc. } I normally just print them as above, but I'm thinking

Re: How to check empty hash value properly?

2008-10-08 Thread John W. Krahn
Jay Savage wrote: On Wed, Oct 8, 2008 at 11:24 AM, Rob Dixon <[EMAIL PROTECTED]> wrote: Jay Savage wrote: On Tue, Oct 7, 2008 at 4:09 PM, Rob Dixon <[EMAIL PROTECTED]> wrote: John W. Krahn wrote: Incorrect, delete does not remove array elements: $ perl -le'use Data::Dumper

Re: $o->document vs $o->document()

2008-10-08 Thread John W. Krahn
oldyork90 wrote: I am using a module having documentation saying document() is a method. However, I see it used as $o->document; Can you reference a method in this way? (I takes no args). I always thought $o->document() and $o->document meant different things, function verses attribute. p

Re: how to count line numbers in file quickly?

2008-10-08 Thread John W. Krahn
loody wrote: Dear all: Hello, I try to write a perl to compare whether the line numbers of 2 files is equivalent. Below is my source code: tie my @src_file,'Tie::File', $src_file, mode => O_RDWR ,autochomp => 1 or die "cannot open file $!"; tie my @src_file,'Tie::File', $src_file, mode => O_

Re: How to check empty hash value properly?

2008-10-07 Thread John W. Krahn
Rob Dixon wrote: loody wrote: if( exists $data{$key} ){ print "\t\$data{$key} exists\n"; thanks for your kind help. Could I get the conclusion that exists is only used for determining the element of hash and arrays? appreciate your help, Consider this program. use strict; use warning

Re: best way to search in a file

2008-10-07 Thread John W. Krahn
[EMAIL PROTECTED] wrote: What is the easiest method to search in a file for a particular term, and output a desired field. For example, in awk, I would simply do: awk '/searchterm/ {print $2}' input.txt to get my result. But in Perl, the shortest way I could find achieve the same result was:

Re: How to check empty hash value properly?

2008-10-06 Thread John W. Krahn
loody wrote: Dear all: Hello, I want to use hash to keep my records. But before using it, I want to determine whether the value of the key exist? perldoc -q "What.s the difference between .delete. and .undef. with hashes" John -- Perl isn't a toolbox, but a small machine shop where you ca

Re: Question about 2's complement

2008-10-06 Thread John W. Krahn
loody wrote: Dear all: Hello, I have to compare 2 values which is represented by 2 bytes as 0x and 0x00fe in 2's complement system. so the difference between them should be -1 - 254 =-255. but before do such calculation, I have to translate 0x as -1. Is there build-in function in perl

Re: Replace first 2 bytes on binary files?

2008-10-05 Thread John W. Krahn
Dr.Ruud wrote: "Mr. Shawn H. Corey" schreef: Louise Hoffman: I would like to replace the first 2 bytes from ## to BM in all the files in a directory. The files are binary. Use glob to get the list of files. Use open with read-write to read the first line and replace the bytes. I wouldn't

Re: How to evaluate a raw string?

2008-10-05 Thread John W. Krahn
Manfred Lotz wrote: Mr. Shawn H. Corey wrote: On Sun, 2008-10-05 at 16:54 +0200, Manfred Lotz wrote: my $DRYRUN="--dry-run"; my $cmd = q(rsync $DRYRUN -avh \ -exclude bla1 \ -exclude bla2 \ src tgtdir }; system($cmd); my $Dry_Run = '--d

Re: join operator for arrays question

2008-10-02 Thread John W. Krahn
JAaronAnderson.com wrote: Ok, thanks guys for posting, I am posting from within my GoogleGroup Account. Ergo my comment... let's not be critical and get down to the code! the code I was asking about was :: map { $_ = $$_[0] } @userlist; I dont understand it fully but I got what I wanted to get

Re: How to extract the Destination address from a UDP package

2008-10-02 Thread John W. Krahn
Tom wrote: Hi all, Hello, Is there anyway to extract the Destination address from a UDP package. I've looked at 3 perl modules IO::Socket::Inet and Net::UDP and Net::Inet but can not make any head way with this task. I am working on an Ubuntu box with perl version 5.8.8 installed. Unfortuna

Re: get function name?

2008-10-01 Thread John W. Krahn
Bryan R Harris wrote: Is it possible from within a function to get the name of the function I'm in? e.g. ** sub function23 { return "I am in function $\n"; } print function23(); ** ... should return "I am in function fun

Re: dynamically input fields to select from my table in the database

2008-10-01 Thread John W. Krahn
Aruna Goke wrote: Thanks Rob, from the query.. if i statically substituted the array elements on both select and the condition sides, it worked. however, I want to give room to "select @smswanted(ie. only requested columns) and the condition too will will be where $given[0]...[6] will be dyna

Re: reference question

2008-09-30 Thread John W. Krahn
Subject: RE: reference question V.Ramkumar wrote: Hi List, How to find out the existence of duplicate values in perl array. What does that have to do with "reference question"? John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low c

Re: negate a string

2008-09-30 Thread John W. Krahn
loke wrote: On Sep 29, 11:03 am, [EMAIL PROTECTED] (Paul Lalli) wrote: On Sep 28, 3:18 pm, [EMAIL PROTECTED] (Loke) wrote: Hi. I am trying to filter strings which do not have :// in them, I am able to find strings with :// but I want to do the exact opposite. regex to match : /(.*:\/\/.*)/i I

Re: How can I execute linux commands on terminal and catch the results?

2008-09-30 Thread John W. Krahn
Daniel Nascimento wrote: Hello Andrew, thanks for your answer. I tried to do this way: *#!/usr/bin/perl -w $res = qx/whoami/; print $res; print "-\n"; if ($res eq "daniel"){ print "Welcome, ".$res." how are you?.\n"; }else{ print "Your name isn't daniel\n"; }* when I

Re: regex and newline

2008-09-30 Thread John W. Krahn
Matthias Leopold wrote: hi, Hello, can someone please explain to me how to match patterns that contain newlines? /\n/ or /./s when file.txt contains aaa bbb ccc ddd eee why doesn't perl -pe 's/bbb.*?ddd//s;' file.txt remove lines 2-4? Because the -p switch creates a while loop tha

Re: if condition question

2008-09-29 Thread John W. Krahn
sanket vaidya wrote: Hi all, Hello, Kindly go through the below codes: use warnings; use strict; my $string = "test"; if ($string eq "test") { print "correct"; } Output: Correct Now when I write the same if condition in program as below, I get warning along with output. use warnings; use

Re: from perl review (first article) question on regex

2008-09-29 Thread John W. Krahn
Richard Lee wrote: I was reading perl magazine and saw sub readable { my $number = shift; $matched = $number =~ s{ (\d+) (\d{3}) (,|$) }{$1,$2$3}x; } while ($matched); ^^^ You have a right brace without a corresponding left brace

Re: Tie::FILE vs open

2008-09-28 Thread John W. Krahn
org chen wrote: I have a huge file, there are 47,286,116 lines. I am search a line and repalce this line with another string. I know this line is between 20,000,000th to 30,000,000th lines. Which way is more fast and safe: method 1: use Tie::FILE; tie my @array, 'Tie""File', "aa.txt", memory =

Re: join operator for arrays question

2008-09-27 Thread John W. Krahn
JAaronAnderson.com wrote: =pod Hey fellow GoogleGroup Brothers & Sisters, I hate to disappoint you but this is not a "GoogleGroup", this is a mailing list controlled by perl.org. I am hoping to ask you all a quick Perl intermediate logic question… I have called an obj command which returns

Re: Combining unique data from several lines to one line

2008-09-27 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I am looking to send a mail message to a large group of users and indicate which groups they are assigned to. Currently I have a tab deliniated file which has in column 1 the email address, column 2 the group, and column 3 the user's name. Using sample data I would like:

Re: Help understanding why the RE does not totally work

2008-09-26 Thread John W. Krahn
Jack Gates wrote: On Friday 26 September 2008 12:48:14 pm Jack Gates wrote: s!(<|)!$1\L$2\E!g; or s/(<|<\/)([^!][A-Z0-9 ]+>)/$1\L$2\E/g; The RE above captures and replaces all HTML tags with lowercase as desired except for any tag that has only one letter such as , or It will get the , and

Re: Help understanding why the RE does not totally work

2008-09-26 Thread John W. Krahn
Rob Dixon wrote: Jack Gates wrote: s!(<|)!$1\L$2\E!g; or s/(<|<\/)([^!][A-Z0-9 ]+>)/$1\L$2\E/g; The RE above captures and replaces all HTML tags with lowercase as desired except for any tag that has only one letter such as , or It will get the , and It properly ignores the tag What i

Re: Help understanding why the RE does not totally work

2008-09-26 Thread John W. Krahn
Jack Gates wrote: s!(<|)!$1\L$2\E!g; or s/(<|<\/)([^!][A-Z0-9 ]+>)/$1\L$2\E/g; The RE above captures and replaces all HTML tags with lowercase as desired except for any tag that has only one letter such as , or It will get the , and It properly ignores the tag What is the correct way

Re: Learning process How? & Why?

2008-09-26 Thread John W. Krahn
Jack Gates wrote: These first four lines are how every Perl script I write starts. #!/usr/bin/perl -T use strict; use warnings; use diagnostics -verbose; my ($oldfile) = $ARGV[0] =~ /^([-a-zA-Z0-9._\/]+)$/; die "bad old filename" unless $oldfile; my ($newfile) = $ARGV[1] =~ /^([-a-zA-Z0-9._\/]

Re: regex count

2008-09-24 Thread John W. Krahn
Stephen Reese wrote: It appears that there is a space (' ') character at the end of the pattern where there should be a ']' character. John, I'm missing where the closing bracket should go. Have a look at the sample data you posted and you will see where. John -- Perl isn't a toolbox, but a

Re: Trying to modify Perl script

2008-09-24 Thread John W. Krahn
Stephen Reese wrote: printf() (as seen three lines down) has a format string and a list of values corresponding to the % escapes in that string. Because you are using a string literal you should use print() instead. foreach my $i (sort { $quad{$b} <=> $quad{$a} } keys %quad) { if ($n++ >= $

Re: How to make part of regex optional.

2008-09-24 Thread John W. Krahn
Rob Coops wrote: Hi all, Hello, I am having some trouble matching the following string: "Some text+...:...:...:...:...+some more text" The trick is there are two dilimiters in this string the + and the : are used to separate the string, the + signifies a part of the string ended and the : s

Re: csv multi-line to single-line

2008-09-24 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi, Hello, We receive a text file with the following entries. "01","item1","apple one","apple two","apple three" "02","item2","body one","body two","body three" "03","item2","body one","body two","body three" "04","item2","body one","body two","body t

Re: Trying to modify Perl script

2008-09-23 Thread John W. Krahn
Stephen Reese wrote: In your original post you presented *two* *separate* scripts and I commented on both scripts, and now you are combining parts of both scripts which is why you seem to be confused. Hint: The "next unless //;" was a replacement for the "if (//) {}" block. John, originally I

Re: regex count

2008-09-23 Thread John W. Krahn
Stephen Reese wrote: Dave wrote: I think the problem might be with your regular expression and not $x. If your regular expression does not match the current line then every line will be skipped. What does the line that is being processed look like? Here are two lines from the log file. S

Re: Trying to modify Perl script

2008-09-23 Thread John W. Krahn
Stephen Reese wrote: [snip] #next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) \; next unless /IPACCESSLOGP: list $acl denied ([tcpud]+) ([0-9.]+)\ ([0-9]+\)\s*->\s*([0-9.]+)\(([0-9]+)\), ([0-9]+) /; Thanks Ron that worked. What

Re: Assign regex match to variable in while loop

2008-09-23 Thread John W. Krahn
Clemens Bieg wrote: Hello, I am trying to iterate over all the lines of a file, each of which starts with a line number, and isolate the line number and the corresponding string into one variable each, then have them printed into a separate file. Could someone give me a clue on how to assign the

Re: map behaviour

2008-09-23 Thread John W. Krahn
Jose Perez wrote: Hi! Hello, I've been using Perl for awhile but I still have some doubts :) hopefully you will help me to clarify some concepts :) In particular, I have the following situation: I have an external command that returns the following: Virtual Disk: 1 Virtual Disk: 6 Virtual D

Re: modify filename by using regular expression

2008-09-23 Thread John W. Krahn
aa aa wrote: Hi everyone, Hello, I get an string from an filename, and then create an mysql table using that filename. Since the rule is different, eg, a file name AA3bb.cc is ok but it can't used as a mysql table's name. So that I will modify that file name to AA3bb-cc. That means if any cha

Re: Get the last entry of log file

2008-09-22 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Wed, 2008-09-17 at 13:18 +0100, Stewart Anderson wrote: How about a system(tail -x inputfile >> mylastfile)type call to get the last line and then open the mylastfile to work on the line there? The UNIX utility tail(1) still reads the entire file. The

Re: Switching two characters

2008-09-22 Thread John W. Krahn
Grant wrote: what about $code =~ tr/['"]/["']/; ? I shouldn't have said characters. I'm actually trying to switch "'" and "'" without the double-quotes. Can that be done as simply as your one-liner above? perldoc HTML::Entities Or: http://search.cpan.org/~gaas/HTML-Parser-3.56/lib/HTML/E

Re: Switching two characters

2008-09-22 Thread John W. Krahn
Paolo Gianrossi wrote: what about $code =~ tr/['"]/["']/; Why are you also replacing '[' with '[' and ']' with ']'? Perhaps you meant: $code =~ tr['"]["']; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short o

Re: Switching two characters

2008-09-22 Thread John W. Krahn
Grant wrote: I'd like to switch the " and ' characters in a block of text so that all " characters become ' and all ' characters become ". The closest thing I can come up with is the following, but of course it doesn't work quite right because one is executed after the other: $code =~ s/"/'/g;

Re: extracting multiple statements ...

2008-09-22 Thread John W. Krahn
Sharan Basappa wrote: Hi, Hello, I have a code snippet as follows: keyword id1 = a x b x c; keyword id2 = c x d x e; I would like to extract strings "a x b x c" and "c x d x e". I know I can loop through the code and extract the strings, but is there a RE that can do this with a single stat

Re: Understanding Perl script functionality

2008-09-21 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Sun, 2008-09-21 at 09:59 -0700, Ron Bergin wrote: #!/usr/bin/perl # You're missing 2 very important pragmas that should be in every script you write. use warnings; # use strict; # forces you to declare your vars prior to their use. # # Set behaviour $log="/var/

Re: one-liner for if condition is met, substitute an incremented number

2008-09-21 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Here's a string in my file, #define MY2D_STRING"4.0.1.999.9" of which I'm trying to increment the last digit; let's say with 1, such that the output is 4.0.1.999.10 I've tried _various_ combinations, here's just one of them. (This works partially, but not

Re: Append a text file to an existing text file

2008-09-21 Thread John W. Krahn
NewbeeUnix wrote: On Sep 18, 11:49 am, [EMAIL PROTECTED] (Back9) wrote: Is there a way to append a text file to an existing text file. For example, File A: Jan Feb Mar April ... File B: 10 30 40 20 ... After appending job, the File A would be like below. Jan Feb Mar April ... 10 30 40 20 ...

Re: how to produce random dates

2008-09-21 Thread John W. Krahn
itshardtogetone wrote: - Original Message - From: "John W. Krahn" <[EMAIL PROTECTED]> use Time::Local; my $start = timegm 0,0,0,1,0,60; my $end = timegm 0,0,0,1,0,86; print scalar gmtime $start + rand $end - $start; Hi, Thanks. (1) But the above from time to

Re: how to produce random dates

2008-09-21 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Sat, 2008-09-20 at 03:53 -0700, John W. Krahn wrote: itshardtogetone wrote: Hi, Hello, How do I randomly produce a date between 1st Jan 1960 to 31th December 1985. It must be able to show the day month year. I only know how to produce a random number between

Re: Index not incrementing

2008-09-20 Thread John W. Krahn
AndrewMcHorney wrote: Hello Hello, I am working on a perl script which is strictly loops for performance testing. For some reason the index for the quarterback index is not incrementing. That is because it is outside of the while loops. Also sometimes I am getting an error message about t

Re: Trying to modify Perl script

2008-09-20 Thread John W. Krahn
Stephen Reese wrote: I found a Perl script that parses Cisco ACL logging format and I would like to modify it to parse the IPS format that Cisco uses. I have made changes to the expression that picks up the Rule and the script still runs but there isn't any useful output. Any recommendations woul

Re: how to produce random dates

2008-09-20 Thread John W. Krahn
itshardtogetone wrote: Hi, Hello, How do I randomly produce a date between 1st Jan 1960 to 31th December 1985. It must be able to show the day month year. I only know how to produce a random number between 1960 to 1985 using rand like this : my $year = int (rand 26) + 1960; use Time::Local

Re: How to append a text file to an existing text file

2008-09-19 Thread John W. Krahn
Back9 wrote: Hello, Hello, Is there a way to append a text file to an existing text file. For example, File A: Jan Feb Mar April ... File B: 10 30 40 20 ... After appending job, the File A would be like below. Jan Feb Mar April ... 10 30 40 20 ... open A, '>>', 'File A' or die "Cannot ope

Re: How to replace use of $* since that's no longer supported?

2008-09-18 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi, Hello, I'm running a perl script using perl 5.10 and getting this warning: $* is no longer supported at migrate.pl line 380. I know very little about perl so am wondering if someone can point me to documentation about what $* was and how to migrate code to whate

Re: Processing multiple line

2008-09-17 Thread John W. Krahn
Aali Naser wrote: Hello All, Hello, I have a file with the info in the following format; Start of File= Server Name: ABCDEF Manufacturer: Dell Model: Some Model Number Of Processors (Includes MultiThread): 2 Maximum Clock Speed: 3 - GHZ Serial Number: 1234

Re: Password Entry

2008-09-17 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hello Hello, I am looking for sample code where a user would enter a password. The key here is to either replace the characters entered with blanks or something like "*" for each character that is entered. I am sure this has been done before. perldoc -q password

Re: Get the last entry of log file

2008-09-17 Thread John W. Krahn
Manasi Bopardikar wrote: I have a log file- [ snip ] How can I get the last entry of this file? use File::ReadBackwards; my $bw = File::ReadBackwards->new( 'log_file' ) or die "can't read 'log_file' $!"; my $last_line = $bw->readline; John -- Perl isn't a toolbox, but a small machine

Re: Formatting Question

2008-09-16 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hello Hello, I am sure the answer to this question is very simple. I have a number value which I am inserting into a string I am building. How can I append the number into the string so that it will always be 2 characters in length? In other words if the month is 9, h

Re: Output files to text document

2008-09-16 Thread John W. Krahn
Vb wrote: What I'm trying to do is to create a program that reads through a certain directory and outputs the location of each file(both in the directory and subdirectorys) into a text file. I am completely new to Perl and under a time restriction so any help would be greatly appreciated...thanks

Re: Help with comparison of variable

2008-09-16 Thread John W. Krahn
Jim wrote: How come this does not work? if ($file_list =~ $file_to_excl) What strings are in $file_list and $file_to_excl? I expect this to be true if $file_list contains the string in $file_to_excl - what am I missing? It won't work correctly if $file_to_excl is longer than $file_list or

Re: 32 bit computation problems with Perl !

2008-09-16 Thread John W. Krahn
Amit Saxena wrote: Are you working on 64 bit system ? No. John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For addit

Re: 32 bit computation problems with Perl !

2008-09-16 Thread John W. Krahn
Amit Saxena wrote: On Tue, Sep 16, 2008 at 5:04 PM, John W. Krahn <[EMAIL PROTECTED]> wrote: Amit Saxena wrote: In the following code, the value of "$string" in last two cases is not printed correctly. Please let me know what i am missing over here. *# cat l3.pl*

Re: Character Sets and Encoding in Web Applications

2008-09-14 Thread John W. Krahn
Nigel Peck wrote: Dr.Ruud wrote: Nigel Peck schreef: I have a web application that gathers various data. When users enter pound signs (english money not #) a number of strange characters get stored in the database: Here's a copy and paste: £6.50 per hour That is UTF8 encoded text. Y

Re: compiler output/global variable

2008-09-11 Thread John W. Krahn
Oliver Block wrote: hello everybody, Hello, what may cause perl to give the following command line output Global symbol "$form" requires explicit package name at /.../Address.pm line 44. even if the variable $form is declared in line 16 as follows my $form = $self->formbuilder;

Re: store first key of a hash to scalar

2008-09-10 Thread John W. Krahn
Noah wrote: Hi there, Hello, What is the easiest way to store the first key of a hash to a scalar variable? A hash doesn't have a "first" key. Which key do you really want? John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low co

Re: local var with no assignment

2008-09-10 Thread John W. Krahn
oldyork90 wrote: True or false. (Trying to figure out why this would be done with no assignment). Without an explicit assignment the variable has the value 'undef'. In the following construct, the current value of $/ is protected by localizing it to the scope of the block. local() allows th

Re: read the time from last line of a file in unix

2008-09-09 Thread John W. Krahn
Rodrick Brown wrote: On Tue, Sep 9, 2008 at 3:23 PM, <[EMAIL PROTECTED]> wrote: i want get the time specified in last line of the file. For eg: $tail -2 test.log 2008 aug 25 14:48:42.800 Sending ping message; 2008 aug 25 14:48:43.390 Sending ping message; The file size is huge, so i dont want

Re: read the time from last line of a file in unix

2008-09-09 Thread John W. Krahn
[EMAIL PROTECTED] wrote: Hi All, Hello, i want get the time specified in last line of the file. For eg: $tail -2 test.log 2008 aug 25 14:48:42.800 Sending ping message; 2008 aug 25 14:48:43.390 Sending ping message; The file size is huge, so i dont want to read the entire file to get the last

Re: Regexp in PERL

2008-09-09 Thread John W. Krahn
anders wrote: Hi i have som text with " and space and then a numbers eg. " 234234 I tested to write $line =~ s/\" [0-9]/[0-9]/g; I like it to change " 234 to "234 But it made "[0-9] Anyone how should i have write to tell it to find and convert corrent. $line =~ s/(?<=") +(?=[0-9])//g;

Re: comparing text files, in a way

2008-09-08 Thread John W. Krahn
frazzmata wrote: I am writing a program where I want to be able to locate information regarding a person in one file, if they appear in another. For instance: I have a file that just has student IDs (for students that are new) It has a long list of Student IDs like this: 100955 104024 564765

Re: need help with subroutines & funtions

2008-09-08 Thread John W. Krahn
Raul Ruiz Jr. wrote: I am taking an online ceu course in scripting with Unix. I have been stumped by this project. Can anyone out there help me out a bit. I created a script at the bottom and it does not quite work. What am I missing? perldoc -q "How do I do .anything.?" I know I am missing

Re: Delete file if it contains x y or z

2008-09-06 Thread John W. Krahn
Aruna Goke wrote: brian54321uk wrote: Aruna Goke wrote: Mr. Shawn H. Corey wrote: On Fri, 2008-09-05 at 19:09 +0100, brian54321uk wrote: HI again I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the

Re: Delete file if it contains x y or z

2008-09-06 Thread John W. Krahn
Dr.Ruud wrote: brian54321uk schreef: I would like to test a folder full of files, and if a file contains abc123blue or xyz357green then that file is to be deleted. What would be the best way of achieving this please? I would use `grep -l` to get the list of filenames, and rm to unlink them. N

Re: Octal code for "^L"

2008-09-05 Thread John W. Krahn
Mr. Shawn H. Corey wrote: On Thu, 2008-09-04 at 17:54 -0400, Moon, John wrote: Does anyone know the octal code for what vi is showing as "^L"? I tried "\n\r" & \r\n" but that does not seem to be the same... I am on a UNIX box... I need the octal code to add to the beginning of first record writt

Re: while loops and the bedlam of the hash key

2008-09-05 Thread John W. Krahn
frazzmata wrote: I have a problem I am trying to take lines in a text file that look like this. although there are 500 more or so (and they have more realistic names) 25727 dude, some M MEX.AMER. DORM1 25797 dude, other M BLACK DORM2 29291 guy, randomM BLACK DORM3 3024

Re: Octal code for "^L"

2008-09-05 Thread John W. Krahn
Moon, John wrote: Does anyone know the octal code for what vi is showing as "^L"? I tried "\n\r" & \r\n" but that does not seem to be the same... I am on a UNIX box... I need the octal code to add to the beginning of first record written from my perl script... I'm using "write" and "format" and n

Re: looping through multiple arrays

2008-09-04 Thread John W. Krahn
Raja Vadlamudi wrote: On Thu, Sep 4, 2008 at 12:36 PM, Raja Vadlamudi <[EMAIL PROTECTED]> wrote: On Thu, Sep 4, 2008 at 11:22 AM, Bobby <[EMAIL PROTECTED]> wrote: I have a large pipe delimited text file that i want to loop through and sort out a column of data within that file. Let's call thi

Re: Problem with Eval for Constructing AoA

2008-09-04 Thread John W. Krahn
Gundala Viswanath wrote: Hi, Hello, This cowde below tries to convert the string in newick format into the corresponding data structure (Array of Array). But somehow the EVAL function doesn't work as expected. What's wrong with my code here? __BEGIN__ use Data::Dumper; use Carp; my $str =

Re: Simultaneous execution of multiple processes

2008-09-02 Thread John W. Krahn
sumeet .. Light my way..!! wrote: Hey thanks for the reply. Things working slowly and steadily.I was able to successfully run many instances of notepad.exe simultaneously.However i am still not able to execute some exe's like firefox.exe , wmplayer.exe , googletalk.exe etc. I am using the follo

Re: Perl equivalent of "sed -f" or "awk -f"

2008-09-02 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I'd like to apply a series of inline edits to a file in Perl. With sed, I could use "sed -f commandfile inputfile" or in awk, "awk - f commandfile inputfile", however, I could not find an equivalent in Perl. perl commandfile inputfile I'd prefer not to use sed or awk

Re: Regex in a variable

2008-09-02 Thread John W. Krahn
Paolo Gianrossi wrote: Alright! This works... I solved the minor issue of modifiers and simple matching instead of substitution (remember I need to take care of *arbitrary* regexes) by: my ($op, $replacement, $modifiers)=('', ''); if($rexp=~/^s(.)/){ $op='s'; my $delimiter=quotemeta($1);

Re: need help on how to make a lib.pl function.

2008-09-01 Thread John W. Krahn
Raul Ruiz Jr. wrote: Here is a basic card shuffling program I wrote. Perl already provides you with a shuffling function: perldoc List::Util I am learning about developing perl libraries. How do I remove my code that does the shuffling and include it as another function in a lib.pl. After t

Re: Regex in a variable

2008-09-01 Thread John W. Krahn
Paolo Gianrossi wrote: On Mon, 2008-09-01 at 04:42 -0700, John W. Krahn wrote: Paolo Gianrossi wrote: However what i want to do is subtly different: i'd like to do this: my $rexp="m/match/g"; $text=~$rexp; The only way to use the /g option like that is to use eval: my $rexp =

Re: Difference between "perl -w" and "use warnings" in perl !

2008-09-01 Thread John W. Krahn
Amit Saxena wrote: Hi all, Hello, What's the difference between "perl -w" and "use warnings" in perl ? perldoc perllexwarn perldoc warnings John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.

Re: Simultaneous execution of multiple processes

2008-09-01 Thread John W. Krahn
sumeet .. Light my way..!! wrote: Hi all, Hello, I have a problem.. I need to run / execute multiple processes SIMULTANEOUSLY ( at the same time) . May it be system processes or any other process For eg:- running notepad.exe , taskmgr.exe , cmd.exe , open media player etc ..

Re: Missing Termination in FORMAT

2008-09-01 Thread John W. Krahn
Dave Thacker wrote: I'm reading from a database and attempting to write out to several different files using a defined format. I'm using this tutorial on formats as a reference. http://www.webreference.com/programming/perl/format/2.html You should really read the documentation that comes w

Re: Regex in a variable

2008-09-01 Thread John W. Krahn
Paolo Gianrossi wrote: Hello, Experts! Hello, I am into perl since a couple of weeks, so please excuse any ingenuity ;) To the problem: I have a regex in a variable, and would like to match it. I clearly understand that I can do this: my $rexp="match"; $text=~m/$rexp/g; However what i wan

<    5   6   7   8   9   10   11   12   13   14   >