71 Posted Topics

Member Avatar for Grep

[CODE] open FILE, ">file.txt" or die $!; [/CODE] The above line creates "file.txt". You are using ">" write mode. So the file position is always beginning of the file. At the end of the process you may got only one matched line. To avoid this kind of circumstance you will …

Member Avatar for Grep
0
211
Member Avatar for techstu
Re: Perl

Read the below topic's. 1) [URL="http://perldoc.perl.org/functions/open.html"]File Handling[/URL] 2) [URL="http://perldoc.perl.org/perlre.html"]Regular Expression[/URL]

Member Avatar for k_manimuthu
0
81
Member Avatar for mibushk

[CODE] use File::Find; ### Declare your path my $dir = "d:/muthu"; ### travel the $dir path find(\&get_lowest_folder, $dir); ### Now the lowest level folder info in array @low print "\n$_" for @low; sub get_lowest_folder { if (-d) # check current path is a directory { ### save current directory name …

Member Avatar for d5e5
0
414
Member Avatar for abdulraqeeb33

[CODE]open (INF, $logfile); read INF, $file, -s INF; close INF; @lines = split /\n/, $file; foreach (@lines) { @values = split / /, $_; $visitors{$values[0]}++; if ($visitors{$values[0]} == 1 ) { # Get starting web page $report{$values[0]}[0] = "$values[6]"; # When a user start browsing # considering this will be …

Member Avatar for abdulraqeeb33
0
89
Member Avatar for Vindhyaauri
Member Avatar for abdulraqeeb33

For your example i derive the below table.. Index -> Field -> Variable --------------------------------- 0 -> IP -> 74.6.72.229 1 -> remoteUser -> NULL 2 -> authUser -> NULL 3 -> Date/Time -> [27/Jan/2007:00:00:36 -0500] 4 -> Request -> GET /~jking/ralph.html HTTP/1.0 5 -> Status -> 404 6 -> Bytes …

Member Avatar for abdulraqeeb33
0
142
Member Avatar for fuyuki

open FILE, ">newseq.txt"; The above line must create "newseq.txt". Suppose the end of the process $newseq should 'null' value, at the time newseq.txt will be a blank file. To avoid this kind of circumstance, the file declaration line should be occurred at before the loop. you will try this below …

Member Avatar for fuyuki
0
125
Member Avatar for aaegcm

[CODE] #! /usr/local/bin/perl use warnings; use strict; undef $/; my $format=<DATA>; $format=~ s{ ([^\n]+) # 1. not equal to newline character (pos\d+) # 2. 'pos' followed by more than 1 digit ([^\n]+) # 3. not equal to newline character (.*?\2[^\n]+)+ # 4. any character followed by 'group and not equal …

Member Avatar for aaegcm
0
100
Member Avatar for k_manimuthu

Hi All, I am trying to get the maximum no of column in a table through XSLT code. Below i had placed the sample table format. Here column tagged as 'th' and 'td'. Some of the column having 'colspan' attribute. I am struggling how to add colspan value in a …

Member Avatar for varun0703
0
840
Member Avatar for SergioQ

Try this, [CODE] $name=qq{your text 100 SDCSDC 1000 some text 101 SDCSDC 1000 some text 1001specific_word100}; # Declare your search words @spec_word=("SDCSDC", "specific_word"); # Search the specific word foreach $key (@spec_word) { push @$key, $1 while $name=~ m{(\d+)\s*$key}g; } # print the words and their numbers foreach $key (@spec_word) { …

Member Avatar for d5e5
0
169
Member Avatar for back2arie

Hi back2arie, For what you wrote the regular expression that's all most right. [CODE] if($string =~ /<(TEXT)>\s*(.*)\s*<\/\1>/g) [/CODE] But $string had the text in multiple line. So it's not worked. You will be add 's' modifier in your code, that gives result what you expect. [CODE] if($string =~ /<(TEXT)>\s*(.*)\s*<\/\1>/g[COLOR="Green"]s[/COLOR]) [/CODE] …

Member Avatar for k_manimuthu
0
144
Member Avatar for anunitha

The File::Find module process the multiple sub directories. [CODE] use strict; use warnings; use File::Find; my $root_path=qq{G:/CNV}; #Declare your input path # Recursively it process all the sub directories in $root_path find(\&process_multiple_dir, $root_path); sub process_multiple_dir { if (-f && $File::Find::name =~ m{\.txt$}) # It process .txt format files only { …

Member Avatar for anunitha
0
82
Member Avatar for roswell1329

[CODE] use strict; use warnings; use File::Path; use Cwd; ## Source.txt file having for the above data undef $/; open (FIN, "<source.txt") || die "Cannot Open the Input File"; my $file=<FIN>; close (FIN); my ($root, @lines, @folder, $flag, $cwd); # Get root folder name $root=$1 if ($file=~ m{(\d+).*?<root>}s); # The …

Member Avatar for roswell1329
0
95
Member Avatar for ajay_p5

while a particular text stored in a scalar variable and the text having any meta characters " \ | ( ) [ { ^ $ * + ? . " , when the scalar variable used to match any string, at the time the above type of error appeared. Better …

Member Avatar for d5e5
-1
142
Member Avatar for viktorijakup

[CODE] my $FP = 'D:\conv'; my $TP = 'D:\sgml_db'; my $cwd = `cd`; # Get current working directory my ($from_dir, $to_dir) = ($cwd, $cwd); # if your current working directory ($to_dir) doesn't have 'D:\conv' the below line doesn't change the value of $to_dir. # So $to_dir equals to current directory …

Member Avatar for k_manimuthu
0
224
Member Avatar for Vandithar

For this case no need to use the split function. regular expression is enough for that one. [QUOTE] $str="\"rna binding protein\" OR \"Transcription factor\" "; # "([^ ]+) # " => match " # ([^ ]+) => not equal to space 1 or more time $str=~ s{"([^ ]+)}{"$1|($1)}g; [/QUOTE]

Member Avatar for 7stud
0
105
Member Avatar for john_prince

The problem is syntax of the passing values through the subroutine. you will be modify this line. [CODE] &OfficePhoneNumber ("554-3211","+1 302-342-2323"); [/CODE]

Member Avatar for john_prince
0
95
Member Avatar for jacquelinek

The data split into two parts. The second part split by space and the data stored in to hash format. $hash{'each second data'} .= "first part data "; [CODE] ### Data splited and store in hash format map($hash{$_}.="$1 ", (split / /, $2)) while (<DATA>=~ m{(.*?): ([^\n]+)}gs); ### print the …

Member Avatar for k_manimuthu
0
145
Member Avatar for riya0707

[CODE] #!/usr/bin/perl -w use strict; undef $/; # Input Record separator open (FILE, "INPUT") || die "cannot open $!\n"; my $var=<FILE>; # Assign the file handler to scalar variable close (FILE); my $match=qq{aaggtaaggt}; # Declare your text my $count=0; # ($match) -> aaggtaaggt # (.{100})? -> any 100 character match …

Member Avatar for thangdd
0
152
Member Avatar for rdevi

You modify the below lines in your code. 1) if (-f "$source$file") Add "\\" in between "$source" and "$file" then only it got the valid file path. 2) copy($source, $dest); Here $source gives the directory name only. File name also must here. use File::Copy; my $source="C:\\shared\\8.4.1\\DXSI"; my $dest="C:\\r45"; my @files; …

Member Avatar for rdevi
0
163
Member Avatar for perlguy

[QUOTE=perlguy;958295]I'm trying to cut off the text leading up to the whitespace past the >. For example the string is 'Web & Programming > Testing & QA Contractor' and my regex is [icode]$job->{'title'} =~ s/^.+>\s+//;[/icode] I need to end up with just 'Testing & QA Contractor'. Can someone point me …

Member Avatar for Amps
-1
76

The End.