Search Results

Search: Posts Made By: KevinADC
4,312
Posted By KevinADC
If you would run your perl scripts with warnings...
If you would run your perl scripts with warnings turned on as is always recommended you might have figured it out:

readline() on unopened filehandle at script line 3.

the construct <"$value">...
4,312
Posted By KevinADC
opendir DIR, "F:/"; # Searching under F drive ...
opendir DIR, "F:/"; # Searching under F drive
my @files = readdir(DIR); # Reading eveythg under F drive
closedir DIR; # closeing the directory handler
foreach my $file (@files) {
print "This is...
2,122
Posted By KevinADC
this is probably the most efficient way: ...
this is probably the most efficient way:

$str = " some text ";
$str =~ s/^\s+//;
$str =~ s/\s+$//;


You can do it with one regexp but it might be a little slower, only testing would...
3,373
Posted By KevinADC
You only need to check the line once: ...
You only need to check the line once:


Connected to 192.168.1.13

#!/usr/local/bin/perl
foreach $line(@lines){
if ($line =~ /connected to (.*?)/i) {
$ip=$1;
}
}


but if...
8,186
Posted By KevinADC
Usted debe utilizar inglés
Usted debe utilizar inglés
17,327
Posted By KevinADC
my $str = 'Mary had a little Lamb'; my $search...
my $str = 'Mary had a little Lamb';
my $search = 'LAMB';
if (index lc($str),lc($search) > -1) {
print "Found [$search] in [$str]\n";
}
3,818
Posted By KevinADC
maybe: @strings = ("[[:<:]](",...
maybe:


@strings = ("[[:<:]](", "[[:<:]]((", "[[:<:]](((", "[[:>:]](((((");

for (@strings) {
s/^([^(]+)([(]+)$/$2$1/;
print "$_\n";
}
7,315
Posted By KevinADC
It is homework, he mentions that on one of the...
It is homework, he mentions that on one of the other perl forums where he is posting the same questions.

Edit: I see he now mentions it is homework
8,896
Posted By KevinADC
If you just want the greatest number use an array...
If you just want the greatest number use an array slice to return only that number:

my @nums = (2.1,1,3,10.1,10.2, 5);
my $grNum = (sort {$a <=> $b} @nums)[-1];
print "Greatest Number is:...
12,553
Posted By KevinADC
##your code above $group = <>; chomp...
##your code above
$group = <>;
chomp $group;#<-- chomp user input to remove the newline
##your code below
1,952
Posted By KevinADC
I suspect the problem is not what you think it is...
I suspect the problem is not what you think it is because your code works fine with your data, for me anyway:


while(<DATA>){
if (/userName\s+:\[(..*)\]/){
$User_Name = $1;
...
3,007
Posted By KevinADC
Extract two times from what? Please try and be...
Extract two times from what? Please try and be more specific.
11,792
Posted By KevinADC
Most likely the arguments you pass the script...
Most likely the arguments you pass the script aren't set/passed correctly because July (correctly set to 6 for Time::Local) does have 31 days. The code you posted works for me as-is.
2,248
Posted By KevinADC
looks like a duplicate of your other thread: ...
looks like a duplicate of your other thread:

https://www.unix.com/shell-programming-scripting/116179-compare-2-arrays-perl.html
2,086
Posted By KevinADC
The "area" you describe is not familiar to me....
The "area" you describe is not familiar to me. How do you know that 0380 is the area part of 0380112? Is it because it starts and ends with zero? If so, and the areas are of varying length, you can...
2,776
Posted By KevinADC
What will happen in your code is that you will...
What will happen in your code is that you will get the first line of "hual" and then read through all the lines of "land" then when you get the second line of "hual" there will be no more lines from...
1,772
Posted By KevinADC
Make sure to transfer the file in ASCII (or text)...
Make sure to transfer the file in ASCII (or text) mode and your ftp application should convert Windows style newlines into Unix newlines automatically. Otherwise the Windows style \r\n newlines might...
3,568
Posted By KevinADC
Do you have a question?
Do you have a question?
1,515
Posted By KevinADC
MIME::Lite is a good module for sending emails...
MIME::Lite is a good module for sending emails that need to more than just sent as-is.
3,568
Posted By KevinADC
No, that does not do any rounding off. If all...
No, that does not do any rounding off. If all you wanted to do was truncate the number of digits then substr() is better for that unless you had to search for the number in a string.
6,283
Posted By KevinADC
is the message coming from die or when you print...
is the message coming from die or when you print the hash or something else? That sure is not any perl error or warning I have ever seen.
6,283
Posted By KevinADC
I'm not sure what happened in the code I posted,...
I'm not sure what happened in the code I posted, but this line:

$unique{$_};


should be:

$unique{$_}++;

So it displays the count of each unique line
2,810
Posted By KevinADC
the line numbers in file one do not seem match...
the line numbers in file one do not seem match the output and the line numbers in the file have to be offset by negative one to match in the array, which will start at zero instead of one like the...
6,283
Posted By KevinADC
Assuming by unique you mean 100% unique, and...
Assuming by unique you mean 100% unique, and things like case or white space are included in the uniqueness:


use strict;
use warnings;
my %unique;
open my $FH, '/path/to/your/file' or die...
3,702
Posted By KevinADC
Splitting on spaces(s) appears to be the correct...
Splitting on spaces(s) appears to be the correct thing to do based on what little information you have provided.
Showing results 1 to 25 of 500

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