Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

The Monastery Gates

( #131=superdoc: print w/replies, xml ) Need Help??

Donations gladly accepted

If you're new here please read PerlMonks FAQ
and Create a new user.

New Questions
from txt file to array
6 direct replies — Read more / Contribute
by WisDomSeeKer34
on Jun 21, 2017 at 15:01

    I have raw data like this:

    Washington
    New York
    Louisiana
    Georgia
    Texas
    Iowa
    etc.

    and I want to turn it into an array:
    qw (Washington, New York ....);

    I can do it manually but it is a fuzz to do it every time.
    Is it perhaps possible with while (< DATA >)? How to input raw data into a perl script?

using a 'here' doc to build a web page
3 direct replies — Read more / Contribute
by Anonymous Monk
on Jun 21, 2017 at 11:23
    I am constructing a web page by first defining variables which are extrapolated in the 'HERE' document. I am creating a HTML file by printing the 'HERE' document. It seems to be working OK. Is this a valid approach?
How to tie a lexical filehandle.
1 direct reply — Read more / Contribute
by clueless newbie
on Jun 20, 2017 at 15:28

    Ave,

    I can do a tie on a file as long as I use bareword filehandles. ie

    package MyTie; use Carp; # So we can croak our error use Data::Dumper; use strict; use warnings; sub TIEHANDLE { #Carp::cluck "\nTIEHANDLE: ",Data::Dumper->Dump([\@_], +[qw(*_)]),' '; no warnings; my $class=shift; my $form=shift; open (my $self,$form,@_) # or Carp::cluck "can't open $form@_: $!" ; return bless $self,$class; # $self is a glob ref } sub CLOSE { #Carp::cluck "\nCLOSE: ",Data::Dumper->Dump([\@_],[qw(*_)] +),' '; my $self=shift; return close $self; } sub DESTROY { #Carp::cluck "\nDESTROY: ",Data::Dumper->Dump([\@_],[qw( +*_)]),' '; my $self=shift; $self->CLOSE; } sub EOF { #Carp::cluck "\nEOF: ",Data::Dumper->Dump([\@_],[qw(*_)]),' +'; my $self = shift; return eof $self; } sub FILENO { #Carp::cluck "\nFILENO: ",Data::Dumper->Dump([\@_],[qw(*_ +)]),' '; my $self=shift; return fileno $self; } sub OPEN { #Carp::cluck "\nOPEN: ",Data::Dumper->Dump([\@_],[qw(*_)]), +' '; my $self=shift; my $form=shift; $self->CLOSE; open($self,$form,@_) or croak "can't reopen '$form@_': $!"; return 1; } sub READLINE { #Carp::cluck "\nREADLINE: ",Data::Dumper->Dump([\@_],[q +w(*_)]),' '; my $self=shift; return undef if $self->EOF; #warn Data::Dumper->Dump([\(my $t=wantarray())],[qw(*wantarray)]), +' '; if (wantarray()) { my @a=<$self>; main::mySub(@a); return @a; } else { my $s=<$self>; main::mySub($s); return $s; }; } package main; use strict; use warnings; my $name='mydata'; tie *FOO,"MyTie"; open(FOO,'<',$name) or die "Can't open '$name' for reading. $!"; my $line=<FOO>; print "Scalar: $line"; $line=<FOO>; print "Scalar: $line"; my @array=<FOO>; print "Array: ",@array; while (<FOO>) { print "In while: $_"; } close(FOO); exit; sub mySub { warn "\nmain::mySub: ",Data::Dumper->Dump([\@_],[qw(*_)]),' '; return; }; __DATA__

    works just fine to record what is read from *FOO.

    But I need to tie a lexical filehandle so I can write

    package main; use strict; use warnings; my $name='mydata'; my $FOO; tie $FOO,"MyTie"; open($FOO,'<',$name) or die "Can't open '$name' for reading. $!"; my $line=<$FOO>; print "Scalar: $line"; $line=<$FOO>; print "Scalar: $line"; my @array=<$FOO>; print "Array: ",@array; while (<$FOO>) { print "In while: $_"; } close($FOO); exit;
    .

    But this throws 'Can't locate object method "TIESCALAR" via package "MyTie" at ...' - where the tie is attempted. Any ideas on how to tie a lexical filehandle?

    "This is perl 5, version 20, subversion 2 (v5.20.2) built for MSWin32-x86-multi-thread-64int"

error variables after IPC::Run
4 direct replies — Read more / Contribute
by CarolinaPerler
on Jun 19, 2017 at 11:47

    Using IPC::Run.
    Would like to examine all the built-in special error variables: $@, $!, $^E, and $?. After an IPC::Run 'run', when I try to check $! and $^E, I get 'Illegal seek'.

    run (\@commandArray, \$in, \$error, timeout(3)); print "LIB LEVEL ERROR: $!\n"; print "OS LEVEL ERROR: $^E\n";

    On some systems in some situations, $^E is not supported. But, $! should be available. IPC::Run hands back $error (given the code above). But, it does not necessarily give back all the detail that can be gleaned from cruising through the built-in error vars. I like using IPC::Run and would like to continue doing so. But, need a robust mechanism for catching error info. It appears that IPC::Run is monkeying with $! and $^E. Any ideas on how to capture the error detail after an IPC::Run run call?

How to ask user for file name and save the output to a new text file
2 direct replies — Read more / Contribute
by mmazlan67
on Jun 18, 2017 at 23:36

    Hi, i am really new to Perl because before this i worked on Excel VBA. For now i have 3 different perl scripts in VNC that i plan to combine them into one.

    The first script will ask user for file name (e.g summary.txt), find the matching string in the summary.txt and saved the output in inout.txt using command on console "perl step1.pl summary.txt > inout.txt". But error will occur Then, i run the second script just to take all the necessary data based on the requirement and saved the output in result.txt using command on console "perl step2.pl inout.txt > result.txt. The third script will send result.txt to an email which can be viewed in Windows. I know that it is possible but i have no idea on how to do it as i got stuck on thinking how to open summary.txt file to read and open inout.txt to write at the same time.

    I add this code below in step1.pl but then i cannot run the script on console using "perl step1.pl summary.txt > inout.txt"

    print "Enter the name of the file: "; my $base_dir = <>; chomp($base_dir);open( my $DATA, "<" , $base_dir) or die "Can't open f +ile '$base_dir': $!"; while ( <$DATA> )

    step1.pl

    #! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; while (<>) { if ($_ =~ /^\s\s(\S+)*delay\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+ +(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+) +/) { print "$_"; } }

    step2.pl

    #! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; while ( <> ) { #if my ( $set ) = m/^\s+(\S+)/; #get the first word my ( $name,$value ) = m/-name (\S+) (\S+)/; #get the name and value my ( $mode ) = m/mode == (\S+)\"/; #get the mode print "$mode $name $set $value\n"; }

    step3.pl

    #! /tools/perl/5.8.8/linux/bin/perl use strict; use warnings; my $name='inoutdata'; system("uuencode /home/user/set/result.txt | mailx -s '$name' email");
System vs. User module version of List::Util
5 direct replies — Read more / Contribute
by Lady_Aleena
on Jun 17, 2017 at 21:12

    Hello. List::Util is a core module, but the system version has not been updated since 1.27. So I installed it in my user directory, and it is version 1.47. However, I am getting an error that uniq is not exported by List::Util. According to the docs, List::Util has had uniq since version 1.45. So, what do I do to get the system to look at the user installed List::Util instead of the system installed List::Util? Is there precedence in @INC? Do I have to beg the system administrators to update their List::Util?

    I went to the command line and read the perldoc for List::Util, and perldoc brought up the docs for 1.47 not 1.27. I am confused by that a bit.

    Here is my @INC from the command line, and it has my user directories first, so that makes this even more confusing.

    Here is my @INC from the browser, and it has my user directories first, so that makes this so much more confusing.

    Any and all help is appreciated.

    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena
Time::Piece reversibility
4 direct replies — Read more / Contribute
by mla12
on Jun 17, 2017 at 17:06

    I'm trying to parse a timestamp with Time::Piece, and then stringify the result back into the original date string.

    The timestamp includes the zone. I can do it with Time::Local and it works as expected. But with Time::Piece, no matter what I seem to try, the result is displayed as GMT.

    See this test:

    #!/usr/bin/env perl use strict; use warnings; use Time::Local; use Time::Piece; my $datestr = '2017-06-19 10:07:42-0700'; print "Original date string: $datestr\n\n"; print "Using Time::Local\n"; my $time = timelocal(42, 7, 10, 19, 6, 2017); print " Epoch seconds: $time\n"; print " CORE::localtime: ", scalar CORE::localtime($time), "\n"; print "\n"; print "Using Time::Piece:\n"; print " strptime as static method:\n"; my $obj = Time::Piece->strptime($datestr, '%Y-%m-%d %H:%M:%S%z'); print " stringified: $obj\n"; print " datetime: ", $obj->datetime, "\n"; print " tzoffset: ", $obj->tzoffset, "\n"; print " hour: ", $obj->hour, "\n"; print " strptime as localtime instance method:\n"; $obj = localtime->strptime($datestr, '%Y-%m-%d %H:%M:%S%z'); print " stringified: $obj\n"; print " datetime: ", $obj->datetime, "\n"; print " tzoffset: ", $obj->tzoffset, "\n"; print " hour: ", $obj->hour, "\n"; print " strptime as gmtime instance method:\n"; $obj = gmtime->strptime($datestr, '%Y-%m-%d %H:%M:%S%z'); print " stringified: $obj\n"; print " datetime: ", $obj->datetime, "\n"; print " tzoffset: ", $obj->tzoffset, "\n"; print " hour: ", $obj->hour, "\n";

    For me, that produces:

    Original date string: 2017-06-19 10:07:42-0700 Using Time::Local Epoch seconds: 1500484062 CORE::localtime: Wed Jul 19 10:07:42 2017 Using Time::Piece: strptime as static method: stringified: Mon Jun 19 17:07:42 2017 datetime: 2017-06-19T17:07:42 tzoffset: 0 hour: 17 strptime as localtime instance method: stringified: Mon Jun 19 17:07:42 2017 datetime: 2017-06-19T17:07:42 tzoffset: -25200 hour: 17 strptime as gmtime instance method: stringified: Mon Jun 19 17:07:42 2017 datetime: 2017-06-19T17:07:42 tzoffset: 0 hour: 17

    The CORE::localtime result is what I want. But how do I get that back out of the Time::Piece instances?

    I'm using the latest Time::Piece, 1.31

Trouble Installing Spreadsheet::Read on Dwim Perl
2 direct replies — Read more / Contribute
by cwk
on Jun 16, 2017 at 15:50

    I'm attempting to install Spreadsheet::Read from CPAN. Environment is Windows 10. Output of "perl -V" below the errors. This is what I'm seeing:

    C:\Dwimperl\src>cpan Spreadsheet::Read CPAN: CPAN::SQLite loaded ok (v0.202) Database was generated on Fri, 16 Jun 2017 19:08:14 GMT Running install for module 'Spreadsheet::Read' Running make for H/HM/HMBRAND/Spreadsheet-Read-0.72.tgz CPAN: Digest::SHA loaded ok (v5.63) CPAN: Compress::Zlib loaded ok (v2.042) Checksum for C:\Dwimperl\cpan\sources\authors\id\H\HM\HMBRAND\Spreadsh +eet-Read-0.72.tgz ok CPAN: Archive::Tar loaded ok (v1.80) CPAN: File::Temp loaded ok (v0.22) CPAN: Parse::CPAN::Meta loaded ok (v1.4401) CPAN: CPAN::Meta loaded ok (v2.120351) CPAN: Module::CoreList loaded ok (v2.57) CPAN.pm: Building H/HM/HMBRAND/Spreadsheet-Read-0.72.tgz Do you want to install 'xlscat' (Convert Spreadsheet to plain text or +CSV) ? [y] Do you want to install 'xlsgrep' (Grep pattern from Spreadsheet) ? [y +] Do you want to install 'ss2tk' (Show a Spreadsheet in Perl/Tk) ? [y] Do you want to install 'ssdiff' (Show diff between two spreadsheets) ? + [y] Do you want to install 'xls2csv' (Wrapper around xlscat for easy XLS = +> CSV) ? [y] Checking if your kit is complete... Looks good Writing Makefile for Spreadsheet::Read Writing MYMETA.yml and MYMETA.json cp Read.pm blib\lib\Spreadsheet\Read.pm C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e cp -- examples/ss +2tk blib\script\ss2tk pl2bat.bat blib\script\ss2tk C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e cp -- examples/xl +s2csv blib\script\xls2csv pl2bat.bat blib\script\xls2csv C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e cp -- examples/xl +sgrep blib\script\xlsgrep pl2bat.bat blib\script\xlsgrep C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e cp -- examples/xl +scat blib\script\xlscat pl2bat.bat blib\script\xlscat C:\Dwimperl\perl\bin\perl.exe -MExtUtils::Command -e cp -- examples/ss +diff blib\script\ssdiff pl2bat.bat blib\script\ssdiff HMBRAND/Spreadsheet-Read-0.72.tgz C:\Dwimperl\c\bin\dmake.EXE -- OK CPAN: YAML loaded ok (v0.77) Running make test C:\Dwimperl\perl\bin\perl.exe "-MExtUtils::Command::MM" "-e" "test_har +ness(0, 'blib\lib', 'blib\arch')" t/*.t t/00_pod.t ...... ok t/01_pod.t ...... ok t/10_basics.t ... ok t/11_call.t ..... ok t/200_csv.t ..... # Parser: Text::CSV_XS-0.86 t/200_csv.t ..... ok t/201_csv.t ..... ok t/202_csv.t ..... ok t/203_csv.t ..... ok t/204_csv.t ..... ok t/205_csv.t ..... ok t/210_csv.t ..... # Parser: Text::CSV_XS-0.86 t/210_csv.t ..... ok t/211_csv.t ..... ok t/212_csv.t ..... ok t/213_csv.t ..... ok t/214_csv.t ..... ok t/220_csv.t ..... # Parser: Text::CSV_PP-1.29 t/220_csv.t ..... ok t/221_csv.t ..... ok t/222_csv.t ..... ok t/223_csv.t ..... ok t/224_csv.t ..... ok t/30_xls.t ...... # Parser: Spreadsheet::ParseExcel-0.59 t/30_xls.t ...... ok t/31_clr.t ...... ok t/32_fmt.t ...... ok t/33_misc.t ..... ok t/34_dates.t .... ok t/35_perc.t ..... ok t/36_xls.t ...... 1/177 # Failed test 'Sheet 2 is active' # at t/36_xls.t line 153. # got: '0' # expected: '1' # Looks like you failed 1 test of 177. t/36_xls.t ...... Dubious, test returned 1 (wstat 256, 0x100) Failed 1/177 subtests t/37_merged.t ... ok t/40_sxc.t ...... skipped: No SXC parser found t/45_ods.t ...... skipped: No SXC parser found t/46_clr.t ...... skipped: No OpenOffice ODS parser found t/50_sc.t ....... # Parser: Spreadsheet::Read-0.72 t/50_sc.t ....... ok t/51_sc.t ....... ok t/600_xlsx.t .... skipped: No MS-Excel parser found t/601_clr.t ..... skipped: No MS-Excel parser found t/602_fmt.t ..... skipped: No MS-Excel parser found t/603_misc.t .... skipped: No MS-Excel parser found t/604_dates.t ... skipped: No MS-Excel parser found t/605_perc.t .... skipped: No MS-Excel parser found t/607_merged.t .. skipped: No MS-Excel parser found t/610_xlsx.t .... skipped: Cannot use Spreadsheet::ParseXLSX t/611_clr.t ..... skipped: Cannot use Spreadsheet::ParseXLSX t/612_fmt.t ..... skipped: Cannot use Spreadsheet::ParseXLSX t/613_misc.t .... skipped: Cannot use Spreadsheet::ParseXLSX t/614_dates.t ... skipped: Cannot use Spreadsheet::ParseXLSX t/615_perc.t .... skipped: Cannot use Spreadsheet::ParseXLSX t/617_merged.t .. skipped: Cannot use Spreadsheet::ParseXLSX t/620_xlsx.t .... skipped: Cannot use Spreadsheet::XLSX t/621_clr.t ..... skipped: Cannot use Spreadsheet::XLSX t/622_fmt.t ..... skipped: Cannot use Spreadsheet::XLSX t/623_misc.t .... skipped: Cannot use Spreadsheet::XLSX t/624_dates.t ... skipped: Cannot use Spreadsheet::XLSX t/625_perc.t .... skipped: Cannot use Spreadsheet::XLSX t/627_merged.t .. skipped: Cannot use Spreadsheet::XLSX Test Summary Report ------------------- t/36_xls.t (Wstat: 256 Tests: 177 Failed: 1) Failed test: 175 Non-zero exit status: 1 Files=54, Tests=2615, 40 wallclock secs ( 0.84 usr + 0.69 sys = 1.53 + CPU) Result: FAIL Failed 1/54 test programs. 1/2615 subtests failed. dmake.EXE: Error code 255, while making 'test_dynamic' HMBRAND/Spreadsheet-Read-0.72.tgz C:\Dwimperl\c\bin\dmake.EXE test -- NOT OK //hint// to see the cpan-testers results for installing this module, t +ry: reports HMBRAND/Spreadsheet-Read-0.72.tgz Running make install make test had returned bad status, won't install without force
    C:\Dwimperl\src>perl -V Summary of my perl5 (revision 5 version 14 subversion 2) configuration +: Platform: osname=MSWin32, osvers=4.0, archname=MSWin32-x86-multi-thread uname='Win32 strawberryperl 5.14.2.1 #1 Tue Nov 22 21:00:59 2011 i +386' config_args='undef' hint=recommended, useposix=true, d_sigaction=undef useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=und +ef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='gcc', ccflags =' -s -O2 -DWIN32 -DPERL_TEXTMODE_SCRIPTS -DUSE +_SITECUSTOMIZE -DPERL_IMPLICIT_CONTEXT -DPERL_IMPLICIT_SYS -fno-stric +t-aliasing -mms-bitfields', optimize='-s -O2', cppflags='-DWIN32' ccversion='', gccversion='4.4.7', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=undef, longlongsize=8, d_longdbl=define, longdblsize=12 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='long lo +ng', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='g++', ldflags ='-s -L"C:\Dwimperl\perl\lib\CORE" -L"C:\Dwimper +l\c\lib"' libpth=C:\Dwimperl\c\lib C:\Dwimperl\c\i686-w64-mingw32\lib libs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 +-ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 -l +mpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 perllibs=-lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdl +g32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_3 +2 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 libc=, so=dll, useshrplib=true, libperl=libperl514.a gnulibc_version='' Dynamic Linking: dlsrc=dl_win32.xs, dlext=dll, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags='-mdll -s -L"C:\Dwimperl\perl\lib\CORE" +-L"C:\Dwimperl\c\lib"' Characteristics of this binary (from libperl): Compile-time options: MULTIPLICITY PERL_DONT_CREATE_GVSV PERL_IMPLICIT_CONTEXT PERL_IMPLICIT_SYS PERL_MALLOC_WRAP PERL_PRESERVE_IVUV PL_OP_SLAB +_ALLOC USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_PE +RL_ATOF USE_SITECUSTOMIZE Built under MSWin32 Compiled at Nov 22 2011 21:13:28 @INC: C:/Dwimperl/perl/site/lib C:/Dwimperl/perl/vendor/lib C:/Dwimperl/perl/lib .
Find the last item in a series of files
5 direct replies — Read more / Contribute
by fredho
on Jun 16, 2017 at 10:39
    Hello Monks,
    I have several files which name has the same root and different suffix (ex: file.001, file.002, file.003) and I need to identify ,for each unique value of root value (file), the file which extension has the highest value (003)
    Do I need to push matching file into an array before sorting elements on the extension?
    Or is there an easiest way to proceed?
    Thanks for the help
Automating Backup of a Google Map
5 direct replies — Read more / Contribute
by jmlynesjr
on Jun 15, 2017 at 16:50

    My Experience: I have done zero web programming.

    Background: The Bitx40 is a 40 meter Ham transcevier kit. Designed by Ashar Farhan as a very economical entry point for Indian Hams into Single Sideband(SSB) amateur radio, the Bitx40 has now become popular with Hams world wide. This low power(QRP) radio is an excellent platform for experimentation with both hardware and Arduino software(the VFO and display). A very active discussion group is located at https://groups.io/g/BITX20/topics. A group member has created a google map(http://BITXmap.com) that members may add their location to.

    The Problem: The map creater would prefer to not be the map Czar and would like to leave the map open for members to maintain their own information. Unfortunately, bungled updates have trashed portions of the map several times. The map can be backed up by manually downloading a .kml file, a royal pain...

    The Map: The map has two panes. The left pane is information/configuration oriented. The right pane is the map. One of the left pane pull-down menus leads to a "Download KML File" choice. Clicking through several pop-up boxes will download the .kml file.

    Possible Solution: It would seem that a Perl script in a cron job could automate these backups.

    The Question: Is this a reasonable approach and where are the snakes?

    Hey, it's a start.

    #! /usr/bin/perl # Script to experiment with the WWW::Mechanize::Firefox module # Must install WWW::Mechanize::Firefox from CPAN(sudo cpanm WWW::Me +chanize::Firefox) # Must install MozRepl Firefox plug-in Tools->Add-ons # (MozRepl is in the Firefox Web Development Add-ons section) # Must start MozRepl from Firefox Tools->MozRepl->Start use strict; use warnings; use WWW::Mechanize::Firefox; # Bring up the Bitx Map, Firefox needs to be running in this version my $mech = WWW::Mechanize::Firefox->new( activate => 1 ); $mech->get('http://BITXmap.com'); # ???Click through to download .kml file to backup the map(add to cron + job???)

    James

    There's never enough time to do it right, but always enough time to do it over...

Is there a way to record perl6 repl input and output?
1 direct reply — Read more / Contribute
by adhrain
on Jun 15, 2017 at 13:00

    Noble monks, I'm reading Laurent Rosenfeld's "Think Perl 6" and I wish to know if there is a way to record the input and output from perl6 repl.

    I tried the script command but, obviously, the result was cluttered by various escape sequences.

    Can you help me?

pack and unpack multiple arrays with one common repeat prefix
2 direct replies — Read more / Contribute
by hexcoder
on Jun 15, 2017 at 10:01
    Dear Monks,

    I am struggling to understand the more advanced (un)pack templates, which allow me to describe my data structure.

    I have this structure packed in a string $testinput:
  • byte: number of members in each of the following arrays
  • array of bytes
  • array of unsigned shorts
  • another array of unsigned shorts
  • I would like to know, if there is a single unpack template, that uses the first entry not only for sizing the following array, but instead three times for each of them.

    This is what I have tried so far, and I am not really happy with it.
    use strict; use warnings; my $testinput = pack('C/a* a* a*', (pack 'C*', 1, 2), (pack 'v*', 3, 4), (pack 'v*', 5, 6)); print join(',', unpack('C/C* v2 v2', $testinput)), "\n"; # gives "1,2,3,4,5,6" which is ok, # but has the repeat factors for 'v' hardcoded my $repeat = unpack('C', $testinput); print join(',', unpack("C/C* v$repeat v$repeat", $testinput)), "\n"; # gives "1,2,3,4,5,6" which is ok, but uses two steps
    Is it possible to use one call to unpack to expand this string to the values above?

    Thanks in advance, hexcoder
Log In?
Username:
Password:

What's my password?
Create A New User
Chatterbox?
Discipulus learn that 'argue' has a little negative sense, he thought was a neutral sense, 'vox media'
[1nickt]: argue == discuss && argue == be contentious
[Discipulus]: you are right 1nickt i didnt voted nor downvoted; I just upvote perl content i like
[1nickt]: In Spanish, to argue (like a fight) is discutir -- does not mean to discuss !
[1nickt]: Sigh, this is why I gave up human-only languages and became a Perl linguist :-)
[Discipulus]: i just, rarely, downvote unpolite posts and spam, and wrong advices
[Discipulus]: discutere in eatalian is neutral: but discutere with wife sounds implicitly negative..
[erix]: what's the offending signature?
[Discipulus]: 'give man a fish erix it sonds like a push towards omosexuality.. ;=)
[Discipulus]: see Re: from txt file to array erix

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2017-06-22 12:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How many monitors do you use while coding?















    Results (519 votes). Check out past polls.