71 Posted Topics
Re: [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 … | |
Re: 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] | |
Re: [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 … | |
Re: [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 … | |
Re: 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 … | |
Re: 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 … | |
Re: [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 … | |
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 … | |
Re: 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) { … | |
Re: 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] … | |
![]() | Re: 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 { … ![]() |
Re: [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 … | |
Re: 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 … | |
Re: [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 … | |
Re: 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] | |
Re: 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] | |
Re: 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 … | |
Re: [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 … | |
Re: 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; … | |
![]() | Re: [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 … |
The End.